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
83 #include "cpl_config.h"
95 #if defined(VSI_NEED_LARGEFILE64_SOURCE) && !defined(_LARGEFILE64_SOURCE)
96 # define _LARGEFILE64_SOURCE 1
105 #if defined(HAVE_ICONV)
106 # define CPL_RECODE_ICONV
109 #define CPL_RECODE_STUB
118 #if defined(__MINGW32__)
119 #ifndef __MSVCRT_VERSION__
120 #define __MSVCRT_VERSION__ 0x0601
136 #if !defined(WIN32CE)
139 # include <wce_time.h>
140 # include <wce_errno.h>
144 #if defined(HAVE_ERRNO_H)
157 # include <strings.h>
160 #if defined(HAVE_LIBDBMALLOC) && defined(HAVE_DBMALLOC_H) && defined(DEBUG)
162 # include <dbmalloc.h>
165 #if !defined(DBMALLOC) && defined(HAVE_DMALLOC_H)
167 # include <dmalloc.h>
178 #if UINT_MAX == 65535
180 typedef unsigned long GUInt32;
183 typedef unsigned int GUInt32;
186 typedef short GInt16;
187 typedef unsigned short GUInt16;
188 typedef unsigned char GByte;
191 #ifndef CPL_GBOOL_DEFINED
192 #define CPL_GBOOL_DEFINED
200 #if defined(WIN32) && defined(_MSC_VER)
202 #define VSI_LARGE_API_SUPPORTED
203 typedef __int64 GIntBig;
204 typedef unsigned __int64 GUIntBig;
208 typedef long long GIntBig;
209 typedef unsigned long long GUIntBig;
213 typedef long GIntBig;
214 typedef unsigned long GUIntBig;
218 #if defined(__MSVCRT__) || (defined(WIN32) && defined(_MSC_VER))
219 #define CPL_FRMT_GB_WITHOUT_PREFIX "I64"
221 #define CPL_FRMT_GB_WITHOUT_PREFIX "ll"
223 #define CPL_FRMT_GB_WITHOUT_PREFIX "l"
226 #define CPL_FRMT_GIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "d"
227 #define CPL_FRMT_GUIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "u"
230 #if defined(_MSC_VER) && (_MSC_VER <= 1200)
231 #define GUINTBIG_TO_DOUBLE(x) (double)(GIntBig)(x)
233 #define GUINTBIG_TO_DOUBLE(x) (double)(x)
240 # define CPL_C_START extern "C" {
248 #if defined(_MSC_VER) && !defined(CPL_DISABLE_DLL)
249 # define CPL_DLL __declspec(dllexport)
251 # if defined(USE_GCC_VISIBILITY_FLAG)
252 # define CPL_DLL __attribute__ ((visibility("default")))
260 #ifdef CPL_OPTIONAL_APIS
261 # define CPL_ODLL CPL_DLL
267 #if defined(_MSC_VER) && !defined(CPL_DISABLE_STDCALL)
268 # define CPL_STDCALL __stdcall
275 # define FORCE_CDECL __cdecl
281 #if defined(__GNUC__) || defined(_MSC_VER)
282 #define HAS_CPL_INLINE 1
283 #define CPL_INLINE __inline
284 #elif defined(__SUNPRO_CC)
285 #define HAS_CPL_INLINE 1
286 #define CPL_INLINE inline
304 # define MIN(a,b) ((a<b) ? a : b)
305 # define MAX(a,b) ((a>b) ? a : b)
309 # define ABS(x) ((x<0) ? (-1*(x)) : x)
318 # define CPLIsEqual(x,y) (fabs((x) - (y)) < 0.0000000000001)
325 # if defined(WIN32) || defined(WIN32CE)
326 # define STRCASECMP(a,b) (stricmp(a,b))
327 # define STRNCASECMP(a,b,n) (strnicmp(a,b,n))
329 # define STRCASECMP(a,b) (strcasecmp(a,b))
330 # define STRNCASECMP(a,b,n) (strncasecmp(a,b,n))
332 # define EQUALN(a,b,n) (STRNCASECMP(a,b,n)==0)
333 # define EQUAL(a,b) (STRCASECMP(a,b)==0)
337 int strcasecmp(
char * str1,
char * str2);
338 int strncasecmp(
char * str1,
char * str2,
int len);
339 char * strdup (
char *instr);
342 #ifndef CPL_THREADLOCAL
343 # define CPL_THREADLOCAL
357 # define CPLIsNan(x) _isnan(x)
358 # define CPLIsInf(x) (!_isnan(x) && !_finite(x))
359 # define CPLIsFinite(x) _finite(x)
361 # define CPLIsNan(x) isnan(x)
363 # define CPLIsInf(x) isinf(x)
364 # define CPLIsFinite(x) (!isnan(x) && !isinf(x))
366 # define CPLIsInf(x) FALSE
367 # define CPLIsFinite(x) (!isnan(x))
378 #if defined(WORDS_BIGENDIAN) && !defined(CPL_MSB) && !defined(CPL_LSB)
382 #if ! ( defined(CPL_LSB) || defined(CPL_MSB) )
387 # define CPL_IS_LSB 1
389 # define CPL_IS_LSB 0
396 #define CPL_SWAP16(x) \
398 (((GUInt16)(x) & 0x00ffU) << 8) | \
399 (((GUInt16)(x) & 0xff00U) >> 8) ))
401 #define CPL_SWAP16PTR(x) \
403 GByte byTemp, *_pabyDataT = (GByte *) (x); \
405 byTemp = _pabyDataT[0]; \
406 _pabyDataT[0] = _pabyDataT[1]; \
407 _pabyDataT[1] = byTemp; \
410 #define CPL_SWAP32(x) \
412 (((GUInt32)(x) & (GUInt32)0x000000ffUL) << 24) | \
413 (((GUInt32)(x) & (GUInt32)0x0000ff00UL) << 8) | \
414 (((GUInt32)(x) & (GUInt32)0x00ff0000UL) >> 8) | \
415 (((GUInt32)(x) & (GUInt32)0xff000000UL) >> 24) ))
417 #define CPL_SWAP32PTR(x) \
419 GByte byTemp, *_pabyDataT = (GByte *) (x); \
421 byTemp = _pabyDataT[0]; \
422 _pabyDataT[0] = _pabyDataT[3]; \
423 _pabyDataT[3] = byTemp; \
424 byTemp = _pabyDataT[1]; \
425 _pabyDataT[1] = _pabyDataT[2]; \
426 _pabyDataT[2] = byTemp; \
429 #define CPL_SWAP64PTR(x) \
431 GByte byTemp, *_pabyDataT = (GByte *) (x); \
433 byTemp = _pabyDataT[0]; \
434 _pabyDataT[0] = _pabyDataT[7]; \
435 _pabyDataT[7] = byTemp; \
436 byTemp = _pabyDataT[1]; \
437 _pabyDataT[1] = _pabyDataT[6]; \
438 _pabyDataT[6] = byTemp; \
439 byTemp = _pabyDataT[2]; \
440 _pabyDataT[2] = _pabyDataT[5]; \
441 _pabyDataT[5] = byTemp; \
442 byTemp = _pabyDataT[3]; \
443 _pabyDataT[3] = _pabyDataT[4]; \
444 _pabyDataT[4] = byTemp; \
464 #define CPL_SWAPDOUBLE(p) CPL_SWAP64PTR(p)
467 # define CPL_MSBWORD16(x) (x)
468 # define CPL_LSBWORD16(x) CPL_SWAP16(x)
469 # define CPL_MSBWORD32(x) (x)
470 # define CPL_LSBWORD32(x) CPL_SWAP32(x)
471 # define CPL_MSBPTR16(x)
472 # define CPL_LSBPTR16(x) CPL_SWAP16PTR(x)
473 # define CPL_MSBPTR32(x)
474 # define CPL_LSBPTR32(x) CPL_SWAP32PTR(x)
475 # define CPL_MSBPTR64(x)
476 # define CPL_LSBPTR64(x) CPL_SWAP64PTR(x)
478 # define CPL_LSBWORD16(x) (x)
479 # define CPL_MSBWORD16(x) CPL_SWAP16(x)
480 # define CPL_LSBWORD32(x) (x)
481 # define CPL_MSBWORD32(x) CPL_SWAP32(x)
482 # define CPL_LSBPTR16(x)
483 # define CPL_MSBPTR16(x) CPL_SWAP16PTR(x)
484 # define CPL_LSBPTR32(x)
485 # define CPL_MSBPTR32(x) CPL_SWAP32PTR(x)
486 # define CPL_LSBPTR64(x)
487 # define CPL_MSBPTR64(x) CPL_SWAP64PTR(x)
491 #define CPL_LSBINT16PTR(x) ((*(GByte*)(x)) | ((*(GByte*)((x)+1)) << 8))
494 #define CPL_LSBINT32PTR(x) ((*(GByte*)(x)) | ((*(GByte*)((x)+1)) << 8) | \
495 ((*(GByte*)((x)+2)) << 16) | ((*(GByte*)((x)+3)) << 24))
499 #ifndef UNREFERENCED_PARAM
500 # ifdef UNREFERENCED_PARAMETER
501 # define UNREFERENCED_PARAM(param) UNREFERENCED_PARAMETER(param)
503 # define UNREFERENCED_PARAM(param) ((void)param)
515 #ifndef DISABLE_CVSID
516 #if defined(__GNUC__) && __GNUC__ >= 4
517 # define CPL_CVSID(string) static char cpl_cvsid[] __attribute__((used)) = string;
519 # define CPL_CVSID(string) static char cpl_cvsid[] = string; \
520 static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : cpl_cvsid ); }
523 # define CPL_CVSID(string)
526 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
527 #define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__printf__, format_idx, arg_idx)))
529 #define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx )
532 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP)
533 #define CPL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
535 #define CPL_WARN_UNUSED_RESULT
Generated for GDAL by
1.8.4.