📄 my_global.h
字号:
#ifdef HAVE_SYS_TYPES_H#include <sys/types.h>#endif#ifdef HAVE_FCNTL_H#include <fcntl.h>#endif#ifdef HAVE_SYS_TIMEB_H#include <sys/timeb.h> /* Avoid warnings on SCO */#endif#if TIME_WITH_SYS_TIME# include <sys/time.h># include <time.h>#else# if HAVE_SYS_TIME_H# include <sys/time.h># else# include <time.h># endif#endif /* TIME_WITH_SYS_TIME */#ifdef HAVE_UNISTD_H#include <unistd.h>#endif#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)#undef HAVE_ALLOCA#undef HAVE_ALLOCA_H#endif#ifdef HAVE_ALLOCA_H#include <alloca.h>#endif#ifdef HAVE_ATOMIC_ADD#define new my_arg_new#define need_to_restore_new 1C_MODE_START#include <asm/atomic.h>C_MODE_END#ifdef need_to_restore_new /* probably safer than #ifdef new */#undef new#undef need_to_restore_new#endif#endif#include <errno.h> /* Recommended by debian *//* We need the following to go around a problem with openssl on solaris */#if defined(HAVE_CRYPT_H)#include <crypt.h>#endif/* A lot of our programs uses asserts, so better to always include it This also fixes a problem when people uses DBUG_ASSERT without including assert.h*/#include <assert.h>/* Go around some bugs in different OS and compilers */#if defined (HPUX11) && defined(_LARGEFILE_SOURCE)#define _LARGEFILE64_SOURCE#endif#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)#include <sys/stream.h> /* HPUX 10.20 defines ulong here. UGLY !!! */#define HAVE_ULONG#endif#ifdef DONT_USE_FINITE /* HPUX 11.x has is_finite() */#undef HAVE_FINITE#endif#if defined(HPUX10) && defined(_LARGEFILE64_SOURCE) && defined(THREAD)/* Fix bug in setrlimit */#undef setrlimit#define setrlimit cma_setrlimit64#endif/* Declare madvise where it is not declared for C++, like Solaris */#if HAVE_MADVISE && !HAVE_DECL_MADVISE && defined(__cplusplus)extern "C" int madvise(void *addr, size_t len, int behav);#endif#ifdef __QNXNTO__/* This has to be after include limits.h */#define HAVE_ERRNO_AS_DEFINE#define HAVE_FCNTL_LOCK#undef HAVE_FINITE#undef LONGLONG_MIN /* These get wrongly defined in QNX 6.2 */#undef LONGLONG_MAX /* standard system library 'limits.h' */#ifdef __cplusplus#ifndef HAVE_RINT#define HAVE_RINT#endif /* rint() and isnan() functions are not */#define rint(a) std::rint(a) /* visible in C++ scope due to an error */#define isnan(a) std::isnan(a) /* in the usr/include/math.h on QNX */#endif#endif/* We can not live without the following defines */#define USE_MYFUNC 1 /* Must use syscall indirection */#define MASTER 1 /* Compile without unireg */#define ENGLISH 1 /* Messages in English */#define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */#define USE_REGEX 1 /* We want the use the regex library *//* Do not define for ultra sparcs */#ifndef OS2#define USE_BMOVE512 1 /* Use this unless system bmove is faster */#endif#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp *//* Paranoid settings. Define I_AM_PARANOID if you are paranoid */#ifdef I_AM_PARANOID#define DONT_ALLOW_USER_CHANGE 1#define DONT_USE_MYSQL_PWD 1#endif/* Does the system remember a signal handler after a signal ? */#ifndef HAVE_BSD_SIGNALS#define DONT_REMEMBER_SIGNAL#endif/* Define void to stop lint from generating "null effekt" comments */#ifndef DONT_DEFINE_VOID#ifdef _lintint __void__;#define VOID(X) (__void__ = (int) (X))#else#undef VOID#define VOID(X) (X)#endif#endif /* DONT_DEFINE_VOID */#if defined(_lint) || defined(FORCE_INIT_OF_VARS)#define LINT_INIT(var) var=0 /* No uninitialize-warning */#else#define LINT_INIT(var)#endif#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_purify)#define PURIFY_OR_LINT_INIT(var) var=0#else#define PURIFY_OR_LINT_INIT(var)#endif/* Define some useful general macros */#if !defined(max)#define max(a, b) ((a) > (b) ? (a) : (b))#define min(a, b) ((a) < (b) ? (a) : (b))#endif#if defined(__EMX__) || !defined(HAVE_UINT)#undef HAVE_UINT#define HAVE_UINTtypedef unsigned int uint;typedef unsigned short ushort;#endif#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; }#define test(a) ((a) ? 1 : 0)#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)#define test_all_bits(a,b) (((a) & (b)) == (b))#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))#ifndef HAVE_RINT#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))#endif/* Define some general constants */#ifndef TRUE#define TRUE (1) /* Logical true */#define FALSE (0) /* Logical false */#endif#if defined(__GNUC__)#define function_volatile volatile#define my_reinterpret_cast(A) reinterpret_cast<A>#define my_const_cast(A) const_cast<A>#elif !defined(my_reinterpret_cast)#define my_reinterpret_cast(A) (A)#define my_const_cast(A) (A)#endif#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)#define __attribute__(A)#endif/* Wen using the embedded library, users might run into link problems, dupicate declaration of __cxa_pure_virtual, solved by declaring it a weak symbol.*/#ifdef USE_MYSYS_NEWC_MODE_STARTint __cxa_pure_virtual () __attribute__ ((weak));C_MODE_END#endif/* From old s-system.h *//* Support macros for non ansi & other old compilers. Since such things are no longer supported we do nothing. We keep then since some of our code may still be needed to upgrade old customers.*/#define _VARARGS(X) X#define _STATIC_VARARGS(X) X#define _PC(X) X#if defined(DBUG_ON) && defined(DBUG_OFF)#undef DBUG_OFF#endif#if defined(_lint) && !defined(DBUG_OFF)#define DBUG_OFF#endif#include <my_dbug.h>#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/#define ASCII_BITS_USED 8 /* Bit char used */#define NEAR_F /* No near function handling *//* Some types that is different between systems */typedef int File; /* File descriptor */#ifndef Socket_definedtypedef int my_socket; /* File descriptor for sockets */#define INVALID_SOCKET -1#endif/* Type for fuctions that handles signals */#define sig_handler RETSIGTYPEC_MODE_STARTtypedef void (*sig_return)();/* Returns type from signal */C_MODE_END#if defined(__GNUC__) && !defined(_lint)typedef char pchar; /* Mixed prototypes can take char */typedef char puchar; /* Mixed prototypes can take char */typedef char pbool; /* Mixed prototypes can take char */typedef short pshort; /* Mixed prototypes can take short int */typedef float pfloat; /* Mixed prototypes can take float */#elsetypedef int pchar; /* Mixed prototypes can't take char */typedef uint puchar; /* Mixed prototypes can't take char */typedef int pbool; /* Mixed prototypes can't take char */typedef int pshort; /* Mixed prototypes can't take short int */typedef double pfloat; /* Mixed prototypes can't take float */#endifC_MODE_STARTtypedef int (*qsort_cmp)(const void *,const void *);typedef int (*qsort_cmp2)(void*, const void *,const void *);C_MODE_END#ifdef HAVE_mit_thread#define qsort_t void#undef QSORT_TYPE_IS_VOID#define QSORT_TYPE_IS_VOID#else#define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */#endif#ifdef HAVE_mit_thread#define size_socket socklen_t /* Type of last arg to accept */#else#ifdef HAVE_SYS_SOCKET_H#include <sys/socket.h>#endiftypedef SOCKET_SIZE_TYPE size_socket;#endif#ifndef SOCKOPT_OPTLEN_TYPE#define SOCKOPT_OPTLEN_TYPE size_socket#endif/* file create flags */#ifndef O_SHARE /* Probably not windows */#define O_SHARE 0 /* Flag to my_open for shared files */#ifndef O_BINARY#define O_BINARY 0 /* Flag to my_open for binary files */#endif#ifndef FILE_BINARY#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */#endif#ifdef HAVE_FCNTL#define HAVE_FCNTL_LOCK#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */#endif#endif /* O_SHARE */#ifndef O_TEMPORARY#define O_TEMPORARY 0#endif#ifndef O_SHORT_LIVED#define O_SHORT_LIVED 0#endif#ifndef O_NOFOLLOW#define O_NOFOLLOW 0#endif/* additional file share flags for win32 */#ifdef __WIN__#define _SH_DENYRWD 0x110 /* deny read/write mode & delete */#define _SH_DENYWRD 0x120 /* deny write mode & delete */#define _SH_DENYRDD 0x130 /* deny read mode & delete */#define _SH_DENYDEL 0x140 /* deny delete only */#endif /* __WIN__ *//* #define USE_RECORD_LOCK */ /* Unsigned types supported by the compiler */#define UNSINT8 /* unsigned int8 (char) */#define UNSINT16 /* unsigned int16 */#define UNSINT32 /* unsigned int32 */ /* General constants */#define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */#define FN_LEN 256 /* Max file name len */#define FN_HEADLEN 253 /* Max length of filepart of file name */#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */#define FN_REFLEN 512 /* Max length of full path-name */#define FN_EXTCHAR '.'#define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */#define FN_PARENTDIR ".." /* Parent directory; Must be a string */#define FN_DEVCHAR ':'#ifndef FN_LIBCHAR#ifdef __EMX__#define FN_LIBCHAR '\\'#define FN_ROOTDIR "\\"#else#define FN_LIBCHAR '/'#define FN_ROOTDIR "/"#endif#endif#define MY_NFILE 64 /* This is only used to save filenames */#ifndef OS_FILE_LIMIT#define OS_FILE_LIMIT 65535#endif/* #define EXT_IN_LIBNAME *//* #define FN_NO_CASE_SENCE *//* #define FN_UPPER_CASE TRUE *//* Io buffer size; Must be a power of 2 and a multiple of 512. May be smaller what the disk page size. This influences the speed of the isam btree library. eg to big to slow.*/#define IO_SIZE 4096/* How much overhead does malloc have. The code often allocates something like 1024-MALLOC_OVERHEAD bytes*/#ifdef SAFEMALLOC#define MALLOC_OVERHEAD (8+24+4)#else#define MALLOC_OVERHEAD 8#endif /* get memory in huncs */#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD) /* Typical record cash */#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD) /* Typical key cash */#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -