📄 my_global.h
字号:
/* Copyright (C) 2000-2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *//* This is the include file that should be included 'first' in every C file. */#ifndef _global_h#define _global_h#ifndef EMBEDDED_LIBRARY#define HAVE_REPLICATION#define HAVE_EXTERNAL_CLIENT#endif#if defined( __EMX__) && !defined( MYSQL_SERVER)/* moved here to use below VOID macro redefinition */#define INCL_BASE#define INCL_NOPMAPI#include <os2.h>#endif /* __EMX__ */#ifdef __CYGWIN__/* We use a Unix API, so pretend it's not Windows */#undef WIN#undef WIN32#undef _WIN#undef _WIN32#undef _WIN64#undef __WIN__#undef __WIN32__#define HAVE_ERRNO_AS_DEFINE#endif /* __CYGWIN__ *//* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */#ifdef USE_PRAGMA_IMPLEMENTATION#define USE_PRAGMA_INTERFACE#endif#if defined(i386) && !defined(__i386__)#define __i386__#endif/* Macros to make switching between C and C++ mode easier */#ifdef __cplusplus#define C_MODE_START extern "C" {#define C_MODE_END }#else#define C_MODE_START#define C_MODE_END#endif#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)#include <config-win.h>#elif defined(OS2)#include <config-os2.h>#elif defined(__NETWARE__)#include <my_config.h>#include <config-netware.h>#if defined(__cplusplus) && defined(inline)#undef inline /* fix configure problem */#endif#else#include <my_config.h>#if defined(__cplusplus) && defined(inline)#undef inline /* fix configure problem */#endif#endif /* _WIN32... *//* Some defines to avoid ifdefs in the code */#ifndef NETWARE_YIELD#define NETWARE_YIELD#define NETWARE_SET_SCREEN_MODE(A)#endif/* The macros below are borrowed from include/linux/compiler.h in the Linux kernel. Use them to indicate the likelyhood of the truthfulness of a condition. This serves two purposes - newer versions of gcc will be able to optimize for branch predication, which could yield siginficant performance gains in frequently executed sections of the code, and the other reason to use them is for documentation*/#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)#define __builtin_expect(x, expected_value) (x)#endif#define likely(x) __builtin_expect((x),1)#define unlikely(x) __builtin_expect((x),0)/* The macros below are useful in optimising places where it has been discovered that cache misses stall the process and where a prefetch of the cache line can improve matters. This is available in GCC 3.1.1 and later versions. PREFETCH_READ says that addr is going to be used for reading and that it is to be kept in caches if possible for a while PREFETCH_WRITE also says that the item to be cached is likely to be updated. The *LOCALITY scripts are also available for experimentation purposes mostly and should only be used if they are verified to improve matters. For more input see GCC manual (available in GCC 3.1.1 and later)*/#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)#define PREFETCH_READ(addr) __builtin_prefetch(addr, 0, 3)#define PREFETCH_WRITE(addr) \ __builtin_prefetch(addr, 1, 3)#define PREFETCH_READ_LOCALITY(addr, locality) \ __builtin_prefetch(addr, 0, locality)#define PREFETCH_WRITE_LOCALITY(addr, locality) \ __builtin_prefetch(addr, 1, locality)#else#define PREFETCH_READ(addr)#define PREFETCH_READ_LOCALITY(addr, locality)#define PREFETCH_WRITE(addr)#define PREFETCH_WRITE_LOCALITY(addr, locality)#endif/* The following macro is used to ensure that code often used in most SQL statements and definitely for parts of the SQL processing are kept in a code segment by itself. This has the advantage that the risk of common code being overlapping in caches of the CPU is less. This can be a cause of big performance problems. Routines should be put in this category with care and when they are put there one should also strive to make as much of the error handling as possible (or uncommon code of the routine) to execute in a separate method to avoid moving to much code to this code segment. It is very easy to use, simply add HOT_METHOD at the end of the function declaration. For more input see GCC manual (available in GCC 2.95 and later)*/#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR > 94)#define HOT_METHOD \ __attribute__ ((section ("hot_code_section")))#else#define HOT_METHOD#endif/* The following macro is used to ensure that popular global variables are located next to each other to avoid that they contend for the same cache lines. It is very easy to use, simply add HOT_DATA at the end of the declaration of the variable, the variable must be initialised because of the way that linker works so a declaration using HOT_DATA should look like: uint global_hot_data HOT_DATA = 0; For more input see GCC manual (available in GCC 2.95 and later)*/#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR > 94)#define HOT_DATA \ __attribute__ ((section ("hot_data_section")))#else#define HOT_DATA#endif/* The following macros are used to control inlining a bit more than usual. These macros are used to ensure that inlining always or never occurs (independent of compilation mode). For more input see GCC manual (available in GCC 3.1.1 and later)*/#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)#define ALWAYS_INLINE __attribute__ ((always_inline))#define NEVER_INLINE __attribute__ ((noinline))#else#define ALWAYS_INLINE#define NEVER_INLINE#endif/* Fix problem with S_ISLNK() on Linux */#if defined(TARGET_OS_LINUX)#undef _GNU_SOURCE#define _GNU_SOURCE 1#endif/* Temporary solution to solve bug#7156. Include "sys/types.h" before the thread headers, else the function madvise() will not be defined*/#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )#include <sys/types.h>#endif/* The client defines this to avoid all thread code */#if defined(UNDEF_THREADS_HACK)#undef THREAD#undef HAVE_mit_thread#undef HAVE_LINUXTHREADS#undef HAVE_NPTL#undef HAVE_UNIXWARE7_THREADS#endif#ifdef HAVE_THREADS_WITHOUT_SOCKETS/* MIT pthreads does not work with unix sockets */#undef HAVE_SYS_UN_H#endif#define __EXTENSIONS__ 1 /* We want some extension */#ifndef __STDC_EXT__#define __STDC_EXT__ 1 /* To get large file support on hpux */#endif/* Solaris 9 include file <sys/feature_tests.h> refers to X/Open document System Interfaces and Headers, Issue 5 saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes, but apparently other systems (namely FreeBSD) don't agree. On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600. Furthermore, it tests that if a program requires older standard (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be run on a new compiler (that defines _STDC_C99) and issues an #error. It's also an #error if a program requires new standard (_XOPEN_SOURCE=600 or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99. To add more to this mess, Sun Studio C compiler defines _STDC_C99 while C++ compiler does not! So, in a desperate attempt to get correct prototypes for both C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500 depending on the compiler's announced C standard support. Cleaner solutions are welcome.*/#ifdef __sun#if __STDC_VERSION__ - 0 >= 199901L#define _XOPEN_SOURCE 600#else#define _XOPEN_SOURCE 500#endif#endif#if defined(THREAD) && !defined(__WIN__) && !defined(OS2)#ifndef _POSIX_PTHREAD_SEMANTICS#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */#endif#if !defined(SCO)#define _REENTRANT 1 /* Some thread libraries require this */#endif#if !defined(_THREAD_SAFE) && !defined(_AIX)#define _THREAD_SAFE /* Required for OSF1 */#endif#ifndef HAVE_mit_thread#ifdef HAVE_UNIXWARE7_THREADS#include <thread.h>#else#if defined(HPUX10) || defined(HPUX11)C_MODE_START /* HPUX needs this, signal.h bug */#include <pthread.h>C_MODE_END#else#include <pthread.h> /* AIX must have this included first */#endif#endif /* HAVE_UNIXWARE7_THREADS */#endif /* HAVE_mit_thread */#if !defined(SCO) && !defined(_REENTRANT)#define _REENTRANT 1 /* Threads requires reentrant code */#endif#endif /* THREAD *//* Go around some bugs in different OS and compilers */#ifdef _AIX /* By soren@t.dk */#define _H_STRINGS#define _SYS_STREAM_H/* #define _AIX32_CURSES */ /* XXX: this breaks AIX 4.3.3 (others?). */#define ulonglong2double(A) my_ulonglong2double(A)#define my_off_t2double(A) my_ulonglong2double(A)C_MODE_STARTdouble my_ulonglong2double(unsigned long long A);C_MODE_END#endif /* _AIX */#ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */#undef HAVE_SNPRINTF#endif#ifdef HAVE_BROKEN_PREAD/* pread()/pwrite() are not 64 bit safe on HP-UX 11.0 without installing the kernel patch PHKL_20349 or greater*/#undef HAVE_PREAD#undef HAVE_PWRITE#endif#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)#undef inline#define inline#endif#ifdef UNDEF_HAVE_GETHOSTBYNAME_R /* For OSF4.x */#undef HAVE_GETHOSTBYNAME_R#endif#ifdef UNDEF_HAVE_INITGROUPS /* For AIX 4.3 */#undef HAVE_INITGROUPS#endif/* gcc/egcs issues */#if defined(__GNUC) && defined(__EXCEPTIONS)#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"#endif/* Fix a bug in gcc 2.8.0 on IRIX 6.2 */#if SIZEOF_LONG == 4 && defined(__LONG_MAX__) && (__GNUC__ == 2 && __GNUC_MINOR__ == 8)#undef __LONG_MAX__ /* Is a longlong value in gcc 2.8.0 ??? */#define __LONG_MAX__ 2147483647#endif/* egcs 1.1.2 has a problem with memcpy on Alpha */#if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))#define BAD_MEMCPY#endif#if defined(_lint) && !defined(lint)#define lint#endif#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)#define _LONG_LONG 1 /* For AIX string library */#endif#ifndef stdin#include <stdio.h>#endif#ifdef HAVE_STDLIB_H#include <stdlib.h>#endif#ifdef HAVE_STDDEF_H#include <stddef.h>#endif#include <math.h>#ifdef HAVE_LIMITS_H#include <limits.h>#endif#ifdef HAVE_FLOAT_H#include <float.h>#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -