~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/global.h

  • Committer: Brian Aker
  • Date: 2008-10-29 13:46:43 UTC
  • Revision ID: brian@tangent.org-20081029134643-z6jcwjvyruhk2vlu
Updates for ignore file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
/* This is the include file that should be included 'first' in every C file. */
 
21
 
 
22
#ifndef DRIZZLE_SERVER_GLOBAL_H
 
23
#define DRIZZLE_SERVER_GLOBAL_H
 
24
 
 
25
#if defined(i386) && !defined(__i386__)
 
26
#define __i386__
 
27
#endif
 
28
 
 
29
#include <config.h>
 
30
 
 
31
#if defined(__cplusplus)
 
32
 
 
33
# if defined(__GNUC) && defined(__EXCEPTIONS)
 
34
#  error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
 
35
# endif
 
36
 
 
37
# include CSTDINT_H
 
38
# include CINTTYPES_H
 
39
# include CMATH_H
 
40
# include <cstdio>
 
41
# include <cstdlib>
 
42
# include <cstddef>
 
43
# include <cassert>
 
44
# include <cerrno>
 
45
#else
 
46
# include <stdint.h>
 
47
# include <inttypes.h>
 
48
# include <stdio.h>
 
49
# include <stdlib.h>
 
50
# include <stddef.h>
 
51
# include <math.h>
 
52
# include <errno.h>        /* Recommended by debian */
 
53
/*
 
54
  A lot of our programs uses asserts, so better to always include it
 
55
*/
 
56
# include <assert.h>
 
57
# include <stdbool.h>
 
58
 
 
59
#endif // __cplusplus
 
60
 
 
61
/*
 
62
#if TIME_WITH_SYS_TIME
 
63
# include <sys/time.h>
 
64
# include <time.h>
 
65
#else
 
66
# if HAVE_SYS_TIME_H
 
67
#  include <sys/time.h>
 
68
# else
 
69
#  include <time.h>
 
70
# endif
 
71
#endif */ /* TIME_WITH_SYS_TIME */
 
72
 
 
73
/*
 
74
  Temporary solution to solve bug#7156. Include "sys/types.h" before
 
75
  the thread headers, else the function madvise() will not be defined
 
76
*/
 
77
#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
 
78
#include <sys/types.h>
 
79
#endif
 
80
 
 
81
 
 
82
#include <pthread.h>    /* AIX must have this included first */
 
83
 
 
84
#define _REENTRANT  1  /* Threads requires reentrant code */
 
85
 
 
86
#ifdef HAVE_LIMITS_H
 
87
#include <limits.h>
 
88
#endif
 
89
 
 
90
#ifdef HAVE_SYS_TYPES_H
 
91
#include <sys/types.h>
 
92
#endif
 
93
#ifdef HAVE_FCNTL_H
 
94
#include <fcntl.h>
 
95
#endif
 
96
 
 
97
#ifdef HAVE_UNISTD_H
 
98
#include <unistd.h>
 
99
#endif
 
100
#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
 
101
#undef HAVE_ALLOCA
 
102
#undef HAVE_ALLOCA_H
 
103
#endif
 
104
#ifdef HAVE_ALLOCA_H
 
105
#include <alloca.h>
 
106
#endif
 
107
 
 
108
 
 
109
 
 
110
#ifdef HAVE_SYS_STAT_H
 
111
# include <sys/stat.h>
 
112
#endif
 
113
 
 
114
#if !defined(HAVE_UINT)
 
115
#undef HAVE_UINT
 
116
#define HAVE_UINT
 
117
typedef unsigned int uint;
 
118
#endif
 
119
 
 
120
/* Declared in int2str() */
 
121
extern char _dig_vec_upper[];
 
122
extern char _dig_vec_lower[];
 
123
 
 
124
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
 
125
 
 
126
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
 
127
#define array_elements(A) ((size_t) (sizeof(A)/sizeof(A[0])))
 
128
 
 
129
/* Some types that is different between systems */
 
130
 
 
131
typedef int  File;    /* File descriptor */
 
132
 
 
133
#ifdef HAVE_SYS_SOCKET_H
 
134
#include <sys/socket.h>
 
135
#endif
 
136
 
 
137
 
 
138
#ifndef FN_LIBCHAR
 
139
#define FN_LIBCHAR  '/'
 
140
#define FN_ROOTDIR  "/"
 
141
#endif
 
142
#define MY_NFILE  64  /* This is only used to save filenames */
 
143
#ifndef OS_FILE_LIMIT
 
144
#define OS_FILE_LIMIT  65535
 
145
#endif
 
146
 
 
147
/*
 
148
  How much overhead does malloc have. The code often allocates
 
149
  something like 1024-MALLOC_OVERHEAD bytes
 
150
*/
 
151
#define MALLOC_OVERHEAD 8
 
152
 
 
153
/* get memory in huncs */
 
154
#define ONCE_ALLOC_INIT    (uint) (4096-MALLOC_OVERHEAD)
 
155
/* Typical record cash */
 
156
#define RECORD_CACHE_SIZE  (uint) (64*1024-MALLOC_OVERHEAD)
 
157
/* Typical key cash */
 
158
#define KEY_CACHE_SIZE    (uint) (8*1024*1024-MALLOC_OVERHEAD)
 
159
/* Default size of a key cache block  */
 
160
#define KEY_CACHE_BLOCK_SIZE  (uint) 1024
 
161
 
 
162
 
 
163
/* Some things that this system doesn't have */
 
164
 
 
165
/* Some defines of functions for portability */
 
166
 
 
167
#undef remove    /* Crashes MySQL on SCO 5.0.0 */
 
168
#ifndef uint64_t2double
 
169
#define uint64_t2double(A) ((double) (uint64_t) (A))
 
170
#define my_off_t2double(A)  ((double) (my_off_t) (A))
 
171
#endif
 
172
 
 
173
#ifndef offsetof
 
174
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 
175
#endif
 
176
#define ulong_to_double(X) ((double) (ulong) (X))
 
177
 
 
178
#ifndef STACK_DIRECTION
 
179
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
 
180
#endif
 
181
 
 
182
#if !defined(HAVE_STRTOK_R)
 
183
#define strtok_r(A,B,C) strtok((A),(B))
 
184
#endif
 
185
 
 
186
#ifdef HAVE_FLOAT_H
 
187
#include <float.h>
 
188
#else
 
189
#if !defined(FLT_MIN)
 
190
#define FLT_MIN         ((float)1.40129846432481707e-45)
 
191
#endif
 
192
#if !defined(FLT_MAX)
 
193
#define FLT_MAX         ((float)3.40282346638528860e+38)
 
194
#endif
 
195
#endif
 
196
 
 
197
/* From limits.h instead */
 
198
#ifndef DBL_MIN
 
199
#define DBL_MIN    4.94065645841246544e-324
 
200
#endif
 
201
#ifndef DBL_MAX
 
202
#define DBL_MAX    1.79769313486231470e+308
 
203
#endif
 
204
#ifndef SIZE_T_MAX
 
205
#define SIZE_T_MAX ~((size_t) 0)
 
206
#endif
 
207
 
 
208
 
 
209
/* Define missing math constants. */
 
210
#ifndef M_PI
 
211
#define M_PI 3.14159265358979323846
 
212
#endif
 
213
#ifndef M_E
 
214
#define M_E 2.7182818284590452354
 
215
#endif
 
216
#ifndef M_LN2
 
217
#define M_LN2 0.69314718055994530942
 
218
#endif
 
219
 
 
220
/*
 
221
  Max size that must be added to a so that we know Size to make
 
222
  adressable obj.
 
223
*/
 
224
typedef ptrdiff_t my_ptrdiff_t;
 
225
 
 
226
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
 
227
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
 
228
/* Size to make adressable obj. */
 
229
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
 
230
/* Offset of field f in structure t */
 
231
#define OFFSET(t, f)  ((size_t)(char *)&((t *)0)->f)
 
232
#define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
 
233
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
 
234
 
 
235
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
 
236
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
 
237
 
 
238
/* Typdefs for easyier portability */
 
239
 
 
240
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
 
241
typedef unsigned long ulong;      /* Short for unsigned long */
 
242
#endif
 
243
 
 
244
typedef uint64_t my_off_t;
 
245
 
 
246
#define MY_FILEPOS_ERROR  (UINT64_MAX)
 
247
 
 
248
typedef int    myf;  /* Type of MyFlags in my_funcs */
 
249
#define MYF(v)          (myf) (v)
 
250
 
 
251
/* Defines for time function */
 
252
#define SCALE_SEC  100
 
253
#define SCALE_USEC  10000
 
254
#define MY_HOW_OFTEN_TO_ALARM  2  /* How often we want info on screen */
 
255
#define MY_HOW_OFTEN_TO_WRITE  1000  /* How often we want info on screen */
 
256
 
 
257
 
 
258
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
 
259
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET "utf8"
 
260
#else
 
261
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET DRIZZLE_DEFAULT_CHARSET_NAME
 
262
#endif
 
263
 
 
264
#include <dlfcn.h>
 
265
 
 
266
/* FreeBSD 2.2.2 does not define RTLD_NOW) */
 
267
#ifndef RTLD_NOW
 
268
#define RTLD_NOW 1
 
269
#endif
 
270
 
 
271
#define cmax(a, b)       ((a) > (b) ? (a) : (b))
 
272
#define cmin(a, b)       ((a) < (b) ? (a) : (b))
 
273
 
 
274
/* Length of decimal number represented by INT32. */
 
275
#define MY_INT32_NUM_DECIMAL_DIGITS 11
 
276
 
 
277
/* Length of decimal number represented by INT64. */
 
278
#define MY_INT64_NUM_DECIMAL_DIGITS 21
 
279
 
 
280
/*
 
281
  Only Linux is known to need an explicit sync of the directory to make sure a
 
282
  file creation/deletion/renaming in(from,to) this directory durable.
 
283
*/
 
284
#ifdef TARGET_OS_LINUX
 
285
#define NEED_EXPLICIT_SYNC_DIR 1
 
286
#endif
 
287
 
 
288
#endif /* DRIZZLE_SERVER_GLOBAL_H */