Go to the documentation of this file. 32 #ifndef CPL_BASE_H_INCLUDED 33 #define CPL_BASE_H_INCLUDED 53 #if defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) 57 #if defined(_WINDOWS) && !defined(WIN32) && !defined(_WIN32_WCE) 64 #if defined(_WIN32_WCE) 73 # ifndef _CRT_SECURE_NO_DEPRECATE 74 # define _CRT_SECURE_NO_DEPRECATE 76 # ifndef _CRT_NONSTDC_NO_DEPRECATE 77 # define _CRT_NONSTDC_NO_DEPRECATE 81 #include "cpl_config.h" 88 #if !defined(SIZEOF_INT) || SIZEOF_INT != 4 89 #error "Unexpected value for SIZEOF_INT" 92 #if !defined(SIZEOF_UNSIGNED_LONG) || (SIZEOF_UNSIGNED_LONG != 4 && SIZEOF_UNSIGNED_LONG != 8) 93 #error "Unexpected value for SIZEOF_UNSIGNED_LONG" 96 #if !defined(SIZEOF_VOIDP) || (SIZEOF_VOIDP != 4 && SIZEOF_VOIDP != 8) 97 #error "Unexpected value for SIZEOF_VOIDP" 111 #if defined(VSI_NEED_LARGEFILE64_SOURCE) && !defined(_LARGEFILE64_SOURCE) 112 # define _LARGEFILE64_SOURCE 1 121 #if defined(HAVE_ICONV) 122 # define CPL_RECODE_ICONV 125 #define CPL_RECODE_STUB 134 #if defined(__MINGW32__) 135 #ifndef __MSVCRT_VERSION__ 136 #define __MSVCRT_VERSION__ 0x0601 152 #if !defined(WIN32CE) 155 # include <wce_time.h> 156 # include <wce_errno.h> 160 #if defined(HAVE_ERRNO_H) 172 #if !(defined(WIN32) || defined(WIN32CE)) 173 # include <strings.h> 176 #if defined(HAVE_LIBDBMALLOC) && defined(HAVE_DBMALLOC_H) && defined(DEBUG) 178 # include <dbmalloc.h> 181 #if !defined(DBMALLOC) && defined(HAVE_DMALLOC_H) 183 # include <dmalloc.h> 194 #if UINT_MAX == 65535 196 typedef unsigned long GUInt32;
199 typedef unsigned int GUInt32;
202 typedef short GInt16;
203 typedef unsigned short GUInt16;
204 typedef unsigned char GByte;
207 #ifndef CPL_GBOOL_DEFINED 208 #define CPL_GBOOL_DEFINED 216 #if defined(WIN32) && defined(_MSC_VER) 218 #define VSI_LARGE_API_SUPPORTED 219 typedef __int64 GIntBig;
220 typedef unsigned __int64 GUIntBig;
224 typedef long long GIntBig;
225 typedef unsigned long long GUIntBig;
229 typedef long GIntBig;
230 typedef unsigned long GUIntBig;
234 #if defined(__MSVCRT__) || (defined(WIN32) && defined(_MSC_VER)) 235 #define CPL_FRMT_GB_WITHOUT_PREFIX "I64" 237 #define CPL_FRMT_GB_WITHOUT_PREFIX "ll" 239 #define CPL_FRMT_GB_WITHOUT_PREFIX "l" 242 #define CPL_FRMT_GIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "d" 243 #define CPL_FRMT_GUIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "u" 246 #if defined(_MSC_VER) && (_MSC_VER <= 1200) 247 #define GUINTBIG_TO_DOUBLE(x) (double)(GIntBig)(x) 249 #define GUINTBIG_TO_DOUBLE(x) (double)(x) 256 # define CPL_C_START extern "C" { 264 #if defined(_MSC_VER) && !defined(CPL_DISABLE_DLL) 265 # define CPL_DLL __declspec(dllexport) 267 # if defined(USE_GCC_VISIBILITY_FLAG) 268 # define CPL_DLL __attribute__ ((visibility("default"))) 276 #ifdef CPL_OPTIONAL_APIS 277 # define CPL_ODLL CPL_DLL 283 #if defined(_MSC_VER) && !defined(CPL_DISABLE_STDCALL) 284 # define CPL_STDCALL __stdcall 291 # define FORCE_CDECL __cdecl 297 #if defined(__GNUC__) || defined(_MSC_VER) 298 #define HAS_CPL_INLINE 1 299 #define CPL_INLINE __inline 300 #elif defined(__SUNPRO_CC) 301 #define HAS_CPL_INLINE 1 302 #define CPL_INLINE inline 320 # define MIN(a,b) ((a<b) ? a : b) 321 # define MAX(a,b) ((a>b) ? a : b) 325 # define ABS(x) ((x<0) ? (-1*(x)) : x) 329 # define M_PI 3.14159265358979323846 338 # define CPLIsEqual(x,y) (fabs((x) - (y)) < 0.0000000000001) 345 # if defined(WIN32) || defined(WIN32CE) 346 # define STRCASECMP(a,b) (stricmp(a,b)) 347 # define STRNCASECMP(a,b,n) (strnicmp(a,b,n)) 349 # define STRCASECMP(a,b) (strcasecmp(a,b)) 350 # define STRNCASECMP(a,b,n) (strncasecmp(a,b,n)) 352 # define EQUALN(a,b,n) (STRNCASECMP(a,b,n)==0) 353 # define EQUAL(a,b) (STRCASECMP(a,b)==0) 357 int strcasecmp(
char * str1,
char * str2);
358 int strncasecmp(
char * str1,
char * str2,
int len);
359 char * strdup (
char *instr);
362 #ifndef CPL_THREADLOCAL 363 # define CPL_THREADLOCAL 377 # define CPLIsNan(x) _isnan(x) 378 # define CPLIsInf(x) (!_isnan(x) && !_finite(x)) 379 # define CPLIsFinite(x) _finite(x) 381 # define CPLIsNan(x) isnan(x) 383 # define CPLIsInf(x) isinf(x) 384 # define CPLIsFinite(x) (!isnan(x) && !isinf(x)) 386 # define CPLIsInf(x) FALSE 387 # define CPLIsFinite(x) (!isnan(x)) 398 #if defined(WORDS_BIGENDIAN) && !defined(CPL_MSB) && !defined(CPL_LSB) 402 #if ! ( defined(CPL_LSB) || defined(CPL_MSB) ) 407 # define CPL_IS_LSB 1 409 # define CPL_IS_LSB 0 416 #define CPL_SWAP16(x) \ 418 (((GUInt16)(x) & 0x00ffU) << 8) | \ 419 (((GUInt16)(x) & 0xff00U) >> 8) )) 421 #define CPL_SWAP16PTR(x) \ 423 GByte byTemp, *_pabyDataT = (GByte *) (x); \ 425 byTemp = _pabyDataT[0]; \ 426 _pabyDataT[0] = _pabyDataT[1]; \ 427 _pabyDataT[1] = byTemp; \ 430 #define CPL_SWAP32(x) \ 432 (((GUInt32)(x) & (GUInt32)0x000000ffUL) << 24) | \ 433 (((GUInt32)(x) & (GUInt32)0x0000ff00UL) << 8) | \ 434 (((GUInt32)(x) & (GUInt32)0x00ff0000UL) >> 8) | \ 435 (((GUInt32)(x) & (GUInt32)0xff000000UL) >> 24) )) 437 #define CPL_SWAP32PTR(x) \ 439 GByte byTemp, *_pabyDataT = (GByte *) (x); \ 441 byTemp = _pabyDataT[0]; \ 442 _pabyDataT[0] = _pabyDataT[3]; \ 443 _pabyDataT[3] = byTemp; \ 444 byTemp = _pabyDataT[1]; \ 445 _pabyDataT[1] = _pabyDataT[2]; \ 446 _pabyDataT[2] = byTemp; \ 449 #define CPL_SWAP64PTR(x) \ 451 GByte byTemp, *_pabyDataT = (GByte *) (x); \ 453 byTemp = _pabyDataT[0]; \ 454 _pabyDataT[0] = _pabyDataT[7]; \ 455 _pabyDataT[7] = byTemp; \ 456 byTemp = _pabyDataT[1]; \ 457 _pabyDataT[1] = _pabyDataT[6]; \ 458 _pabyDataT[6] = byTemp; \ 459 byTemp = _pabyDataT[2]; \ 460 _pabyDataT[2] = _pabyDataT[5]; \ 461 _pabyDataT[5] = byTemp; \ 462 byTemp = _pabyDataT[3]; \ 463 _pabyDataT[3] = _pabyDataT[4]; \ 464 _pabyDataT[4] = byTemp; \ 484 #define CPL_SWAPDOUBLE(p) CPL_SWAP64PTR(p) 487 # define CPL_MSBWORD16(x) (x) 488 # define CPL_LSBWORD16(x) CPL_SWAP16(x) 489 # define CPL_MSBWORD32(x) (x) 490 # define CPL_LSBWORD32(x) CPL_SWAP32(x) 491 # define CPL_MSBPTR16(x) 492 # define CPL_LSBPTR16(x) CPL_SWAP16PTR(x) 493 # define CPL_MSBPTR32(x) 494 # define CPL_LSBPTR32(x) CPL_SWAP32PTR(x) 495 # define CPL_MSBPTR64(x) 496 # define CPL_LSBPTR64(x) CPL_SWAP64PTR(x) 498 # define CPL_LSBWORD16(x) (x) 499 # define CPL_MSBWORD16(x) CPL_SWAP16(x) 500 # define CPL_LSBWORD32(x) (x) 501 # define CPL_MSBWORD32(x) CPL_SWAP32(x) 502 # define CPL_LSBPTR16(x) 503 # define CPL_MSBPTR16(x) CPL_SWAP16PTR(x) 504 # define CPL_LSBPTR32(x) 505 # define CPL_MSBPTR32(x) CPL_SWAP32PTR(x) 506 # define CPL_LSBPTR64(x) 507 # define CPL_MSBPTR64(x) CPL_SWAP64PTR(x) 511 #define CPL_LSBINT16PTR(x) ((*(GByte*)(x)) | ((*(GByte*)((x)+1)) << 8)) 514 #define CPL_LSBINT32PTR(x) ((*(GByte*)(x)) | ((*(GByte*)((x)+1)) << 8) | \ 515 ((*(GByte*)((x)+2)) << 16) | ((*(GByte*)((x)+3)) << 24)) 518 #define CPL_LSBSINT16PTR(x) ((GInt16) CPL_LSBINT16PTR(x)) 521 #define CPL_LSBUINT16PTR(x) ((GUInt16)CPL_LSBINT16PTR(x)) 524 #define CPL_LSBSINT32PTR(x) ((GInt32) CPL_LSBINT32PTR(x)) 527 #define CPL_LSBUINT32PTR(x) ((GUInt32)CPL_LSBINT32PTR(x)) 531 #ifndef UNREFERENCED_PARAM 532 # ifdef UNREFERENCED_PARAMETER 533 # define UNREFERENCED_PARAM(param) UNREFERENCED_PARAMETER(param) 535 # define UNREFERENCED_PARAM(param) ((void)param) 547 #ifndef DISABLE_CVSID 548 #if defined(__GNUC__) && __GNUC__ >= 4 549 # define CPL_CVSID(string) static char cpl_cvsid[] __attribute__((used)) = string; 551 # define CPL_CVSID(string) static char cpl_cvsid[] = string; \ 552 static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : cpl_cvsid ); } 555 # define CPL_CVSID(string) 559 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP) 560 # define CPL_NULL_TERMINATED __attribute__((__sentinel__)) 562 # define CPL_NULL_TERMINATED 565 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP) 566 #define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__printf__, format_idx, arg_idx))) 568 #define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx ) 571 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP) 572 #define CPL_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 574 #define CPL_WARN_UNUSED_RESULT 577 #if defined(__GNUC__) && __GNUC__ >= 4 578 # define CPL_UNUSED __attribute((__unused__)) 584 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP) 585 #define CPL_NO_RETURN __attribute__((noreturn)) 587 #define CPL_NO_RETURN 590 #if !defined(DOXYGEN_SKIP) 591 #if defined(__has_extension) 592 #if __has_extension(attribute_deprecated_with_message) 594 #define CPL_WARN_DEPRECATED(x) __attribute__ ((deprecated(x))) 596 #define CPL_WARN_DEPRECATED(x) 598 #elif defined(__GNUC__) 599 #define CPL_WARN_DEPRECATED(x) __attribute__ ((deprecated)) 601 #define CPL_WARN_DEPRECATED(x)
Generated for GDAL by
1.8.11.