390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
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 |
*/
|
|
1
by brian
clean slate |
19 |
|
20 |
/* This is the include file that should be included 'first' in every C file. */
|
|
21 |
||
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
22 |
#ifndef DRIZZLE_SERVER_GLOBAL_H
|
23 |
#define DRIZZLE_SERVER_GLOBAL_H
|
|
1
by brian
clean slate |
24 |
|
25 |
#if defined(i386) && !defined(__i386__)
|
|
26 |
#define __i386__
|
|
27 |
#endif
|
|
28 |
||
212.5.45
by Monty Taylor
Removed excess AM_CPPFLAGS from the tree. Now the only thing that should be in the include path should be -I${top_srcdir} and -I${top_builddir}w |
29 |
#include "config.h" |
1
by brian
clean slate |
30 |
|
481.1.9
by Monty Taylor
Added autoconf tests for location of cstdint and cinttypes. Use those in C++ programs now, so that we don't have to define _STDC_LIMIT_MACROS, etc by hand. Stop, in fact, defining those by hand. |
31 |
#if defined(__cplusplus)
|
481.1.13
by Monty Taylor
Added tests for C99 math extensions for cmath. |
32 |
|
33 |
# if defined(__GNUC) && defined(__EXCEPTIONS)
|
|
34 |
# error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
|
|
35 |
# endif
|
|
36 |
||
481.1.9
by Monty Taylor
Added autoconf tests for location of cstdint and cinttypes. Use those in C++ programs now, so that we don't have to define _STDC_LIMIT_MACROS, etc by hand. Stop, in fact, defining those by hand. |
37 |
# include CSTDINT_H
|
38 |
# include CINTTYPES_H
|
|
481.1.13
by Monty Taylor
Added tests for C99 math extensions for cmath. |
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 |
||
481.1.15
by Monty Taylor
Removed time.h and sys/time.h from global.h. |
61 |
/*
|
481.1.13
by Monty Taylor
Added tests for C99 math extensions for cmath. |
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
|
|
481.1.15
by Monty Taylor
Removed time.h and sys/time.h from global.h. |
71 |
#endif */ /* TIME_WITH_SYS_TIME */ |
481.1.9
by Monty Taylor
Added autoconf tests for location of cstdint and cinttypes. Use those in C++ programs now, so that we don't have to define _STDC_LIMIT_MACROS, etc by hand. Stop, in fact, defining those by hand. |
72 |
|
1
by brian
clean slate |
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 |
||
316
by Brian Aker
First pass of new sql_db.cc work |
81 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
82 |
#include <pthread.h> /* AIX must have this included first */ |
83 |
||
84 |
#define _REENTRANT 1 /* Threads requires reentrant code */ |
|
1
by brian
clean slate |
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
|
|
481.1.13
by Monty Taylor
Added tests for C99 math extensions for cmath. |
96 |
|
1
by brian
clean slate |
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 |
||
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
109 |
|
236.1.12
by Monty Taylor
Add global include of sys/stat.h. |
110 |
#ifdef HAVE_SYS_STAT_H
|
111 |
# include <sys/stat.h>
|
|
112 |
#endif
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
113 |
|
1
by brian
clean slate |
114 |
#if !defined(HAVE_UINT)
|
115 |
#undef HAVE_UINT
|
|
116 |
#define HAVE_UINT
|
|
117 |
typedef unsigned int uint; |
|
118 |
#endif
|
|
119 |
||
240.1.6
by Toru Maesaka
removed mystring dependencies from libdrizzle.c |
120 |
/* Declared in int2str() */
|
121 |
extern char _dig_vec_upper[]; |
|
122 |
extern char _dig_vec_lower[]; |
|
123 |
||
1
by brian
clean slate |
124 |
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
|
465
by Monty Taylor
Made a few macros into template functions. |
125 |
|
1
by brian
clean slate |
126 |
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
|
465
by Monty Taylor
Made a few macros into template functions. |
127 |
#define array_elements(A) ((size_t) (sizeof(A)/sizeof(A[0])))
|
1
by brian
clean slate |
128 |
|
129 |
/* Some types that is different between systems */
|
|
130 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
131 |
typedef int File; /* File descriptor */ |
398.1.9
by Monty Taylor
Cleaned up stuff out of global.h. |
132 |
|
1
by brian
clean slate |
133 |
#ifdef HAVE_SYS_SOCKET_H
|
134 |
#include <sys/socket.h> |
|
135 |
#endif
|
|
136 |
||
137 |
||
138 |
#ifndef FN_LIBCHAR
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
139 |
#define FN_LIBCHAR '/'
|
140 |
#define FN_ROOTDIR "/"
|
|
1
by brian
clean slate |
141 |
#endif
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
142 |
#define MY_NFILE 64 /* This is only used to save filenames */ |
1
by brian
clean slate |
143 |
#ifndef OS_FILE_LIMIT
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
144 |
#define OS_FILE_LIMIT 65535
|
1
by brian
clean slate |
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 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
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 */
|
|
1
by brian
clean slate |
164 |
|
165 |
/* Some defines of functions for portability */
|
|
166 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
167 |
#undef remove /* Crashes MySQL on SCO 5.0.0 */ |
151
by Brian Aker
Ulonglong to uint64_t |
168 |
#ifndef uint64_t2double
|
169 |
#define uint64_t2double(A) ((double) (uint64_t) (A))
|
|
1
by brian
clean slate |
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 |
||
77.1.24
by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there. |
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 |
||
1
by brian
clean slate |
197 |
/* From limits.h instead */
|
198 |
#ifndef DBL_MIN
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
199 |
#define DBL_MIN 4.94065645841246544e-324
|
1
by brian
clean slate |
200 |
#endif
|
201 |
#ifndef DBL_MAX
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
202 |
#define DBL_MAX 1.79769313486231470e+308
|
1
by brian
clean slate |
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 |
*/
|
|
481.1.21
by Monty Taylor
Got rid of some size testing. |
224 |
typedef ptrdiff_t my_ptrdiff_t; |
1
by brian
clean slate |
225 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
226 |
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
|
227 |
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
|
|
1
by brian
clean slate |
228 |
/* Size to make adressable obj. */
|
229 |
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
230 |
/* Offset of field f in structure t */
|
231 |
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
|
|
481
by Brian Aker
Remove all of uchar. |
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))
|
|
1
by brian
clean slate |
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)
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
241 |
typedef unsigned long ulong; /* Short for unsigned long */ |
1
by brian
clean slate |
242 |
#endif
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
243 |
|
151
by Brian Aker
Ulonglong to uint64_t |
244 |
typedef uint64_t my_off_t; |
1
by brian
clean slate |
245 |
|
489.1.13
by Monty Taylor
One step closer to simpler off_t support. |
246 |
#define MY_FILEPOS_ERROR (UINT64_MAX)
|
1
by brian
clean slate |
247 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
248 |
typedef int myf; /* Type of MyFlags in my_funcs */ |
1
by brian
clean slate |
249 |
#define MYF(v) (myf) (v)
|
250 |
||
251 |
/* Defines for time function */
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
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 */ |
|
1
by brian
clean slate |
256 |
|
257 |
||
258 |
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
|
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
259 |
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET "utf8"
|
1
by brian
clean slate |
260 |
#else
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
261 |
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET DRIZZLE_DEFAULT_CHARSET_NAME
|
1
by brian
clean slate |
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 |
||
398.1.4
by Monty Taylor
Renamed max/min. |
271 |
#define cmax(a, b) ((a) > (b) ? (a) : (b))
|
272 |
#define cmin(a, b) ((a) < (b) ? (a) : (b))
|
|
1
by brian
clean slate |
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 |
||
202.3.5
by Monty Taylor
Giant merge. |
288 |
#include <libdrizzle/gettext.h> |
202.3.2
by Monty Taylor
Added gettext calls in to my_getopt.c and drizzle.c |
289 |
|
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
290 |
#endif /* DRIZZLE_SERVER_GLOBAL_H */ |