1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
20
/* This is the include file that should be included 'first' in every C file. */
22
#ifndef DRIZZLE_SERVER_GLOBAL_H
23
#define DRIZZLE_SERVER_GLOBAL_H
25
#if defined(i386) && !defined(__i386__)
31
#if defined(__cplusplus)
33
# if defined(__GNUC) && defined(__EXCEPTIONS)
34
# error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
47
# include <inttypes.h>
52
# include <errno.h> /* Recommended by debian */
54
A lot of our programs uses asserts, so better to always include it
62
#if TIME_WITH_SYS_TIME
63
# include <sys/time.h>
67
# include <sys/time.h>
71
#endif */ /* TIME_WITH_SYS_TIME */
74
Temporary solution to solve bug#7156. Include "sys/types.h" before
75
the thread headers, else the function madvise() will not be defined
77
#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
78
#include <sys/types.h>
82
#include <pthread.h> /* AIX must have this included first */
84
#define _REENTRANT 1 /* Threads requires reentrant code */
90
#ifdef HAVE_SYS_TYPES_H
91
#include <sys/types.h>
100
#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
110
#ifdef HAVE_SYS_STAT_H
111
# include <sys/stat.h>
114
#if !defined(HAVE_UINT)
117
typedef unsigned int uint;
120
/* Declared in int2str() */
121
extern char _dig_vec_upper[];
122
extern char _dig_vec_lower[];
124
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
126
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
127
#define array_elements(A) ((size_t) (sizeof(A)/sizeof(A[0])))
129
/* Some types that is different between systems */
131
typedef int File; /* File descriptor */
133
#ifdef HAVE_SYS_SOCKET_H
134
#include <sys/socket.h>
139
#define FN_LIBCHAR '/'
140
#define FN_ROOTDIR "/"
142
#define MY_NFILE 64 /* This is only used to save filenames */
143
#ifndef OS_FILE_LIMIT
144
#define OS_FILE_LIMIT 65535
148
How much overhead does malloc have. The code often allocates
149
something like 1024-MALLOC_OVERHEAD bytes
151
#define MALLOC_OVERHEAD 8
153
/* get memory in huncs */
154
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
155
/* Typical record cash */
156
#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
157
/* Typical key cash */
158
#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
159
/* Default size of a key cache block */
160
#define KEY_CACHE_BLOCK_SIZE (uint) 1024
163
/* Some things that this system doesn't have */
165
/* Some defines of functions for portability */
167
#undef remove /* Crashes MySQL on SCO 5.0.0 */
168
#ifndef uint64_t2double
169
#define uint64_t2double(A) ((double) (uint64_t) (A))
170
#define my_off_t2double(A) ((double) (my_off_t) (A))
174
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
176
#define ulong_to_double(X) ((double) (ulong) (X))
178
#ifndef STACK_DIRECTION
179
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
182
#if !defined(HAVE_STRTOK_R)
183
#define strtok_r(A,B,C) strtok((A),(B))
189
#if !defined(FLT_MIN)
190
#define FLT_MIN ((float)1.40129846432481707e-45)
192
#if !defined(FLT_MAX)
193
#define FLT_MAX ((float)3.40282346638528860e+38)
197
/* From limits.h instead */
199
#define DBL_MIN 4.94065645841246544e-324
202
#define DBL_MAX 1.79769313486231470e+308
205
#define SIZE_T_MAX ~((size_t) 0)
209
/* Define missing math constants. */
211
#define M_PI 3.14159265358979323846
214
#define M_E 2.7182818284590452354
217
#define M_LN2 0.69314718055994530942
221
Max size that must be added to a so that we know Size to make
224
typedef ptrdiff_t my_ptrdiff_t;
226
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
227
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
228
/* Size to make adressable obj. */
229
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
230
/* Offset of field f in structure t */
231
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
232
#define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
233
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
235
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
236
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
238
/* Typdefs for easyier portability */
240
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
241
typedef unsigned long ulong; /* Short for unsigned long */
244
typedef uint64_t my_off_t;
246
#define MY_FILEPOS_ERROR (UINT64_MAX)
248
typedef int myf; /* Type of MyFlags in my_funcs */
249
#define MYF(v) (myf) (v)
251
/* Defines for time function */
252
#define SCALE_SEC 100
253
#define SCALE_USEC 10000
254
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */
255
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
258
#if defined(HAVE_CHARSET_utf8mb3) || defined(HAVE_CHARSET_utf8mb4)
259
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET "utf8"
261
#define DRIZZLE_UNIVERSAL_CLIENT_CHARSET DRIZZLE_DEFAULT_CHARSET_NAME
266
/* FreeBSD 2.2.2 does not define RTLD_NOW) */
271
#define cmax(a, b) ((a) > (b) ? (a) : (b))
272
#define cmin(a, b) ((a) < (b) ? (a) : (b))
274
/* Length of decimal number represented by INT32. */
275
#define MY_INT32_NUM_DECIMAL_DIGITS 11
277
/* Length of decimal number represented by INT64. */
278
#define MY_INT64_NUM_DECIMAL_DIGITS 21
281
Only Linux is known to need an explicit sync of the directory to make sure a
282
file creation/deletion/renaming in(from,to) this directory durable.
284
#ifdef TARGET_OS_LINUX
285
#define NEED_EXPLICIT_SYNC_DIR 1
288
#endif /* DRIZZLE_SERVER_GLOBAL_H */