1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2003 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
14 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
/* This is the include file that should be included 'first' in every C file. */
|
|
17 |
||
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
18 |
#ifndef DRIZZLE_SERVER_GLOBAL_H
|
19 |
#define DRIZZLE_SERVER_GLOBAL_H
|
|
1
by brian
clean slate |
20 |
|
21 |
#define HAVE_REPLICATION
|
|
22 |
#define HAVE_EXTERNAL_CLIENT
|
|
23 |
||
24 |
/*
|
|
25 |
InnoDB depends on some MySQL internals which other plugins should not
|
|
26 |
need. This is because of InnoDB's foreign key support, "safe" binlog
|
|
27 |
truncation, and other similar legacy features.
|
|
28 |
||
29 |
We define accessors for these internals unconditionally, but do not
|
|
30 |
expose them in mysql/plugin.h. They are declared in ha_innodb.h for
|
|
31 |
InnoDB's use.
|
|
32 |
*/
|
|
33 |
#define INNODB_COMPATIBILITY_HOOKS
|
|
34 |
||
35 |
/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
|
|
36 |
#ifdef USE_PRAGMA_IMPLEMENTATION
|
|
37 |
#define USE_PRAGMA_INTERFACE
|
|
38 |
#endif
|
|
39 |
||
40 |
#if defined(i386) && !defined(__i386__)
|
|
41 |
#define __i386__
|
|
42 |
#endif
|
|
43 |
||
44 |
/* Macros to make switching between C and C++ mode easier */
|
|
45 |
#ifdef __cplusplus
|
|
46 |
#define C_MODE_START extern "C" {
|
|
47 |
#define C_MODE_END }
|
|
48 |
#else
|
|
49 |
#define C_MODE_START
|
|
50 |
#define C_MODE_END
|
|
51 |
#endif
|
|
52 |
||
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 |
53 |
#include "config.h" |
1
by brian
clean slate |
54 |
|
55 |
/* Make it easier to add conditionl code for windows */
|
|
56 |
#define IF_WIN(A,B) (B)
|
|
57 |
||
58 |
/*
|
|
59 |
The macros below are borrowed from include/linux/compiler.h in the
|
|
60 |
Linux kernel. Use them to indicate the likelyhood of the truthfulness
|
|
61 |
of a condition. This serves two purposes - newer versions of gcc will be
|
|
62 |
able to optimize for branch predication, which could yield siginficant
|
|
63 |
performance gains in frequently executed sections of the code, and the
|
|
64 |
other reason to use them is for documentation
|
|
65 |
*/
|
|
66 |
||
67 |
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
|
|
68 |
#define __builtin_expect(x, expected_value) (x)
|
|
69 |
#endif
|
|
70 |
||
71 |
#define likely(x) __builtin_expect((x),1)
|
|
72 |
#define unlikely(x) __builtin_expect((x),0)
|
|
73 |
||
74 |
||
75 |
/*
|
|
76 |
The macros below are useful in optimising places where it has been
|
|
77 |
discovered that cache misses stall the process and where a prefetch
|
|
78 |
of the cache line can improve matters. This is available in GCC 3.1.1
|
|
79 |
and later versions.
|
|
80 |
PREFETCH_READ says that addr is going to be used for reading and that
|
|
81 |
it is to be kept in caches if possible for a while
|
|
82 |
PREFETCH_WRITE also says that the item to be cached is likely to be
|
|
83 |
updated.
|
|
84 |
The *LOCALITY scripts are also available for experimentation purposes
|
|
85 |
mostly and should only be used if they are verified to improve matters.
|
|
86 |
For more input see GCC manual (available in GCC 3.1.1 and later)
|
|
87 |
*/
|
|
88 |
||
89 |
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)
|
|
90 |
#define PREFETCH_READ(addr) __builtin_prefetch(addr, 0, 3)
|
|
91 |
#define PREFETCH_WRITE(addr) \
|
|
92 |
__builtin_prefetch(addr, 1, 3)
|
|
93 |
#define PREFETCH_READ_LOCALITY(addr, locality) \
|
|
94 |
__builtin_prefetch(addr, 0, locality)
|
|
95 |
#define PREFETCH_WRITE_LOCALITY(addr, locality) \
|
|
96 |
__builtin_prefetch(addr, 1, locality)
|
|
97 |
#else
|
|
98 |
#define PREFETCH_READ(addr)
|
|
99 |
#define PREFETCH_READ_LOCALITY(addr, locality)
|
|
100 |
#define PREFETCH_WRITE(addr)
|
|
101 |
#define PREFETCH_WRITE_LOCALITY(addr, locality)
|
|
102 |
#endif
|
|
103 |
||
104 |
/*
|
|
105 |
now let's figure out if inline functions are supported
|
|
106 |
autoconf defines 'inline' to be empty, if not
|
|
107 |
*/
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
108 |
#if defined(inline)
|
1
by brian
clean slate |
109 |
#define HAVE_INLINE
|
110 |
#endif
|
|
111 |
/* helper macro for "instantiating" inline functions */
|
|
112 |
#define STATIC_INLINE static inline
|
|
113 |
||
114 |
/*
|
|
115 |
The following macros are used to control inlining a bit more than
|
|
116 |
usual. These macros are used to ensure that inlining always or
|
|
117 |
never occurs (independent of compilation mode).
|
|
118 |
For more input see GCC manual (available in GCC 3.1.1 and later)
|
|
119 |
*/
|
|
120 |
||
121 |
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)
|
|
122 |
#define ALWAYS_INLINE __attribute__ ((always_inline))
|
|
123 |
#define NEVER_INLINE __attribute__ ((noinline))
|
|
124 |
#else
|
|
125 |
#define ALWAYS_INLINE
|
|
126 |
#define NEVER_INLINE
|
|
127 |
#endif
|
|
128 |
||
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. |
129 |
/*
|
130 |
* Disable __attribute__ for non GNU compilers, since we're using them
|
|
131 |
* only to either generate or suppress warnings.
|
|
132 |
* */
|
|
133 |
#ifndef __attribute__
|
|
134 |
# if !defined(__GNUC__)
|
|
135 |
# define __attribute__(A)
|
|
136 |
# endif
|
|
137 |
#endif
|
|
138 |
||
1
by brian
clean slate |
139 |
|
140 |
/* Fix problem with S_ISLNK() on Linux */
|
|
141 |
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
|
|
142 |
#undef _GNU_SOURCE
|
|
143 |
#define _GNU_SOURCE 1
|
|
144 |
#endif
|
|
145 |
||
77.1.103
by Monty Taylor
Fixed some format strings to use PRIu64 for the uint64_t types. |
146 |
|
1
by brian
clean slate |
147 |
/*
|
148 |
Temporary solution to solve bug#7156. Include "sys/types.h" before
|
|
149 |
the thread headers, else the function madvise() will not be defined
|
|
150 |
*/
|
|
151 |
#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
|
|
152 |
#include <sys/types.h> |
|
153 |
#endif
|
|
154 |
||
155 |
#ifdef HAVE_THREADS_WITHOUT_SOCKETS
|
|
156 |
/* MIT pthreads does not work with unix sockets */
|
|
157 |
#undef HAVE_SYS_UN_H
|
|
158 |
#endif
|
|
159 |
||
160 |
#define __EXTENSIONS__ 1 /* We want some extension */ |
|
161 |
#ifndef __STDC_EXT__
|
|
162 |
#define __STDC_EXT__ 1 /* To get large file support on hpux */ |
|
163 |
#endif
|
|
164 |
||
165 |
/*
|
|
166 |
Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
|
|
167 |
||
168 |
System Interfaces and Headers, Issue 5
|
|
169 |
||
170 |
saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
|
|
171 |
but apparently other systems (namely FreeBSD) don't agree.
|
|
172 |
||
173 |
On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
|
|
174 |
Furthermore, it tests that if a program requires older standard
|
|
175 |
(_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
|
|
176 |
run on a new compiler (that defines _STDC_C99) and issues an #error.
|
|
177 |
It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
|
|
178 |
or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
|
|
179 |
||
180 |
To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
|
|
181 |
C++ compiler does not!
|
|
182 |
||
183 |
So, in a desperate attempt to get correct prototypes for both
|
|
184 |
C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
|
|
185 |
depending on the compiler's announced C standard support.
|
|
186 |
||
187 |
Cleaner solutions are welcome.
|
|
188 |
*/
|
|
189 |
#ifdef __sun
|
|
190 |
#if __STDC_VERSION__ - 0 >= 199901L
|
|
191 |
#define _XOPEN_SOURCE 600
|
|
192 |
#else
|
|
193 |
#define _XOPEN_SOURCE 500
|
|
194 |
#endif
|
|
195 |
#endif
|
|
196 |
||
197 |
#ifndef _POSIX_PTHREAD_SEMANTICS
|
|
198 |
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */ |
|
199 |
#endif
|
|
200 |
||
201 |
#define _REENTRANT 1 /* Some thread libraries require this */ |
|
202 |
||
203 |
#if !defined(_THREAD_SAFE) && !defined(_AIX)
|
|
204 |
#define _THREAD_SAFE /* Required for OSF1 */ |
|
205 |
#endif
|
|
206 |
||
207 |
#include <pthread.h> /* AIX must have this included first */ |
|
208 |
||
209 |
#define _REENTRANT 1 /* Threads requires reentrant code */ |
|
210 |
||
211 |
/* Go around some bugs in different OS and compilers */
|
|
212 |
||
213 |
#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
|
|
214 |
#undef inline
|
|
215 |
#define inline
|
|
216 |
#endif
|
|
217 |
||
218 |
/* gcc/egcs issues */
|
|
219 |
||
220 |
#if defined(__GNUC) && defined(__EXCEPTIONS)
|
|
221 |
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
|
|
222 |
#endif
|
|
223 |
||
212.1.2
by Monty Taylor
Moved include location of stdint.h, per Eric Day. |
224 |
#if defined(HAVE_STDINT_H)
|
225 |
/* Need to include this _before_ stdlib, so that all defines are right */
|
|
226 |
/* We are mixing C and C++, so we wan the C limit macros in the C++ too */
|
|
227 |
/* Enable some extra C99 extensions */
|
|
228 |
#define __STDC_LIMIT_MACROS
|
|
229 |
#define __STDC_FORMAT_MACROS
|
|
230 |
#include <inttypes.h> |
|
231 |
#include <stdint.h> |
|
232 |
#endif
|
|
233 |
||
1
by brian
clean slate |
234 |
#ifndef stdin
|
235 |
#include <stdio.h> |
|
236 |
#endif
|
|
237 |
#ifdef HAVE_STDLIB_H
|
|
238 |
#include <stdlib.h> |
|
239 |
#endif
|
|
240 |
#ifdef HAVE_STDDEF_H
|
|
241 |
#include <stddef.h> |
|
242 |
#endif
|
|
243 |
||
244 |
#include <math.h> |
|
245 |
#ifdef HAVE_LIMITS_H
|
|
246 |
#include <limits.h> |
|
247 |
#endif
|
|
248 |
||
249 |
#ifdef HAVE_SYS_TYPES_H
|
|
250 |
#include <sys/types.h> |
|
251 |
#endif
|
|
252 |
#ifdef HAVE_FCNTL_H
|
|
253 |
#include <fcntl.h> |
|
254 |
#endif
|
|
255 |
#ifdef HAVE_SYS_TIMEB_H
|
|
256 |
#include <sys/timeb.h> /* Avoid warnings on SCO */ |
|
257 |
#endif
|
|
258 |
#if TIME_WITH_SYS_TIME
|
|
259 |
# include <sys/time.h>
|
|
260 |
# include <time.h>
|
|
261 |
#else
|
|
262 |
# if HAVE_SYS_TIME_H
|
|
263 |
# include <sys/time.h>
|
|
264 |
# else
|
|
265 |
# include <time.h>
|
|
266 |
# endif
|
|
267 |
#endif /* TIME_WITH_SYS_TIME */ |
|
268 |
#ifdef HAVE_UNISTD_H
|
|
269 |
#include <unistd.h> |
|
270 |
#endif
|
|
271 |
#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
|
|
272 |
#undef HAVE_ALLOCA
|
|
273 |
#undef HAVE_ALLOCA_H
|
|
274 |
#endif
|
|
275 |
#ifdef HAVE_ALLOCA_H
|
|
276 |
#include <alloca.h> |
|
277 |
#endif
|
|
278 |
||
279 |
#include <errno.h> /* Recommended by debian */ |
|
280 |
||
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
281 |
#if defined(HAVE_STDBOOL_H)
|
282 |
#include <stdbool.h> |
|
283 |
#endif
|
|
284 |
||
236.1.12
by Monty Taylor
Add global include of sys/stat.h. |
285 |
#ifdef HAVE_SYS_STAT_H
|
286 |
# include <sys/stat.h>
|
|
287 |
#endif
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
288 |
|
1
by brian
clean slate |
289 |
/*
|
290 |
A lot of our programs uses asserts, so better to always include it
|
|
291 |
*/
|
|
292 |
#include <assert.h> |
|
293 |
||
294 |
/* an assert that works at compile-time. only for constant expression */
|
|
295 |
#ifndef __GNUC__
|
|
296 |
#define compile_time_assert(X) do { } while(0)
|
|
297 |
#else
|
|
298 |
#define compile_time_assert(X) \
|
|
299 |
do \
|
|
300 |
{ \
|
|
301 |
char compile_time_assert[(X) ? 1 : -1] \
|
|
302 |
__attribute__ ((unused)); \
|
|
303 |
} while(0)
|
|
304 |
#endif
|
|
305 |
||
306 |
/* Declare madvise where it is not declared for C++, like Solaris */
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
307 |
#if HAVE_MADVISE && !defined(HAVE_DECL_MADVISE) && defined(__cplusplus)
|
1
by brian
clean slate |
308 |
extern "C" int madvise(void *addr, size_t len, int behav); |
309 |
#endif
|
|
310 |
||
311 |
/* We can not live without the following defines */
|
|
312 |
||
313 |
#define USE_MYFUNC 1 /* Must use syscall indirection */ |
|
314 |
#define MASTER 1 /* Compile without unireg */ |
|
315 |
#define ENGLISH 1 /* Messages in English */ |
|
316 |
#define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */ |
|
317 |
||
318 |
#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */ |
|
319 |
#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */ |
|
320 |
/* Does the system remember a signal handler after a signal ? */
|
|
321 |
#ifndef HAVE_BSD_SIGNALS
|
|
322 |
#define DONT_REMEMBER_SIGNAL
|
|
323 |
#endif
|
|
324 |
||
325 |
/* Define void to stop lint from generating "null effekt" comments */
|
|
326 |
#ifndef DONT_DEFINE_VOID
|
|
327 |
#ifdef _lint
|
|
328 |
int __void__; |
|
329 |
#define VOID(X) (__void__ = (int) (X))
|
|
330 |
#else
|
|
331 |
#undef VOID
|
|
332 |
#define VOID(X) (X)
|
|
333 |
#endif
|
|
334 |
#endif /* DONT_DEFINE_VOID */ |
|
335 |
||
336 |
#if !defined(HAVE_UINT)
|
|
337 |
#undef HAVE_UINT
|
|
338 |
#define HAVE_UINT
|
|
339 |
typedef unsigned int uint; |
|
340 |
typedef unsigned short ushort; |
|
341 |
#endif
|
|
342 |
||
240.1.6
by Toru Maesaka
removed mystring dependencies from libdrizzle.c |
343 |
/* Declared in int2str() */
|
344 |
extern char _dig_vec_upper[]; |
|
345 |
extern char _dig_vec_lower[]; |
|
346 |
||
1
by brian
clean slate |
347 |
#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
|
348 |
#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
|
|
349 |
#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; }
|
|
350 |
#define test(a) ((a) ? 1 : 0)
|
|
351 |
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
|
|
352 |
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
|
|
353 |
#define test_all_bits(a,b) (((a) & (b)) == (b))
|
|
354 |
#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. |
355 |
#define array_elements(A) ((uint32_t) (sizeof(A)/sizeof(A[0])))
|
1
by brian
clean slate |
356 |
#ifndef HAVE_RINT
|
357 |
#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
|
|
358 |
#endif
|
|
359 |
||
360 |
#if defined(__GNUC__)
|
|
361 |
#define function_volatile volatile
|
|
362 |
#define my_reinterpret_cast(A) reinterpret_cast<A>
|
|
363 |
#define my_const_cast(A) const_cast<A>
|
|
364 |
# ifndef GCC_VERSION
|
|
365 |
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
|
366 |
# endif
|
|
367 |
#elif !defined(my_reinterpret_cast)
|
|
368 |
#define my_reinterpret_cast(A) (A)
|
|
369 |
#define my_const_cast(A) (A)
|
|
370 |
#endif
|
|
371 |
||
372 |
/* From old s-system.h */
|
|
373 |
||
374 |
/*
|
|
375 |
Support macros for non ansi & other old compilers. Since such
|
|
376 |
things are no longer supported we do nothing. We keep then since
|
|
377 |
some of our code may still be needed to upgrade old customers.
|
|
378 |
*/
|
|
379 |
#define _VARARGS(X) X
|
|
380 |
#define _STATIC_VARARGS(X) X
|
|
381 |
#define _PC(X) X
|
|
382 |
||
383 |
#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/ |
|
384 |
#define ASCII_BITS_USED 8 /* Bit char used */ |
|
385 |
||
386 |
/* Some types that is different between systems */
|
|
387 |
||
388 |
typedef int File; /* File descriptor */ |
|
389 |
/* Type for fuctions that handles signals */
|
|
390 |
#define sig_handler RETSIGTYPE
|
|
391 |
C_MODE_START
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
392 |
typedef void (*sig_return)(void);/* Returns type from signal */ |
1
by brian
clean slate |
393 |
typedef int (*qsort_cmp)(const void *,const void *); |
394 |
typedef int (*qsort_cmp2)(void*, const void *,const void *); |
|
395 |
C_MODE_END
|
|
396 |
#define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */ |
|
397 |
#ifdef HAVE_SYS_SOCKET_H
|
|
398 |
#include <sys/socket.h> |
|
399 |
#endif
|
|
400 |
typedef SOCKET_SIZE_TYPE size_socket; |
|
401 |
||
402 |
#ifndef SOCKOPT_OPTLEN_TYPE
|
|
403 |
#define SOCKOPT_OPTLEN_TYPE size_socket
|
|
404 |
#endif
|
|
405 |
||
406 |
/* file create flags */
|
|
407 |
||
408 |
#ifndef O_SHARE /* Probably not windows */ |
|
409 |
#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. |
410 |
#endif /* O_SHARE */ |
411 |
||
1
by brian
clean slate |
412 |
#ifndef O_BINARY
|
413 |
#define O_BINARY 0 /* Flag to my_open for binary files */ |
|
414 |
#endif
|
|
77.1.24
by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there. |
415 |
|
1
by brian
clean slate |
416 |
#ifndef FILE_BINARY
|
417 |
#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */ |
|
418 |
#endif
|
|
77.1.24
by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there. |
419 |
|
1
by brian
clean slate |
420 |
#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */ |
421 |
||
422 |
#ifndef O_TEMPORARY
|
|
423 |
#define O_TEMPORARY 0
|
|
424 |
#endif
|
|
425 |
#ifndef O_SHORT_LIVED
|
|
426 |
#define O_SHORT_LIVED 0
|
|
427 |
#endif
|
|
428 |
#ifndef O_NOFOLLOW
|
|
429 |
#define O_NOFOLLOW 0
|
|
430 |
#endif
|
|
431 |
||
432 |
/* #define USE_RECORD_LOCK */
|
|
433 |
||
434 |
/* Unsigned types supported by the compiler */
|
|
206
by Brian Aker
Removed final uint dead types. |
435 |
#define UNSINT8 /* unsigned int8_t (char) */ |
436 |
#define UNSINT16 /* unsigned int16_t */ |
|
205
by Brian Aker
uint32 -> uin32_t |
437 |
#define UNSINT32 /* unsigned int32_t */ |
1
by brian
clean slate |
438 |
|
439 |
/* General constants */
|
|
440 |
#define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */ |
|
441 |
#define FN_LEN 256 /* Max file name len */ |
|
442 |
#define FN_HEADLEN 253 /* Max length of filepart of file name */ |
|
443 |
#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */ |
|
444 |
#define FN_REFLEN 512 /* Max length of full path-name */ |
|
445 |
#define FN_EXTCHAR '.'
|
|
446 |
#define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */ |
|
447 |
#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */ |
|
448 |
#define FN_PARENTDIR ".." /* Parent directory; Must be a string */ |
|
449 |
||
450 |
#ifndef FN_LIBCHAR
|
|
451 |
#define FN_LIBCHAR '/'
|
|
452 |
#define FN_ROOTDIR "/"
|
|
453 |
#endif
|
|
454 |
#define MY_NFILE 64 /* This is only used to save filenames */ |
|
455 |
#ifndef OS_FILE_LIMIT
|
|
456 |
#define OS_FILE_LIMIT 65535
|
|
457 |
#endif
|
|
458 |
||
459 |
/* #define EXT_IN_LIBNAME */
|
|
460 |
/* #define FN_NO_CASE_SENCE */
|
|
461 |
/* #define FN_UPPER_CASE TRUE */
|
|
462 |
||
463 |
/*
|
|
464 |
Io buffer size; Must be a power of 2 and a multiple of 512. May be
|
|
465 |
smaller what the disk page size. This influences the speed of the
|
|
466 |
isam btree library. eg to big to slow.
|
|
467 |
*/
|
|
468 |
#define IO_SIZE 4096
|
|
469 |
/*
|
|
470 |
How much overhead does malloc have. The code often allocates
|
|
471 |
something like 1024-MALLOC_OVERHEAD bytes
|
|
472 |
*/
|
|
473 |
#define MALLOC_OVERHEAD 8
|
|
474 |
||
475 |
/* get memory in huncs */
|
|
476 |
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
|
|
477 |
/* Typical record cash */
|
|
478 |
#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
|
|
479 |
/* Typical key cash */
|
|
480 |
#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
|
|
481 |
/* Default size of a key cache block */
|
|
482 |
#define KEY_CACHE_BLOCK_SIZE (uint) 1024
|
|
483 |
||
484 |
||
485 |
/* Some things that this system doesn't have */
|
|
486 |
||
487 |
/* Some defines of functions for portability */
|
|
488 |
||
489 |
#undef remove /* Crashes MySQL on SCO 5.0.0 */ |
|
490 |
#define closesocket(A) close(A)
|
|
151
by Brian Aker
Ulonglong to uint64_t |
491 |
#ifndef uint64_t2double
|
492 |
#define uint64_t2double(A) ((double) (uint64_t) (A))
|
|
1
by brian
clean slate |
493 |
#define my_off_t2double(A) ((double) (my_off_t) (A))
|
494 |
#endif
|
|
495 |
||
496 |
#ifndef offsetof
|
|
497 |
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
|
498 |
#endif
|
|
499 |
#define ulong_to_double(X) ((double) (ulong) (X))
|
|
500 |
#define SET_STACK_SIZE(X) /* Not needed on real machines */ |
|
501 |
||
502 |
#ifndef STACK_DIRECTION
|
|
503 |
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
|
|
504 |
#endif
|
|
505 |
||
506 |
#if !defined(HAVE_STRTOK_R)
|
|
507 |
#define strtok_r(A,B,C) strtok((A),(B))
|
|
508 |
#endif
|
|
509 |
||
77.1.24
by Monty Taylor
Removed non-fcntl code and made it a fatal configure error if it's not there. |
510 |
#ifdef HAVE_FLOAT_H
|
511 |
#include <float.h> |
|
512 |
#else
|
|
513 |
#if !defined(FLT_MIN)
|
|
514 |
#define FLT_MIN ((float)1.40129846432481707e-45)
|
|
515 |
#endif
|
|
516 |
#if !defined(FLT_MAX)
|
|
517 |
#define FLT_MAX ((float)3.40282346638528860e+38)
|
|
518 |
#endif
|
|
519 |
#endif
|
|
520 |
||
1
by brian
clean slate |
521 |
/* From limits.h instead */
|
522 |
#ifndef DBL_MIN
|
|
523 |
#define DBL_MIN 4.94065645841246544e-324
|
|
524 |
#endif
|
|
525 |
#ifndef DBL_MAX
|
|
526 |
#define DBL_MAX 1.79769313486231470e+308
|
|
527 |
#endif
|
|
528 |
#ifndef SIZE_T_MAX
|
|
529 |
#define SIZE_T_MAX ~((size_t) 0)
|
|
530 |
#endif
|
|
531 |
||
532 |
#ifndef isfinite
|
|
533 |
#ifdef HAVE_FINITE
|
|
534 |
#define isfinite(x) finite(x)
|
|
535 |
#else
|
|
536 |
#define finite(x) (1.0 / fabs(x) > 0.0)
|
|
537 |
#endif /* HAVE_FINITE */ |
|
538 |
#endif /* isfinite */ |
|
539 |
||
540 |
#ifndef HAVE_ISNAN
|
|
541 |
#define isnan(x) ((x) != (x))
|
|
542 |
#endif
|
|
543 |
||
544 |
#ifdef HAVE_ISINF
|
|
545 |
/* isinf() can be used in both C and C++ code */
|
|
546 |
#define my_isinf(X) isinf(X)
|
|
547 |
#else
|
|
548 |
#define my_isinf(X) (!isfinite(X) && !isnan(X))
|
|
549 |
#endif
|
|
550 |
||
551 |
/* Define missing math constants. */
|
|
552 |
#ifndef M_PI
|
|
553 |
#define M_PI 3.14159265358979323846
|
|
554 |
#endif
|
|
555 |
#ifndef M_E
|
|
556 |
#define M_E 2.7182818284590452354
|
|
557 |
#endif
|
|
558 |
#ifndef M_LN2
|
|
559 |
#define M_LN2 0.69314718055994530942
|
|
560 |
#endif
|
|
561 |
||
562 |
/*
|
|
563 |
Max size that must be added to a so that we know Size to make
|
|
564 |
adressable obj.
|
|
565 |
*/
|
|
566 |
#if SIZEOF_CHARP == 4
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
567 |
typedef int32_t my_ptrdiff_t; |
1
by brian
clean slate |
568 |
#else
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
569 |
typedef int64_t my_ptrdiff_t; |
1
by brian
clean slate |
570 |
#endif
|
571 |
||
572 |
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
|
|
573 |
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
|
|
574 |
/* Size to make adressable obj. */
|
|
575 |
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
|
|
576 |
/* Offset of field f in structure t */
|
|
577 |
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
|
|
578 |
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
|
|
579 |
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
|
|
580 |
||
581 |
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
|
|
582 |
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
|
|
583 |
||
584 |
/*
|
|
585 |
Custom version of standard offsetof() macro which can be used to get
|
|
586 |
offsets of members in class for non-POD types (according to the current
|
|
587 |
version of C++ standard offsetof() macro can't be used in such cases and
|
|
588 |
attempt to do so causes warnings to be emitted, OTOH in many cases it is
|
|
589 |
still OK to assume that all instances of the class has the same offsets
|
|
590 |
for the same members).
|
|
591 |
||
592 |
This is temporary solution which should be removed once File_parser class
|
|
593 |
and related routines are refactored.
|
|
594 |
*/
|
|
595 |
||
596 |
#define my_offsetof(TYPE, MEMBER) \
|
|
597 |
((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
|
|
598 |
||
599 |
#define NullS (char *) 0
|
|
600 |
||
601 |
#define STDCALL
|
|
602 |
||
603 |
/* Typdefs for easyier portability */
|
|
604 |
||
605 |
#ifndef HAVE_UCHAR
|
|
606 |
typedef unsigned char uchar; /* Short for unsigned char */ |
|
607 |
#endif
|
|
608 |
||
609 |
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
|
|
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
610 |
typedef unsigned long ulong; /* Short for unsigned long */ |
1
by brian
clean slate |
611 |
#endif
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
612 |
|
1
by brian
clean slate |
613 |
#define MY_ERRPTR ((void*)(intptr)1)
|
614 |
||
77.1.103
by Monty Taylor
Fixed some format strings to use PRIu64 for the uint64_t types. |
615 |
#if SIZEOF_OFF_T > 4
|
151
by Brian Aker
Ulonglong to uint64_t |
616 |
typedef uint64_t my_off_t; |
1
by brian
clean slate |
617 |
#else
|
618 |
typedef unsigned long my_off_t; |
|
77.1.103
by Monty Taylor
Fixed some format strings to use PRIu64 for the uint64_t types. |
619 |
#endif
|
1
by brian
clean slate |
620 |
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
|
621 |
||
622 |
typedef off_t os_off_t; |
|
623 |
||
624 |
#define socket_errno errno
|
|
625 |
#define closesocket(A) close(A)
|
|
626 |
#define SOCKET_EINTR EINTR
|
|
627 |
#define SOCKET_EAGAIN EAGAIN
|
|
628 |
#define SOCKET_ETIMEDOUT SOCKET_EINTR
|
|
629 |
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
|
|
630 |
#define SOCKET_EADDRINUSE EADDRINUSE
|
|
631 |
#define SOCKET_ENFILE ENFILE
|
|
632 |
#define SOCKET_EMFILE EMFILE
|
|
633 |
||
206
by Brian Aker
Removed final uint dead types. |
634 |
typedef uint8_t int7; /* Most effective integer 0 <= x <= 127 */ |
1
by brian
clean slate |
635 |
typedef short int15; /* Most effective integer 0 <= x <= 32767 */ |
636 |
typedef int myf; /* Type of MyFlags in my_funcs */ |
|
637 |
typedef char my_bool; /* Small bool */ |
|
638 |
#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
|
|
639 |
typedef char bool; /* Ordinary boolean values 0 1 */ |
|
640 |
#endif
|
|
641 |
/* Macros for converting *constants* to the right type */
|
|
206
by Brian Aker
Removed final uint dead types. |
642 |
#define INT8(v) (int8_t) (v)
|
643 |
#define INT16(v) (int16_t) (v)
|
|
205
by Brian Aker
uint32 -> uin32_t |
644 |
#define INT32(v) (int32_t) (v)
|
1
by brian
clean slate |
645 |
#define MYF(v) (myf) (v)
|
646 |
||
647 |
/* Defines for time function */
|
|
648 |
#define SCALE_SEC 100
|
|
649 |
#define SCALE_USEC 10000
|
|
650 |
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */ |
|
651 |
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */ |
|
652 |
||
653 |
||
654 |
||
655 |
/*
|
|
656 |
Define-funktions for reading and storing in machine independent format
|
|
657 |
(low byte first)
|
|
658 |
*/
|
|
659 |
||
660 |
/* Optimized store functions for Intel x86 */
|
|
661 |
#if defined(__i386__)
|
|
206
by Brian Aker
Removed final uint dead types. |
662 |
#define sint2korr(A) (*((int16_t *) (A)))
|
205
by Brian Aker
uint32 -> uin32_t |
663 |
#define sint3korr(A) ((int32_t) ((((uchar) (A)[2]) & 128) ? \
|
664 |
(((uint32_t) 255L << 24) | \
|
|
665 |
(((uint32_t) (uchar) (A)[2]) << 16) |\
|
|
666 |
(((uint32_t) (uchar) (A)[1]) << 8) | \
|
|
667 |
((uint32_t) (uchar) (A)[0])) : \
|
|
668 |
(((uint32_t) (uchar) (A)[2]) << 16) |\
|
|
669 |
(((uint32_t) (uchar) (A)[1]) << 8) | \
|
|
670 |
((uint32_t) (uchar) (A)[0])))
|
|
1
by brian
clean slate |
671 |
#define sint4korr(A) (*((long *) (A)))
|
206
by Brian Aker
Removed final uint dead types. |
672 |
#define uint2korr(A) (*((uint16_t *) (A)))
|
1
by brian
clean slate |
673 |
#if defined(HAVE_purify)
|
205
by Brian Aker
uint32 -> uin32_t |
674 |
#define uint3korr(A) (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
|
675 |
(((uint32_t) ((uchar) (A)[1])) << 8) +\
|
|
676 |
(((uint32_t) ((uchar) (A)[2])) << 16))
|
|
1
by brian
clean slate |
677 |
#else
|
678 |
/*
|
|
679 |
ATTENTION !
|
|
680 |
|
|
681 |
Please, note, uint3korr reads 4 bytes (not 3) !
|
|
682 |
It means, that you have to provide enough allocated space !
|
|
683 |
*/
|
|
684 |
#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF)
|
|
685 |
#endif /* HAVE_purify */ |
|
205
by Brian Aker
uint32 -> uin32_t |
686 |
#define uint4korr(A) (*((uint32_t *) (A)))
|
687 |
#define uint5korr(A) ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
|
|
688 |
(((uint32_t) ((uchar) (A)[1])) << 8) +\
|
|
689 |
(((uint32_t) ((uchar) (A)[2])) << 16) +\
|
|
690 |
(((uint32_t) ((uchar) (A)[3])) << 24)) +\
|
|
151
by Brian Aker
Ulonglong to uint64_t |
691 |
(((uint64_t) ((uchar) (A)[4])) << 32))
|
205
by Brian Aker
uint32 -> uin32_t |
692 |
#define uint6korr(A) ((uint64_t)(((uint32_t) ((uchar) (A)[0])) + \
|
693 |
(((uint32_t) ((uchar) (A)[1])) << 8) + \
|
|
694 |
(((uint32_t) ((uchar) (A)[2])) << 16) + \
|
|
695 |
(((uint32_t) ((uchar) (A)[3])) << 24)) + \
|
|
151
by Brian Aker
Ulonglong to uint64_t |
696 |
(((uint64_t) ((uchar) (A)[4])) << 32) + \
|
697 |
(((uint64_t) ((uchar) (A)[5])) << 40))
|
|
698 |
#define uint8korr(A) (*((uint64_t *) (A)))
|
|
152
by Brian Aker
longlong replacement |
699 |
#define sint8korr(A) (*((int64_t *) (A)))
|
206
by Brian Aker
Removed final uint dead types. |
700 |
#define int2store(T,A) *((uint16_t*) (T))= (uint16_t) (A)
|
1
by brian
clean slate |
701 |
#define int3store(T,A) do { *(T)= (uchar) ((A));\
|
702 |
*(T+1)=(uchar) (((uint) (A) >> 8));\
|
|
703 |
*(T+2)=(uchar) (((A) >> 16)); } while (0)
|
|
704 |
#define int4store(T,A) *((long *) (T))= (long) (A)
|
|
705 |
#define int5store(T,A) do { *(T)= (uchar)((A));\
|
|
706 |
*((T)+1)=(uchar) (((A) >> 8));\
|
|
707 |
*((T)+2)=(uchar) (((A) >> 16));\
|
|
708 |
*((T)+3)=(uchar) (((A) >> 24)); \
|
|
709 |
*((T)+4)=(uchar) (((A) >> 32)); } while(0)
|
|
710 |
#define int6store(T,A) do { *(T)= (uchar)((A)); \
|
|
711 |
*((T)+1)=(uchar) (((A) >> 8)); \
|
|
712 |
*((T)+2)=(uchar) (((A) >> 16)); \
|
|
713 |
*((T)+3)=(uchar) (((A) >> 24)); \
|
|
714 |
*((T)+4)=(uchar) (((A) >> 32)); \
|
|
715 |
*((T)+5)=(uchar) (((A) >> 40)); } while(0)
|
|
151
by Brian Aker
Ulonglong to uint64_t |
716 |
#define int8store(T,A) *((uint64_t *) (T))= (uint64_t) (A)
|
1
by brian
clean slate |
717 |
|
718 |
typedef union { |
|
719 |
double v; |
|
720 |
long m[2]; |
|
721 |
} doubleget_union; |
|
722 |
#define doubleget(V,M) \
|
|
723 |
do { doubleget_union _tmp; \
|
|
724 |
_tmp.m[0] = *((long*)(M)); \
|
|
725 |
_tmp.m[1] = *(((long*) (M))+1); \
|
|
726 |
(V) = _tmp.v; } while(0)
|
|
727 |
#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
|
|
728 |
*(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
|
|
729 |
} while (0)
|
|
730 |
#define float4get(V,M) do { *((float *) &(V)) = *((float*) (M)); } while(0)
|
|
731 |
#define float8get(V,M) doubleget((V),(M))
|
|
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
732 |
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
|
733 |
#define floatstore(T,V) memcpy((T), (&V), sizeof(float))
|
|
734 |
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
|
|
1
by brian
clean slate |
735 |
#define float8store(V,M) doublestore((V),(M))
|
736 |
#else
|
|
737 |
||
738 |
/*
|
|
739 |
We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
|
|
740 |
were done before)
|
|
741 |
*/
|
|
206
by Brian Aker
Removed final uint dead types. |
742 |
#define sint2korr(A) (int16_t) (((int16_t) ((uchar) (A)[0])) +\
|
743 |
((int16_t) ((int16_t) (A)[1]) << 8))
|
|
205
by Brian Aker
uint32 -> uin32_t |
744 |
#define sint3korr(A) ((int32_t) ((((uchar) (A)[2]) & 128) ? \
|
745 |
(((uint32_t) 255L << 24) | \
|
|
746 |
(((uint32_t) (uchar) (A)[2]) << 16) |\
|
|
747 |
(((uint32_t) (uchar) (A)[1]) << 8) | \
|
|
748 |
((uint32_t) (uchar) (A)[0])) : \
|
|
749 |
(((uint32_t) (uchar) (A)[2]) << 16) |\
|
|
750 |
(((uint32_t) (uchar) (A)[1]) << 8) | \
|
|
751 |
((uint32_t) (uchar) (A)[0])))
|
|
752 |
#define sint4korr(A) (int32_t) (((int32_t) ((uchar) (A)[0])) +\
|
|
753 |
(((int32_t) ((uchar) (A)[1]) << 8)) +\
|
|
754 |
(((int32_t) ((uchar) (A)[2]) << 16)) +\
|
|
206
by Brian Aker
Removed final uint dead types. |
755 |
(((int32_t) ((int16_t) (A)[3]) << 24)))
|
152
by Brian Aker
longlong replacement |
756 |
#define sint8korr(A) (int64_t) uint8korr(A)
|
206
by Brian Aker
Removed final uint dead types. |
757 |
#define uint2korr(A) (uint16_t) (((uint16_t) ((uchar) (A)[0])) +\
|
758 |
((uint16_t) ((uchar) (A)[1]) << 8))
|
|
205
by Brian Aker
uint32 -> uin32_t |
759 |
#define uint3korr(A) (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
|
760 |
(((uint32_t) ((uchar) (A)[1])) << 8) +\
|
|
761 |
(((uint32_t) ((uchar) (A)[2])) << 16))
|
|
762 |
#define uint4korr(A) (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
|
|
763 |
(((uint32_t) ((uchar) (A)[1])) << 8) +\
|
|
764 |
(((uint32_t) ((uchar) (A)[2])) << 16) +\
|
|
765 |
(((uint32_t) ((uchar) (A)[3])) << 24))
|
|
766 |
#define uint5korr(A) ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
|
|
767 |
(((uint32_t) ((uchar) (A)[1])) << 8) +\
|
|
768 |
(((uint32_t) ((uchar) (A)[2])) << 16) +\
|
|
769 |
(((uint32_t) ((uchar) (A)[3])) << 24)) +\
|
|
151
by Brian Aker
Ulonglong to uint64_t |
770 |
(((uint64_t) ((uchar) (A)[4])) << 32))
|
205
by Brian Aker
uint32 -> uin32_t |
771 |
#define uint6korr(A) ((uint64_t)(((uint32_t) ((uchar) (A)[0])) + \
|
772 |
(((uint32_t) ((uchar) (A)[1])) << 8) + \
|
|
773 |
(((uint32_t) ((uchar) (A)[2])) << 16) + \
|
|
774 |
(((uint32_t) ((uchar) (A)[3])) << 24)) + \
|
|
151
by Brian Aker
Ulonglong to uint64_t |
775 |
(((uint64_t) ((uchar) (A)[4])) << 32) + \
|
776 |
(((uint64_t) ((uchar) (A)[5])) << 40))
|
|
205
by Brian Aker
uint32 -> uin32_t |
777 |
#define uint8korr(A) ((uint64_t)(((uint32_t) ((uchar) (A)[0])) +\
|
778 |
(((uint32_t) ((uchar) (A)[1])) << 8) +\
|
|
779 |
(((uint32_t) ((uchar) (A)[2])) << 16) +\
|
|
780 |
(((uint32_t) ((uchar) (A)[3])) << 24)) +\
|
|
781 |
(((uint64_t) (((uint32_t) ((uchar) (A)[4])) +\
|
|
782 |
(((uint32_t) ((uchar) (A)[5])) << 8) +\
|
|
783 |
(((uint32_t) ((uchar) (A)[6])) << 16) +\
|
|
784 |
(((uint32_t) ((uchar) (A)[7])) << 24))) <<\
|
|
1
by brian
clean slate |
785 |
32))
|
786 |
#define int2store(T,A) do { uint def_temp= (uint) (A) ;\
|
|
787 |
*((uchar*) (T))= (uchar)(def_temp); \
|
|
788 |
*((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
|
|
789 |
} while(0)
|
|
790 |
#define int3store(T,A) do { /*lint -save -e734 */\ |
|
791 |
*((uchar*)(T))=(uchar) ((A));\
|
|
792 |
*((uchar*) (T)+1)=(uchar) (((A) >> 8));\
|
|
793 |
*((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
|
|
794 |
/*lint -restore */} while(0) |
|
795 |
#define int4store(T,A) do { *((char *)(T))=(char) ((A));\
|
|
796 |
*(((char *)(T))+1)=(char) (((A) >> 8));\
|
|
797 |
*(((char *)(T))+2)=(char) (((A) >> 16));\
|
|
798 |
*(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
|
|
799 |
#define int5store(T,A) do { *((char *)(T))= (char)((A)); \
|
|
800 |
*(((char *)(T))+1)= (char)(((A) >> 8)); \
|
|
801 |
*(((char *)(T))+2)= (char)(((A) >> 16)); \
|
|
802 |
*(((char *)(T))+3)= (char)(((A) >> 24)); \
|
|
803 |
*(((char *)(T))+4)= (char)(((A) >> 32)); \
|
|
804 |
} while(0)
|
|
805 |
#define int6store(T,A) do { *((char *)(T))= (char)((A)); \
|
|
806 |
*(((char *)(T))+1)= (char)(((A) >> 8)); \
|
|
807 |
*(((char *)(T))+2)= (char)(((A) >> 16)); \
|
|
808 |
*(((char *)(T))+3)= (char)(((A) >> 24)); \
|
|
809 |
*(((char *)(T))+4)= (char)(((A) >> 32)); \
|
|
810 |
*(((char *)(T))+5)= (char)(((A) >> 40)); \
|
|
811 |
} while(0)
|
|
812 |
#define int8store(T,A) do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
|
|
813 |
int4store((T),def_temp); \
|
|
814 |
int4store((T+4),def_temp2); } while(0)
|
|
815 |
#ifdef WORDS_BIGENDIAN
|
|
816 |
#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
|
|
817 |
*((T)+1)=(char) ((uchar *) &A)[2];\
|
|
818 |
*((T)+2)=(char) ((uchar *) &A)[1];\
|
|
819 |
*((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
|
|
820 |
||
821 |
#define float4get(V,M) do { float def_temp;\
|
|
822 |
((uchar*) &def_temp)[0]=(M)[3];\
|
|
823 |
((uchar*) &def_temp)[1]=(M)[2];\
|
|
824 |
((uchar*) &def_temp)[2]=(M)[1];\
|
|
825 |
((uchar*) &def_temp)[3]=(M)[0];\
|
|
826 |
(V)=def_temp; } while(0)
|
|
827 |
#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
|
|
828 |
*((T)+1)=(char) ((uchar *) &V)[6];\
|
|
829 |
*((T)+2)=(char) ((uchar *) &V)[5];\
|
|
830 |
*((T)+3)=(char) ((uchar *) &V)[4];\
|
|
831 |
*((T)+4)=(char) ((uchar *) &V)[3];\
|
|
832 |
*((T)+5)=(char) ((uchar *) &V)[2];\
|
|
833 |
*((T)+6)=(char) ((uchar *) &V)[1];\
|
|
834 |
*((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
|
|
835 |
||
836 |
#define float8get(V,M) do { double def_temp;\
|
|
837 |
((uchar*) &def_temp)[0]=(M)[7];\
|
|
838 |
((uchar*) &def_temp)[1]=(M)[6];\
|
|
839 |
((uchar*) &def_temp)[2]=(M)[5];\
|
|
840 |
((uchar*) &def_temp)[3]=(M)[4];\
|
|
841 |
((uchar*) &def_temp)[4]=(M)[3];\
|
|
842 |
((uchar*) &def_temp)[5]=(M)[2];\
|
|
843 |
((uchar*) &def_temp)[6]=(M)[1];\
|
|
844 |
((uchar*) &def_temp)[7]=(M)[0];\
|
|
845 |
(V) = def_temp; } while(0)
|
|
846 |
#else
|
|
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
847 |
#define float4get(V,M) memcpy(&V, (M), sizeof(float))
|
848 |
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
|
|
1
by brian
clean slate |
849 |
|
850 |
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
|
|
851 |
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
|
|
852 |
*(((char*)T)+1)=(char) ((uchar *) &V)[5];\
|
|
853 |
*(((char*)T)+2)=(char) ((uchar *) &V)[6];\
|
|
854 |
*(((char*)T)+3)=(char) ((uchar *) &V)[7];\
|
|
855 |
*(((char*)T)+4)=(char) ((uchar *) &V)[0];\
|
|
856 |
*(((char*)T)+5)=(char) ((uchar *) &V)[1];\
|
|
857 |
*(((char*)T)+6)=(char) ((uchar *) &V)[2];\
|
|
858 |
*(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\
|
|
859 |
while(0)
|
|
860 |
#define doubleget(V,M) do { double def_temp;\
|
|
861 |
((uchar*) &def_temp)[0]=(M)[4];\
|
|
862 |
((uchar*) &def_temp)[1]=(M)[5];\
|
|
863 |
((uchar*) &def_temp)[2]=(M)[6];\
|
|
864 |
((uchar*) &def_temp)[3]=(M)[7];\
|
|
865 |
((uchar*) &def_temp)[4]=(M)[0];\
|
|
866 |
((uchar*) &def_temp)[5]=(M)[1];\
|
|
867 |
((uchar*) &def_temp)[6]=(M)[2];\
|
|
868 |
((uchar*) &def_temp)[7]=(M)[3];\
|
|
869 |
(V) = def_temp; } while(0)
|
|
870 |
#endif /* __FLOAT_WORD_ORDER */ |
|
871 |
||
872 |
#define float8get(V,M) doubleget((V),(M))
|
|
873 |
#define float8store(V,M) doublestore((V),(M))
|
|
874 |
#endif /* WORDS_BIGENDIAN */ |
|
875 |
||
876 |
#endif /* __i386__ */ |
|
877 |
||
878 |
/*
|
|
879 |
Macro for reading 32-bit integer from network byte order (big-endian)
|
|
880 |
from unaligned memory location.
|
|
881 |
*/
|
|
205
by Brian Aker
uint32 -> uin32_t |
882 |
#define int4net(A) (int32_t) (((uint32_t) ((uchar) (A)[3])) |\
|
883 |
(((uint32_t) ((uchar) (A)[2])) << 8) |\
|
|
884 |
(((uint32_t) ((uchar) (A)[1])) << 16) |\
|
|
885 |
(((uint32_t) ((uchar) (A)[0])) << 24))
|
|
1
by brian
clean slate |
886 |
/*
|
887 |
Define-funktions for reading and storing in machine format from/to
|
|
888 |
short/long to/from some place in memory V should be a (not
|
|
889 |
register) variable, M is a pointer to byte
|
|
890 |
*/
|
|
891 |
||
892 |
#ifdef WORDS_BIGENDIAN
|
|
893 |
||
206
by Brian Aker
Removed final uint dead types. |
894 |
#define ushortget(V,M) do { V = (uint16_t) (((uint16_t) ((uchar) (M)[1]))+\
|
895 |
((uint16_t) ((uint16_t) (M)[0]) << 8)); } while(0)
|
|
1
by brian
clean slate |
896 |
#define shortget(V,M) do { V = (short) (((short) ((uchar) (M)[1]))+\
|
897 |
((short) ((short) (M)[0]) << 8)); } while(0)
|
|
205
by Brian Aker
uint32 -> uin32_t |
898 |
#define longget(V,M) do { int32_t def_temp;\
|
1
by brian
clean slate |
899 |
((uchar*) &def_temp)[0]=(M)[0];\
|
900 |
((uchar*) &def_temp)[1]=(M)[1];\
|
|
901 |
((uchar*) &def_temp)[2]=(M)[2];\
|
|
902 |
((uchar*) &def_temp)[3]=(M)[3];\
|
|
903 |
(V)=def_temp; } while(0)
|
|
205
by Brian Aker
uint32 -> uin32_t |
904 |
#define ulongget(V,M) do { uint32_t def_temp;\
|
1
by brian
clean slate |
905 |
((uchar*) &def_temp)[0]=(M)[0];\
|
906 |
((uchar*) &def_temp)[1]=(M)[1];\
|
|
907 |
((uchar*) &def_temp)[2]=(M)[2];\
|
|
908 |
((uchar*) &def_temp)[3]=(M)[3];\
|
|
909 |
(V)=def_temp; } while(0)
|
|
910 |
#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
|
|
911 |
*(((char*)T)+1)=(char)(def_temp); \
|
|
912 |
*(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
|
|
913 |
#define longstore(T,A) do { *(((char*)T)+3)=((A));\
|
|
914 |
*(((char*)T)+2)=(((A) >> 8));\
|
|
915 |
*(((char*)T)+1)=(((A) >> 16));\
|
|
916 |
*(((char*)T)+0)=(((A) >> 24)); } while(0)
|
|
917 |
||
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
918 |
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
|
919 |
#define floatstore(T, V) memcpy((T), (&V), sizeof(float))
|
|
920 |
#define doubleget(V, M) memcpy(&V, (M), sizeof(double))
|
|
921 |
#define doublestore(T, V) memcpy((T), &V, sizeof(double))
|
|
922 |
#define int64_tget(V, M) memcpy(&V, (M), sizeof(uint64_t))
|
|
923 |
#define int64_tstore(T, V) memcpy((T), &V, sizeof(uint64_t))
|
|
1
by brian
clean slate |
924 |
|
925 |
#else
|
|
926 |
||
927 |
#define ushortget(V,M) do { V = uint2korr(M); } while(0)
|
|
928 |
#define shortget(V,M) do { V = sint2korr(M); } while(0)
|
|
929 |
#define longget(V,M) do { V = sint4korr(M); } while(0)
|
|
930 |
#define ulongget(V,M) do { V = uint4korr(M); } while(0)
|
|
931 |
#define shortstore(T,V) int2store(T,V)
|
|
932 |
#define longstore(T,V) int4store(T,V)
|
|
933 |
#ifndef floatstore
|
|
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
934 |
#define floatstore(T,V) memcpy((T), (&V), sizeof(float))
|
935 |
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
|
|
1
by brian
clean slate |
936 |
#endif
|
937 |
#ifndef doubleget
|
|
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
938 |
#define doubleget(V, M) memcpy(&V, (M), sizeof(double))
|
939 |
#define doublestore(T,V) memcpy((T), &V, sizeof(double))
|
|
1
by brian
clean slate |
940 |
#endif /* doubleget */ |
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
941 |
#define int64_tget(V,M) memcpy(&V, (M), sizeof(uint64_t))
|
942 |
#define int64_tstore(T,V) memcpy((T), &V, sizeof(uint64_t))
|
|
1
by brian
clean slate |
943 |
|
944 |
#endif /* WORDS_BIGENDIAN */ |
|
945 |
||
171.1.1
by Patrick Galbraith
Dar, I forgot to commit this earlier. |
946 |
/* my_sprintf was here. RIP */
|
1
by brian
clean slate |
947 |
|
948 |
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
|
|
949 |
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
|
|
950 |
#else
|
|
951 |
#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
|
|
952 |
#endif
|
|
953 |
||
954 |
#include <dlfcn.h> |
|
955 |
||
956 |
/* FreeBSD 2.2.2 does not define RTLD_NOW) */
|
|
957 |
#ifndef RTLD_NOW
|
|
958 |
#define RTLD_NOW 1
|
|
959 |
#endif
|
|
960 |
||
961 |
/*
|
|
962 |
* Include standard definitions of operator new and delete.
|
|
963 |
*/
|
|
964 |
#ifdef __cplusplus
|
|
965 |
#include <new> |
|
966 |
#endif
|
|
967 |
||
968 |
/* Length of decimal number represented by INT32. */
|
|
969 |
#define MY_INT32_NUM_DECIMAL_DIGITS 11
|
|
970 |
||
971 |
/* Length of decimal number represented by INT64. */
|
|
972 |
#define MY_INT64_NUM_DECIMAL_DIGITS 21
|
|
973 |
||
77.1.31
by Monty Taylor
Replaced regex lib with pcre. Reworked mysqltest to use it. |
974 |
#ifdef _cplusplus
|
975 |
#include <string> |
|
976 |
#endif
|
|
977 |
||
1
by brian
clean slate |
978 |
/* Define some useful general macros (should be done after all headers). */
|
979 |
#if !defined(max)
|
|
980 |
#define max(a, b) ((a) > (b) ? (a) : (b))
|
|
981 |
#define min(a, b) ((a) < (b) ? (a) : (b))
|
|
982 |
#endif
|
|
983 |
/*
|
|
984 |
Only Linux is known to need an explicit sync of the directory to make sure a
|
|
985 |
file creation/deletion/renaming in(from,to) this directory durable.
|
|
986 |
*/
|
|
987 |
#ifdef TARGET_OS_LINUX
|
|
988 |
#define NEED_EXPLICIT_SYNC_DIR 1
|
|
989 |
#endif
|
|
990 |
||
202.3.5
by Monty Taylor
Giant merge. |
991 |
#include <libdrizzle/gettext.h> |
202.3.2
by Monty Taylor
Added gettext calls in to my_getopt.c and drizzle.c |
992 |
|
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
993 |
#endif /* DRIZZLE_SERVER_GLOBAL_H */ |