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 |
||
549
by Monty Taylor
Took gettext.h out of header files. |
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 <cstdio>
|
40 |
# include <cstdlib>
|
|
41 |
# include <cstddef>
|
|
42 |
# include <cassert>
|
|
43 |
# include <cerrno>
|
|
670.1.11
by Monty Taylor
Merged from Toru. |
44 |
# include <sstream>
|
481.1.13
by Monty Taylor
Added tests for C99 math extensions for cmath. |
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 |
||
612.2.13
by Monty Taylor
Work on removing global.h from headers that should be installed. |
61 |
#ifndef EOVERFLOW
|
62 |
#define EOVERFLOW 84
|
|
63 |
#endif
|
|
64 |
||
481.1.15
by Monty Taylor
Removed time.h and sys/time.h from global.h. |
65 |
/*
|
1
by brian
clean slate |
66 |
Temporary solution to solve bug#7156. Include "sys/types.h" before
|
67 |
the thread headers, else the function madvise() will not be defined
|
|
68 |
*/
|
|
69 |
#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
|
|
70 |
#include <sys/types.h> |
|
71 |
#endif
|
|
72 |
||
316
by Brian Aker
First pass of new sql_db.cc work |
73 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
74 |
#include <pthread.h> /* AIX must have this included first */ |
75 |
||
76 |
#define _REENTRANT 1 /* Threads requires reentrant code */ |
|
1
by brian
clean slate |
77 |
|
78 |
#ifdef HAVE_LIMITS_H
|
|
79 |
#include <limits.h> |
|
80 |
#endif
|
|
81 |
||
82 |
#ifdef HAVE_SYS_TYPES_H
|
|
83 |
#include <sys/types.h> |
|
84 |
#endif
|
|
85 |
#ifdef HAVE_FCNTL_H
|
|
86 |
#include <fcntl.h> |
|
87 |
#endif
|
|
481.1.13
by Monty Taylor
Added tests for C99 math extensions for cmath. |
88 |
|
1
by brian
clean slate |
89 |
#ifdef HAVE_UNISTD_H
|
90 |
#include <unistd.h> |
|
91 |
#endif
|
|
92 |
||
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
93 |
|
236.1.12
by Monty Taylor
Add global include of sys/stat.h. |
94 |
#ifdef HAVE_SYS_STAT_H
|
95 |
# include <sys/stat.h>
|
|
96 |
#endif
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
97 |
|
1
by brian
clean slate |
98 |
#if !defined(HAVE_UINT)
|
99 |
#undef HAVE_UINT
|
|
100 |
#define HAVE_UINT
|
|
101 |
typedef unsigned int uint; |
|
102 |
#endif
|
|
103 |
||
240.1.6
by Toru Maesaka
removed mystring dependencies from libdrizzle.c |
104 |
/* Declared in int2str() */
|
105 |
extern char _dig_vec_upper[]; |
|
106 |
extern char _dig_vec_lower[]; |
|
107 |
||
1
by brian
clean slate |
108 |
#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. |
109 |
|
1
by brian
clean slate |
110 |
#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. |
111 |
#define array_elements(A) ((size_t) (sizeof(A)/sizeof(A[0])))
|
1
by brian
clean slate |
112 |
|
113 |
/* Some types that is different between systems */
|
|
114 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
115 |
typedef int File; /* File descriptor */ |
398.1.9
by Monty Taylor
Cleaned up stuff out of global.h. |
116 |
|
1
by brian
clean slate |
117 |
#ifdef HAVE_SYS_SOCKET_H
|
118 |
#include <sys/socket.h> |
|
119 |
#endif
|
|
120 |
||
121 |
||
122 |
#ifndef FN_LIBCHAR
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
123 |
#define FN_LIBCHAR '/'
|
124 |
#define FN_ROOTDIR "/"
|
|
1
by brian
clean slate |
125 |
#endif
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
126 |
#define MY_NFILE 64 /* This is only used to save filenames */ |
1
by brian
clean slate |
127 |
#ifndef OS_FILE_LIMIT
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
128 |
#define OS_FILE_LIMIT 65535
|
1
by brian
clean slate |
129 |
#endif
|
130 |
||
131 |
/*
|
|
132 |
How much overhead does malloc have. The code often allocates
|
|
133 |
something like 1024-MALLOC_OVERHEAD bytes
|
|
134 |
*/
|
|
135 |
#define MALLOC_OVERHEAD 8
|
|
136 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
137 |
/* get memory in huncs */
|
138 |
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
|
|
139 |
/* Typical record cash */
|
|
140 |
#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
|
|
141 |
/* Typical key cash */
|
|
142 |
#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
|
|
143 |
/* Default size of a key cache block */
|
|
144 |
#define KEY_CACHE_BLOCK_SIZE (uint) 1024
|
|
145 |
||
146 |
||
147 |
/* Some things that this system doesn't have */
|
|
1
by brian
clean slate |
148 |
|
149 |
/* Some defines of functions for portability */
|
|
150 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
151 |
#undef remove /* Crashes MySQL on SCO 5.0.0 */ |
151
by Brian Aker
Ulonglong to uint64_t |
152 |
#ifndef uint64_t2double
|
153 |
#define uint64_t2double(A) ((double) (uint64_t) (A))
|
|
1
by brian
clean slate |
154 |
#define my_off_t2double(A) ((double) (my_off_t) (A))
|
155 |
#endif
|
|
156 |
||
157 |
#ifndef offsetof
|
|
158 |
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
|
159 |
#endif
|
|
160 |
#define ulong_to_double(X) ((double) (ulong) (X))
|
|
161 |
||
162 |
#ifndef STACK_DIRECTION
|
|
163 |
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
|
|
164 |
#endif
|
|
165 |
||
166 |
#if !defined(HAVE_STRTOK_R)
|
|
167 |
#define strtok_r(A,B,C) strtok((A),(B))
|
|
168 |
#endif
|
|
169 |
||
77.1.24
by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there. |
170 |
#ifdef HAVE_FLOAT_H
|
171 |
#include <float.h> |
|
172 |
#else
|
|
173 |
#if !defined(FLT_MIN)
|
|
174 |
#define FLT_MIN ((float)1.40129846432481707e-45)
|
|
175 |
#endif
|
|
176 |
#if !defined(FLT_MAX)
|
|
177 |
#define FLT_MAX ((float)3.40282346638528860e+38)
|
|
178 |
#endif
|
|
179 |
#endif
|
|
180 |
||
1
by brian
clean slate |
181 |
/* From limits.h instead */
|
182 |
#ifndef DBL_MIN
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
183 |
#define DBL_MIN 4.94065645841246544e-324
|
1
by brian
clean slate |
184 |
#endif
|
185 |
#ifndef DBL_MAX
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
186 |
#define DBL_MAX 1.79769313486231470e+308
|
1
by brian
clean slate |
187 |
#endif
|
188 |
#ifndef SIZE_T_MAX
|
|
189 |
#define SIZE_T_MAX ~((size_t) 0)
|
|
190 |
#endif
|
|
191 |
||
192 |
||
193 |
/* Define missing math constants. */
|
|
194 |
#ifndef M_PI
|
|
195 |
#define M_PI 3.14159265358979323846
|
|
196 |
#endif
|
|
197 |
#ifndef M_E
|
|
198 |
#define M_E 2.7182818284590452354
|
|
199 |
#endif
|
|
200 |
#ifndef M_LN2
|
|
201 |
#define M_LN2 0.69314718055994530942
|
|
202 |
#endif
|
|
203 |
||
204 |
/*
|
|
205 |
Max size that must be added to a so that we know Size to make
|
|
206 |
adressable obj.
|
|
207 |
*/
|
|
481.1.21
by Monty Taylor
Got rid of some size testing. |
208 |
typedef ptrdiff_t my_ptrdiff_t; |
1
by brian
clean slate |
209 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
210 |
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
|
211 |
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
|
|
1
by brian
clean slate |
212 |
/* Size to make adressable obj. */
|
213 |
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
214 |
/* Offset of field f in structure t */
|
215 |
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
|
|
481
by Brian Aker
Remove all of uchar. |
216 |
#define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
|
217 |
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
|
|
1
by brian
clean slate |
218 |
|
219 |
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
|
|
220 |
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
|
|
221 |
||
222 |
/* Typdefs for easyier portability */
|
|
223 |
||
224 |
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
225 |
typedef unsigned long ulong; /* Short for unsigned long */ |
1
by brian
clean slate |
226 |
#endif
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
227 |
|
151
by Brian Aker
Ulonglong to uint64_t |
228 |
typedef uint64_t my_off_t; |
1
by brian
clean slate |
229 |
|
656.1.39
by Monty Taylor
Removed my_seek, my_tell, my_fwrite, my_fseek. |
230 |
#if defined(SIZEOF_OFF_T)
|
231 |
# if (SIZEOF_OFF_T == 8)
|
|
232 |
# define OFF_T_MAX (INT64_MAX)
|
|
233 |
# else
|
|
234 |
# define OFF_T_MAX (INT32_MAX)
|
|
235 |
# endif
|
|
236 |
#endif
|
|
1
by brian
clean slate |
237 |
|
656.1.39
by Monty Taylor
Removed my_seek, my_tell, my_fwrite, my_fseek. |
238 |
#define MY_FILEPOS_ERROR -1
|
1
by brian
clean slate |
239 |
|
240 |
/* Defines for time function */
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
241 |
#define SCALE_SEC 100
|
242 |
#define SCALE_USEC 10000
|
|
243 |
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */ |
|
244 |
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */ |
|
1
by brian
clean slate |
245 |
|
246 |
||
247 |
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
|
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
248 |
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET "utf8"
|
1
by brian
clean slate |
249 |
#else
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
250 |
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET DRIZZLE_DEFAULT_CHARSET_NAME
|
1
by brian
clean slate |
251 |
#endif
|
252 |
||
253 |
#include <dlfcn.h> |
|
254 |
||
255 |
/* FreeBSD 2.2.2 does not define RTLD_NOW) */
|
|
256 |
#ifndef RTLD_NOW
|
|
257 |
#define RTLD_NOW 1
|
|
258 |
#endif
|
|
259 |
||
398.1.4
by Monty Taylor
Renamed max/min. |
260 |
#define cmax(a, b) ((a) > (b) ? (a) : (b))
|
261 |
#define cmin(a, b) ((a) < (b) ? (a) : (b))
|
|
1
by brian
clean slate |
262 |
|
722.1.4
by Monty Taylor
Removed all the setting of DEFS everywhere. Use configmake.h to get the values |
263 |
#define DRIZZLE_SERVER
|
264 |
||
1
by brian
clean slate |
265 |
/* Length of decimal number represented by INT32. */
|
266 |
#define MY_INT32_NUM_DECIMAL_DIGITS 11
|
|
267 |
||
268 |
/* Length of decimal number represented by INT64. */
|
|
269 |
#define MY_INT64_NUM_DECIMAL_DIGITS 21
|
|
270 |
||
722.1.3
by Monty Taylor
Cleaned up a few build things. |
271 |
#define PROTOCOL_VERSION 10
|
272 |
/*
|
|
273 |
Io buffer size; Must be a power of 2 and
|
|
274 |
a multiple of 512. May be
|
|
275 |
smaller what the disk page size. This influences the speed of the
|
|
276 |
isam btree library. eg to big to slow.
|
|
277 |
*/
|
|
278 |
#define IO_SIZE 4096
|
|
279 |
/* Max file name len */
|
|
280 |
#define FN_LEN 256
|
|
281 |
/* Max length of extension (part of FN_LEN) */
|
|
282 |
#define FN_EXTLEN 20
|
|
283 |
/* Max length of full path-name */
|
|
284 |
#define FN_REFLEN 512
|
|
285 |
/* File extension character */
|
|
286 |
#define FN_EXTCHAR '.'
|
|
287 |
/* ~ is used as abbrev for home dir */
|
|
288 |
#define FN_HOMELIB '~'
|
|
289 |
/* ./ is used as abbrev for current dir */
|
|
290 |
#define FN_CURLIB '.'
|
|
291 |
/* Parent directory; Must be a string */
|
|
292 |
#define FN_PARENTDIR ".."
|
|
293 |
||
294 |
/* Quote argument (before cpp) */
|
|
295 |
#ifndef QUOTE_ARG
|
|
296 |
# define QUOTE_ARG(x) #x
|
|
297 |
#endif
|
|
298 |
/* Quote argument, (after cpp) */
|
|
299 |
#ifndef STRINGIFY_ARG
|
|
300 |
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
|
|
301 |
#endif
|
|
302 |
||
303 |
/*
|
|
304 |
* The macros below are borrowed from include/linux/compiler.h in the
|
|
305 |
* Linux kernel. Use them to indicate the likelyhood of the truthfulness
|
|
306 |
* of a condition. This serves two purposes - newer versions of gcc will be
|
|
307 |
* able to optimize for branch predication, which could yield siginficant
|
|
308 |
* performance gains in frequently executed sections of the code, and the
|
|
309 |
* other reason to use them is for documentation
|
|
310 |
*/
|
|
311 |
#if !defined(__GNUC__)
|
|
312 |
#define __builtin_expect(x, expected_value) (x)
|
|
313 |
#endif
|
|
314 |
||
315 |
#define likely(x) __builtin_expect((x),1)
|
|
316 |
#define unlikely(x) __builtin_expect((x),0)
|
|
317 |
||
318 |
||
1
by brian
clean slate |
319 |
/*
|
320 |
Only Linux is known to need an explicit sync of the directory to make sure a
|
|
321 |
file creation/deletion/renaming in(from,to) this directory durable.
|
|
322 |
*/
|
|
323 |
#ifdef TARGET_OS_LINUX
|
|
324 |
#define NEED_EXPLICIT_SYNC_DIR 1
|
|
325 |
#endif
|
|
326 |
||
520.4.43
by mordred
A set of Solaris fixes. |
327 |
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
|
328 |
#if !defined(HAVE_DTRACE)
|
|
329 |
# undef _DTRACE_VERSION
|
|
330 |
# define _DTRACE_VERSION 0
|
|
331 |
#endif
|
|
332 |
||
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
333 |
#endif /* DRIZZLE_SERVER_GLOBAL_H */ |