Go to the documentation of this file.
31 #ifndef CPL_BASE_H_INCLUDED
32 #define CPL_BASE_H_INCLUDED
52 #if defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE)
56 #if defined(_WINDOWS) && !defined(WIN32) && !defined(_WIN32_WCE)
63 #if defined(_WIN32_WCE)
72 # ifndef _CRT_SECURE_NO_DEPRECATE
73 # define _CRT_SECURE_NO_DEPRECATE
75 # ifndef _CRT_NONSTDC_NO_DEPRECATE
76 # define _CRT_NONSTDC_NO_DEPRECATE
80 #include "cpl_config.h"
87 #if !defined(SIZEOF_INT) || SIZEOF_INT != 4
88 #error "Unexpected value for SIZEOF_INT"
91 #if !defined(SIZEOF_UNSIGNED_LONG) || (SIZEOF_UNSIGNED_LONG != 4 && SIZEOF_UNSIGNED_LONG != 8)
92 #error "Unexpected value for SIZEOF_UNSIGNED_LONG"
95 #if !defined(SIZEOF_VOIDP) || (SIZEOF_VOIDP != 4 && SIZEOF_VOIDP != 8)
96 #error "Unexpected value for SIZEOF_VOIDP"
110 #if defined(VSI_NEED_LARGEFILE64_SOURCE) && !defined(_LARGEFILE64_SOURCE)
111 # define _LARGEFILE64_SOURCE 1
120 #if defined(HAVE_ICONV)
121 # define CPL_RECODE_ICONV
124 #define CPL_RECODE_STUB
133 #if defined(__MINGW32__)
134 #ifndef __MSVCRT_VERSION__
135 #define __MSVCRT_VERSION__ 0x0601
151 #if !defined(WIN32CE)
154 # include <wce_time.h>
155 # include <wce_errno.h>
159 #if defined(HAVE_ERRNO_H)
172 # include <strings.h>
175 #if defined(HAVE_LIBDBMALLOC) && defined(HAVE_DBMALLOC_H) && defined(DEBUG)
177 # include <dbmalloc.h>
180 #if !defined(DBMALLOC) && defined(HAVE_DMALLOC_H)
182 # include <dmalloc.h>
193 #if UINT_MAX == 65535
195 typedef unsigned long GUInt32;
198 typedef unsigned int GUInt32;
201 typedef short GInt16;
202 typedef unsigned short GUInt16;
203 typedef unsigned char GByte;
206 #ifndef CPL_GBOOL_DEFINED
207 #define CPL_GBOOL_DEFINED
215 #if defined(WIN32) && defined(_MSC_VER)
217 #define VSI_LARGE_API_SUPPORTED
218 typedef __int64 GIntBig;
219 typedef unsigned __int64 GUIntBig;
223 typedef long long GIntBig;
224 typedef unsigned long long GUIntBig;
228 typedef long GIntBig;
229 typedef unsigned long GUIntBig;
233 #if defined(__MSVCRT__) || (defined(WIN32) && defined(_MSC_VER))
234 #define CPL_FRMT_GB_WITHOUT_PREFIX "I64"
236 #define CPL_FRMT_GB_WITHOUT_PREFIX "ll"
238 #define CPL_FRMT_GB_WITHOUT_PREFIX "l"
241 #define CPL_FRMT_GIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "d"
242 #define CPL_FRMT_GUIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "u"
245 #if defined(_MSC_VER) && (_MSC_VER <= 1200)
246 #define GUINTBIG_TO_DOUBLE(x) (double)(GIntBig)(x)
248 #define GUINTBIG_TO_DOUBLE(x) (double)(x)
255 # define CPL_C_START extern "C" {
263 #if defined(_MSC_VER) && !defined(CPL_DISABLE_DLL)
264 # define CPL_DLL __declspec(dllexport)
266 # if defined(USE_GCC_VISIBILITY_FLAG)
267 # define CPL_DLL __attribute__ ((visibility("default")))
275 #ifdef CPL_OPTIONAL_APIS
276 # define CPL_ODLL CPL_DLL
282 #if defined(_MSC_VER) && !defined(CPL_DISABLE_STDCALL)
283 # define CPL_STDCALL __stdcall
290 # define FORCE_CDECL __cdecl
296 #if defined(__GNUC__) || defined(_MSC_VER)
297 #define HAS_CPL_INLINE 1
298 #define CPL_INLINE __inline
299 #elif defined(__SUNPRO_CC)
300 #define HAS_CPL_INLINE 1
301 #define CPL_INLINE inline
319 # define MIN(a,b) ((a<b) ? a : b)
320 # define MAX(a,b) ((a>b) ? a : b)
324 # define ABS(x) ((x<0) ? (-1*(x)) : x)
328 # define M_PI 3.14159265358979323846
337 # define CPLIsEqual(x,y) (fabs((x) - (y)) < 0.0000000000001)
344 # if defined(WIN32) || defined(WIN32CE)
345 # define STRCASECMP(a,b) (stricmp(a,b))
346 # define STRNCASECMP(a,b,n) (strnicmp(a,b,n))
348 # define STRCASECMP(a,b) (strcasecmp(a,b))
349 # define STRNCASECMP(a,b,n) (strncasecmp(a,b,n))
351 # define EQUALN(a,b,n) (STRNCASECMP(a,b,n)==0)
352 # define EQUAL(a,b) (STRCASECMP(a,b)==0)
356 int strcasecmp(
char * str1,
char * str2);
357 int strncasecmp(
char * str1,
char * str2,
int len);
358 char * strdup (
char *instr);
361 #ifndef CPL_THREADLOCAL
362 # define CPL_THREADLOCAL
376 # define CPLIsNan(x) _isnan(x)
377 # define CPLIsInf(x) (!_isnan(x) && !_finite(x))
378 # define CPLIsFinite(x) _finite(x)
380 # define CPLIsNan(x) isnan(x)
382 # define CPLIsInf(x) isinf(x)
383 # define CPLIsFinite(x) (!isnan(x) && !isinf(x))
385 # define CPLIsInf(x) FALSE
386 # define CPLIsFinite(x) (!isnan(x))
397 #if defined(WORDS_BIGENDIAN) && !defined(CPL_MSB) && !defined(CPL_LSB)
401 #if ! ( defined(CPL_LSB) || defined(CPL_MSB) )
406 # define CPL_IS_LSB 1
408 # define CPL_IS_LSB 0
415 #define CPL_SWAP16(x) \
417 (((GUInt16)(x) & 0x00ffU) << 8) | \
418 (((GUInt16)(x) & 0xff00U) >> 8) ))
420 #define CPL_SWAP16PTR(x) \
422 GByte byTemp, *_pabyDataT = (GByte *) (x); \
424 byTemp = _pabyDataT[0]; \
425 _pabyDataT[0] = _pabyDataT[1]; \
426 _pabyDataT[1] = byTemp; \
429 #define CPL_SWAP32(x) \
431 (((GUInt32)(x) & (GUInt32)0x000000ffUL) << 24) | \
432 (((GUInt32)(x) & (GUInt32)0x0000ff00UL) << 8) | \
433 (((GUInt32)(x) & (GUInt32)0x00ff0000UL) >> 8) | \
434 (((GUInt32)(x) & (GUInt32)0xff000000UL) >> 24) ))
436 #define CPL_SWAP32PTR(x) \
438 GByte byTemp, *_pabyDataT = (GByte *) (x); \
440 byTemp = _pabyDataT[0]; \
441 _pabyDataT[0] = _pabyDataT[3]; \
442 _pabyDataT[3] = byTemp; \
443 byTemp = _pabyDataT[1]; \
444 _pabyDataT[1] = _pabyDataT[2]; \
445 _pabyDataT[2] = byTemp; \
448 #define CPL_SWAP64PTR(x) \
450 GByte byTemp, *_pabyDataT = (GByte *) (x); \
452 byTemp = _pabyDataT[0]; \
453 _pabyDataT[0] = _pabyDataT[7]; \
454 _pabyDataT[7] = byTemp; \
455 byTemp = _pabyDataT[1]; \
456 _pabyDataT[1] = _pabyDataT[6]; \
457 _pabyDataT[6] = byTemp; \
458 byTemp = _pabyDataT[2]; \
459 _pabyDataT[2] = _pabyDataT[5]; \
460 _pabyDataT[5] = byTemp; \
461 byTemp = _pabyDataT[3]; \
462 _pabyDataT[3] = _pabyDataT[4]; \
463 _pabyDataT[4] = byTemp; \
483 #define CPL_SWAPDOUBLE(p) CPL_SWAP64PTR(p)
486 # define CPL_MSBWORD16(x) (x)
487 # define CPL_LSBWORD16(x) CPL_SWAP16(x)
488 # define CPL_MSBWORD32(x) (x)
489 # define CPL_LSBWORD32(x) CPL_SWAP32(x)
490 # define CPL_MSBPTR16(x)
491 # define CPL_LSBPTR16(x) CPL_SWAP16PTR(x)
492 # define CPL_MSBPTR32(x)
493 # define CPL_LSBPTR32(x) CPL_SWAP32PTR(x)
494 # define CPL_MSBPTR64(x)
495 # define CPL_LSBPTR64(x) CPL_SWAP64PTR(x)
497 # define CPL_LSBWORD16(x) (x)
498 # define CPL_MSBWORD16(x) CPL_SWAP16(x)
499 # define CPL_LSBWORD32(x) (x)
500 # define CPL_MSBWORD32(x) CPL_SWAP32(x)
501 # define CPL_LSBPTR16(x)
502 # define CPL_MSBPTR16(x) CPL_SWAP16PTR(x)
503 # define CPL_LSBPTR32(x)
504 # define CPL_MSBPTR32(x) CPL_SWAP32PTR(x)
505 # define CPL_LSBPTR64(x)
506 # define CPL_MSBPTR64(x) CPL_SWAP64PTR(x)
510 #define CPL_LSBINT16PTR(x) ((*(GByte*)(x)) | ((*(GByte*)((x)+1)) << 8))
513 #define CPL_LSBINT32PTR(x) ((*(GByte*)(x)) | ((*(GByte*)((x)+1)) << 8) | \
514 ((*(GByte*)((x)+2)) << 16) | ((*(GByte*)((x)+3)) << 24))
517 #define CPL_LSBSINT16PTR(x) ((GInt16) CPL_LSBINT16PTR(x))
520 #define CPL_LSBUINT16PTR(x) ((GUInt16)CPL_LSBINT16PTR(x))
523 #define CPL_LSBSINT32PTR(x) ((GInt32) CPL_LSBINT32PTR(x))
526 #define CPL_LSBUINT32PTR(x) ((GUInt32)CPL_LSBINT32PTR(x))
530 #ifndef UNREFERENCED_PARAM
531 # ifdef UNREFERENCED_PARAMETER
532 # define UNREFERENCED_PARAM(param) UNREFERENCED_PARAMETER(param)
534 # define UNREFERENCED_PARAM(param) ((void)param)
546 #ifndef DISABLE_CVSID
547 #if defined(__GNUC__) && __GNUC__ >= 4
548 # define CPL_CVSID(string) static char cpl_cvsid[] __attribute__((used)) = string;
550 # define CPL_CVSID(string) static char cpl_cvsid[] = string; \
551 static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : cpl_cvsid ); }
554 # define CPL_CVSID(string)
557 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
558 #define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__printf__, format_idx, arg_idx)))
560 #define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx )
563 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP)
564 #define CPL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
566 #define CPL_WARN_UNUSED_RESULT
569 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
570 #define CPL_NO_RETURN __attribute__((noreturn))
572 #define CPL_NO_RETURN
575 #if !defined(DOXYGEN_SKIP)
576 #if defined(__has_extension)
577 #if __has_extension(attribute_deprecated_with_message)
579 #define CPL_WARN_DEPRECATED(x) __attribute__ ((deprecated(x)))
581 #define CPL_WARN_DEPRECATED(x)
583 #elif defined(__GNUC__)
584 #define CPL_WARN_DEPRECATED(x) __attribute__ ((deprecated))
586 #define CPL_WARN_DEPRECATED(x)
Generated for GDAL by
1.8.4.