/usr/include/gdal/cpl_port.h is in libgdal1-dev 1.7.3-6ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | /******************************************************************************
* $Id: cpl_port.h 19887 2010-06-17 22:47:55Z rouault $
*
* Project: CPL - Common Portability Library
* Author: Frank Warmerdam, warmerdam@pobox.com
* Purpose: Include file providing low level portability services for CPL.
* This should be the first include file for any CPL based code.
*
******************************************************************************
* Copyright (c) 1998, 2005, Frank Warmerdam <warmerdam@pobox.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#ifndef CPL_BASE_H_INCLUDED
#define CPL_BASE_H_INCLUDED
/* Remove annoying warnings Microsoft Visual C++ */
#if defined(_MSC_VER)
# pragma warning(disable:4251 4275 4786)
#endif
/**
* \file cpl_port.h
*
* Core portability definitions for CPL.
*
*/
/* ==================================================================== */
/* We will use macos_pre10 to indicate compilation with MacOS */
/* versions before MacOS X. */
/* ==================================================================== */
#ifdef macintosh
# define macos_pre10
#endif
/* ==================================================================== */
/* We will use WIN32 as a standard windows define. */
/* ==================================================================== */
#if defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE)
# define WIN32
#endif
#if defined(_WINDOWS) && !defined(WIN32) && !defined(_WIN32_WCE)
# define WIN32
#endif
/* ==================================================================== */
/* We will use WIN32CE as a standard Windows CE (Mobile) define. */
/* ==================================================================== */
#if defined(_WIN32_WCE)
# define WIN32CE
#endif
/* -------------------------------------------------------------------- */
/* The following apparently allow you to use strcpy() and other */
/* functions judged "unsafe" by microsoft in VS 8 (2005). */
/* -------------------------------------------------------------------- */
#ifdef _MSC_VER
# ifndef _CRT_SECURE_NO_DEPRECATE
# define _CRT_SECURE_NO_DEPRECATE
# endif
# ifndef _CRT_NONSTDC_NO_DEPRECATE
# define _CRT_NONSTDC_NO_DEPRECATE
# endif
# ifdef MSVC_USE_VLD
# include <vld.h>
# endif
#endif
#include "cpl_config.h"
/* ==================================================================== */
/* This will disable most WIN32 stuff in a Cygnus build which */
/* defines unix to 1. */
/* ==================================================================== */
#ifdef unix
# undef WIN32
# undef WIN32CE
#endif
#if defined(VSI_NEED_LARGEFILE64_SOURCE) && !defined(_LARGEFILE64_SOURCE)
# define _LARGEFILE64_SOURCE 1
#endif
/* ==================================================================== */
/* Standard include files. */
/* ==================================================================== */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#if !defined(WIN32CE)
# include <time.h>
#else
# include <wce_time.h>
# include <wce_errno.h>
#endif
#if defined(HAVE_ERRNO_H)
# include <errno.h>
#endif
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
#ifdef HAVE_DIRECT_H
# include <direct.h>
#endif
#ifdef _AIX
# include <strings.h>
#endif
#if defined(HAVE_LIBDBMALLOC) && defined(HAVE_DBMALLOC_H) && defined(DEBUG)
# define DBMALLOC
# include <dbmalloc.h>
#endif
#if !defined(DBMALLOC) && defined(HAVE_DMALLOC_H)
# define USE_DMALLOC
# include <dmalloc.h>
#endif
/* ==================================================================== */
/* Base portability stuff ... this stuff may need to be */
/* modified for new platforms. */
/* ==================================================================== */
/*---------------------------------------------------------------------
* types for 16 and 32 bits integers, etc...
*--------------------------------------------------------------------*/
#if UINT_MAX == 65535
typedef long GInt32;
typedef unsigned long GUInt32;
#else
typedef int GInt32;
typedef unsigned int GUInt32;
#endif
typedef short GInt16;
typedef unsigned short GUInt16;
typedef unsigned char GByte;
typedef int GBool;
/* -------------------------------------------------------------------- */
/* 64bit support */
/* -------------------------------------------------------------------- */
#if defined(WIN32) && defined(_MSC_VER)
#define VSI_LARGE_API_SUPPORTED
typedef __int64 GIntBig;
typedef unsigned __int64 GUIntBig;
#elif HAVE_LONG_LONG
typedef long long GIntBig;
typedef unsigned long long GUIntBig;
#else
typedef long GIntBig;
typedef unsigned long GUIntBig;
#endif
#if defined(__MSVCRT__) || (defined(WIN32) && defined(_MSC_VER))
#define CPL_FRMT_GB_WITHOUT_PREFIX "I64"
#elif HAVE_LONG_LONG
#define CPL_FRMT_GB_WITHOUT_PREFIX "ll"
#else
#define CPL_FRMT_GB_WITHOUT_PREFIX "l"
#endif
#define CPL_FRMT_GIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "d"
#define CPL_FRMT_GUIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "u"
/* Workaround VC6 bug */
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
#define GUINTBIG_TO_DOUBLE(x) (double)(GIntBig)(x)
#else
#define GUINTBIG_TO_DOUBLE(x) (double)(x)
#endif
/* ==================================================================== */
/* Other standard services. */
/* ==================================================================== */
#ifdef __cplusplus
# define CPL_C_START extern "C" {
# define CPL_C_END }
#else
# define CPL_C_START
# define CPL_C_END
#endif
#ifndef CPL_DLL
#if defined(_MSC_VER) && !defined(CPL_DISABLE_DLL)
# define CPL_DLL __declspec(dllexport)
#else
# if defined(USE_GCC_VISIBILITY_FLAG)
# define CPL_DLL __attribute__ ((visibility("default")))
# else
# define CPL_DLL
# endif
#endif
#endif
/* Should optional (normally private) interfaces be exported? */
#ifdef CPL_OPTIONAL_APIS
# define CPL_ODLL CPL_DLL
#else
# define CPL_ODLL
#endif
#ifndef CPL_STDCALL
#if defined(_MSC_VER) && !defined(CPL_DISABLE_STDCALL)
# define CPL_STDCALL __stdcall
#else
# define CPL_STDCALL
#endif
#endif
#ifdef _MSC_VER
# define FORCE_CDECL __cdecl
#else
# define FORCE_CDECL
#endif
/* TODO : support for other compilers needed */
#if defined(__GNUC__) || defined(_MSC_VER)
#define HAS_CPL_INLINE 1
#define CPL_INLINE __inline
#elif defined(__SUNPRO_CC)
#define HAS_CPL_INLINE 1
#define CPL_INLINE inline
#else
#define CPL_INLINE
#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((x) - (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, defined in math.h */
/* 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 isinf()*/
/* function but no corresponding macro, but I can live with */
/* that since it isn't that important a test. */
/* -------------------------------------------------------------------- */
#ifdef _MSC_VER
# include <float.h>
# 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
* 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
/** Return a Int16 from the 2 bytes ordered in LSB order at address x */
#define CPL_LSBINT16PTR(x) ((*(GByte*)(x)) | ((*(GByte*)((x)+1)) << 8))
/** Return a Int32 from the 4 bytes ordered in LSB order at address x */
#define CPL_LSBINT32PTR(x) ((*(GByte*)(x)) | ((*(GByte*)((x)+1)) << 8) | \
((*(GByte*)((x)+2)) << 16) | ((*(GByte*)((x)+3)) << 24))
/* Utility macro to explicitly mark intentionally unreferenced parameters. */
#ifndef UNREFERENCED_PARAM
# ifdef UNREFERENCED_PARAMETER /* May be defined by Windows API */
# define UNREFERENCED_PARAM(param) UNREFERENCED_PARAMETER(param)
# else
# define UNREFERENCED_PARAM(param) ((void)param)
# endif /* UNREFERENCED_PARAMETER */
#endif /* UNREFERENCED_PARAM */
/***********************************************************************
* 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
#if defined(__GNUC__) && __GNUC__ >= 4
# define CPL_CVSID(string) static char cpl_cvsid[] __attribute__((used)) = string;
#else
# define CPL_CVSID(string) static char cpl_cvsid[] = string; \
static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : cpl_cvsid ); }
#endif
#else
# define CPL_CVSID(string)
#endif
#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP)
#define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__printf__, format_idx, arg_idx)))
#else
#define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx )
#endif
#endif /* ndef CPL_BASE_H_INCLUDED */
|