📄 cpl_port.h
字号:
#endif
#endif
#ifdef _MSC_VER
# define FORCE_CDECL __cdecl
#else
# define FORCE_CDECL
#endif
#ifndef NULL
# define NULL 0
#endif
#ifndef FALSE
# define FALSE 0
#endif
#ifndef TRUE
# define TRUE 1
#endif
#ifndef MAX
# define MIN(a,b) ((a<b) ? a : b)
# define MAX(a,b) ((a>b) ? a : b)
#endif
#ifndef ABS
# define ABS(x) ((x<0) ? (-1*(x)) : x)
#endif
/* -------------------------------------------------------------------- */
/* Macro to test equality of two floating point values. */
/* We use fabs() function instead of ABS() macro to avoid side */
/* effects. */
/* -------------------------------------------------------------------- */
#ifndef CPLIsEqual
# define CPLIsEqual(x,y) (fabs(fabs(x) - fabs(y)) < 0.0000000000001)
#endif
#ifndef EQUAL
#if defined(WIN32) || defined(WIN32CE)
# define EQUALN(a,b,n) (strnicmp(a,b,n)==0)
# define EQUAL(a,b) (stricmp(a,b)==0)
#else
# define EQUALN(a,b,n) (strncasecmp(a,b,n)==0)
# define EQUAL(a,b) (strcasecmp(a,b)==0)
#endif
#endif
#ifdef macos_pre10
int strcasecmp(char * str1, char * str2);
int strncasecmp(char * str1, char * str2, int len);
char * strdup (char *instr);
#endif
#ifndef CPL_THREADLOCAL
# define CPL_THREADLOCAL
#endif
/* -------------------------------------------------------------------- */
/* Handle isnan() and isinf(). Note that isinf() and isnan() */
/* are supposed to be macros according to C99. Some systems */
/* (ie. Tru64) don't have isinf() at all, so if the macro is */
/* not defined we just assume nothing is infinite. This may */
/* mean we have no real CPLIsInf() on systems with an isinf() */
/* function but no corresponding macro, but I can live with */
/* that since it isn't that important a test. */
/* -------------------------------------------------------------------- */
#ifdef _MSC_VER
# define CPLIsNan(x) _isnan(x)
# define CPLIsInf(x) (!_isnan(x) && !_finite(x))
# define CPLIsFinite(x) _finite(x)
#else
# define CPLIsNan(x) isnan(x)
# ifdef isinf
# define CPLIsInf(x) isinf(x)
# define CPLIsFinite(x) (!isnan(x) && !isinf(x))
# else
# define CPLIsInf(x) FALSE
# define CPLIsFinite(x) (!isnan(x))
# endif
#endif
/*---------------------------------------------------------------------
* CPL_LSB and CPL_MSB
* Only one of these 2 macros should be defined and specifies the byte
* ordering for the current platform.
* This should be defined in the Makefile, but if it is not then
* the default is CPL_LSB (Intel ordering, LSB first).
*--------------------------------------------------------------------*/
#if defined(WORDS_BIGENDIAN) && !defined(CPL_MSB) && !defined(CPL_LSB)
# define CPL_MSB
#endif
#if ! ( defined(CPL_LSB) || defined(CPL_MSB) )
#define CPL_LSB
#endif
#if defined(CPL_LSB)
# define CPL_IS_LSB 1
#else
# define CPL_IS_LSB 0
#endif
/*---------------------------------------------------------------------
* Little endian <==> big endian byte swap macros.
*--------------------------------------------------------------------*/
#define CPL_SWAP16(x) \
((GUInt16)( \
(((GUInt16)(x) & 0x00ffU) << 8) | \
(((GUInt16)(x) & 0xff00U) >> 8) ))
#define CPL_SWAP16PTR(x) \
{ \
GByte byTemp, *_pabyDataT = (GByte *) (x); \
\
byTemp = _pabyDataT[0]; \
_pabyDataT[0] = _pabyDataT[1]; \
_pabyDataT[1] = byTemp; \
}
#define CPL_SWAP32(x) \
((GUInt32)( \
(((GUInt32)(x) & (GUInt32)0x000000ffUL) << 24) | \
(((GUInt32)(x) & (GUInt32)0x0000ff00UL) << 8) | \
(((GUInt32)(x) & (GUInt32)0x00ff0000UL) >> 8) | \
(((GUInt32)(x) & (GUInt32)0xff000000UL) >> 24) ))
#define CPL_SWAP32PTR(x) \
{ \
GByte byTemp, *_pabyDataT = (GByte *) (x); \
\
byTemp = _pabyDataT[0]; \
_pabyDataT[0] = _pabyDataT[3]; \
_pabyDataT[3] = byTemp; \
byTemp = _pabyDataT[1]; \
_pabyDataT[1] = _pabyDataT[2]; \
_pabyDataT[2] = byTemp; \
}
#define CPL_SWAP64PTR(x) \
{ \
GByte byTemp, *_pabyDataT = (GByte *) (x); \
\
byTemp = _pabyDataT[0]; \
_pabyDataT[0] = _pabyDataT[7]; \
_pabyDataT[7] = byTemp; \
byTemp = _pabyDataT[1]; \
_pabyDataT[1] = _pabyDataT[6]; \
_pabyDataT[6] = byTemp; \
byTemp = _pabyDataT[2]; \
_pabyDataT[2] = _pabyDataT[5]; \
_pabyDataT[5] = byTemp; \
byTemp = _pabyDataT[3]; \
_pabyDataT[3] = _pabyDataT[4]; \
_pabyDataT[4] = byTemp; \
}
/* Until we have a safe 64 bits integer data type defined, we'll replace
m * this version of the CPL_SWAP64() macro with a less efficient one.
*/
/*
#define CPL_SWAP64(x) \
((uint64)( \
(uint64)(((uint64)(x) & (uint64)0x00000000000000ffULL) << 56) | \
(uint64)(((uint64)(x) & (uint64)0x000000000000ff00ULL) << 40) | \
(uint64)(((uint64)(x) & (uint64)0x0000000000ff0000ULL) << 24) | \
(uint64)(((uint64)(x) & (uint64)0x00000000ff000000ULL) << 8) | \
(uint64)(((uint64)(x) & (uint64)0x000000ff00000000ULL) >> 8) | \
(uint64)(((uint64)(x) & (uint64)0x0000ff0000000000ULL) >> 24) | \
(uint64)(((uint64)(x) & (uint64)0x00ff000000000000ULL) >> 40) | \
(uint64)(((uint64)(x) & (uint64)0xff00000000000000ULL) >> 56) ))
*/
#define CPL_SWAPDOUBLE(p) CPL_SWAP64PTR(p)
#ifdef CPL_MSB
# define CPL_MSBWORD16(x) (x)
# define CPL_LSBWORD16(x) CPL_SWAP16(x)
# define CPL_MSBWORD32(x) (x)
# define CPL_LSBWORD32(x) CPL_SWAP32(x)
# define CPL_MSBPTR16(x)
# define CPL_LSBPTR16(x) CPL_SWAP16PTR(x)
# define CPL_MSBPTR32(x)
# define CPL_LSBPTR32(x) CPL_SWAP32PTR(x)
# define CPL_MSBPTR64(x)
# define CPL_LSBPTR64(x) CPL_SWAP64PTR(x)
#else
# define CPL_LSBWORD16(x) (x)
# define CPL_MSBWORD16(x) CPL_SWAP16(x)
# define CPL_LSBWORD32(x) (x)
# define CPL_MSBWORD32(x) CPL_SWAP32(x)
# define CPL_LSBPTR16(x)
# define CPL_MSBPTR16(x) CPL_SWAP16PTR(x)
# define CPL_LSBPTR32(x)
# define CPL_MSBPTR32(x) CPL_SWAP32PTR(x)
# define CPL_LSBPTR64(x)
# define CPL_MSBPTR64(x) CPL_SWAP64PTR(x)
#endif
/***********************************************************************
* Define CPL_CVSID() macro. It can be disabled during a build by
* defining DISABLE_CPLID in the compiler options.
*
* The cvsid_aw() function is just there to prevent reports of cpl_cvsid()
* being unused.
*/
#ifndef DISABLE_CVSID
# define CPL_CVSID(string) static char cpl_cvsid[] = string; \
static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : cpl_cvsid ); }
#else
# define CPL_CVSID(string)
#endif
#endif /* ndef CPL_BASE_H_INCLUDED */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -