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 |
#define HAVE_REPLICATION
|
|
26 |
||
27 |
/*
|
|
28 |
InnoDB depends on some MySQL internals which other plugins should not
|
|
29 |
need. This is because of InnoDB's foreign key support, "safe" binlog
|
|
30 |
truncation, and other similar legacy features.
|
|
31 |
||
32 |
We define accessors for these internals unconditionally, but do not
|
|
33 |
expose them in mysql/plugin.h. They are declared in ha_innodb.h for
|
|
34 |
InnoDB's use.
|
|
35 |
*/
|
|
36 |
#define INNODB_COMPATIBILITY_HOOKS
|
|
37 |
||
38 |
/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
|
|
39 |
#ifdef USE_PRAGMA_IMPLEMENTATION
|
|
40 |
#define USE_PRAGMA_INTERFACE
|
|
41 |
#endif
|
|
42 |
||
43 |
#if defined(i386) && !defined(__i386__)
|
|
44 |
#define __i386__
|
|
45 |
#endif
|
|
46 |
||
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 |
47 |
#include "config.h" |
1
by brian
clean slate |
48 |
|
49 |
/*
|
|
50 |
The macros below are borrowed from include/linux/compiler.h in the
|
|
51 |
Linux kernel. Use them to indicate the likelyhood of the truthfulness
|
|
52 |
of a condition. This serves two purposes - newer versions of gcc will be
|
|
53 |
able to optimize for branch predication, which could yield siginficant
|
|
54 |
performance gains in frequently executed sections of the code, and the
|
|
55 |
other reason to use them is for documentation
|
|
56 |
*/
|
|
57 |
||
58 |
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
|
|
59 |
#define __builtin_expect(x, expected_value) (x)
|
|
60 |
#endif
|
|
61 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
62 |
#define likely(x) __builtin_expect((x),1)
|
63 |
#define unlikely(x) __builtin_expect((x),0)
|
|
1
by brian
clean slate |
64 |
|
212.5.26
by Monty Taylor
Removed my_attribute. Renaming __attribute__((format(x,y,z))) to ATTRIBUTE_FORMAT(x,y,z) is retarded. So we don't do it anymore. |
65 |
/*
|
66 |
* Disable __attribute__ for non GNU compilers, since we're using them
|
|
67 |
* only to either generate or suppress warnings.
|
|
68 |
* */
|
|
69 |
#ifndef __attribute__
|
|
70 |
# if !defined(__GNUC__)
|
|
71 |
# define __attribute__(A)
|
|
72 |
# endif
|
|
73 |
#endif
|
|
74 |
||
1
by brian
clean slate |
75 |
|
76 |
/* Fix problem with S_ISLNK() on Linux */
|
|
77 |
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
|
|
78 |
#undef _GNU_SOURCE
|
|
79 |
#define _GNU_SOURCE 1
|
|
80 |
#endif
|
|
81 |
||
77.1.103
by Monty Taylor
Fixed some format strings to use PRIu64 for the uint64_t types. |
82 |
|
1
by brian
clean slate |
83 |
/*
|
84 |
Temporary solution to solve bug#7156. Include "sys/types.h" before
|
|
85 |
the thread headers, else the function madvise() will not be defined
|
|
86 |
*/
|
|
87 |
#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
|
|
88 |
#include <sys/types.h> |
|
89 |
#endif
|
|
90 |
||
316
by Brian Aker
First pass of new sql_db.cc work |
91 |
#if defined(HAVE_STDINT_H)
|
421
by Monty
Made including stdint.h work. |
92 |
#include <stdint.h> |
93 |
#else
|
|
94 |
#error "You must have stdint!"
|
|
95 |
#endif
|
|
96 |
||
97 |
#if defined(HAVE_INTTYPES_H)
|
|
316
by Brian Aker
First pass of new sql_db.cc work |
98 |
#include <inttypes.h> |
319
by Brian Aker
Fix (yuck!) for OSX/Google bug. |
99 |
#else
|
100 |
#error "You must have inttypes!"
|
|
316
by Brian Aker
First pass of new sql_db.cc work |
101 |
#endif
|
102 |
||
103 |
||
1
by brian
clean slate |
104 |
/*
|
105 |
Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
|
|
106 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
107 |
System Interfaces and Headers, Issue 5
|
1
by brian
clean slate |
108 |
|
109 |
saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
|
|
110 |
but apparently other systems (namely FreeBSD) don't agree.
|
|
111 |
||
112 |
On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
|
|
113 |
Furthermore, it tests that if a program requires older standard
|
|
114 |
(_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
|
|
115 |
run on a new compiler (that defines _STDC_C99) and issues an #error.
|
|
116 |
It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
|
|
117 |
or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
|
|
118 |
||
119 |
To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
|
|
120 |
C++ compiler does not!
|
|
121 |
||
122 |
So, in a desperate attempt to get correct prototypes for both
|
|
123 |
C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
|
|
124 |
depending on the compiler's announced C standard support.
|
|
125 |
||
126 |
Cleaner solutions are welcome.
|
|
127 |
*/
|
|
139.1.20
by Trond Norbye
g++ does not define __STDC_VERSION__ |
128 |
#if defined(__sun) && !defined(__cplusplus)
|
1
by brian
clean slate |
129 |
#if __STDC_VERSION__ - 0 >= 199901L
|
130 |
#define _XOPEN_SOURCE 600
|
|
131 |
#else
|
|
132 |
#define _XOPEN_SOURCE 500
|
|
133 |
#endif
|
|
134 |
#endif
|
|
135 |
||
136 |
#ifndef _POSIX_PTHREAD_SEMANTICS
|
|
137 |
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */ |
|
138 |
#endif
|
|
139 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
140 |
#define _REENTRANT 1 /* Some thread libraries require this */ |
141 |
||
142 |
#include <pthread.h> /* AIX must have this included first */ |
|
143 |
||
144 |
#define _REENTRANT 1 /* Threads requires reentrant code */ |
|
1
by brian
clean slate |
145 |
|
146 |
||
147 |
/* gcc/egcs issues */
|
|
148 |
||
149 |
#if defined(__GNUC) && defined(__EXCEPTIONS)
|
|
150 |
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
|
|
151 |
#endif
|
|
152 |
||
153 |
#ifndef stdin
|
|
154 |
#include <stdio.h> |
|
155 |
#endif
|
|
156 |
#ifdef HAVE_STDLIB_H
|
|
157 |
#include <stdlib.h> |
|
158 |
#endif
|
|
159 |
#ifdef HAVE_STDDEF_H
|
|
160 |
#include <stddef.h> |
|
161 |
#endif
|
|
162 |
||
163 |
#include <math.h> |
|
164 |
#ifdef HAVE_LIMITS_H
|
|
165 |
#include <limits.h> |
|
166 |
#endif
|
|
167 |
||
168 |
#ifdef HAVE_SYS_TYPES_H
|
|
169 |
#include <sys/types.h> |
|
170 |
#endif
|
|
171 |
#ifdef HAVE_FCNTL_H
|
|
172 |
#include <fcntl.h> |
|
173 |
#endif
|
|
174 |
#ifdef HAVE_SYS_TIMEB_H
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
175 |
#include <sys/timeb.h> /* Avoid warnings on SCO */ |
1
by brian
clean slate |
176 |
#endif
|
177 |
#if TIME_WITH_SYS_TIME
|
|
178 |
# include <sys/time.h>
|
|
179 |
# include <time.h>
|
|
180 |
#else
|
|
181 |
# if HAVE_SYS_TIME_H
|
|
182 |
# include <sys/time.h>
|
|
183 |
# else
|
|
184 |
# include <time.h>
|
|
185 |
# endif
|
|
186 |
#endif /* TIME_WITH_SYS_TIME */ |
|
187 |
#ifdef HAVE_UNISTD_H
|
|
188 |
#include <unistd.h> |
|
189 |
#endif
|
|
190 |
#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
|
|
191 |
#undef HAVE_ALLOCA
|
|
192 |
#undef HAVE_ALLOCA_H
|
|
193 |
#endif
|
|
194 |
#ifdef HAVE_ALLOCA_H
|
|
195 |
#include <alloca.h> |
|
196 |
#endif
|
|
197 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
198 |
#include <errno.h> /* Recommended by debian */ |
1
by brian
clean slate |
199 |
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
200 |
#if defined(HAVE_STDBOOL_H)
|
201 |
#include <stdbool.h> |
|
202 |
#endif
|
|
203 |
||
236.1.12
by Monty Taylor
Add global include of sys/stat.h. |
204 |
#ifdef HAVE_SYS_STAT_H
|
205 |
# include <sys/stat.h>
|
|
206 |
#endif
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
207 |
|
1
by brian
clean slate |
208 |
/*
|
209 |
A lot of our programs uses asserts, so better to always include it
|
|
210 |
*/
|
|
211 |
#include <assert.h> |
|
212 |
||
213 |
/* an assert that works at compile-time. only for constant expression */
|
|
214 |
#ifndef __GNUC__
|
|
215 |
#define compile_time_assert(X) do { } while(0)
|
|
216 |
#else
|
|
217 |
#define compile_time_assert(X) \
|
|
218 |
do \
|
|
219 |
{ \
|
|
220 |
char compile_time_assert[(X) ? 1 : -1] \
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
221 |
__attribute__ ((unused)); \
|
1
by brian
clean slate |
222 |
} while(0)
|
223 |
#endif
|
|
224 |
||
225 |
/* Declare madvise where it is not declared for C++, like Solaris */
|
|
392
by Monty Taylor
Fixed a small compile problem. |
226 |
#if defined(HAVE_MADVISE) && !defined(HAVE_DECL_MADVISE) && defined(__cplusplus)
|
1
by brian
clean slate |
227 |
extern "C" int madvise(void *addr, size_t len, int behav); |
228 |
#endif
|
|
229 |
||
230 |
/* We can not live without the following defines */
|
|
231 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
232 |
#define MASTER 1 /* Compile without unireg */ |
1
by brian
clean slate |
233 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
234 |
#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */ |
235 |
#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */ |
|
1
by brian
clean slate |
236 |
/* Does the system remember a signal handler after a signal ? */
|
237 |
#ifndef HAVE_BSD_SIGNALS
|
|
238 |
#define DONT_REMEMBER_SIGNAL
|
|
239 |
#endif
|
|
240 |
||
241 |
#if !defined(HAVE_UINT)
|
|
242 |
#undef HAVE_UINT
|
|
243 |
#define HAVE_UINT
|
|
244 |
typedef unsigned int uint; |
|
245 |
typedef unsigned short ushort; |
|
246 |
#endif
|
|
247 |
||
240.1.6
by Toru Maesaka
removed mystring dependencies from libdrizzle.c |
248 |
/* Declared in int2str() */
|
249 |
extern char _dig_vec_upper[]; |
|
250 |
extern char _dig_vec_lower[]; |
|
251 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
252 |
#define test(a) ((a) ? 1 : 0)
|
1
by brian
clean slate |
253 |
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
|
254 |
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
|
|
255 |
#define test_all_bits(a,b) (((a) & (b)) == (b))
|
|
256 |
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
|
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
257 |
#define array_elements(A) ((uint32_t) (sizeof(A)/sizeof(A[0])))
|
1
by brian
clean slate |
258 |
#ifndef HAVE_RINT
|
259 |
#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
|
|
260 |
#endif
|
|
261 |
||
262 |
#if defined(__GNUC__)
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
263 |
#define function_volatile volatile
|
1
by brian
clean slate |
264 |
#define my_reinterpret_cast(A) reinterpret_cast<A>
|
265 |
#define my_const_cast(A) const_cast<A>
|
|
266 |
# ifndef GCC_VERSION
|
|
267 |
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
|
268 |
# endif
|
|
269 |
#elif !defined(my_reinterpret_cast)
|
|
270 |
#define my_reinterpret_cast(A) (A)
|
|
271 |
#define my_const_cast(A) (A)
|
|
272 |
#endif
|
|
273 |
||
274 |
/* Some types that is different between systems */
|
|
275 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
276 |
typedef int File; /* File descriptor */ |
1
by brian
clean slate |
277 |
/* Type for fuctions that handles signals */
|
398.1.9
by Monty Taylor
Cleaned up stuff out of global.h. |
278 |
/* RETSIGTYPE is defined by autoconf */
|
1
by brian
clean slate |
279 |
#define sig_handler RETSIGTYPE
|
398.1.9
by Monty Taylor
Cleaned up stuff out of global.h. |
280 |
|
281 |
#ifdef __cplusplus
|
|
282 |
extern "C" { |
|
283 |
#endif
|
|
284 |
||
285 |
typedef void (*sig_return)(void);/* Returns type from signal */ |
|
286 |
typedef int (*qsort_cmp)(const void *,const void *); |
|
287 |
typedef int (*qsort_cmp2)(void*, const void *,const void *); |
|
288 |
||
289 |
#ifdef __cplusplus
|
|
290 |
}
|
|
291 |
#endif
|
|
292 |
||
1
by brian
clean slate |
293 |
#ifdef HAVE_SYS_SOCKET_H
|
294 |
#include <sys/socket.h> |
|
295 |
#endif
|
|
296 |
typedef SOCKET_SIZE_TYPE size_socket; |
|
297 |
||
298 |
#ifndef SOCKOPT_OPTLEN_TYPE
|
|
299 |
#define SOCKOPT_OPTLEN_TYPE size_socket
|
|
300 |
#endif
|
|
301 |
||
302 |
/* file create flags */
|
|
303 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
304 |
#ifndef O_SHARE /* Probably not windows */ |
305 |
#define O_SHARE 0 /* Flag to my_open for shared files */ |
|
77.1.24
by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there. |
306 |
#endif /* O_SHARE */ |
307 |
||
1
by brian
clean slate |
308 |
#ifndef O_BINARY
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
309 |
#define O_BINARY 0 /* Flag to my_open for binary files */ |
1
by brian
clean slate |
310 |
#endif
|
77.1.24
by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there. |
311 |
|
1
by brian
clean slate |
312 |
#ifndef FILE_BINARY
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
313 |
#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */ |
1
by brian
clean slate |
314 |
#endif
|
77.1.24
by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there. |
315 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
316 |
#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */ |
1
by brian
clean slate |
317 |
|
318 |
#ifndef O_TEMPORARY
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
319 |
#define O_TEMPORARY 0
|
1
by brian
clean slate |
320 |
#endif
|
321 |
#ifndef O_SHORT_LIVED
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
322 |
#define O_SHORT_LIVED 0
|
1
by brian
clean slate |
323 |
#endif
|
324 |
#ifndef O_NOFOLLOW
|
|
325 |
#define O_NOFOLLOW 0
|
|
326 |
#endif
|
|
327 |
||
390.1.6
by Monty Taylor
Oh dear god the changes. The changes. I'd tell you what they are, but I'd just be making stuff up. Suffice it to day it's mostly all around splitting files in libdrizzle into different files and removing interdepends. And whatever else I happened to see... |
328 |
|
1
by brian
clean slate |
329 |
|
330 |
#ifndef FN_LIBCHAR
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
331 |
#define FN_LIBCHAR '/'
|
332 |
#define FN_ROOTDIR "/"
|
|
1
by brian
clean slate |
333 |
#endif
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
334 |
#define MY_NFILE 64 /* This is only used to save filenames */ |
1
by brian
clean slate |
335 |
#ifndef OS_FILE_LIMIT
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
336 |
#define OS_FILE_LIMIT 65535
|
1
by brian
clean slate |
337 |
#endif
|
338 |
||
339 |
/* #define EXT_IN_LIBNAME */
|
|
340 |
/* #define FN_NO_CASE_SENCE */
|
|
341 |
/* #define FN_UPPER_CASE TRUE */
|
|
342 |
||
343 |
/*
|
|
344 |
How much overhead does malloc have. The code often allocates
|
|
345 |
something like 1024-MALLOC_OVERHEAD bytes
|
|
346 |
*/
|
|
347 |
#define MALLOC_OVERHEAD 8
|
|
348 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
349 |
/* get memory in huncs */
|
350 |
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
|
|
351 |
/* Typical record cash */
|
|
352 |
#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
|
|
353 |
/* Typical key cash */
|
|
354 |
#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
|
|
355 |
/* Default size of a key cache block */
|
|
356 |
#define KEY_CACHE_BLOCK_SIZE (uint) 1024
|
|
357 |
||
358 |
||
359 |
/* Some things that this system doesn't have */
|
|
1
by brian
clean slate |
360 |
|
361 |
/* Some defines of functions for portability */
|
|
362 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
363 |
#undef remove /* Crashes MySQL on SCO 5.0.0 */ |
151
by Brian Aker
Ulonglong to uint64_t |
364 |
#ifndef uint64_t2double
|
365 |
#define uint64_t2double(A) ((double) (uint64_t) (A))
|
|
1
by brian
clean slate |
366 |
#define my_off_t2double(A) ((double) (my_off_t) (A))
|
367 |
#endif
|
|
368 |
||
369 |
#ifndef offsetof
|
|
370 |
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
|
371 |
#endif
|
|
372 |
#define ulong_to_double(X) ((double) (ulong) (X))
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
373 |
#define SET_STACK_SIZE(X) /* Not needed on real machines */ |
1
by brian
clean slate |
374 |
|
375 |
#ifndef STACK_DIRECTION
|
|
376 |
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
|
|
377 |
#endif
|
|
378 |
||
379 |
#if !defined(HAVE_STRTOK_R)
|
|
380 |
#define strtok_r(A,B,C) strtok((A),(B))
|
|
381 |
#endif
|
|
382 |
||
77.1.24
by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there. |
383 |
#ifdef HAVE_FLOAT_H
|
384 |
#include <float.h> |
|
385 |
#else
|
|
386 |
#if !defined(FLT_MIN)
|
|
387 |
#define FLT_MIN ((float)1.40129846432481707e-45)
|
|
388 |
#endif
|
|
389 |
#if !defined(FLT_MAX)
|
|
390 |
#define FLT_MAX ((float)3.40282346638528860e+38)
|
|
391 |
#endif
|
|
392 |
#endif
|
|
393 |
||
1
by brian
clean slate |
394 |
/* From limits.h instead */
|
395 |
#ifndef DBL_MIN
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
396 |
#define DBL_MIN 4.94065645841246544e-324
|
1
by brian
clean slate |
397 |
#endif
|
398 |
#ifndef DBL_MAX
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
399 |
#define DBL_MAX 1.79769313486231470e+308
|
1
by brian
clean slate |
400 |
#endif
|
401 |
#ifndef SIZE_T_MAX
|
|
402 |
#define SIZE_T_MAX ~((size_t) 0)
|
|
403 |
#endif
|
|
404 |
||
405 |
#ifndef isfinite
|
|
406 |
#ifdef HAVE_FINITE
|
|
407 |
#define isfinite(x) finite(x)
|
|
408 |
#else
|
|
409 |
#define finite(x) (1.0 / fabs(x) > 0.0)
|
|
410 |
#endif /* HAVE_FINITE */ |
|
411 |
#endif /* isfinite */ |
|
412 |
||
413 |
#ifndef HAVE_ISNAN
|
|
414 |
#define isnan(x) ((x) != (x))
|
|
415 |
#endif
|
|
416 |
||
417 |
#ifdef HAVE_ISINF
|
|
418 |
/* isinf() can be used in both C and C++ code */
|
|
419 |
#define my_isinf(X) isinf(X)
|
|
420 |
#else
|
|
421 |
#define my_isinf(X) (!isfinite(X) && !isnan(X))
|
|
422 |
#endif
|
|
423 |
||
424 |
/* Define missing math constants. */
|
|
425 |
#ifndef M_PI
|
|
426 |
#define M_PI 3.14159265358979323846
|
|
427 |
#endif
|
|
428 |
#ifndef M_E
|
|
429 |
#define M_E 2.7182818284590452354
|
|
430 |
#endif
|
|
431 |
#ifndef M_LN2
|
|
432 |
#define M_LN2 0.69314718055994530942
|
|
433 |
#endif
|
|
434 |
||
435 |
/*
|
|
436 |
Max size that must be added to a so that we know Size to make
|
|
437 |
adressable obj.
|
|
438 |
*/
|
|
439 |
#if SIZEOF_CHARP == 4
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
440 |
typedef int32_t my_ptrdiff_t; |
1
by brian
clean slate |
441 |
#else
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
442 |
typedef int64_t my_ptrdiff_t; |
1
by brian
clean slate |
443 |
#endif
|
444 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
445 |
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
|
446 |
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
|
|
1
by brian
clean slate |
447 |
/* Size to make adressable obj. */
|
448 |
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
449 |
/* Offset of field f in structure t */
|
450 |
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
|
|
1
by brian
clean slate |
451 |
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
|
452 |
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
|
|
453 |
||
454 |
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
|
|
455 |
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
|
|
456 |
||
457 |
/*
|
|
458 |
Custom version of standard offsetof() macro which can be used to get
|
|
459 |
offsets of members in class for non-POD types (according to the current
|
|
460 |
version of C++ standard offsetof() macro can't be used in such cases and
|
|
461 |
attempt to do so causes warnings to be emitted, OTOH in many cases it is
|
|
462 |
still OK to assume that all instances of the class has the same offsets
|
|
463 |
for the same members).
|
|
464 |
||
465 |
This is temporary solution which should be removed once File_parser class
|
|
466 |
and related routines are refactored.
|
|
467 |
*/
|
|
468 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
469 |
#define my_offsetof(TYPE, MEMBER) \
|
470 |
((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
|
|
1
by brian
clean slate |
471 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
472 |
#define NullS (char *) 0
|
1
by brian
clean slate |
473 |
|
474 |
/* Typdefs for easyier portability */
|
|
475 |
||
476 |
#ifndef HAVE_UCHAR
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
477 |
typedef unsigned char uchar; /* Short for unsigned char */ |
1
by brian
clean slate |
478 |
#endif
|
479 |
||
480 |
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
481 |
typedef unsigned long ulong; /* Short for unsigned long */ |
1
by brian
clean slate |
482 |
#endif
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
483 |
|
77.1.103
by Monty Taylor
Fixed some format strings to use PRIu64 for the uint64_t types. |
484 |
#if SIZEOF_OFF_T > 4
|
151
by Brian Aker
Ulonglong to uint64_t |
485 |
typedef uint64_t my_off_t; |
1
by brian
clean slate |
486 |
#else
|
487 |
typedef unsigned long my_off_t; |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
488 |
#endif
|
489 |
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
|
|
1
by brian
clean slate |
490 |
|
491 |
typedef off_t os_off_t; |
|
492 |
||
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
493 |
#define socket_errno errno
|
494 |
#define SOCKET_EINTR EINTR
|
|
495 |
#define SOCKET_EAGAIN EAGAIN
|
|
1
by brian
clean slate |
496 |
#define SOCKET_ETIMEDOUT SOCKET_EINTR
|
497 |
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
|
|
498 |
#define SOCKET_EADDRINUSE EADDRINUSE
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
499 |
#define SOCKET_ENFILE ENFILE
|
500 |
#define SOCKET_EMFILE EMFILE
|
|
1
by brian
clean slate |
501 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
502 |
typedef uint8_t int7; /* Most effective integer 0 <= x <= 127 */ |
503 |
typedef short int15; /* Most effective integer 0 <= x <= 32767 */ |
|
504 |
typedef int myf; /* Type of MyFlags in my_funcs */ |
|
1
by brian
clean slate |
505 |
#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
506 |
typedef char bool; /* Ordinary boolean values 0 1 */ |
1
by brian
clean slate |
507 |
#endif
|
508 |
#define MYF(v) (myf) (v)
|
|
509 |
||
510 |
/* Defines for time function */
|
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
511 |
#define SCALE_SEC 100
|
512 |
#define SCALE_USEC 10000
|
|
513 |
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */ |
|
514 |
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */ |
|
1
by brian
clean slate |
515 |
|
516 |
||
517 |
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
|
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
518 |
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET "utf8"
|
1
by brian
clean slate |
519 |
#else
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
520 |
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET DRIZZLE_DEFAULT_CHARSET_NAME
|
1
by brian
clean slate |
521 |
#endif
|
522 |
||
523 |
#include <dlfcn.h> |
|
524 |
||
525 |
/* FreeBSD 2.2.2 does not define RTLD_NOW) */
|
|
526 |
#ifndef RTLD_NOW
|
|
527 |
#define RTLD_NOW 1
|
|
528 |
#endif
|
|
529 |
||
398.1.4
by Monty Taylor
Renamed max/min. |
530 |
#define cmax(a, b) ((a) > (b) ? (a) : (b))
|
531 |
#define cmin(a, b) ((a) < (b) ? (a) : (b))
|
|
1
by brian
clean slate |
532 |
|
533 |
/* Length of decimal number represented by INT32. */
|
|
534 |
#define MY_INT32_NUM_DECIMAL_DIGITS 11
|
|
535 |
||
536 |
/* Length of decimal number represented by INT64. */
|
|
537 |
#define MY_INT64_NUM_DECIMAL_DIGITS 21
|
|
538 |
||
539 |
/*
|
|
540 |
Only Linux is known to need an explicit sync of the directory to make sure a
|
|
541 |
file creation/deletion/renaming in(from,to) this directory durable.
|
|
542 |
*/
|
|
543 |
#ifdef TARGET_OS_LINUX
|
|
544 |
#define NEED_EXPLICIT_SYNC_DIR 1
|
|
545 |
#endif
|
|
546 |
||
202.3.5
by Monty Taylor
Giant merge. |
547 |
#include <libdrizzle/gettext.h> |
202.3.2
by Monty Taylor
Added gettext calls in to my_getopt.c and drizzle.c |
548 |
|
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
549 |
#endif /* DRIZZLE_SERVER_GLOBAL_H */ |