📄 portability.h
字号:
/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB This file is public domain and comes with NO WARRANTY of any kind *//* Parts of the original, which are not applicable to mysqlnd have been removed. With small modifications, mostly casting but adding few more macros by Andrey Hristov <andrey@mysql.com> . The additions are in the public domain and were added to improve the header file, to get it more consistent.*/#ifndef __attribute#if !defined(__GNUC__)#define __attribute(A)#endif#endif#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__#endif /* __CYGWIN__ */#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)#include <ext/mysqli/mysqlnd/config-win.h>#endif /* _WIN32... */#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)#define _LONG_LONG 1 /* For AIX string library */#endif/* Go around some bugs in different OS and compilers */#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)#include <sys/stream.h> /* HPUX 10.20 defines ulong here. UGLY !!! */#define HAVE_ULONG#endif/* Some defines of functions for portability */#ifndef HAVE_ATOD#define atod atof#endif#if SIZEOF_LONG_LONG > 4#define HAVE_LONG_LONG 1#endif#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)#define LONGLONG_MIN ((long long) 0x8000000000000000LL)#define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL)#endif#if SIZEOF_LONG == 4#define INT_MIN32 (long) 0x80000000L#define INT_MAX32 (long) 0x7FFFFFFFL#define INT_MIN24 ((long) 0xff800000L)#define INT_MAX24 0x007fffffL#define INT_MIN16 ((short int) 0x8000)#define INT_MAX16 0x7FFF#define INT_MIN8 ((char) 0x80)#define INT_MAX8 ((char) 0x7F)#else /* Probably Alpha */#define INT_MIN32 ((long) (int) 0x80000000)#define INT_MAX32 ((long) (int) 0x7FFFFFFF)#define INT_MIN24 ((long) (int) 0xff800000)#define INT_MAX24 ((long) (int) 0x007fffff)#define INT_MIN16 ((short int) 0xffff8000)#define INT_MAX16 ((short int) 0x00007FFF)#endif/* Typdefs for easyier portability */#ifndef HAVE_INT_8_16_32typedef char int8; /* Signed integer >= 8 bits */typedef short int16; /* Signed integer >= 16 bits */#endif#ifndef HAVE_UCHARtypedef unsigned char uchar; /* Short for unsigned char */#endiftypedef unsigned char uint8; /* Short for unsigned integer >= 8 bits */typedef unsigned short uint16; /* Short for unsigned integer >= 16 bits */#if SIZEOF_INT == 4#ifndef HAVE_INT_8_16_32typedef int int32;#endiftypedef unsigned int uint32; /* Short for unsigned integer >= 32 bits */#elif SIZEOF_LONG == 4#ifndef HAVE_INT_8_16_32typedef long int32;#endiftypedef unsigned long uint32; /* Short for unsigned integer >= 32 bits */#elseerror "Neither int or long is of 4 bytes width"#endif#if !defined(HAVE_ULONG) && !defined(__USE_MISC)typedef unsigned long ulong; /* Short for unsigned long */#endif#ifndef longlong_defined#if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8typedef unsigned long long int ulonglong; /* ulong or unsigned long long */typedef long long int longlong;#elsetypedef unsigned long ulonglong; /* ulong or unsigned long long */typedef long longlong;#endif#endif#if A0#ifndef byte_definedtypedef char byte; /* Smallest addressable unit */#endif#endif /* Macros for converting *constants* to the right type */#define INT8(v) (int8) (v)#define INT16(v) (int16) (v)#define INT32(v) (int32) (v)#define int1store(T,A) do { *((zend_uchar*) (T)) = (A); } while(0)#define uint1korr(A) (*(((zend_uchar*)(A))))/*** Define-funktions for reading and storing in machine independent format** (low byte first)*//* Optimized store functions for Intel x86, non-valid for WIN64 */#if defined(__i386__) && !defined(_WIN64)#define sint2korr(A) (*((int16 *) (A)))#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ (((uint32) 255L << 24) | \ (((uint32) (uchar) (A)[2]) << 16) |\ (((uint32) (uchar) (A)[1]) << 8) | \ ((uint32) (uchar) (A)[0])) : \ (((uint32) (uchar) (A)[2]) << 16) |\ (((uint32) (uchar) (A)[1]) << 8) | \ ((uint32) (uchar) (A)[0])))#define sint4korr(A) (*((long *) (A)))#define uint2korr(A) (*((uint16 *) (A)))#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ (((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[2])) << 16))#define uint4korr(A) (*((unsigned long *) (A)))#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ (((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[2])) << 16) +\ (((uint32) ((uchar) (A)[3])) << 24)) +\ (((ulonglong) ((uchar) (A)[4])) << 32))/* From Andrey Hristov, based on uint5korr() */#define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ (((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[2])) << 16) +\ (((uint32) ((uchar) (A)[3])) << 24)) +\ (((ulonglong) ((uchar) (A)[4])) << 32)) +\ (((ulonglong) ((uchar) (A)[5])) << 40))#define uint8korr(A) (*((ulonglong *) (A)))#define sint8korr(A) (*((longlong *) (A)))#define int2store(T,A) *((uint16*) (T))= (uint16) (A)#define int3store(T,A) { \ *(T)= (uchar) ((A));\ *(T+1)=(uchar) (((uint) (A) >> 8));\ *(T+2)=(uchar) (((A) >> 16)); }#define int4store(T,A) *((long *) (T))= (long) (A)#define int5store(T,A) { \ *((uchar *)(T))= (uchar)((A));\ *(((uchar *)(T))+1)=(uchar) (((A) >> 8));\ *(((uchar *)(T))+2)=(uchar) (((A) >> 16));\ *(((uchar *)(T))+3)=(uchar) (((A) >> 24)); \ *(((uchar *)(T))+4)=(uchar) (((A) >> 32)); }/* From Andrey Hristov, based on int5store() */#define int6store(T,A) { \ *(((uchar *)(T)))= (uchar)((A));\ *(((uchar *)(T))+1))=(uchar) (((A) >> 8));\ *(((uchar *)(T))+2))=(uchar) (((A) >> 16));\ *(((uchar *)(T))+3))=(uchar) (((A) >> 24)); \ *(((uchar *)(T))+4))=(uchar) (((A) >> 32)); \ *(((uchar *)(T))+5))=(uchar) (((A) >> 40)); }#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)typedef union { double v; long m[2];} doubleget_union;#define doubleget(V,M) { ((doubleget_union *)&(V))->m[0] = *((long*) (M)); \ ((doubleget_union *)&(V))->m[1] = *(((long*) (M))+1); }#define doublestore(T,V) { *((long *) (T)) = ((doubleget_union *)&(V))->m[0]; \ *(((long *) (T))+1) = ((doubleget_union *)&(V))->m[1]; }#define float4get(V,M) { *((float *) &(V)) = *((float*) (M)); }#define float8get(V,M) doubleget((V),(M))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -