plibsys
0.0.4
|
Types definitions. More...
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... | |
Types definitions.
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.
#define FALSE (0) |
#define p_htonl | ( | val | ) | (PUINT32_TO_BE (val)) |
#define p_htons | ( | val | ) | (PUINT16_TO_BE (val)) |
#define P_INT_TO_POINTER | ( | i | ) | ((void *) (long long) (i)) |
Casts an int to a pointer.
i | Variable to cast. |
#define P_MAXINT16 ((pint16) 0x7FFF) |
#define P_MAXINT32 ((pint32) 0x7FFFFFFF) |
#define P_MAXINT64 ((pint64) 0x7FFFFFFFFFFFFFFFLL) |
#define P_MAXINT8 ((pint8) 0x7F) |
#define P_MAXUINT16 ((puint16) 0xFFFF) |
#define P_MAXUINT32 ((puint32) 0xFFFFFFFF) |
#define P_MAXUINT64 ((puint64) 0xFFFFFFFFFFFFFFFFULL) |
#define P_MAXUINT8 ((puint8) 0xFF) |
#define P_MININT16 ((pint16) 0x8000) |
#define P_MININT32 ((pint32) 0x80000000) |
#define P_MININT64 ((pint64) 0x8000000000000000LL) |
#define P_MININT8 ((pint8) 0x80) |
#define p_ntohl | ( | val | ) | (PUINT32_FROM_BE (val)) |
#define p_ntohs | ( | val | ) | (PUINT16_FROM_BE (val)) |
#define P_POINTER_TO_INT | ( | p | ) | ((int) (long long) (p)) |
Casts a pointer to an int.
p | Pointer to cast. |
#define PINT16_FROM_BE | ( | val | ) | (PINT16_TO_BE (val)) |
#define PINT16_FROM_LE | ( | val | ) | (PINT16_TO_LE (val)) |
#define PINT16_MODIFIER "h" |
#define PINT16_TO_BE | ( | val | ) | ((pint16) PUINT16_SWAP_BYTES (val)) |
#define PINT16_TO_LE | ( | val | ) | ((pint16) (val)) |
#define PINT32_FROM_BE | ( | val | ) | (PINT32_TO_BE (val)) |
#define PINT32_FROM_LE | ( | val | ) | (PINT32_TO_LE (val)) |
#define PINT32_MODIFIER "" |
#define PINT32_TO_BE | ( | val | ) | ((pint32) PUINT32_SWAP_BYTES (val)) |
#define PINT32_TO_LE | ( | val | ) | ((pint32) (val)) |
#define PINT64_FROM_BE | ( | val | ) | (PINT64_TO_BE (val)) |
#define PINT64_FROM_LE | ( | val | ) | (PINT64_TO_LE (val)) |
#define PINT64_MODIFIER "I64" |
#define PINT64_TO_BE | ( | val | ) | ((pint64) PUINT64_SWAP_BYTES (val)) |
#define PINT64_TO_LE | ( | val | ) | ((pint64) (val)) |
#define PINT_FROM_BE | ( | val | ) | (PINT_TO_BE (val)) |
#define PINT_FROM_LE | ( | val | ) | (PINT_TO_LE (val)) |
#define PINT_TO_BE | ( | val | ) | ((pint) PINT32_TO_BE (val)) |
#define PINT_TO_LE | ( | val | ) | ((pint) PINT32_TO_LE (val)) |
#define PINTPTR_MODIFIER "I64" |
#define PLONG_FROM_BE | ( | val | ) | (PLONG_TO_BE (val)) |
#define PLONG_FROM_LE | ( | val | ) | (PLONG_TO_LE (val)) |
#define PLONG_TO_BE | ( | val | ) | ((plong) PINT64_TO_BE (val)) |
#define PLONG_TO_LE | ( | val | ) | ((plong) PINT64_TO_LE (val)) |
#define POFFSET_MODIFIER PINT64_MODIFIER |
#define PPOINTER_TO_PSIZE | ( | p | ) | ((psize) (p)) |
#define PSIZE_FROM_BE | ( | val | ) | (PSIZE_TO_BE (val)) |
#define PSIZE_FROM_LE | ( | val | ) | (PSIZE_TO_LE (val)) |
#define PSIZE_MODIFIER "I64" |
#define PSIZE_TO_BE | ( | val | ) | ((psize) PUINT64_TO_BE (val)) |
#define PSIZE_TO_LE | ( | val | ) | ((psize) PUINT64_TO_LE (val)) |
#define PSSIZE_FORMAT "I64d" |
Platform dependent conversion specifier of pssize type for printing and scanning values.
#define PSSIZE_FROM_BE | ( | val | ) | (PSSIZE_TO_BE (val)) |
#define PSSIZE_FROM_LE | ( | val | ) | (PSSIZE_TO_LE (val)) |
#define PSSIZE_TO_BE | ( | val | ) | ((pssize) PINT64_TO_BE (val)) |
#define PSSIZE_TO_LE | ( | val | ) | ((pssize) PINT64_TO_LE (val)) |
#define PUINT16_FROM_BE | ( | val | ) | (PUINT16_TO_BE (val)) |
#define PUINT16_FROM_LE | ( | val | ) | (PUINT16_TO_LE (val)) |
#define PUINT16_TO_BE | ( | val | ) | (PUINT16_SWAP_BYTES (val)) |
#define PUINT16_TO_LE | ( | val | ) | ((puint16) (val)) |
#define PUINT32_FROM_BE | ( | val | ) | (PUINT32_TO_BE (val)) |
#define PUINT32_FROM_LE | ( | val | ) | (PUINT32_TO_LE (val)) |
#define PUINT32_SWAP_BYTES | ( | val | ) |
#define PUINT32_TO_BE | ( | val | ) | (PUINT32_SWAP_BYTES (val)) |
#define PUINT32_TO_LE | ( | val | ) | ((puint32) (val)) |
#define PUINT64_FROM_BE | ( | val | ) | (PUINT64_TO_BE (val)) |
#define PUINT64_FROM_LE | ( | val | ) | (PUINT64_TO_LE (val)) |
#define PUINT64_SWAP_BYTES | ( | val | ) |
#define PUINT64_TO_BE | ( | val | ) | (PUINT64_SWAP_BYTES (val)) |
#define PUINT64_TO_LE | ( | val | ) | ((puint64) (val)) |
#define PUINT_FROM_BE | ( | val | ) | (PUINT_TO_BE (val)) |
#define PUINT_FROM_LE | ( | val | ) | (PUINT_TO_LE (val)) |
#define PUINT_TO_BE | ( | val | ) | ((puint) PUINT32_TO_BE (val)) |
#define PUINT_TO_LE | ( | val | ) | ((puint) PUINT32_TO_LE (val)) |
#define PULONG_FROM_BE | ( | val | ) | (PULONG_TO_BE (val)) |
#define PULONG_FROM_LE | ( | val | ) | (PULONG_TO_LE (val)) |
#define PULONG_TO_BE | ( | val | ) | ((pulong) PUINT64_TO_BE (val)) |
#define PULONG_TO_LE | ( | val | ) | ((pulong) PUINT64_TO_LE (val)) |
#define TRUE (!FALSE) |
typedef pint(* PCompareDataFunc) (pconstpointer a, pconstpointer b, ppointer data) |
Compares two values with additional data.
a | First value to compare. |
b | Second value to compare. |
data | Addition data, may be NULL. |
typedef pint(* PCompareFunc) (pconstpointer a, pconstpointer b) |
typedef const void* pconstpointer |
typedef void(* PDestroyFunc) (ppointer data) |