plibsys  0.0.4
Macros | Typedefs
ptypes.h File Reference

Types definitions. More...

#include <plibsysconfig.h>
#include <pmacros.h>

Go to the source code of this file.

Macros

#define PSIZE_MODIFIER   "I64"
 Platform dependent length modifier for conversion specifiers of psize or pssize type for printing and scanning values. More...
 
#define PSSIZE_FORMAT   "I64d"
 Platform dependent conversion specifier of pssize type for printing and scanning values. More...
 
#define PSIZE_FORMAT   "I64u"
 Platform dependent conversion specifier of psize type for printing and scanning values.
 
#define P_MAXSIZE   P_MAXUINT64
 Maximum value of a psize type.
 
#define P_MINSSIZE   P_MININT64
 Minimum value of a pssize type.
 
#define P_MAXSSIZE   P_MAXINT64
 Maximum value of a pssize type.
 
#define PINTPTR_MODIFIER   "I64"
 Platform dependent length modifier for conversion specifiers of pintptr or puintptr type for printing and scanning values. More...
 
#define PINTPTR_FORMAT   "I64i"
 Platform dependent conversion specifier of pintptr type for printing and scanning values.
 
#define PUINTPTR_FORMAT   "I64u"
 Platform dependent conversion specifier of puintptr type for printing and scanning values.
 
#define P_INT_TO_POINTER(i)   ((void *) (long long) (i))
 Casts an int to a pointer. More...
 
#define P_POINTER_TO_INT(p)   ((int) (long long) (p))
 Casts a pointer to an int. More...
 
#define PPOINTER_TO_INT(p)   ((pint) ((pint64) (p)))
 Casts a ppointer to a pint value. More...
 
#define PPOINTER_TO_UINT(p)   ((puint) ((puint64) (p)))
 Casts a ppointer to a pint value. More...
 
#define PINT_TO_POINTER(i)   ((ppointer) (pint64) (i))
 Casts a pint value to a ppointer. More...
 
#define PUINT_TO_POINTER(u)   ((ppointer) (puint64) (u))
 Casts a puint value to a ppointer. More...
 
#define PSIZE_TO_POINTER(i)   ((ppointer) ((psize) (i)))
 Casts a psize value to a ppointer. More...
 
#define PPOINTER_TO_PSIZE(p)   ((psize) (p))
 Casts a ppointer to a psize value. More...
 
#define P_MININT8   ((pint8) 0x80)
 Min value for a 8-bit int. More...
 
#define P_MAXINT8   ((pint8) 0x7F)
 Max value for a 8-bit int. More...
 
#define P_MAXUINT8   ((puint8) 0xFF)
 Max value for a 8-bit unsigned int. More...
 
#define P_MININT16   ((pint16) 0x8000)
 Min value for a 16-bit int. More...
 
#define P_MAXINT16   ((pint16) 0x7FFF)
 Max value for a 16-bit int. More...
 
#define P_MAXUINT16   ((puint16) 0xFFFF)
 Max value for a 16-bit unsigned int. More...
 
#define P_MININT32   ((pint32) 0x80000000)
 Min value for a 32-bit int. More...
 
#define P_MAXINT32   ((pint32) 0x7FFFFFFF)
 Max value for a 32-bit int. More...
 
#define P_MAXUINT32   ((puint32) 0xFFFFFFFF)
 Max value for a 32-bit unsigned int. More...
 
#define P_MININT64   ((pint64) 0x8000000000000000LL)
 Min value for a 64-bit int. More...
 
#define P_MAXINT64   ((pint64) 0x7FFFFFFFFFFFFFFFLL)
 Max value for a 64-bit int. More...
 
#define P_MAXUINT64   ((puint64) 0xFFFFFFFFFFFFFFFFULL)
 Max value for a 64-bit unsigned int. More...
 
#define PINT16_MODIFIER   "h"
 Platform dependent length modifier for conversion specifiers of pint16 or puint16 type for printing and scanning values. More...
 
#define PINT16_FORMAT   "hi"
 Platform dependent conversion specifier of pint16 type for printing and scanning values.
 
#define PUINT16_FORMAT   "hu"
 Platform dependent conversion specifier of puint16 type for printing and scanning values.
 
#define PINT32_MODIFIER   ""
 Platform dependent length modifier for conversion specifiers of pint32 or puint32 type for printing and scanning values. More...
 
#define PINT32_FORMAT   "i"
 Platform dependent conversion specifier of pint32 type for printing and scanning values.
 
#define PUINT32_FORMAT   "u"
 Platform dependent conversion specifier of puint32 type for printing and scanning values.
 
#define PINT64_MODIFIER   "I64"
 Platform dependent length modifier for conversion specifiers of pint64 or puint64 type for printing and scanning values. More...
 
#define PINT64_FORMAT   "I64i"
 Platform dependent conversion specifier of pint64 type for printing and scanning values.
 
#define PUINT64_FORMAT   "I64u"
 Platform dependent conversion specifier of puint64 type for printing and scanning values.
 
#define POFFSET_MODIFIER   PINT64_MODIFIER
 Platform dependent length modifier for conversion specifiers of poffset type for printing and scanning values. More...
 
#define POFFSET_FORMAT   PINT64_FORMAT
 Platform dependent conversion specifier of poffset type for printing and scanning values.
 
#define P_LITTLE_ENDIAN   1234
 Little endian mark. More...
 
#define P_BIG_ENDIAN   4321
 Big endian mark. More...
 
#define PINT16_TO_LE(val)   ((pint16) (val))
 Swaps a pint16 variable from the host to the little endian order. More...
 
#define PUINT16_TO_LE(val)   ((puint16) (val))
 Swaps a puint16 variable from the host to the little the endian order. More...
 
#define PINT16_TO_BE(val)   ((pint16) PUINT16_SWAP_BYTES (val))
 Swaps a pint16 variable from the host to the big endian order. More...
 
#define PUINT16_TO_BE(val)   (PUINT16_SWAP_BYTES (val))
 Swaps a puint16 variable from the host to the big endian order. More...
 
#define PINT32_TO_LE(val)   ((pint32) (val))
 Swaps a pint32 variable from the host to the little endian order. More...
 
#define PUINT32_TO_LE(val)   ((puint32) (val))
 Swaps a puint32 variable from the host to the little endian order. More...
 
#define PINT32_TO_BE(val)   ((pint32) PUINT32_SWAP_BYTES (val))
 Swaps a pint32 variable from the host to the big endian order. More...
 
#define PUINT32_TO_BE(val)   (PUINT32_SWAP_BYTES (val))
 Swaps a puint32 variable from the host to the big endian order. More...
 
#define PINT64_TO_LE(val)   ((pint64) (val))
 Swaps a pint64 variable from the host to the little endian order. More...
 
#define PUINT64_TO_LE(val)   ((puint64) (val))
 Swaps a puint64 variable from the host to the little endian order. More...
 
#define PINT64_TO_BE(val)   ((pint64) PUINT64_SWAP_BYTES (val))
 Swaps a pint64 variable from the host to the big endian order. More...
 
#define PUINT64_TO_BE(val)   (PUINT64_SWAP_BYTES (val))
 Swaps a puint64 variable from the host to the big endian order. More...
 
#define PLONG_TO_LE(val)   ((plong) PINT64_TO_LE (val))
 Swaps a plong variable from the host to the little endian order. More...
 
#define PULONG_TO_LE(val)   ((pulong) PUINT64_TO_LE (val))
 Swaps a pulong variable from the host to the little endian order. More...
 
#define PLONG_TO_BE(val)   ((plong) PINT64_TO_BE (val))
 Swaps a plong variable from the host to the big endian order. More...
 
#define PULONG_TO_BE(val)   ((pulong) PUINT64_TO_BE (val))
 Swaps a pulong variable from the host to the big endian order. More...
 
#define PSIZE_TO_LE(val)   ((psize) PUINT64_TO_LE (val))
 Swaps a psize variable from the host to the little endian order. More...
 
#define PSSIZE_TO_LE(val)   ((pssize) PINT64_TO_LE (val))
 Swaps a pssize variable from the host to the little endian order. More...
 
#define PSIZE_TO_BE(val)   ((psize) PUINT64_TO_BE (val))
 Swaps a psize variable from the host to the big endian order. More...
 
#define PSSIZE_TO_BE(val)   ((pssize) PINT64_TO_BE (val))
 Swaps a pssize variable from the host to the big endian order. More...
 
#define PINT_TO_LE(val)   ((pint) PINT32_TO_LE (val))
 Swaps a pint variable from the host to the little endian order. More...
 
#define PUINT_TO_LE(val)   ((puint) PUINT32_TO_LE (val))
 Swaps a puint variable from the host to the little endian order. More...
 
#define PINT_TO_BE(val)   ((pint) PINT32_TO_BE (val))
 Swaps a pint variable from the host to the big endian order. More...
 
#define PUINT_TO_BE(val)   ((puint) PUINT32_TO_BE (val))
 Swaps a puint variable from the host to the big endian order. More...
 
#define PUINT16_SWAP_BYTES(val)   ((puint16) (((puint16) (val)) >> 8 | ((puint16) (val)) << 8))
 Swaps a 16-bit unsigned int. More...
 
#define PUINT32_SWAP_BYTES(val)
 Swaps a 32-bit unsigned int. More...
 
#define PUINT64_SWAP_BYTES(val)
 Swaps a 64-bit unsigned int. More...
 
#define PINT16_FROM_LE(val)   (PINT16_TO_LE (val))
 Swaps a 16-bit int from the little endian byte order to the host one. More...
 
#define PUINT16_FROM_LE(val)   (PUINT16_TO_LE (val))
 Swaps a 16-bit unsigned int from the little endian byte order to the host one. More...
 
#define PINT16_FROM_BE(val)   (PINT16_TO_BE (val))
 Swaps a 16-bit int from the big endian byte order to the host one. More...
 
#define PUINT16_FROM_BE(val)   (PUINT16_TO_BE (val))
 Swaps a 16-bit unsigned int from the big endian byte order to the host one. More...
 
#define PINT32_FROM_LE(val)   (PINT32_TO_LE (val))
 Swaps a 32-bit int from the little endian byte order to the host one. More...
 
#define PUINT32_FROM_LE(val)   (PUINT32_TO_LE (val))
 Swaps a 32-bit unsigned int from the little endian byte order to the host one. More...
 
#define PINT32_FROM_BE(val)   (PINT32_TO_BE (val))
 Swaps a 32-bit int from the big endian byte order to the host one. More...
 
#define PUINT32_FROM_BE(val)   (PUINT32_TO_BE (val))
 Swaps a 32-bit unsigned int from the big endian byte order to the host one. More...
 
#define PINT64_FROM_LE(val)   (PINT64_TO_LE (val))
 Swaps a 64-bit int from the little endian byte order to the host one. More...
 
#define PUINT64_FROM_LE(val)   (PUINT64_TO_LE (val))
 Swaps a 64-bit unsigned int from the little endian byte order to the host one. More...
 
#define PINT64_FROM_BE(val)   (PINT64_TO_BE (val))
 Swaps a 64-bit int from the big endian byte order to the host one. More...
 
#define PUINT64_FROM_BE(val)   (PUINT64_TO_BE (val))
 Swaps a 64-bit unsigned int from the big endian byte order to the host one. More...
 
#define PLONG_FROM_LE(val)   (PLONG_TO_LE (val))
 Swaps a long int from the little endian byte order to the host one. More...
 
#define PULONG_FROM_LE(val)   (PULONG_TO_LE (val))
 Swaps an unsigned long int from the little endian byte order to the host one. More...
 
#define PLONG_FROM_BE(val)   (PLONG_TO_BE (val))
 Swaps a long int from the big endian byte order to the host one. More...
 
#define PULONG_FROM_BE(val)   (PULONG_TO_BE (val))
 Swaps an unsigned long int from the big endian byte order to the host one. More...
 
#define PINT_FROM_LE(val)   (PINT_TO_LE (val))
 Swaps a pint from the little endian byte order to the host one. More...
 
#define PUINT_FROM_LE(val)   (PUINT_TO_LE (val))
 Swaps a puint from the little endian byte order to the host one. More...
 
#define PINT_FROM_BE(val)   (PINT_TO_BE (val))
 Swaps a pint from the big endian byte order to the host one. More...
 
#define PUINT_FROM_BE(val)   (PUINT_TO_BE (val))
 Swaps a puint from the big endian byte order to the host one. More...
 
#define PSIZE_FROM_LE(val)   (PSIZE_TO_LE (val))
 Swaps a psize from the little endian byte order to the host one. More...
 
#define PSSIZE_FROM_LE(val)   (PSSIZE_TO_LE (val))
 Swaps a pssize from the little endian byte order to the host one. More...
 
#define PSIZE_FROM_BE(val)   (PSIZE_TO_BE (val))
 Swaps a psize from the big endian byte order to the host one. More...
 
#define PSSIZE_FROM_BE(val)   (PSSIZE_TO_BE (val))
 Swaps a pssize from the big endian byte order to the host one. More...
 
#define p_ntohl(val)   (PUINT32_FROM_BE (val))
 Swaps a long int from the network byte order to the host one. More...
 
#define p_ntohs(val)   (PUINT16_FROM_BE (val))
 Swaps a short int from the network byte order to the host one. More...
 
#define p_htonl(val)   (PUINT32_TO_BE (val))
 Swaps a long int from the host byte order to the network one. More...
 
#define p_htons(val)   (PUINT16_TO_BE (val))
 Swaps a short int from the host byte order to the network one. More...
 
#define FALSE   (0)
 Type definition for a false boolean value. More...
 
#define TRUE   (!FALSE)
 Type definition for a true boolean value. More...
 

Typedefs

typedef signed char pint8
 Type for signed 8 bit. More...
 
typedef unsigned char puint8
 Type for unsigned 8 bit. More...
 
typedef signed short pint16
 Type for signed 16 bit. More...
 
typedef unsigned short puint16
 Type for unsigned 16 bit. More...
 
typedef signed int pint32
 Type for signed 32 bit. More...
 
typedef unsigned int puint32
 Type for unsigned 32 bit. More...
 
typedef signed __int64 pint64
 Type for signed 64 bit.
 
typedef unsigned __int64 puint64
 Type for unsigned 64 bit.
 
typedef void * ppointer
 Type for a pointer. More...
 
typedef const void * pconstpointer
 Type for a const pointer. More...
 
typedef signed int pboolean
 Type for a bool. More...
 
typedef char pchar
 Type for a char. More...
 
typedef short pshort
 Type for a short. More...
 
typedef int pint
 Type for an int. More...
 
typedef long plong
 Type for a long. More...
 
typedef unsigned char puchar
 Type for an unsigned char. More...
 
typedef unsigned short pushort
 Type for an unsigned short. More...
 
typedef unsigned int puint
 Type for an unsigned int. More...
 
typedef unsigned long pulong
 Type for an unsigned long. More...
 
typedef float pfloat
 Type for a float. More...
 
typedef double pdouble
 Type for a double precision float. More...
 
typedef signed __int64 pssize
 Type for a platform independent signed size_t.
 
typedef unsigned __int64 psize
 Type for a platform independent size_t.
 
typedef signed __int64 pintptr
 Type for a platform independent signed pointer represented by an integer.
 
typedef unsigned __int64 puintptr
 Type for a platform independent unsigned pointer represented by an integer.
 
typedef pint64 poffset
 Platform independent offset_t definition. More...
 
typedef void * P_HANDLE
 Platform independent system handle.
 
typedef pboolean(* PTraverseFunc) (ppointer key, ppointer value, ppointer user_data)
 Function to traverse through a key-value container. More...
 
typedef void(* PFunc) (ppointer data, ppointer user_data)
 General purpose function. More...
 
typedef void(* PDestroyFunc) (ppointer data)
 Object destroy notification function. More...
 
typedef pint(* PCompareFunc) (pconstpointer a, pconstpointer b)
 Compares two values. More...
 
typedef pint(* PCompareDataFunc) (pconstpointer a, pconstpointer b, ppointer data)
 Compares two values with additional data. More...
 

Detailed Description

Types definitions.

Author
Alexander Saprykin

Every operating system in pair with a compiler has its own set of data types. Here you can find unified platform independent data types which guarantee the same bit-size on every supported platform: pint8, pint16, pint32, pint64 and their unsigned variants. Also other types are defined for convinience: ppointer, pboolean, pint, plong, pdouble and more.

Along with the types, length and format modifiers are defined. They can be used to print and scan data from/to a variable.

Sometimes it is useful to use an integer variable as a pointer, i.e. to prevent memory allocation when using hash tables or trees. Use special macros for that case: PINT_TO_POINTER, PPOINTER_TO_INT and their variants. Note that it will not work with 64-bit data types.

To check data type limits use P_MIN* and P_MAX* macros.

If you need to check system endianness compare the P_BYTE_ORDER definition with the P_LITTLE_ENDIAN or P_BIG_ENDIAN macro.

To convert between the little and big endian byte orders use the Px_TO_LE, Px_TO_BE, Px_FROM_LE and Px_FROM_BE macros. Macros for the network<->host byte order conversion are also provided: p_ntohl, p_ntohs, p_ntohs and p_ntohl. All the described above macros depend on the target system endianness. Use PUINTx_SWAP_BYTES to manually swap data types independently from the endianness.

You can also find some of the function definitions used within the library.

Definition in file ptypes.h.

Macro Definition Documentation

◆ FALSE

#define FALSE   (0)

Type definition for a false boolean value.

Definition at line 1059 of file ptypes.h.

◆ P_BIG_ENDIAN

#define P_BIG_ENDIAN   4321

Big endian mark.

Definition at line 506 of file ptypes.h.

◆ p_htonl

#define p_htonl (   val)    (PUINT32_TO_BE (val))

Swaps a long int from the host byte order to the network one.

Parameters
valValue to swap.
Returns
Swapped long int.
Since
0.0.1

Definition at line 1047 of file ptypes.h.

◆ p_htons

#define p_htons (   val)    (PUINT16_TO_BE (val))

Swaps a short int from the host byte order to the network one.

Parameters
valValue to swap.
Returns
Swapped short int.
Since
0.0.1

Definition at line 1055 of file ptypes.h.

◆ P_INT_TO_POINTER

#define P_INT_TO_POINTER (   i)    ((void *) (long long) (i))

Casts an int to a pointer.

Parameters
iVariable to cast.
Returns
Casted variable.
Since
0.0.1

◆ P_LITTLE_ENDIAN

#define P_LITTLE_ENDIAN   1234

Little endian mark.

Definition at line 504 of file ptypes.h.

◆ P_MAXINT16

#define P_MAXINT16   ((pint16) 0x7FFF)

Max value for a 16-bit int.

Definition at line 377 of file ptypes.h.

◆ P_MAXINT32

#define P_MAXINT32   ((pint32) 0x7FFFFFFF)

Max value for a 32-bit int.

Definition at line 384 of file ptypes.h.

◆ P_MAXINT64

#define P_MAXINT64   ((pint64) 0x7FFFFFFFFFFFFFFFLL)

Max value for a 64-bit int.

Definition at line 391 of file ptypes.h.

◆ P_MAXINT8

#define P_MAXINT8   ((pint8) 0x7F)

Max value for a 8-bit int.

Definition at line 370 of file ptypes.h.

◆ P_MAXUINT16

#define P_MAXUINT16   ((puint16) 0xFFFF)

Max value for a 16-bit unsigned int.

Definition at line 379 of file ptypes.h.

◆ P_MAXUINT32

#define P_MAXUINT32   ((puint32) 0xFFFFFFFF)

Max value for a 32-bit unsigned int.

Definition at line 386 of file ptypes.h.

◆ P_MAXUINT64

#define P_MAXUINT64   ((puint64) 0xFFFFFFFFFFFFFFFFULL)

Max value for a 64-bit unsigned int.

Definition at line 393 of file ptypes.h.

◆ P_MAXUINT8

#define P_MAXUINT8   ((puint8) 0xFF)

Max value for a 8-bit unsigned int.

Definition at line 372 of file ptypes.h.

◆ P_MININT16

#define P_MININT16   ((pint16) 0x8000)

Min value for a 16-bit int.

Definition at line 375 of file ptypes.h.

◆ P_MININT32

#define P_MININT32   ((pint32) 0x80000000)

Min value for a 32-bit int.

Definition at line 382 of file ptypes.h.

◆ P_MININT64

#define P_MININT64   ((pint64) 0x8000000000000000LL)

Min value for a 64-bit int.

Definition at line 389 of file ptypes.h.

◆ P_MININT8

#define P_MININT8   ((pint8) 0x80)

Min value for a 8-bit int.

Definition at line 368 of file ptypes.h.

◆ p_ntohl

#define p_ntohl (   val)    (PUINT32_FROM_BE (val))

Swaps a long int from the network byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped long int.
Since
0.0.1

Definition at line 1031 of file ptypes.h.

◆ p_ntohs

#define p_ntohs (   val)    (PUINT16_FROM_BE (val))

Swaps a short int from the network byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped short int.
Since
0.0.1

Definition at line 1039 of file ptypes.h.

◆ P_POINTER_TO_INT

#define P_POINTER_TO_INT (   p)    ((int) (long long) (p))

Casts a pointer to an int.

Parameters
pPointer to cast.
Returns
Casted pointer.
Since
0.0.1

◆ PINT16_FROM_BE

#define PINT16_FROM_BE (   val)    (PINT16_TO_BE (val))

Swaps a 16-bit int from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 16-bit int.
Since
0.0.1

Definition at line 845 of file ptypes.h.

◆ PINT16_FROM_LE

#define PINT16_FROM_LE (   val)    (PINT16_TO_LE (val))

Swaps a 16-bit int from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 16-bit int.
Since
0.0.1

Definition at line 828 of file ptypes.h.

◆ PINT16_MODIFIER

#define PINT16_MODIFIER   "h"

Platform dependent length modifier for conversion specifiers of pint16 or puint16 type for printing and scanning values.

It is a string literal, but doesn't include the percent sign so you can add precision and length modifiers and append a conversion specifier.

Definition at line 470 of file ptypes.h.

◆ PINT16_TO_BE

#define PINT16_TO_BE (   val)    ((pint16) PUINT16_SWAP_BYTES (val))

Swaps a pint16 variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 703 of file ptypes.h.

◆ PINT16_TO_LE

#define PINT16_TO_LE (   val)    ((pint16) (val))

Swaps a pint16 variable from the host to the little endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 701 of file ptypes.h.

◆ PINT32_FROM_BE

#define PINT32_FROM_BE (   val)    (PINT32_TO_BE (val))

Swaps a 32-bit int from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 32-bit int.
Since
0.0.1

Definition at line 880 of file ptypes.h.

◆ PINT32_FROM_LE

#define PINT32_FROM_LE (   val)    (PINT32_TO_LE (val))

Swaps a 32-bit int from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 32-bit int.
Since
0.0.1

Definition at line 863 of file ptypes.h.

◆ PINT32_MODIFIER

#define PINT32_MODIFIER   ""

Platform dependent length modifier for conversion specifiers of pint32 or puint32 type for printing and scanning values.

It is a string literal, but doesn't include the percent sign so you can add precision and length modifiers and append a conversion specifier.

Definition at line 478 of file ptypes.h.

◆ PINT32_TO_BE

#define PINT32_TO_BE (   val)    ((pint32) PUINT32_SWAP_BYTES (val))

Swaps a pint32 variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 707 of file ptypes.h.

◆ PINT32_TO_LE

#define PINT32_TO_LE (   val)    ((pint32) (val))

Swaps a pint32 variable from the host to the little endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 705 of file ptypes.h.

◆ PINT64_FROM_BE

#define PINT64_FROM_BE (   val)    (PINT64_TO_BE (val))

Swaps a 64-bit int from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 64-bit int.
Since
0.0.1

Definition at line 914 of file ptypes.h.

◆ PINT64_FROM_LE

#define PINT64_FROM_LE (   val)    (PINT64_TO_LE (val))

Swaps a 64-bit int from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 64-bit int.
Since
0.0.1

Definition at line 897 of file ptypes.h.

◆ PINT64_MODIFIER

#define PINT64_MODIFIER   "I64"

Platform dependent length modifier for conversion specifiers of pint64 or puint64 type for printing and scanning values.

It is a string literal, but doesn't include the percent sign so you can add precision and length modifiers and append a conversion specifier.

Definition at line 483 of file ptypes.h.

◆ PINT64_TO_BE

#define PINT64_TO_BE (   val)    ((pint64) PUINT64_SWAP_BYTES (val))

Swaps a pint64 variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 711 of file ptypes.h.

◆ PINT64_TO_LE

#define PINT64_TO_LE (   val)    ((pint64) (val))

Swaps a pint64 variable from the host to the little endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 709 of file ptypes.h.

◆ PINT_FROM_BE

#define PINT_FROM_BE (   val)    (PINT_TO_BE (val))

Swaps a pint from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped pint.
Since
0.0.1

Definition at line 981 of file ptypes.h.

◆ PINT_FROM_LE

#define PINT_FROM_LE (   val)    (PINT_TO_LE (val))

Swaps a pint from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped pint.
Since
0.0.1

Definition at line 965 of file ptypes.h.

◆ PINT_TO_BE

#define PINT_TO_BE (   val)    ((pint) PINT32_TO_BE (val))

Swaps a pint variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 737 of file ptypes.h.

◆ PINT_TO_LE

#define PINT_TO_LE (   val)    ((pint) PINT32_TO_LE (val))

Swaps a pint variable from the host to the little endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 735 of file ptypes.h.

◆ PINT_TO_POINTER

#define PINT_TO_POINTER (   i)    ((ppointer) (pint64) (i))

Casts a pint value to a ppointer.

Parameters
ipint to cast.
Returns
Casted pint.
Since
0.0.1

◆ PINTPTR_MODIFIER

#define PINTPTR_MODIFIER   "I64"

Platform dependent length modifier for conversion specifiers of pintptr or puintptr type for printing and scanning values.

It is a string literal, but doesn't include the percent sign so you can add precision and length modifiers and append a conversion specifier.

Definition at line 269 of file ptypes.h.

◆ PLONG_FROM_BE

#define PLONG_FROM_BE (   val)    (PLONG_TO_BE (val))

Swaps a long int from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped long int.
Since
0.0.1

Definition at line 948 of file ptypes.h.

◆ PLONG_FROM_LE

#define PLONG_FROM_LE (   val)    (PLONG_TO_LE (val))

Swaps a long int from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped long int.
Since
0.0.1

Definition at line 931 of file ptypes.h.

◆ PLONG_TO_BE

#define PLONG_TO_BE (   val)    ((plong) PINT64_TO_BE (val))

Swaps a plong variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 716 of file ptypes.h.

◆ PLONG_TO_LE

#define PLONG_TO_LE (   val)    ((plong) PINT64_TO_LE (val))

Swaps a plong variable from the host to the little endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 714 of file ptypes.h.

◆ POFFSET_MODIFIER

#define POFFSET_MODIFIER   PINT64_MODIFIER

Platform dependent length modifier for conversion specifiers of poffset type for printing and scanning values.

It is a string literal, but doesn't include the percent sign so you can add precision and length modifiers and append a conversion specifier.

Definition at line 498 of file ptypes.h.

◆ PPOINTER_TO_INT

#define PPOINTER_TO_INT (   p)    ((pint) ((pint64) (p)))

Casts a ppointer to a pint value.

Parameters
pppointer to cast.
Returns
Casted ppointer.
Since
0.0.1

◆ PPOINTER_TO_PSIZE

#define PPOINTER_TO_PSIZE (   p)    ((psize) (p))

Casts a ppointer to a psize value.

Definition at line 365 of file ptypes.h.

◆ PPOINTER_TO_UINT

#define PPOINTER_TO_UINT (   p)    ((puint) ((puint64) (p)))

Casts a ppointer to a pint value.

Parameters
pppointer to cast.
Returns
Casted ppointer.
Since
0.0.1

◆ PSIZE_FROM_BE

#define PSIZE_FROM_BE (   val)    (PSIZE_TO_BE (val))

Swaps a psize from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped psize.
Since
0.0.1

Definition at line 1013 of file ptypes.h.

◆ PSIZE_FROM_LE

#define PSIZE_FROM_LE (   val)    (PSIZE_TO_LE (val))

Swaps a psize from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped psize.
Since
0.0.1

Definition at line 997 of file ptypes.h.

◆ PSIZE_MODIFIER

#define PSIZE_MODIFIER   "I64"

Platform dependent length modifier for conversion specifiers of psize or pssize type for printing and scanning values.

It is a string literal, but doesn't include the percent sign so you can add precision and length modifiers and append a conversion specifier.

psize size_val = 256;
printf ("%#" PSIZE_MODIFIER "x", size_val);

Definition at line 195 of file ptypes.h.

◆ PSIZE_TO_BE

#define PSIZE_TO_BE (   val)    ((psize) PUINT64_TO_BE (val))

Swaps a psize variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 727 of file ptypes.h.

◆ PSIZE_TO_LE

#define PSIZE_TO_LE (   val)    ((psize) PUINT64_TO_LE (val))

Swaps a psize variable from the host to the little endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 725 of file ptypes.h.

◆ PSIZE_TO_POINTER

#define PSIZE_TO_POINTER (   i)    ((ppointer) ((psize) (i)))

Casts a psize value to a ppointer.

Definition at line 363 of file ptypes.h.

◆ PSSIZE_FORMAT

#define PSSIZE_FORMAT   "I64d"

Platform dependent conversion specifier of pssize type for printing and scanning values.

pssize size_val = 100;
printf ("%" PSSIZE_FORMAT, size_val);

Definition at line 196 of file ptypes.h.

◆ PSSIZE_FROM_BE

#define PSSIZE_FROM_BE (   val)    (PSSIZE_TO_BE (val))

Swaps a pssize from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped pssize.
Since
0.0.1

Definition at line 1021 of file ptypes.h.

◆ PSSIZE_FROM_LE

#define PSSIZE_FROM_LE (   val)    (PSSIZE_TO_LE (val))

Swaps a pssize from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped pssize.
Since
0.0.1

Definition at line 1005 of file ptypes.h.

◆ PSSIZE_TO_BE

#define PSSIZE_TO_BE (   val)    ((pssize) PINT64_TO_BE (val))

Swaps a pssize variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 728 of file ptypes.h.

◆ PSSIZE_TO_LE

#define PSSIZE_TO_LE (   val)    ((pssize) PINT64_TO_LE (val))

Swaps a pssize variable from the host to the little endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 726 of file ptypes.h.

◆ PUINT16_FROM_BE

#define PUINT16_FROM_BE (   val)    (PUINT16_TO_BE (val))

Swaps a 16-bit unsigned int from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 16-bit unsigned int.
Since
0.0.1

Definition at line 854 of file ptypes.h.

◆ PUINT16_FROM_LE

#define PUINT16_FROM_LE (   val)    (PUINT16_TO_LE (val))

Swaps a 16-bit unsigned int from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 16-bit unsigned int.
Since
0.0.1

Definition at line 837 of file ptypes.h.

◆ PUINT16_SWAP_BYTES

#define PUINT16_SWAP_BYTES (   val)    ((puint16) (((puint16) (val)) >> 8 | ((puint16) (val)) << 8))

Swaps a 16-bit unsigned int.

Parameters
valValue to swap.
Returns
Swapped 16-bit unsigned int.
Since
0.0.1

Definition at line 789 of file ptypes.h.

◆ PUINT16_TO_BE

#define PUINT16_TO_BE (   val)    (PUINT16_SWAP_BYTES (val))

Swaps a puint16 variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 704 of file ptypes.h.

◆ PUINT16_TO_LE

#define PUINT16_TO_LE (   val)    ((puint16) (val))

Swaps a puint16 variable from the host to the little the endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 702 of file ptypes.h.

◆ PUINT32_FROM_BE

#define PUINT32_FROM_BE (   val)    (PUINT32_TO_BE (val))

Swaps a 32-bit unsigned int from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 32-bit unsigned int.
Since
0.0.1

Definition at line 889 of file ptypes.h.

◆ PUINT32_FROM_LE

#define PUINT32_FROM_LE (   val)    (PUINT32_TO_LE (val))

Swaps a 32-bit unsigned int from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 32-bit unsigned int.
Since
0.0.1

Definition at line 872 of file ptypes.h.

◆ PUINT32_SWAP_BYTES

#define PUINT32_SWAP_BYTES (   val)
Value:
((puint32) ( \
(((puint32) (val)) >> 24) | \
((((puint32) (val)) << 8) & ((puint32) 0x00FF0000U)) | \
((((puint32) (val)) >> 8) & ((puint32) 0x0000FF00U)) | \
(((puint32) (val)) << 24)))
unsigned int puint32
Type for unsigned 32 bit.
Definition: ptypes.h:83

Swaps a 32-bit unsigned int.

Parameters
valValue to swap.
Returns
Swapped 32-bit unsigned int.
Since
0.0.1

Definition at line 798 of file ptypes.h.

◆ PUINT32_TO_BE

#define PUINT32_TO_BE (   val)    (PUINT32_SWAP_BYTES (val))

Swaps a puint32 variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 708 of file ptypes.h.

◆ PUINT32_TO_LE

#define PUINT32_TO_LE (   val)    ((puint32) (val))

Swaps a puint32 variable from the host to the little endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 706 of file ptypes.h.

◆ PUINT64_FROM_BE

#define PUINT64_FROM_BE (   val)    (PUINT64_TO_BE (val))

Swaps a 64-bit unsigned int from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 64-bit unsigned int.
Since
0.0.1

Definition at line 923 of file ptypes.h.

◆ PUINT64_FROM_LE

#define PUINT64_FROM_LE (   val)    (PUINT64_TO_LE (val))

Swaps a 64-bit unsigned int from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped 64-bit unsigned int.
Since
0.0.1

Definition at line 906 of file ptypes.h.

◆ PUINT64_SWAP_BYTES

#define PUINT64_SWAP_BYTES (   val)
Value:
((puint64) ( \
(((puint64) (val)) >> 56) | \
((((puint64) (val)) << 40) & ((puint64) 0x00FF000000000000ULL)) | \
((((puint64) (val)) << 24) & ((puint64) 0x0000FF0000000000ULL)) | \
((((puint64) (val)) << 8) & ((puint64) 0x000000FF00000000ULL)) | \
((((puint64) (val)) >> 8) & ((puint64) 0x00000000FF000000ULL)) | \
((((puint64) (val)) >> 24) & ((puint64) 0x0000000000FF0000ULL)) | \
((((puint64) (val)) >> 40) & ((puint64) 0x000000000000FF00ULL)) | \
(((puint64) (val)) << 56)))
unsigned __int64 puint64
Type for unsigned 64 bit.
Definition: ptypes.h:97

Swaps a 64-bit unsigned int.

Parameters
valValue to swap.
Returns
Swapped 64-bit unsigned int.
Since
0.0.1

Definition at line 810 of file ptypes.h.

◆ PUINT64_TO_BE

#define PUINT64_TO_BE (   val)    (PUINT64_SWAP_BYTES (val))

Swaps a puint64 variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 712 of file ptypes.h.

◆ PUINT64_TO_LE

#define PUINT64_TO_LE (   val)    ((puint64) (val))

Swaps a puint64 variable from the host to the little endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 710 of file ptypes.h.

◆ PUINT_FROM_BE

#define PUINT_FROM_BE (   val)    (PUINT_TO_BE (val))

Swaps a puint from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped puint.
Since
0.0.1

Definition at line 989 of file ptypes.h.

◆ PUINT_FROM_LE

#define PUINT_FROM_LE (   val)    (PUINT_TO_LE (val))

Swaps a puint from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped puint.
Since
0.0.1

Definition at line 973 of file ptypes.h.

◆ PUINT_TO_BE

#define PUINT_TO_BE (   val)    ((puint) PUINT32_TO_BE (val))

Swaps a puint variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 738 of file ptypes.h.

◆ PUINT_TO_LE

#define PUINT_TO_LE (   val)    ((puint) PUINT32_TO_LE (val))

Swaps a puint variable from the host to the little endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 736 of file ptypes.h.

◆ PUINT_TO_POINTER

#define PUINT_TO_POINTER (   u)    ((ppointer) (puint64) (u))

Casts a puint value to a ppointer.

Parameters
upuint to cast.
Returns
Casted puint.
Since
0.0.1

◆ PULONG_FROM_BE

#define PULONG_FROM_BE (   val)    (PULONG_TO_BE (val))

Swaps an unsigned long int from the big endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped unsigned long int.
Since
0.0.1

Definition at line 957 of file ptypes.h.

◆ PULONG_FROM_LE

#define PULONG_FROM_LE (   val)    (PULONG_TO_LE (val))

Swaps an unsigned long int from the little endian byte order to the host one.

Parameters
valValue to swap.
Returns
Swapped unsigned long int.
Since
0.0.1

Definition at line 940 of file ptypes.h.

◆ PULONG_TO_BE

#define PULONG_TO_BE (   val)    ((pulong) PUINT64_TO_BE (val))

Swaps a pulong variable from the host to the big endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 717 of file ptypes.h.

◆ PULONG_TO_LE

#define PULONG_TO_LE (   val)    ((pulong) PUINT64_TO_LE (val))

Swaps a pulong variable from the host to the little endian order.

Parameters
valValue to swap.
Returns
Swapped value.
Since
0.0.1

Definition at line 715 of file ptypes.h.

◆ TRUE

#define TRUE   (!FALSE)

Type definition for a true boolean value.

Definition at line 1064 of file ptypes.h.

Typedef Documentation

◆ pboolean

typedef signed int pboolean

Type for a bool.

Definition at line 114 of file ptypes.h.

◆ pchar

typedef char pchar

Type for a char.

Definition at line 116 of file ptypes.h.

◆ PCompareDataFunc

typedef pint(* PCompareDataFunc) (pconstpointer a, pconstpointer b, ppointer data)

Compares two values with additional data.

Parameters
aFirst value to compare.
bSecond value to compare.
dataAddition data, may be NULL.
Returns
-1 if the first value is less than the second, 1 if the first value is greater than the second, 0 otherwise.
Since
0.0.1

Definition at line 1118 of file ptypes.h.

◆ PCompareFunc

typedef pint(* PCompareFunc) (pconstpointer a, pconstpointer b)

Compares two values.

Parameters
aFirst value to compare.
bSecond value to compare.
Returns
-1 if the first value is less than the second, 1 if the first value is greater than the second, 0 otherwise.
Since
0.0.1

Definition at line 1107 of file ptypes.h.

◆ pconstpointer

typedef const void* pconstpointer

Type for a const pointer.

Definition at line 111 of file ptypes.h.

◆ PDestroyFunc

typedef void(* PDestroyFunc) (ppointer data)

Object destroy notification function.

Parameters
dataPointer to an object to be destroyed.
Since
0.0.1

Definition at line 1097 of file ptypes.h.

◆ pdouble

typedef double pdouble

Type for a double precision float.

Definition at line 136 of file ptypes.h.

◆ pfloat

typedef float pfloat

Type for a float.

Definition at line 134 of file ptypes.h.

◆ PFunc

typedef void(* PFunc) (ppointer data, ppointer user_data)

General purpose function.

Parameters
dataMain argument related to a context value.
user_dataAdditional (maybe NULL) user-provided data.
Since
0.0.1

Definition at line 1090 of file ptypes.h.

◆ pint

typedef int pint

Type for an int.

Definition at line 120 of file ptypes.h.

◆ pint16

typedef signed short pint16

Type for signed 16 bit.

Definition at line 77 of file ptypes.h.

◆ pint32

typedef signed int pint32

Type for signed 32 bit.

Definition at line 81 of file ptypes.h.

◆ pint8

typedef signed char pint8

Type for signed 8 bit.

Definition at line 73 of file ptypes.h.

◆ plong

typedef long plong

Type for a long.

Definition at line 122 of file ptypes.h.

◆ poffset

typedef pint64 poffset

Platform independent offset_t definition.

Definition at line 296 of file ptypes.h.

◆ ppointer

typedef void* ppointer

Type for a pointer.

Definition at line 109 of file ptypes.h.

◆ pshort

typedef short pshort

Type for a short.

Definition at line 118 of file ptypes.h.

◆ PTraverseFunc

typedef pboolean(* PTraverseFunc) (ppointer key, ppointer value, ppointer user_data)

Function to traverse through a key-value container.

Parameters
keyThe key of an item.
valueThe value of the item.
user_dataData provided by a user, maybe NULL.
Returns
FALSE to continue traversing, TRUE to stop it.
Since
0.0.1

Definition at line 1080 of file ptypes.h.

◆ puchar

typedef unsigned char puchar

Type for an unsigned char.

Definition at line 125 of file ptypes.h.

◆ puint

typedef unsigned int puint

Type for an unsigned int.

Definition at line 129 of file ptypes.h.

◆ puint16

typedef unsigned short puint16

Type for unsigned 16 bit.

Definition at line 79 of file ptypes.h.

◆ puint32

typedef unsigned int puint32

Type for unsigned 32 bit.

Definition at line 83 of file ptypes.h.

◆ puint8

typedef unsigned char puint8

Type for unsigned 8 bit.

Definition at line 75 of file ptypes.h.

◆ pulong

typedef unsigned long pulong

Type for an unsigned long.

Definition at line 131 of file ptypes.h.

◆ pushort

typedef unsigned short pushort

Type for an unsigned short.

Definition at line 127 of file ptypes.h.