1 | /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
---|
2 |
|
---|
3 | This library is free software; you can redistribute it and/or
|
---|
4 | modify it under the terms of the GNU Library General Public
|
---|
5 | License as published by the Free Software Foundation; either
|
---|
6 | version 2 of the License, or (at your option) any later version.
|
---|
7 |
|
---|
8 | This library is distributed in the hope that it will be useful,
|
---|
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
11 | Library General Public License for more details.
|
---|
12 |
|
---|
13 | You should have received a copy of the GNU Library General Public
|
---|
14 | License along with this library; if not, write to the Free
|
---|
15 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
---|
16 | MA 02111-1307, USA */
|
---|
17 |
|
---|
18 | /* This is the main include file that should included 'first' in every
|
---|
19 | C file. */
|
---|
20 |
|
---|
21 | #ifndef _global_h
|
---|
22 | #define _global_h
|
---|
23 |
|
---|
24 | #if defined( __EMX__) && !defined( MYSQL_SERVER)
|
---|
25 | /* moved here to use below VOID macro redefinition */
|
---|
26 | #define INCL_BASE
|
---|
27 | #define INCL_NOPMAPI
|
---|
28 | #include <os2.h>
|
---|
29 | #endif /* __EMX__ */
|
---|
30 |
|
---|
31 | #ifdef __CYGWIN__
|
---|
32 | /* We use a Unix API, so pretend it's not Windows */
|
---|
33 | #undef WIN
|
---|
34 | #undef WIN32
|
---|
35 | #undef _WIN
|
---|
36 | #undef _WIN32
|
---|
37 | #undef _WIN64
|
---|
38 | #undef __WIN__
|
---|
39 | #undef __WIN32__
|
---|
40 | #define HAVE_ERRNO_AS_DEFINE
|
---|
41 | #endif /* __CYGWIN__ */
|
---|
42 |
|
---|
43 |
|
---|
44 | #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
---|
45 | #include <config-win.h>
|
---|
46 | #else
|
---|
47 | #include <my_config.h>
|
---|
48 | #endif
|
---|
49 | #if defined(__cplusplus)
|
---|
50 | #if defined(inline)
|
---|
51 | #undef inline /* fix configure problem */
|
---|
52 | #endif
|
---|
53 | #endif /* _cplusplus */
|
---|
54 |
|
---|
55 | /* Fix problem with S_ISLNK() on Linux */
|
---|
56 | #if defined(HAVE_LINUXTHREADS)
|
---|
57 | #undef _GNU_SOURCE
|
---|
58 | #define _GNU_SOURCE 1
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | /* The client defines this to avoid all thread code */
|
---|
62 | #if defined(UNDEF_THREADS_HACK)
|
---|
63 | #undef THREAD
|
---|
64 | #undef HAVE_mit_thread
|
---|
65 | #undef HAVE_LINUXTHREADS
|
---|
66 | #undef HAVE_UNIXWARE7_THREADS
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | #ifdef HAVE_THREADS_WITHOUT_SOCKETS
|
---|
70 | /* MIT pthreads does not work with unix sockets */
|
---|
71 | #undef HAVE_SYS_UN_H
|
---|
72 | #endif
|
---|
73 |
|
---|
74 | #define __EXTENSIONS__ 1 /* We want some extension */
|
---|
75 | #ifndef __STDC_EXT__
|
---|
76 | #define __STDC_EXT__ 1 /* To get large file support on hpux */
|
---|
77 | #endif
|
---|
78 |
|
---|
79 | #if defined(THREAD) && !defined(__WIN__)
|
---|
80 | #ifndef _POSIX_PTHREAD_SEMANTICS
|
---|
81 | #define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
|
---|
82 | #endif
|
---|
83 | /* was #if defined(HAVE_LINUXTHREADS) || defined(HAVE_DEC_THREADS) || defined(HPUX) */
|
---|
84 | #if !defined(SCO)
|
---|
85 | #define _REENTRANT 1 /* Some thread libraries require this */
|
---|
86 | #endif
|
---|
87 | #if !defined(_THREAD_SAFE) && !defined(_AIX)
|
---|
88 | #define _THREAD_SAFE /* Required for OSF1 */
|
---|
89 | #endif
|
---|
90 | #ifndef HAVE_mit_thread
|
---|
91 | #ifdef HAVE_UNIXWARE7_THREADS
|
---|
92 | #include <thread.h>
|
---|
93 | #else
|
---|
94 | #include <pthread.h> /* AIX must have this included first */
|
---|
95 | #endif /* HAVE_UNIXWARE7_THREADS */
|
---|
96 | #endif /* HAVE_mit_thread */
|
---|
97 | #if !defined(SCO) && !defined(_REENTRANT)
|
---|
98 | #define _REENTRANT 1 /* Threads requires reentrant code */
|
---|
99 | #endif
|
---|
100 | #endif /* THREAD */
|
---|
101 |
|
---|
102 | /* Go around some bugs in different OS and compilers */
|
---|
103 | #ifdef _AIX /* By soren@t.dk */
|
---|
104 | #define _H_STRINGS
|
---|
105 | #define _SYS_STREAM_H
|
---|
106 | #define _AIX32_CURSES
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | #ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */
|
---|
110 | #undef HAVE_SNPRINTF
|
---|
111 | #endif
|
---|
112 | #ifdef HAVE_BROKEN_PREAD /* These doesn't work on HPUX 11.x */
|
---|
113 | #undef HAVE_PREAD
|
---|
114 | #undef HAVE_PWRITE
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | #ifdef UNDEF_HAVE_GETHOSTBYNAME_R /* For OSF4.x */
|
---|
118 | #undef HAVE_GETHOSTBYNAME_R
|
---|
119 | #endif
|
---|
120 | #ifdef UNDEF_HAVE_INITGROUPS /* For AIX 4.3 */
|
---|
121 | #undef HAVE_INITGROUPS
|
---|
122 | #endif
|
---|
123 |
|
---|
124 | /* Fix a bug in gcc 2.8.0 on IRIX 6.2 */
|
---|
125 | #if SIZEOF_LONG == 4 && defined(__LONG_MAX__)
|
---|
126 | #undef __LONG_MAX__ /* Is a longlong value in gcc 2.8.0 ??? */
|
---|
127 | #define __LONG_MAX__ 2147483647
|
---|
128 | #endif
|
---|
129 |
|
---|
130 | /* egcs 1.1.2 has a problem with memcpy on Alpha */
|
---|
131 | #if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
|
---|
132 | #define BAD_MEMCPY
|
---|
133 | #endif
|
---|
134 |
|
---|
135 | /* In Linux-alpha we have atomic.h if we are using gcc */
|
---|
136 | #if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95)) && !defined(HAVE_ATOMIC_ADD)
|
---|
137 | #define HAVE_ATOMIC_ADD
|
---|
138 | #define HAVE_ATOMIC_SUB
|
---|
139 | #endif
|
---|
140 |
|
---|
141 | /* In Linux-ia64 including atomic.h will give us an error */
|
---|
142 | #if (defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__ia64__)) || !defined(THREAD)
|
---|
143 | #undef HAVE_ATOMIC_ADD
|
---|
144 | #undef HAVE_ATOMIC_SUB
|
---|
145 | #endif
|
---|
146 |
|
---|
147 | #if defined(_lint) && !defined(lint)
|
---|
148 | #define lint
|
---|
149 | #endif
|
---|
150 | #if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
|
---|
151 | #define _LONG_LONG 1 /* For AIX string library */
|
---|
152 | #endif
|
---|
153 |
|
---|
154 | #ifndef stdin
|
---|
155 | #include <stdio.h>
|
---|
156 | #endif
|
---|
157 | #ifdef HAVE_STDLIB_H
|
---|
158 | #include <stdlib.h>
|
---|
159 | #endif
|
---|
160 | #ifdef HAVE_STDDEF_H
|
---|
161 | #include <stddef.h>
|
---|
162 | #endif
|
---|
163 |
|
---|
164 | #include <math.h>
|
---|
165 | #ifdef HAVE_LIMITS_H
|
---|
166 | #include <limits.h>
|
---|
167 | #endif
|
---|
168 | #ifdef HAVE_FLOAT_H
|
---|
169 | #include <float.h>
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | #ifdef HAVE_SYS_TYPES_H
|
---|
173 | #include <sys/types.h>
|
---|
174 | #endif
|
---|
175 | #ifdef HAVE_FCNTL_H
|
---|
176 | #include <fcntl.h>
|
---|
177 | #endif
|
---|
178 | #ifdef HAVE_SYS_TIMEB_H
|
---|
179 | #include <sys/timeb.h> /* Avoid warnings on SCO */
|
---|
180 | #endif
|
---|
181 | #if TIME_WITH_SYS_TIME
|
---|
182 | # include <sys/time.h>
|
---|
183 | # include <time.h>
|
---|
184 | #else
|
---|
185 | # if HAVE_SYS_TIME_H
|
---|
186 | # include <sys/time.h>
|
---|
187 | # else
|
---|
188 | # include <time.h>
|
---|
189 | # endif
|
---|
190 | #endif /* TIME_WITH_SYS_TIME */
|
---|
191 | #ifdef HAVE_UNISTD_H
|
---|
192 | #include <unistd.h>
|
---|
193 | #endif
|
---|
194 | #if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
|
---|
195 | #undef HAVE_ALLOCA
|
---|
196 | #undef HAVE_ALLOCA_H
|
---|
197 | #endif
|
---|
198 | #ifdef HAVE_ALLOCA_H
|
---|
199 | #include <alloca.h>
|
---|
200 | #endif
|
---|
201 | #ifdef HAVE_ATOMIC_ADD
|
---|
202 | #define __SMP__
|
---|
203 | #include <asm/atomic.h>
|
---|
204 | #endif
|
---|
205 |
|
---|
206 | /* Go around some bugs in different OS and compilers */
|
---|
207 | #if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
|
---|
208 | #include <sys/stream.h> /* HPUX 10.20 defines ulong here. UGLY !!! */
|
---|
209 | #define HAVE_ULONG
|
---|
210 | #endif
|
---|
211 | #ifdef DONT_USE_FINITE /* HPUX 11.x has is_finite() */
|
---|
212 | #undef HAVE_FINITE
|
---|
213 | #endif
|
---|
214 |
|
---|
215 | /* We can not live without these */
|
---|
216 |
|
---|
217 | #define USE_MYFUNC 1 /* Must use syscall indirection */
|
---|
218 | #define MASTER 1 /* Compile without unireg */
|
---|
219 | #define ENGLISH 1 /* Messages in English */
|
---|
220 | #define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */
|
---|
221 | #define USE_REGEX 1 /* We want the use the regex library */
|
---|
222 | /* Do not define for ultra sparcs */
|
---|
223 | #define USE_BMOVE512 1 /* Use this unless the system bmove is faster */
|
---|
224 |
|
---|
225 | /* Paranoid settings. Define I_AM_PARANOID if you are paranoid */
|
---|
226 | #ifdef I_AM_PARANOID
|
---|
227 | #define DONT_ALLOW_USER_CHANGE 1
|
---|
228 | #define DONT_USE_MYSQL_PWD 1
|
---|
229 | #endif
|
---|
230 |
|
---|
231 | /* #define USE_some_charset 1 was deprecated by changes to configure */
|
---|
232 | /* my_ctype my_to_upper, my_to_lower, my_sort_order gain theit right value */
|
---|
233 | /* automagically during configuration */
|
---|
234 |
|
---|
235 | /* Does the system remember a signal handler after a signal ? */
|
---|
236 | #ifndef HAVE_BSD_SIGNALS
|
---|
237 | #define DONT_REMEMBER_SIGNAL
|
---|
238 | #endif
|
---|
239 |
|
---|
240 | /* Define void to stop lint from generating "null effekt" comments */
|
---|
241 | #ifndef DONT_DEFINE_VOID
|
---|
242 | #ifdef _lint
|
---|
243 | int __void__;
|
---|
244 | #define VOID(X) (__void__ = (int) (X))
|
---|
245 | #else
|
---|
246 | #undef VOID
|
---|
247 | #define VOID(X) (X)
|
---|
248 | #endif
|
---|
249 | #endif /* DONT_DEFINE_VOID */
|
---|
250 |
|
---|
251 | #if defined(_lint) || defined(FORCE_INIT_OF_VARS)
|
---|
252 | #define LINT_INIT(var) var=0 /* No uninitialize-warning */
|
---|
253 | #else
|
---|
254 | #define LINT_INIT(var)
|
---|
255 | #endif
|
---|
256 |
|
---|
257 | /* Define som useful general macros */
|
---|
258 | #if defined(__cplusplus) && defined(__GNUC__)
|
---|
259 | #define max(a, b) ((a) >? (b))
|
---|
260 | #define min(a, b) ((a) <? (b))
|
---|
261 | #elif !defined(max)
|
---|
262 | #define max(a, b) ((a) > (b) ? (a) : (b))
|
---|
263 | #define min(a, b) ((a) < (b) ? (a) : (b))
|
---|
264 | #endif
|
---|
265 |
|
---|
266 | #if defined(__EMX__) || !defined(HAVE_UINT)
|
---|
267 | typedef unsigned int uint;
|
---|
268 | typedef unsigned short ushort;
|
---|
269 | #endif
|
---|
270 |
|
---|
271 | #define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
|
---|
272 | #define swap(t,a,b) { register t dummy; dummy = a; a = b; b = dummy; }
|
---|
273 | #define test(a) ((a) ? 1 : 0)
|
---|
274 | #define set_if_bigger(a,b) { if ((a) < (b)) (a)=(b); }
|
---|
275 | #define set_if_smaller(a,b) { if ((a) > (b)) (a)=(b); }
|
---|
276 | #define test_all_bits(a,b) (((a) & (b)) == (b))
|
---|
277 | #define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
|
---|
278 | #ifndef HAVE_RINT
|
---|
279 | #define rint(A) floor((A)+0.5)
|
---|
280 | #endif
|
---|
281 |
|
---|
282 | /* Define som general constants */
|
---|
283 | #ifndef TRUE
|
---|
284 | #define TRUE (1) /* Logical true */
|
---|
285 | #define FALSE (0) /* Logical false */
|
---|
286 | #endif
|
---|
287 |
|
---|
288 | #if defined(__GNUC__)
|
---|
289 | #define function_volatile volatile
|
---|
290 | #define my_reinterpret_cast(A) reinterpret_cast<A>
|
---|
291 | #define my_const_cast(A) const_cast<A>
|
---|
292 | #elif !defined(my_reinterpret_cast)
|
---|
293 | #define my_reinterpret_cast(A) (A)
|
---|
294 | #define my_const_cast(A) (A)
|
---|
295 | #endif
|
---|
296 | #if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
---|
297 | #define __attribute__(A)
|
---|
298 | #endif
|
---|
299 |
|
---|
300 | /* From old s-system.h */
|
---|
301 |
|
---|
302 | /* Support macros for non ansi & other old compilers. Since such
|
---|
303 | things are no longer supported we do nothing. We keep then since
|
---|
304 | some of our code may still be needed to upgrade old customers. */
|
---|
305 | #define _VARARGS(X) X
|
---|
306 | #define _STATIC_VARARGS(X) X
|
---|
307 | #define _PC(X) X
|
---|
308 |
|
---|
309 | #if defined(DBUG_ON) && defined(DBUG_OFF)
|
---|
310 | #undef DBUG_OFF
|
---|
311 | #endif
|
---|
312 |
|
---|
313 | #if defined(_lint) && !defined(DBUG_OFF)
|
---|
314 | #define DBUG_OFF
|
---|
315 | #endif
|
---|
316 |
|
---|
317 | #include <dbug.h>
|
---|
318 | #ifndef DBUG_OFF
|
---|
319 | #define dbug_assert(A) assert(A)
|
---|
320 | #else
|
---|
321 | #define dbug_assert(A)
|
---|
322 | #endif
|
---|
323 |
|
---|
324 | #define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/
|
---|
325 | #define ASCII_BITS_USED 8 /* Bit char used */
|
---|
326 | #define NEAR_F /* No near function handling */
|
---|
327 |
|
---|
328 | /* Some types that is different between systems */
|
---|
329 |
|
---|
330 | typedef int File; /* File descriptor */
|
---|
331 | #ifndef Socket_defined
|
---|
332 | typedef int my_socket; /* File descriptor for sockets */
|
---|
333 | #define INVALID_SOCKET -1
|
---|
334 | #endif
|
---|
335 | /* Type for fuctions that handles signals */
|
---|
336 | #define sig_handler RETSIGTYPE
|
---|
337 | typedef void (*sig_return)();/* Returns type from signal */
|
---|
338 | #if defined(__GNUC__) && !defined(_lint)
|
---|
339 | typedef char pchar; /* Mixed prototypes can take char */
|
---|
340 | typedef char puchar; /* Mixed prototypes can take char */
|
---|
341 | typedef char pbool; /* Mixed prototypes can take char */
|
---|
342 | typedef short pshort; /* Mixed prototypes can take short int */
|
---|
343 | typedef float pfloat; /* Mixed prototypes can take float */
|
---|
344 | #else
|
---|
345 | typedef int pchar; /* Mixed prototypes can't take char */
|
---|
346 | typedef uint puchar; /* Mixed prototypes can't take char */
|
---|
347 | typedef int pbool; /* Mixed prototypes can't take char */
|
---|
348 | typedef int pshort; /* Mixed prototypes can't take short int */
|
---|
349 | typedef double pfloat; /* Mixed prototypes can't take float */
|
---|
350 | #endif
|
---|
351 | typedef int (*qsort_cmp)(const void *,const void *);
|
---|
352 | #ifdef HAVE_mit_thread
|
---|
353 | #define qsort_t void
|
---|
354 | #undef QSORT_TYPE_IS_VOID
|
---|
355 | #define QSORT_TYPE_IS_VOID
|
---|
356 | #else
|
---|
357 | #define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */
|
---|
358 | #endif
|
---|
359 | #ifdef HAVE_mit_thread
|
---|
360 | #define size_socket socklen_t /* Type of last arg to accept */
|
---|
361 | #else
|
---|
362 | #ifdef HAVE_SYS_SOCKET_H
|
---|
363 | #include <sys/socket.h>
|
---|
364 | #endif
|
---|
365 | typedef SOCKET_SIZE_TYPE size_socket;
|
---|
366 | #endif
|
---|
367 |
|
---|
368 | #ifndef SOCKOPT_OPTLEN_TYPE
|
---|
369 | #define SOCKOPT_OPTLEN_TYPE size_socket
|
---|
370 | #endif
|
---|
371 |
|
---|
372 | /* file create flags */
|
---|
373 |
|
---|
374 | #ifndef O_SHARE
|
---|
375 | #define O_SHARE 0 /* Flag to my_open for shared files */
|
---|
376 | #ifndef O_BINARY
|
---|
377 | #define O_BINARY 0 /* Flag to my_open for binary files */
|
---|
378 | #endif
|
---|
379 | #define FILE_BINARY 0 /* Flag to my_fopen for binary streams */
|
---|
380 | #ifdef HAVE_FCNTL
|
---|
381 | #define HAVE_FCNTL_LOCK
|
---|
382 | #define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
|
---|
383 | #endif
|
---|
384 | #endif /* O_SHARE */
|
---|
385 | #ifndef O_TEMPORARY
|
---|
386 | #define O_TEMPORARY 0
|
---|
387 | #endif
|
---|
388 | #ifndef O_SHORT_LIVED
|
---|
389 | #define O_SHORT_LIVED 0
|
---|
390 | #endif
|
---|
391 |
|
---|
392 | /* #define USE_RECORD_LOCK */
|
---|
393 |
|
---|
394 | /* Unsigned types supported by the compiler */
|
---|
395 | #define UNSINT8 /* unsigned int8 (char) */
|
---|
396 | #define UNSINT16 /* unsigned int16 */
|
---|
397 | #define UNSINT32 /* unsigned int32 */
|
---|
398 |
|
---|
399 | /* General constants */
|
---|
400 | #define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */
|
---|
401 | #define FN_LEN 256 /* Max file name len */
|
---|
402 | #define FN_HEADLEN 253 /* Max length of filepart of file name */
|
---|
403 | #define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */
|
---|
404 | #define FN_REFLEN 512 /* Max length of full path-name */
|
---|
405 | #define FN_EXTCHAR '.'
|
---|
406 | #define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */
|
---|
407 | #define FN_CURLIB '.' /* ./ is used as abbrev for current dir */
|
---|
408 | #define FN_PARENTDIR ".." /* Parentdirectory; Must be a string */
|
---|
409 | #define FN_DEVCHAR ':'
|
---|
410 |
|
---|
411 | #ifndef FN_LIBCHAR
|
---|
412 | #ifdef __EMX__
|
---|
413 | #define FN_LIBCHAR '\\'
|
---|
414 | #define FN_ROOTDIR "\\"
|
---|
415 | #else
|
---|
416 | #define FN_LIBCHAR '/'
|
---|
417 | #define FN_ROOTDIR "/"
|
---|
418 | #endif
|
---|
419 | #define MY_NFILE 1024 /* This is only used to save filenames */
|
---|
420 | #endif
|
---|
421 |
|
---|
422 | /* #define EXT_IN_LIBNAME */
|
---|
423 | /* #define FN_NO_CASE_SENCE */
|
---|
424 | /* #define FN_UPPER_CASE TRUE */
|
---|
425 |
|
---|
426 | /* Io buffer size; Must be a power of 2 and a multiple of 512. May be
|
---|
427 | smaller what the disk page size. This influences the speed of the
|
---|
428 | isam btree library. eg to big to slow. */
|
---|
429 | #define IO_SIZE 4096
|
---|
430 | /* How much overhead does malloc have. The code often allocates
|
---|
431 | something like 1024-MALLOC_OVERHEAD bytes */
|
---|
432 | #ifdef SAFEMALLOC
|
---|
433 | #define MALLOC_OVERHEAD (8+24+4)
|
---|
434 | #else
|
---|
435 | #define MALLOC_OVERHEAD 8
|
---|
436 | #endif
|
---|
437 | /* get memory in huncs */
|
---|
438 | #define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
|
---|
439 | /* Typical record cash */
|
---|
440 | #define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
|
---|
441 | /* Typical key cash */
|
---|
442 | #define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
|
---|
443 |
|
---|
444 | /* Some things that this system doesn't have */
|
---|
445 |
|
---|
446 | #define ONLY_OWN_DATABASES /* We are using only databases by monty */
|
---|
447 | #define NO_PISAM /* Not needed anymore */
|
---|
448 | #define NO_MISAM /* Not needed anymore */
|
---|
449 | #define NO_HASH /* Not needed anymore */
|
---|
450 | #ifdef __WIN__
|
---|
451 | #define NO_DIR_LIBRARY /* Not standar dir-library */
|
---|
452 | #define USE_MY_STAT_STRUCT /* For my_lib */
|
---|
453 | #endif
|
---|
454 |
|
---|
455 | /* Some things that this system does have */
|
---|
456 |
|
---|
457 | #ifndef HAVE_ITOA
|
---|
458 | #define USE_MY_ITOA /* There is no itoa */
|
---|
459 | #endif
|
---|
460 |
|
---|
461 | /* Some defines of functions for portability */
|
---|
462 |
|
---|
463 | #ifndef HAVE_ATOD
|
---|
464 | #define atod atof
|
---|
465 | #endif
|
---|
466 | #ifdef USE_MY_ATOF
|
---|
467 | #define atof my_atof
|
---|
468 | extern void init_my_atof(void);
|
---|
469 | extern double my_atof(const char*);
|
---|
470 | #endif
|
---|
471 | #undef remove /* Crashes MySQL on SCO 5.0.0 */
|
---|
472 | #ifndef __WIN__
|
---|
473 | #define closesocket(A) close(A)
|
---|
474 | #ifndef ulonglong2double
|
---|
475 | #define ulonglong2double(A) ((double) (A))
|
---|
476 | #define my_off_t2double(A) ((double) (A))
|
---|
477 | #endif
|
---|
478 | #endif
|
---|
479 |
|
---|
480 | #ifndef offsetof
|
---|
481 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
---|
482 | #endif
|
---|
483 | #define ulong_to_double(X) ((double) (ulong) (X))
|
---|
484 | #define SET_STACK_SIZE(X) /* Not needed on real machines */
|
---|
485 |
|
---|
486 | #if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R)
|
---|
487 | #define strtok_r(A,B,C) strtok((A),(B))
|
---|
488 | #endif
|
---|
489 |
|
---|
490 | #ifdef HAVE_LINUXTHREADS
|
---|
491 | /* #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) */
|
---|
492 | /* #define sigset(A,B) signal((A),(B)) */
|
---|
493 | #endif
|
---|
494 |
|
---|
495 | /* Remove some things that mit_thread break or doesn't support */
|
---|
496 | #if defined(HAVE_mit_thread) && defined(THREAD)
|
---|
497 | #undef HAVE_PREAD
|
---|
498 | #undef HAVE_REALPATH
|
---|
499 | #undef HAVE_MLOCK
|
---|
500 | #undef HAVE_TEMPNAM /* Use ours */
|
---|
501 | #undef HAVE_PTHREAD_SETPRIO
|
---|
502 | #undef HAVE_FTRUNCATE
|
---|
503 | #undef HAVE_READLINK
|
---|
504 | #endif
|
---|
505 |
|
---|
506 | /* This is from the old m-machine.h file */
|
---|
507 |
|
---|
508 | #if SIZEOF_LONG_LONG > 4
|
---|
509 | #define HAVE_LONG_LONG 1
|
---|
510 | #endif
|
---|
511 |
|
---|
512 | #if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
|
---|
513 | #define LONGLONG_MIN ((long long) 0x8000000000000000LL)
|
---|
514 | #define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL)
|
---|
515 | #endif
|
---|
516 |
|
---|
517 | #if SIZEOF_LONG == 4
|
---|
518 | #define INT_MIN32 (long) 0x80000000L
|
---|
519 | #define INT_MAX32 (long) 0x7FFFFFFFL
|
---|
520 | #define INT_MIN24 ((long) 0xff800000L)
|
---|
521 | #define INT_MAX24 0x007fffffL
|
---|
522 | #define INT_MIN16 ((short int) 0x8000)
|
---|
523 | #define INT_MAX16 0x7FFF
|
---|
524 | #define INT_MIN8 ((char) 0x80)
|
---|
525 | #define INT_MAX8 ((char) 0x7F)
|
---|
526 | #else /* Probably Alpha */
|
---|
527 | #define INT_MIN32 ((long) (int) 0x80000000)
|
---|
528 | #define INT_MAX32 ((long) (int) 0x7FFFFFFF)
|
---|
529 | #define INT_MIN24 ((long) (int) 0xff800000)
|
---|
530 | #define INT_MAX24 ((long) (int) 0x007fffff)
|
---|
531 | #define INT_MIN16 ((short int) 0xffff8000)
|
---|
532 | #define INT_MAX16 ((short int) 0x00007FFF)
|
---|
533 | #endif
|
---|
534 |
|
---|
535 | /* From limits.h instead */
|
---|
536 | #ifndef DBL_MIN
|
---|
537 | #define DBL_MIN 4.94065645841246544e-324
|
---|
538 | #define FLT_MIN ((float)1.40129846432481707e-45)
|
---|
539 | #endif
|
---|
540 | #ifndef DBL_MAX
|
---|
541 | #define DBL_MAX 1.79769313486231470e+308
|
---|
542 | #define FLT_MAX ((float)3.40282346638528860e+38)
|
---|
543 | #endif
|
---|
544 |
|
---|
545 | /* Max size that must be added to a so that we know Size to make
|
---|
546 | adressable obj. */
|
---|
547 | typedef long my_ptrdiff_t;
|
---|
548 | #define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
|
---|
549 | #define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
|
---|
550 | /* Size to make adressable obj. */
|
---|
551 | #define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
|
---|
552 | /* Offset of filed f in structure t */
|
---|
553 | #define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
|
---|
554 | #define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size)
|
---|
555 | #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B))
|
---|
556 |
|
---|
557 | #define NullS (char *) 0
|
---|
558 | /* Nowdays we do not support MessyDos */
|
---|
559 | #ifndef NEAR
|
---|
560 | #define NEAR /* Who needs segments ? */
|
---|
561 | #define FAR /* On a good machine */
|
---|
562 | #define HUGE_PTR
|
---|
563 | #endif
|
---|
564 | #ifndef STDCALL
|
---|
565 | #define STDCALL
|
---|
566 | #endif
|
---|
567 |
|
---|
568 | /* Typdefs for easyier portability */
|
---|
569 |
|
---|
570 | #if defined(VOIDTYPE)
|
---|
571 | typedef void *gptr; /* Generic pointer */
|
---|
572 | #else
|
---|
573 | typedef char *gptr; /* Generic pointer */
|
---|
574 | #endif
|
---|
575 | #ifndef HAVE_INT_8_16_32
|
---|
576 | typedef char int8; /* Signed integer >= 8 bits */
|
---|
577 | typedef short int16; /* Signed integer >= 16 bits */
|
---|
578 | #endif
|
---|
579 | #ifndef HAVE_UCHAR
|
---|
580 | typedef unsigned char uchar; /* Short for unsigned char */
|
---|
581 | #endif
|
---|
582 | typedef unsigned char uint8; /* Short for unsigned integer >= 8 bits */
|
---|
583 | typedef unsigned short uint16; /* Short for unsigned integer >= 16 bits */
|
---|
584 |
|
---|
585 | #if SIZEOF_INT == 4
|
---|
586 | #ifndef HAVE_INT_8_16_32
|
---|
587 | typedef int int32;
|
---|
588 | #endif
|
---|
589 | typedef unsigned int uint32; /* Short for unsigned integer >= 32 bits */
|
---|
590 | #elif SIZEOF_LONG == 4
|
---|
591 | #ifndef HAVE_INT_8_16_32
|
---|
592 | typedef long int32;
|
---|
593 | #endif
|
---|
594 | typedef unsigned long uint32; /* Short for unsigned integer >= 32 bits */
|
---|
595 | #else
|
---|
596 | error "Neither int or long is of 4 bytes width"
|
---|
597 | #endif
|
---|
598 |
|
---|
599 | #if !defined(HAVE_ULONG) && !defined(HAVE_LINUXTHREADS) && !defined(__USE_MISC)
|
---|
600 | typedef unsigned long ulong; /* Short for unsigned long */
|
---|
601 | #endif
|
---|
602 | #ifndef longlong_defined
|
---|
603 | #if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8
|
---|
604 | typedef unsigned long long ulonglong; /* ulong or unsigned long long */
|
---|
605 | typedef long long longlong;
|
---|
606 | #else
|
---|
607 | typedef unsigned long ulonglong; /* ulong or unsigned long long */
|
---|
608 | typedef long longlong;
|
---|
609 | #endif
|
---|
610 | #endif
|
---|
611 |
|
---|
612 | #ifdef USE_RAID
|
---|
613 | /* The following is done with a if to not get problems with pre-processors
|
---|
614 | with late define evaluation */
|
---|
615 | #if SIZEOF_OFF_T == 4
|
---|
616 | #define SYSTEM_SIZEOF_OFF_T 4
|
---|
617 | #else
|
---|
618 | #define SYSTEM_SIZEOF_OFF_T 8
|
---|
619 | #endif
|
---|
620 | #undef SIZEOF_OFF_T
|
---|
621 | #define SIZEOF_OFF_T 8
|
---|
622 | #else
|
---|
623 | #define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T
|
---|
624 | #endif /* USE_RAID */
|
---|
625 |
|
---|
626 | #if SIZEOF_OFF_T > 4
|
---|
627 | typedef ulonglong my_off_t;
|
---|
628 | #else
|
---|
629 | typedef unsigned long my_off_t;
|
---|
630 | #endif
|
---|
631 | #define MY_FILEPOS_ERROR (~(my_off_t) 0)
|
---|
632 | #ifndef __WIN__
|
---|
633 | typedef off_t os_off_t;
|
---|
634 | #endif
|
---|
635 |
|
---|
636 | typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */
|
---|
637 | typedef short int15; /* Most effective integer 0 <= x <= 32767 */
|
---|
638 | typedef char *my_string; /* String of characters */
|
---|
639 | typedef unsigned long size_s; /* Size of strings (In string-funcs) */
|
---|
640 | typedef int myf; /* Type of MyFlags in my_funcs */
|
---|
641 | #ifndef byte_defined
|
---|
642 | typedef char byte; /* Smallest addressable unit */
|
---|
643 | #endif
|
---|
644 | typedef char my_bool; /* Small bool */
|
---|
645 | #if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
|
---|
646 | typedef char bool; /* Ordinary boolean values 0 1 */
|
---|
647 | #endif
|
---|
648 | /* Macros for converting *constants* to the right type */
|
---|
649 | #define INT8(v) (int8) (v)
|
---|
650 | #define INT16(v) (int16) (v)
|
---|
651 | #define INT32(v) (int32) (v)
|
---|
652 | #define MYF(v) (myf) (v)
|
---|
653 |
|
---|
654 | /* Defines to make it possible to prioritize register assignments. No
|
---|
655 | longer needed with moder compilers */
|
---|
656 | #ifndef USING_X
|
---|
657 | #define reg1 register
|
---|
658 | #define reg2 register
|
---|
659 | #define reg3 register
|
---|
660 | #define reg4 register
|
---|
661 | #define reg5 register
|
---|
662 | #define reg6 register
|
---|
663 | #define reg7 register
|
---|
664 | #define reg8 register
|
---|
665 | #define reg9 register
|
---|
666 | #define reg10 register
|
---|
667 | #define reg11 register
|
---|
668 | #define reg12 register
|
---|
669 | #define reg13 register
|
---|
670 | #define reg14 register
|
---|
671 | #define reg15 register
|
---|
672 | #define reg16 register
|
---|
673 | #endif
|
---|
674 |
|
---|
675 | /* Defines for time function */
|
---|
676 | #define SCALE_SEC 100
|
---|
677 | #define SCALE_USEC 10000
|
---|
678 | #define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */
|
---|
679 | #define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
|
---|
680 |
|
---|
681 | /*
|
---|
682 | ** Define-funktions for reading and storing in machine independent format
|
---|
683 | ** (low byte first)
|
---|
684 | */
|
---|
685 |
|
---|
686 | /* Optimized store functions for Intel x86 */
|
---|
687 | #ifdef __i386__
|
---|
688 | #define sint2korr(A) (*((int16 *) (A)))
|
---|
689 | #define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
|
---|
690 | (((uint32) 255L << 24) | \
|
---|
691 | (((uint32) (uchar) (A)[2]) << 16) |\
|
---|
692 | (((uint32) (uchar) (A)[1]) << 8) | \
|
---|
693 | ((uint32) (uchar) (A)[0])) : \
|
---|
694 | (((uint32) (uchar) (A)[2]) << 16) |\
|
---|
695 | (((uint32) (uchar) (A)[1]) << 8) | \
|
---|
696 | ((uint32) (uchar) (A)[0])))
|
---|
697 | #define sint4korr(A) (*((long *) (A)))
|
---|
698 | #define uint2korr(A) (*((uint16 *) (A)))
|
---|
699 | #define uint3korr(A) (long) (*((unsigned long *) (A)) & 0xFFFFFF)
|
---|
700 | #define uint4korr(A) (*((unsigned long *) (A)))
|
---|
701 | #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
|
---|
702 | (((uint32) ((uchar) (A)[1])) << 8) +\
|
---|
703 | (((uint32) ((uchar) (A)[2])) << 16) +\
|
---|
704 | (((uint32) ((uchar) (A)[3])) << 24)) +\
|
---|
705 | (((ulonglong) ((uchar) (A)[4])) << 32))
|
---|
706 | #define uint8korr(A) (*((ulonglong *) (A)))
|
---|
707 | #define sint8korr(A) (*((longlong *) (A)))
|
---|
708 | #define int2store(T,A) *((uint16*) (T))= (uint16) (A)
|
---|
709 | #define int3store(T,A) { *(T)= (uchar) ((A));\
|
---|
710 | *(T+1)=(uchar) (((uint) (A) >> 8));\
|
---|
711 | *(T+2)=(uchar) (((A) >> 16)); }
|
---|
712 | #define int4store(T,A) *((long *) (T))= (long) (A)
|
---|
713 | #define int5store(T,A) { *(T)= (uchar)((A));\
|
---|
714 | *((T)+1)=(uchar) (((A) >> 8));\
|
---|
715 | *((T)+2)=(uchar) (((A) >> 16));\
|
---|
716 | *((T)+3)=(uchar) (((A) >> 24)); \
|
---|
717 | *((T)+4)=(uchar) (((A) >> 32)); }
|
---|
718 | #define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)
|
---|
719 |
|
---|
720 | typedef union {
|
---|
721 | double v;
|
---|
722 | long m[2];
|
---|
723 | } doubleget_union;
|
---|
724 | #define doubleget(V,M) { ((doubleget_union *)&V)->m[0] = *((long*) M); \
|
---|
725 | ((doubleget_union *)&V)->m[1] = *(((long*) M)+1); }
|
---|
726 | #define doublestore(T,V) { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
|
---|
727 | *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; }
|
---|
728 | #define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
|
---|
729 | #define float8get(V,M) doubleget((V),(M))
|
---|
730 | #define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
|
---|
731 | #define float8store(V,M) doublestore((V),(M))
|
---|
732 | #endif /* __i386__ */
|
---|
733 |
|
---|
734 | #ifndef sint2korr
|
---|
735 | #define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\
|
---|
736 | ((int16) ((int16) (A)[1]) << 8))
|
---|
737 | #define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
|
---|
738 | (((uint32) 255L << 24) | \
|
---|
739 | (((uint32) (uchar) (A)[2]) << 16) |\
|
---|
740 | (((uint32) (uchar) (A)[1]) << 8) | \
|
---|
741 | ((uint32) (uchar) (A)[0])) : \
|
---|
742 | (((uint32) (uchar) (A)[2]) << 16) |\
|
---|
743 | (((uint32) (uchar) (A)[1]) << 8) | \
|
---|
744 | ((uint32) (uchar) (A)[0])))
|
---|
745 | #define sint4korr(A) (int32) (((int32) ((uchar) (A)[0])) +\
|
---|
746 | (((int32) ((uchar) (A)[1]) << 8)) +\
|
---|
747 | (((int32) ((uchar) (A)[2]) << 16)) +\
|
---|
748 | (((int32) ((int16) (A)[3]) << 24)))
|
---|
749 | #define sint8korr(A) (longlong) uint8korr(A)
|
---|
750 | #define uint2korr(A) (uint16) (((uint16) ((uchar) (A)[0])) +\
|
---|
751 | ((uint16) ((uchar) (A)[1]) << 8))
|
---|
752 | #define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
|
---|
753 | (((uint32) ((uchar) (A)[1])) << 8) +\
|
---|
754 | (((uint32) ((uchar) (A)[2])) << 16))
|
---|
755 | #define uint4korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
|
---|
756 | (((uint32) ((uchar) (A)[1])) << 8) +\
|
---|
757 | (((uint32) ((uchar) (A)[2])) << 16) +\
|
---|
758 | (((uint32) ((uchar) (A)[3])) << 24))
|
---|
759 | #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
|
---|
760 | (((uint32) ((uchar) (A)[1])) << 8) +\
|
---|
761 | (((uint32) ((uchar) (A)[2])) << 16) +\
|
---|
762 | (((uint32) ((uchar) (A)[3])) << 24)) +\
|
---|
763 | (((ulonglong) ((uchar) (A)[4])) << 32))
|
---|
764 | #define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
|
---|
765 | (((uint32) ((uchar) (A)[1])) << 8) +\
|
---|
766 | (((uint32) ((uchar) (A)[2])) << 16) +\
|
---|
767 | (((uint32) ((uchar) (A)[3])) << 24)) +\
|
---|
768 | (((ulonglong) (((uint32) ((uchar) (A)[4])) +\
|
---|
769 | (((uint32) ((uchar) (A)[5])) << 8) +\
|
---|
770 | (((uint32) ((uchar) (A)[6])) << 16) +\
|
---|
771 | (((uint32) ((uchar) (A)[7])) << 24))) <<\
|
---|
772 | 32))
|
---|
773 | #define int2store(T,A) { uint def_temp= (uint) (A) ;\
|
---|
774 | *((uchar*) (T))= (uchar)(def_temp); \
|
---|
775 | *((uchar*) (T+1))=(uchar)((def_temp >> 8)); }
|
---|
776 | #define int3store(T,A) { /*lint -save -e734 */\
|
---|
777 | *((T))=(char) ((A));\
|
---|
778 | *((T)+1)=(char) (((A) >> 8));\
|
---|
779 | *((T)+2)=(char) (((A) >> 16)); \
|
---|
780 | /*lint -restore */}
|
---|
781 | #define int4store(T,A) { *(T)=(char) ((A));\
|
---|
782 | *((T)+1)=(char) (((A) >> 8));\
|
---|
783 | *((T)+2)=(char) (((A) >> 16));\
|
---|
784 | *((T)+3)=(char) (((A) >> 24)); }
|
---|
785 | #define int5store(T,A) { *(T)=((A));\
|
---|
786 | *((T)+1)=(((A) >> 8));\
|
---|
787 | *((T)+2)=(((A) >> 16));\
|
---|
788 | *((T)+3)=(((A) >> 24)); \
|
---|
789 | *((T)+4)=(((A) >> 32)); }
|
---|
790 | #define int8store(T,A) { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
|
---|
791 | int4store((T),def_temp); \
|
---|
792 | int4store((T+4),def_temp2); \
|
---|
793 | }
|
---|
794 | #ifdef WORDS_BIGENDIAN
|
---|
795 | #define float4store(T,A) { *(T)= ((byte *) &A)[3];\
|
---|
796 | *((T)+1)=(char) ((byte *) &A)[2];\
|
---|
797 | *((T)+2)=(char) ((byte *) &A)[1];\
|
---|
798 | *((T)+3)=(char) ((byte *) &A)[0]; }
|
---|
799 |
|
---|
800 | #define float4get(V,M) { float def_temp;\
|
---|
801 | ((byte*) &def_temp)[0]=(M)[3];\
|
---|
802 | ((byte*) &def_temp)[1]=(M)[2];\
|
---|
803 | ((byte*) &def_temp)[2]=(M)[1];\
|
---|
804 | ((byte*) &def_temp)[3]=(M)[0];\
|
---|
805 | (V)=def_temp; }
|
---|
806 | #define float8store(T,V) { *(T)= ((byte *) &V)[7];\
|
---|
807 | *((T)+1)=(char) ((byte *) &V)[6];\
|
---|
808 | *((T)+2)=(char) ((byte *) &V)[5];\
|
---|
809 | *((T)+3)=(char) ((byte *) &V)[4];\
|
---|
810 | *((T)+4)=(char) ((byte *) &V)[3];\
|
---|
811 | *((T)+5)=(char) ((byte *) &V)[2];\
|
---|
812 | *((T)+6)=(char) ((byte *) &V)[1];\
|
---|
813 | *((T)+7)=(char) ((byte *) &V)[0]; }
|
---|
814 |
|
---|
815 | #define float8get(V,M) { double def_temp;\
|
---|
816 | ((byte*) &def_temp)[0]=(M)[7];\
|
---|
817 | ((byte*) &def_temp)[1]=(M)[6];\
|
---|
818 | ((byte*) &def_temp)[2]=(M)[5];\
|
---|
819 | ((byte*) &def_temp)[3]=(M)[4];\
|
---|
820 | ((byte*) &def_temp)[4]=(M)[3];\
|
---|
821 | ((byte*) &def_temp)[5]=(M)[2];\
|
---|
822 | ((byte*) &def_temp)[6]=(M)[1];\
|
---|
823 | ((byte*) &def_temp)[7]=(M)[0];\
|
---|
824 | (V) = def_temp; }
|
---|
825 | #else
|
---|
826 | #define float4get(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
|
---|
827 | #define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float))
|
---|
828 |
|
---|
829 | #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
|
---|
830 | #define doublestore(T,V) { *(T)= ((byte *) &V)[4];\
|
---|
831 | *((T)+1)=(char) ((byte *) &V)[5];\
|
---|
832 | *((T)+2)=(char) ((byte *) &V)[6];\
|
---|
833 | *((T)+3)=(char) ((byte *) &V)[7];\
|
---|
834 | *((T)+4)=(char) ((byte *) &V)[0];\
|
---|
835 | *((T)+5)=(char) ((byte *) &V)[1];\
|
---|
836 | *((T)+6)=(char) ((byte *) &V)[2];\
|
---|
837 | *((T)+7)=(char) ((byte *) &V)[3]; }
|
---|
838 | #define doubleget(V,M) { double def_temp;\
|
---|
839 | ((byte*) &def_temp)[0]=(M)[4];\
|
---|
840 | ((byte*) &def_temp)[1]=(M)[5];\
|
---|
841 | ((byte*) &def_temp)[2]=(M)[6];\
|
---|
842 | ((byte*) &def_temp)[3]=(M)[7];\
|
---|
843 | ((byte*) &def_temp)[4]=(M)[0];\
|
---|
844 | ((byte*) &def_temp)[5]=(M)[1];\
|
---|
845 | ((byte*) &def_temp)[6]=(M)[2];\
|
---|
846 | ((byte*) &def_temp)[7]=(M)[3];\
|
---|
847 | (V) = def_temp; }
|
---|
848 | #endif /* __FLOAT_WORD_ORDER */
|
---|
849 |
|
---|
850 | #define float8get(V,M) doubleget((V),(M))
|
---|
851 | #define float8store(V,M) doublestore((V),(M))
|
---|
852 | #endif /* WORDS_BIGENDIAN */
|
---|
853 |
|
---|
854 | #endif /* sint2korr */
|
---|
855 |
|
---|
856 | /* Define-funktions for reading and storing in machine format from/to
|
---|
857 | short/long to/from some place in memory V should be a (not
|
---|
858 | register) variable, M is a pointer to byte */
|
---|
859 |
|
---|
860 | #ifdef WORDS_BIGENDIAN
|
---|
861 |
|
---|
862 | #define ushortget(V,M) { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
|
---|
863 | ((uint16) ((uint16) (M)[0]) << 8)); }
|
---|
864 | #define shortget(V,M) { V = (short) (((short) ((uchar) (M)[1]))+\
|
---|
865 | ((short) ((short) (M)[0]) << 8)); }
|
---|
866 | #define longget(V,M) { int32 def_temp;\
|
---|
867 | ((byte*) &def_temp)[0]=(M)[0];\
|
---|
868 | ((byte*) &def_temp)[1]=(M)[1];\
|
---|
869 | ((byte*) &def_temp)[2]=(M)[2];\
|
---|
870 | ((byte*) &def_temp)[3]=(M)[3];\
|
---|
871 | (V)=def_temp; }
|
---|
872 | #define ulongget(V,M) { uint32 def_temp;\
|
---|
873 | ((byte*) &def_temp)[0]=(M)[0];\
|
---|
874 | ((byte*) &def_temp)[1]=(M)[1];\
|
---|
875 | ((byte*) &def_temp)[2]=(M)[2];\
|
---|
876 | ((byte*) &def_temp)[3]=(M)[3];\
|
---|
877 | (V)=def_temp; }
|
---|
878 | #define shortstore(T,A) { uint def_temp=(uint) (A) ;\
|
---|
879 | *(T+1)=(char)(def_temp); \
|
---|
880 | *(T+0)=(char)(def_temp >> 8); }
|
---|
881 | #define longstore(T,A) { *((T)+3)=((A));\
|
---|
882 | *((T)+2)=(((A) >> 8));\
|
---|
883 | *((T)+1)=(((A) >> 16));\
|
---|
884 | *((T)+0)=(((A) >> 24)); }
|
---|
885 |
|
---|
886 | #define doubleget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(double))
|
---|
887 | #define doublestore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(double))
|
---|
888 | #define longlongget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(ulonglong))
|
---|
889 | #define longlongstore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(ulonglong))
|
---|
890 |
|
---|
891 | #else
|
---|
892 |
|
---|
893 | #define ushortget(V,M) { V = uint2korr(M); }
|
---|
894 | #define shortget(V,M) { V = sint2korr(M); }
|
---|
895 | #define longget(V,M) { V = sint4korr(M); }
|
---|
896 | #define ulongget(V,M) { V = uint4korr(M); }
|
---|
897 | #define shortstore(T,V) int2store(T,V)
|
---|
898 | #define longstore(T,V) int4store(T,V)
|
---|
899 | #ifndef doubleget
|
---|
900 | #define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
|
---|
901 | #define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
|
---|
902 | #endif /* doubleget */
|
---|
903 | #define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
|
---|
904 | #define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
|
---|
905 |
|
---|
906 | #endif /* WORDS_BIGENDIAN */
|
---|
907 |
|
---|
908 | /* sprintf does not always return the number of bytes :- */
|
---|
909 | #ifdef SPRINTF_RETURNS_INT
|
---|
910 | #define my_sprintf(buff,args) sprintf args
|
---|
911 | #else
|
---|
912 | #ifdef SPRINTF_RETURNS_PTR
|
---|
913 | #define my_sprintf(buff,args) ((int)(sprintf args - buff))
|
---|
914 | #else
|
---|
915 | #define my_sprintf(buff,args) sprintf args,strlen(buff)
|
---|
916 | #endif
|
---|
917 | #endif
|
---|
918 |
|
---|
919 | #ifndef THREAD
|
---|
920 | #define thread_safe_increment(V,L) (V)++
|
---|
921 | #define thread_safe_add(V,C,L) (V)+=(C)
|
---|
922 | #define thread_safe_sub(V,C,L) (V)-=(C)
|
---|
923 | #define statistic_increment(V,L) (V)++
|
---|
924 | #define statistic_add(V,C,L) (V)+=(C)
|
---|
925 | #endif
|
---|
926 |
|
---|
927 | #endif /* _global_h */
|
---|