Main Page Class Hierarchy Compound List File List Compound Members File Members Related Pages

# cpl_port.h File Reference

`#include "cpl_config.h"`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <math.h>`
`#include <stdarg.h>`
`#include <string.h>`
`#include <errno.h>`

Go to the source code of this file.

## Defines
#define | NULL 0
#define | FALSE 0
#define | TRUE 1
#define | MIN(a,b) ((a<b) ? a : b)
#define | MAX(a,b) ((a>b) ? a : b)
#define | ABS(x) ((x<0) ? (-1*(x)) : x)
#define | EQUALN(a,b,n) (strncasecmp(a,b,n)==0)
#define | EQUAL(a,b) (strcasecmp(a,b)==0)
#define | CPL_SWAP16(x)
#define | CPL_SWAP16PTR(x)
#define | CPL_SWAP32(x)
#define | CPL_SWAP32PTR(x)
#define | CPL_SWAP64PTR(x)
#define | CPL_SWAPDOUBLE(p)
#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)
## Typedefs
typedef int | GInt32
typedef unsigned int | GUInt32
typedef short | GInt16
typedef unsigned short | GUInt16
typedef unsigned char | GByte
typedef int | GBool

## Detailed Description

Core portability definitions for CPL.

## Define Documentation

#define CPL_SWAP16( | x )

| Initializer:
    \
            ((GUInt16)( \
                (((GUInt16)(x) & 0x00ffU) << 8) | \
                (((GUInt16)(x) & 0xff00U) >> 8) ))

#define CPL_SWAP16PTR( | x )

| Initializer:
    \
    {                                                               \
        GByte       byTemp, *pabyData = (GByte *) (x);              \
                                                                    \
        byTemp = pabyData[0];                                       \
        pabyData[0] = pabyData[1];                                  \
        pabyData[1] = byTemp;                                       \
    }

#define CPL_SWAP32( | x )

| Initializer:
    \
            ((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 )

| Initializer:
    \
    {                                                               \
        GByte       byTemp, *pabyData = (GByte *) (x);              \
                                                                    \
        byTemp = pabyData[0];                                       \
        pabyData[0] = pabyData[3];                                  \
        pabyData[3] = byTemp;                                       \
        byTemp = pabyData[1];                                       \
        pabyData[1] = pabyData[2];                                  \
        pabyData[2] = byTemp;                                       \
    }

#define CPL_SWAP64PTR( | x )

| Initializer:
    \
    {                                                               \
        GByte       byTemp, *pabyData = (GByte *) (x);              \
                                                                    \
        byTemp = pabyData[0];                                       \
        pabyData[0] = pabyData[7];                                  \
        pabyData[7] = byTemp;                                       \
        byTemp = pabyData[1];                                       \
        pabyData[1] = pabyData[6];                                  \
        pabyData[6] = byTemp;                                       \
        byTemp = pabyData[2];                                       \
        pabyData[2] = pabyData[5];                                  \
        pabyData[5] = byTemp;                                       \
        byTemp = pabyData[3];                                       \
        pabyData[3] = pabyData[4];                                  \
        pabyData[4] = byTemp;                                       \
    }

#define CPL_SWAPDOUBLE( | p )

| Initializer:
    {                             \
            double _tmp = *(double *)(p);                     \
            ((GByte *)(p))[0] = ((GByte *)&_tmp)[7];          \
            ((GByte *)(p))[1] = ((GByte *)&_tmp)[6];          \
            ((GByte *)(p))[2] = ((GByte *)&_tmp)[5];          \
            ((GByte *)(p))[3] = ((GByte *)&_tmp)[4];          \
            ((GByte *)(p))[4] = ((GByte *)&_tmp)[3];          \
            ((GByte *)(p))[5] = ((GByte *)&_tmp)[2];          \
            ((GByte *)(p))[6] = ((GByte *)&_tmp)[1];          \
            ((GByte *)(p))[7] = ((GByte *)&_tmp)[0];          \
    }