![]() |
netmsgs
1.2.2
RoadNarrows Robotics Network Messaging Package
|
Field value packing/unpacking definitions. More...
#include <stdio.h>#include <stdlib.h>#include <limits.h>#include <libgen.h>#include <string.h>#include <ctype.h>#include <endian.h>#include <ieee754.h>#include "rnr/rnrconfig.h"#include "rnr/log.h"#include "rnr/netmsgs.h"#include "nmLibInternal.h"Go to the source code of this file.
Macros | |
| #define | HOST_BIG_ENDIAN |
| big-endian byte order | |
| #define | HOST_WORD_SIZE 32 |
| 32-bit architecture | |
| #define | PACKNATIVE(val, buf) packbig((byte_t *)&(val), sizeof(val), buf) |
| Pack an element into the message buffer in native byte order. More... | |
| #define | UNPACKNATIVE(buf, pval) unpackbig(buf, (byte_t *)pval, sizeof(*pval)) |
| Unpack an element from the message buffer in native byte order. More... | |
| #define | PACK64NATIVE(uMSB, uLSB, buf) PACK64BIG(uMSB, uLSB, buf) |
| Pack two 4-btye unsigned integers into the message buffer in native byte order. More... | |
| #define | UNPACK64NATIVE(buf, puMSB, puLSB) UNPACK64BIG(buf, puMSB, puLSB) |
| Unpack two 4-byte unsigned integers from the message buffer in native byte order. More... | |
| #define | PACKBIG(val, buf) packbig((byte_t *)&(val), sizeof(val), buf) |
| Pack an element into the message buffer in big-endian byte order. More... | |
| #define | UNPACKBIG(buf, pval) unpackbig(buf, (byte_t *)pval, sizeof(*pval)); |
| Unpack an element from the message buffer in big-endian byte order. More... | |
| #define | PACKLITTLE(val, buf) packlittle((byte_t *)&(val), sizeof(val), buf) |
| Pack an element into the message buffer in little-endian byte order. More... | |
| #define | UNPACKLITTLE(buf, pval) unpacklittle(buf, (byte_t *)pval, sizeof(*pval)) |
| Unpack an element from the message buffer in little-endian byte order. More... | |
| #define | PACK64BIG(uMSB, uLSB, buf) |
| Pack two 4-btye unsigned integers into the message buffer in big-endian byte order. More... | |
| #define | UNPACK64BIG(buf, puMSB, puLSB) |
| Unpack two 4-byte unsigned integers from the message buffer in big-endian byte order. More... | |
| #define | PACK64LITTLE(uMSB, uLSB, buf) |
| Pack two 4-btye unsigned integers into the message buffer in little-endian byte order. More... | |
| #define | UNPACK64LITTLE(buf, puMSB, puLSB) |
| Unpack two 4-byte unsigned integers from the message buffer in little-endian byte order. More... | |
| #define | IEEE754_F32_SIGN_SHIFT 31 |
| f32 sign shift | |
| #define | IEEE754_F32_SIGN_MASK 0x00000001 |
| f32 sign mask | |
| #define | IEEE754_F32_EXPONENT_SHIFT 23 |
| f32 exponent shift | |
| #define | IEEE754_F32_EXPONENT_MASK 0x000000ff |
| f32 exponent mask | |
| #define | IEEE754_F32_MANTISSA_SHIFT 0 |
| f32 mantissa shift | |
| #define | IEEE754_F32_MANTISSA_MASK 0x007fffff |
| f32 mantissa mask | |
| #define | IEEE754_F64_SIGN_SHIFT 31 |
| f64 sign shift | |
| #define | IEEE754_F64_SIGN_MASK 0x00000001 |
| f64 sign mask | |
| #define | IEEE754_F64_EXPONENT_SHIFT 20 |
| f64 exponent shift | |
| #define | IEEE754_F64_EXPONENT_MASK 0x000007ff |
| f64 exponent mask | |
| #define | IEEE754_F64_MANTISSA0_SHIFT 0 |
| f64 msb mantissa shift | |
| #define | IEEE754_F64_MANTISSA0_MASK 0x000fffff |
| f64 msb mantissa mask | |
| #define | IEEE754_F64_MANTISSA1_SHIFT 0 |
| f64 lsb mantissa shift | |
| #define | IEEE754_F64_MANTISSA1_MASK 0xffffffff |
| f64 lsb mantissa mask | |
| #define | IEEE754_F32_F64_MANTISSA0_SHIFT 3 |
| msb mantissa shift | |
| #define | IEEE754_F32_F64_MANTISSA1_SHIFT 29 |
| lsb mantissa shift | |
| #define | IEEE754_F32_F64_MANTISSA1_MASK 0x00000007 |
| lsb mantissa mask | |
| #define | IEEE754_F32_EXP_MAX 127 |
| maximum power of 2 exponent | |
| #define | IEEE754_F32_EXP_MIN (-126) |
| minimum power of 2 exponent | |
| #define | IEEE754_F64_EXP_MAX 1023 |
| maximum power of 2 exponent | |
| #define | IEEE754_F64_EXP_MIN (-1022) |
| minimum power of 2 exponent | |
| #define | IEEE754_F32_POS_INF HUGE_VALF |
| f32 positive infinity | |
| #define | IEEE754_F32_NEG_INF (-HUGE_VALF) |
| f32 negative infinity | |
| #define | IEEE754_F64_POS_INF HUGE_VAL |
| f64 positive infinity | |
| #define | IEEE754_F64_NEG_INF (-HUGE_VAL) |
| f64 negative infinity | |
| #define | _NM_CHK_MEM(size, count) |
| Check if memory is available. More... | |
| #define | _NM_CHK_ARCH(val, size) |
| Check if host architecture supports basic element sizes. More... | |
Functions | |
| static void | packbig (byte_t *p, size_t size, byte_t buf[]) |
| Pack an element into the message buffer in big-endian byte order. More... | |
| static void | unpackbig (byte_t buf[], byte_t *p, size_t size) |
| Unpack an element from the message buffer in big-endian byte order. More... | |
| static void | packlittle (byte_t *p, size_t size, byte_t buf[]) |
| Pack an element into the message buffer in little-endian byte order. More... | |
| static void | unpacklittle (byte_t buf[], byte_t *p, size_t size) |
| Unpack an element from the message buffer in little-endian byte order. More... | |
| static bool_t | ieee754_f32_is_nan (union ieee754_float f) |
| Test if 32-bit floating-point number is a NaN. More... | |
| static bool_t | ieee754_f64_is_nan (union ieee754_double d) |
| Test if 64-bit floating-point number is a NaN. More... | |
| static bool_t | ieee754_f32_is_inf (union ieee754_float f) |
| Test if 32-bit floating-point number is ± infinity. More... | |
| static bool_t | ieee754_f64_is_inf (union ieee754_double d) |
| Test if 64-bit floating-point number is ± infinity. More... | |
| static bool_t | ieee754_f32_is_zero (union ieee754_float f) |
| Test if 32-bit floating-point number is ± 0.0. More... | |
| static bool_t | ieee754_f64_is_zero (union ieee754_double d) |
| Test if 64-bit floating-point number is ± 0.0. More... | |
| int | nmPackU8 (byte_t val, byte_t buf[], size_t bufSize, NMEndian_T eEndian) |
| Pack an unsigned 8-bit byte into the message buffer. More... | |
| int | nmPackU16 (ushort_t val, byte_t buf[], size_t bufSize, NMEndian_T eEndian) |
| Pack an unsigned 16-bit integer into the message buffer. More... | |
| int | nmPackU32 (uint_t val, byte_t buf[], size_t bufSize, NMEndian_T eEndian) |
| Pack an unsigned 32-bit integer into the message buffer. More... | |
| int | nmPackU64 (ulonglong_t val, byte_t buf[], size_t bufSize, NMEndian_T eEndian) |
| Pack an unsigned 64-bit integer into the message buffer. More... | |
| int | nmPackS64 (long long val, byte_t buf[], size_t bufSize, NMEndian_T eEndian) |
| Pack an signed 64-bit integer into the message buffer. More... | |
| int | nmPackF32 (float val, byte_t buf[], size_t bufSize, NMEndian_T eEndian) |
| Pack a 32-bit float into the message buffer. More... | |
| int | nmPackF64 (double val, byte_t buf[], size_t bufSize, NMEndian_T eEndian) |
| Pack a 64-bit float into the message buffer. More... | |
| int | nmPackP32 (void *val, byte_t buf[], size_t bufSize, NMEndian_T eEndian) |
| Pack a 32-bit pointer into the message buffer. More... | |
| int | nmPackP64 (void *val, byte_t buf[], size_t bufSize, NMEndian_T eEndian) |
| Pack a 64-bit pointer into the message buffer. More... | |
| int | nmPackBuf (byte_t bufSrc[], size_t uCount, byte_t buf[], size_t bufSize, NMEndian_T eEndian) |
| Pack a byte buffer into the message buffer. More... | |
| int | nmUnpackU8 (byte_t buf[], size_t bufSize, byte_t *pVal, NMEndian_T eEndian) |
| Unpack an unsigned 8-bit byte from the message buffer. More... | |
| int | nmUnpackU16 (byte_t buf[], size_t bufSize, ushort_t *pVal, NMEndian_T eEndian) |
| Unpack an unsigned 16-bit integer from the message buffer. More... | |
| int | nmUnpackU32 (byte_t buf[], size_t bufSize, uint_t *pVal, NMEndian_T eEndian) |
| Unpack an unsigned 32-bit integer from the message buffer. More... | |
| int | nmUnpackU64 (byte_t buf[], size_t bufSize, ulonglong_t *pVal, NMEndian_T eEndian) |
| Unpack an unsigned 64-bit integer from the message buffer. More... | |
| int | nmUnpackS64 (byte_t buf[], size_t bufSize, long long *pVal, NMEndian_T eEndian) |
| Unpack an signed 64-bit integer from the message buffer. More... | |
| int | nmUnpackF32 (byte_t buf[], size_t bufSize, float *pVal, NMEndian_T eEndian) |
| Unpack a 32-bit float from the message buffer. More... | |
| int | nmUnpackF64 (byte_t buf[], size_t bufSize, double *pVal, NMEndian_T eEndian) |
| Unpack a 64-bit float from the message buffer. More... | |
| int | nmUnpackP32 (byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian) |
| Unpack a 32-bit pointer from the message buffer. More... | |
| int | nmUnpackP64 (byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian) |
| Unpack a 64-bit pointer from the message buffer. More... | |
| int | nmUnpackBuf (byte_t buf[], size_t bufSize, byte_t bufDst[], size_t uCount, NMEndian_T eEndian) |
| Unpack a byte buffer from the message buffer. More... | |
Variables | |
| static const union ieee754_float | IEEE754_F32_NaN |
| static const union ieee754_double | IEEE754_F64_NaN |
| static const union ieee754_float | IEEE754_F32_Inf |
| static const union ieee754_double | IEEE754_F64_Inf |
| static const union ieee754_float | IEEE754_F32_Zero |
| static const union ieee754_double | IEEE754_F64_Zero |
Field value packing/unpacking definitions.
The host may be either a big-endian or little-endian architecture. Currenly, any exotic architectures are not supported. It is assumed that 1, 2, and 4 byte (unsigned) integers and 4 byte floats are supported. For systems that do not support 8 byte (unsigned) integers or 8 byte doubles, promotion will be done in software. However, on unpacking, rounding or truncation will occur if the unpacked element exceeds the 4 byte limits.
Floats are expected to be in IEEE 754 format.
Definition in file nmLibPack.c.
| #define _NM_CHK_ARCH | ( | val, | |
| size | |||
| ) |
Check if host architecture supports basic element sizes.
On check failure, returns from calling function with NM_ECODE_ARCH_NOTSUP.
| val | Element to check |
| size | Required byte size. |
Definition at line 724 of file nmLibPack.c.
Referenced by nmPackF32(), nmPackF64(), nmPackP64(), nmPackS64(), nmPackU64(), nmUnpackF32(), nmUnpackF64(), nmUnpackP64(), nmUnpackS64(), and nmUnpackU64().
| #define _NM_CHK_MEM | ( | size, | |
| count | |||
| ) |
Check if memory is available.
On check failure, returns from calling function with NM_ECODE_NOMEM.
| size | Available memory in bytes. |
| count | Required memory. |
Definition at line 705 of file nmLibPack.c.
Referenced by nmPackBuf(), nmPackF32(), nmPackF64(), nmPackP32(), nmPackP64(), nmPackS64(), nmPackU16(), nmPackU32(), nmPackU64(), nmPackU8(), nmUnpackBuf(), nmUnpackF32(), nmUnpackF64(), nmUnpackP32(), nmUnpackP64(), nmUnpackS64(), nmUnpackU16(), nmUnpackU32(), nmUnpackU64(), and nmUnpackU8().
| #define PACK64BIG | ( | uMSB, | |
| uLSB, | |||
| buf | |||
| ) |
Pack two 4-btye unsigned integers into the message buffer in big-endian byte order.
Safe 8-byte packing.
| [in] | uMSB | Most Significant Bytes. |
| [in] | uLSB | Least Significant Bytes. |
| [out] | buf | Output message buffer. |
Definition at line 436 of file nmLibPack.c.
Referenced by nmPackF64(), nmPackS64(), and nmPackU64().
| #define PACK64LITTLE | ( | uMSB, | |
| uLSB, | |||
| buf | |||
| ) |
Pack two 4-btye unsigned integers into the message buffer in little-endian byte order.
Safe 8-byte packing.
| [in] | uMSB | Most Significant Bytes. |
| [in] | uLSB | Least Significant Bytes. |
| [out] | buf | Output message buffer. |
Definition at line 477 of file nmLibPack.c.
Referenced by nmPackF64(), nmPackS64(), and nmPackU64().
| #define PACK64NATIVE | ( | uMSB, | |
| uLSB, | |||
| buf | |||
| ) | PACK64BIG(uMSB, uLSB, buf) |
Pack two 4-btye unsigned integers into the message buffer in native byte order.
Big-Endian Host Version
| [in] | uMSB | Most Significant Bytes. |
| [in] | uLSB | Least Significant Bytes. |
| [out] | buf | Output message buffer. |
Definition at line 238 of file nmLibPack.c.
Referenced by nmPackF64(), nmPackP64(), nmPackS64(), and nmPackU64().
| #define PACKBIG | ( | val, | |
| buf | |||
| ) | packbig((byte_t *)&(val), sizeof(val), buf) |
Pack an element into the message buffer in big-endian byte order.
| [in] | val | Type T element to be packed. |
| [out] | buf | Output message buffer. |
Definition at line 397 of file nmLibPack.c.
Referenced by nmPackF32(), nmPackS64(), nmPackU16(), nmPackU32(), and nmPackU64().
| #define PACKLITTLE | ( | val, | |
| buf | |||
| ) | packlittle((byte_t *)&(val), sizeof(val), buf) |
Pack an element into the message buffer in little-endian byte order.
| [in] | val | Type T element to be packed. |
| [out] | buf | Output message buffer. |
Definition at line 413 of file nmLibPack.c.
Referenced by nmPackF32(), nmPackS64(), nmPackU16(), nmPackU32(), and nmPackU64().
| #define PACKNATIVE | ( | val, | |
| buf | |||
| ) | packbig((byte_t *)&(val), sizeof(val), buf) |
Pack an element into the message buffer in native byte order.
Big-Endian Host Version
| [in] | val | Type T element to be packed. |
| [out] | buf | Output message buffer. |
Definition at line 216 of file nmLibPack.c.
Referenced by nmPackF32(), nmPackP32(), nmPackS64(), nmPackU16(), nmPackU32(), and nmPackU64().
| #define UNPACK64BIG | ( | buf, | |
| puMSB, | |||
| puLSB | |||
| ) |
Unpack two 4-byte unsigned integers from the message buffer in big-endian byte order.
Safe 8-byte packing.
| [in] | buf | Output message buffer. |
| [out] | puMSB | Pointer to Most Significant Bytes. |
| [out] | puLSB | Pointer to Least Significant Bytes. |
Definition at line 457 of file nmLibPack.c.
Referenced by nmUnpackF64(), nmUnpackS64(), and nmUnpackU64().
| #define UNPACK64LITTLE | ( | buf, | |
| puMSB, | |||
| puLSB | |||
| ) |
Unpack two 4-byte unsigned integers from the message buffer in little-endian byte order.
Safe 8-byte packing.
| [in] | buf | Output message buffer. |
| [out] | puMSB | Pointer to Most Significant Bytes. |
| [out] | puLSB | Pointer to Least Significant Bytes. |
Definition at line 498 of file nmLibPack.c.
Referenced by nmUnpackF64(), nmUnpackS64(), and nmUnpackU64().
| #define UNPACK64NATIVE | ( | buf, | |
| puMSB, | |||
| puLSB | |||
| ) | UNPACK64BIG(buf, puMSB, puLSB) |
Unpack two 4-byte unsigned integers from the message buffer in native byte order.
Big-Endian Host Version
| [in] | buf | Output message buffer. |
| [out] | puMSB | Most Significant Bytes. |
| [out] | puLSB | Least Significant Bytes. |
Definition at line 250 of file nmLibPack.c.
Referenced by nmUnpackF64(), nmUnpackP64(), nmUnpackS64(), and nmUnpackU64().
| #define UNPACKBIG | ( | buf, | |
| pval | |||
| ) | unpackbig(buf, (byte_t *)pval, sizeof(*pval)); |
Unpack an element from the message buffer in big-endian byte order.
| [in] | buf | Output message buffer. |
| [out] | pval | Type T* element to be unpacked (set). |
Definition at line 405 of file nmLibPack.c.
Referenced by nmUnpackF32(), nmUnpackF64(), nmUnpackS64(), nmUnpackU16(), nmUnpackU32(), and nmUnpackU64().
| #define UNPACKLITTLE | ( | buf, | |
| pval | |||
| ) | unpacklittle(buf, (byte_t *)pval, sizeof(*pval)) |
Unpack an element from the message buffer in little-endian byte order.
| [in] | buf | Output message buffer. |
| [out] | pval | Type T* element to be unpacked (set). |
Definition at line 421 of file nmLibPack.c.
Referenced by nmUnpackF32(), nmUnpackF64(), nmUnpackS64(), nmUnpackU16(), nmUnpackU32(), and nmUnpackU64().
| #define UNPACKNATIVE | ( | buf, | |
| pval | |||
| ) | unpackbig(buf, (byte_t *)pval, sizeof(*pval)) |
Unpack an element from the message buffer in native byte order.
Big-Endian Host Version
| [in] | buf | Output message buffer. |
| [out] | pval | Type T* element to be unpacked (set). |
Definition at line 226 of file nmLibPack.c.
Referenced by nmUnpackF32(), nmUnpackF64(), nmUnpackP32(), nmUnpackS64(), nmUnpackU16(), nmUnpackU32(), and nmUnpackU64().
|
inlinestatic |
Test if 32-bit floating-point number is ± infinity.
| f | 32-bit float with bit overlay. |
Definition at line 653 of file nmLibPack.c.
Referenced by nmPackF64().
|
inlinestatic |
Test if 32-bit floating-point number is a NaN.
| f | 32-bit float with bit overlay. |
Definition at line 631 of file nmLibPack.c.
Referenced by nmPackF64().
|
inlinestatic |
Test if 32-bit floating-point number is ± 0.0.
| f | 32-bit float with bit overlay. |
Definition at line 675 of file nmLibPack.c.
Referenced by nmPackF64().
|
inlinestatic |
Test if 64-bit floating-point number is ± infinity.
| d | 64-bit float with bit overlay. |
Definition at line 664 of file nmLibPack.c.
Referenced by nmUnpackF64().
|
inlinestatic |
Test if 64-bit floating-point number is a NaN.
| d | 64-bit float with bit overlay. |
Definition at line 642 of file nmLibPack.c.
Referenced by nmUnpackF64().
|
inlinestatic |
Test if 64-bit floating-point number is ± 0.0.
| d | 64-bit float with bit overlay. |
Definition at line 686 of file nmLibPack.c.
Referenced by nmUnpackF64().
| int nmPackBuf | ( | byte_t | bufSrc[], |
| size_t | uCount, | ||
| byte_t | buf[], | ||
| size_t | bufSize, | ||
| NMEndian_T | eEndian | ||
| ) |
Pack a byte buffer into the message buffer.
The source and message buffer memory areas can overlap.
| [in] | bufSrc | Source buffer. |
| uCount | Number of bytes to copy. | |
| [out] | buf | Output message buffer. |
| bufSize | Size of output buffer. | |
| eEndian | Packing order. See NMEndian_T. |
Definition at line 1215 of file nmLibPack.c.
References _NM_CHK_MEM.
| int nmPackF32 | ( | float | val, |
| byte_t | buf[], | ||
| size_t | bufSize, | ||
| NMEndian_T | eEndian | ||
| ) |
Pack a 32-bit float into the message buffer.
The IEEE 754 32-bit format is used with both the big and little endian byte orders.
| [in] | val | Value to pack. |
| [out] | buf | Output message buffer. |
| bufSize | Size of output buffer. | |
| eEndian | Packing order. See NMEndian_T. |
Definition at line 957 of file nmLibPack.c.
References _NM_CHK_ARCH, _NM_CHK_MEM, IEEE754_F32_EXPONENT_MASK, IEEE754_F32_EXPONENT_SHIFT, IEEE754_F32_MANTISSA_MASK, IEEE754_F32_MANTISSA_SHIFT, IEEE754_F32_SIGN_MASK, IEEE754_F32_SIGN_SHIFT, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_F32, PACKBIG, PACKLITTLE, and PACKNATIVE.
Referenced by nmPackFlatF32(), and nmPackITVF32().
| int nmPackF64 | ( | double | val, |
| byte_t | buf[], | ||
| size_t | bufSize, | ||
| NMEndian_T | eEndian | ||
| ) |
Pack a 64-bit float into the message buffer.
The IEEE 754 64-bit format is used with both the big and little endian byte orders. If the machine architecture only supports 32-bit doubles, then a conversion to 64-bit representation is performed first.
| [in] | val | Value to pack. |
| [out] | buf | Output message buffer. |
| bufSize | Size of output buffer. | |
| eEndian | Packing order. See NMEndian_T. |
Definition at line 1013 of file nmLibPack.c.
References _NM_CHK_ARCH, _NM_CHK_MEM, IEEE754_F32_F64_MANTISSA0_SHIFT, IEEE754_F32_F64_MANTISSA1_MASK, IEEE754_F32_F64_MANTISSA1_SHIFT, ieee754_f32_is_inf(), ieee754_f32_is_nan(), ieee754_f32_is_zero(), IEEE754_F64_EXPONENT_MASK, IEEE754_F64_EXPONENT_SHIFT, IEEE754_F64_Inf, IEEE754_F64_MANTISSA0_MASK, IEEE754_F64_MANTISSA0_SHIFT, IEEE754_F64_MANTISSA1_MASK, IEEE754_F64_MANTISSA1_SHIFT, IEEE754_F64_NaN, IEEE754_F64_SIGN_MASK, IEEE754_F64_SIGN_SHIFT, IEEE754_F64_Zero, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_F32, NMFVAL_LEN_F64, PACK64BIG, PACK64LITTLE, and PACK64NATIVE.
Referenced by nmPackFlatF64(), and nmPackITVF64().
| int nmPackP32 | ( | void * | val, |
| byte_t | buf[], | ||
| size_t | bufSize, | ||
| NMEndian_T | eEndian | ||
| ) |
Pack a 32-bit pointer into the message buffer.
If the machine architecture has 64-bit pointers, then only the LSB 4 bytes are packed.
| [in] | val | Value to pack. |
| [out] | buf | Output message buffer. |
| bufSize | Size of output buffer. | |
| eEndian | Packing order. See NMEndian_T. |
Definition at line 1113 of file nmLibPack.c.
References _NM_CHK_MEM, NMFVAL_LEN_P32, NMFVAL_LEN_P64, NMLIB_WARNING, and PACKNATIVE.
Referenced by nmPackFlatP32(), nmPackITVP32(), and nmPackPointer().
| int nmPackP64 | ( | void * | val, |
| byte_t | buf[], | ||
| size_t | bufSize, | ||
| NMEndian_T | eEndian | ||
| ) |
Pack a 64-bit pointer into the message buffer.
If the machine architecture only supports 32-bit pointers, then the 4 MSBs are padded with 0's.
| [in] | val | Value to pack. |
| [out] | buf | Output message buffer. |
| bufSize | Size of output buffer. | |
| eEndian | Packing order. See NMEndian_T. |
Definition at line 1160 of file nmLibPack.c.
References _NM_CHK_ARCH, _NM_CHK_MEM, NMFVAL_LEN_P32, NMFVAL_LEN_P64, and PACK64NATIVE.
Referenced by nmPackFlatP64(), nmPackITVP64(), and nmPackPointer().
| int nmPackS64 | ( | long long | val, |
| byte_t | buf[], | ||
| size_t | bufSize, | ||
| NMEndian_T | eEndian | ||
| ) |
Pack an signed 64-bit integer into the message buffer.
If the machine architecture only supports 32-bit long longs, then the 4 MSBs are signed extended.
| [in] | val | Value to pack. |
| [out] | buf | Output message buffer. |
| bufSize | Size of output buffer. | |
| eEndian | Packing order. See NMEndian_T. |
Definition at line 885 of file nmLibPack.c.
References _NM_CHK_ARCH, _NM_CHK_MEM, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_S32, NMFVAL_LEN_S64, PACK64BIG, PACK64LITTLE, PACK64NATIVE, PACKBIG, PACKLITTLE, and PACKNATIVE.
Referenced by nmPackFlatS64(), nmPackITVS64(), nmPackLong(), and nmPackLongLong().
| int nmPackU16 | ( | ushort_t | val, |
| byte_t | buf[], | ||
| size_t | bufSize, | ||
| NMEndian_T | eEndian | ||
| ) |
Pack an unsigned 16-bit integer into the message buffer.
| [in] | val | Value to pack. |
| [out] | buf | Output message buffer. |
| bufSize | Size of output buffer. | |
| eEndian | Packing order. See NMEndian_T. |
Definition at line 762 of file nmLibPack.c.
References _NM_CHK_MEM, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_U16, PACKBIG, PACKLITTLE, and PACKNATIVE.
Referenced by nmPackFlatU16(), nmPackITVMsg(), nmPackITVMsgDebug(), nmPackITVU16(), nmPackS16(), nmPackShort(), and nmPackUShort().
| int nmPackU32 | ( | uint_t | val, |
| byte_t | buf[], | ||
| size_t | bufSize, | ||
| NMEndian_T | eEndian | ||
| ) |
Pack an unsigned 32-bit integer into the message buffer.
| [in] | val | Value to pack. |
| [out] | buf | Output message buffer. |
| bufSize | Size of output buffer. | |
| eEndian | Packing order. See NMEndian_T. |
Definition at line 791 of file nmLibPack.c.
References _NM_CHK_MEM, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_U32, PACKBIG, PACKLITTLE, and PACKNATIVE.
Referenced by nmPackFlatU32(), nmPackInt(), nmPackITVU32(), nmPackS32(), nmPackUInt(), and nmPackULong().
| int nmPackU64 | ( | ulonglong_t | val, |
| byte_t | buf[], | ||
| size_t | bufSize, | ||
| NMEndian_T | eEndian | ||
| ) |
Pack an unsigned 64-bit integer into the message buffer.
If the machine architecture only supports 32-bit long longs, then the 4 MSBs are padded with zero's.
| [in] | val | Value to pack. |
| [out] | buf | Output message buffer. |
| bufSize | Size of output buffer. | |
| eEndian | Packing order. See NMEndian_T. |
Definition at line 823 of file nmLibPack.c.
References _NM_CHK_ARCH, _NM_CHK_MEM, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_U32, NMFVAL_LEN_U64, PACK64BIG, PACK64LITTLE, PACK64NATIVE, PACKBIG, PACKLITTLE, and PACKNATIVE.
Referenced by nmPackFlatU64(), nmPackITVU64(), nmPackULong(), and nmPackULongLong().
| int nmPackU8 | ( | byte_t | val, |
| byte_t | buf[], | ||
| size_t | bufSize, | ||
| NMEndian_T | eEndian | ||
| ) |
Pack an unsigned 8-bit byte into the message buffer.
| [in] | val | Value to pack. |
| [out] | buf | Output message buffer. |
| bufSize | Size of output buffer. | |
| eEndian | Packing order. See NMEndian_T. |
Definition at line 745 of file nmLibPack.c.
References _NM_CHK_MEM, and NMFVAL_LEN_U8.
Referenced by nmPackBool(), nmPackByte(), nmPackChar(), nmPackFlatU8(), nmPackITVU8(), nmPackS8(), and nmPackSChar().
| int nmUnpackBuf | ( | byte_t | buf[], |
| size_t | bufSize, | ||
| byte_t | bufDst[], | ||
| size_t | uCount, | ||
| NMEndian_T | eEndian | ||
| ) |
Unpack a byte buffer from the message buffer.
The source and message buffer memory areas can overlap.
| [in] | buf | Input message buffer. |
| bufSize | Size of input buffer. | |
| [out] | bufDst | Destination output buffer. |
| uCount | Number of bytes to copy. | |
| eEndian | Unpacking order. See NMEndian_T. |
Definition at line 1735 of file nmLibPack.c.
References _NM_CHK_MEM.
Referenced by nmPackPointer().
| int nmUnpackF32 | ( | byte_t | buf[], |
| size_t | bufSize, | ||
| float * | pVal, | ||
| NMEndian_T | eEndian | ||
| ) |
Unpack a 32-bit float from the message buffer.
The IEEE 754 32-bit format is used with both the big and little endian byte orders.
| [in] | buf | Input message buffer. |
| bufSize | Size of input buffer. | |
| [out] | pVal | Pointer to value to unpack (set). |
| eEndian | Unpacking order. See NMEndian_T. |
Definition at line 1472 of file nmLibPack.c.
References _NM_CHK_ARCH, _NM_CHK_MEM, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_F32, UNPACKBIG, UNPACKLITTLE, and UNPACKNATIVE.
Referenced by nmPackPointer(), nmUnpackFlatF32(), and nmUnpackITVF32().
| int nmUnpackF64 | ( | byte_t | buf[], |
| size_t | bufSize, | ||
| double * | pVal, | ||
| NMEndian_T | eEndian | ||
| ) |
Unpack a 64-bit float from the message buffer.
The IEEE 754 64-bit format is used with both the big and little endian byte orders. If the machine architecture only supports 32-bit doubles, then mantissa truncation will occur.
| [in] | buf | Input message buffer. |
| bufSize | Size of input buffer. | |
| [out] | pVal | Pointer to value to unpack (set). |
| eEndian | Unpacking order. See NMEndian_T. |
Definition at line 1517 of file nmLibPack.c.
References _NM_CHK_ARCH, _NM_CHK_MEM, IEEE754_F32_EXP_MAX, IEEE754_F32_EXP_MIN, IEEE754_F32_F64_MANTISSA0_SHIFT, IEEE754_F32_F64_MANTISSA1_MASK, IEEE754_F32_F64_MANTISSA1_SHIFT, IEEE754_F32_Inf, IEEE754_F32_MANTISSA_MASK, IEEE754_F32_NaN, IEEE754_F32_Zero, IEEE754_F64_EXPONENT_MASK, IEEE754_F64_EXPONENT_SHIFT, ieee754_f64_is_inf(), ieee754_f64_is_nan(), ieee754_f64_is_zero(), IEEE754_F64_MANTISSA0_MASK, IEEE754_F64_MANTISSA0_SHIFT, IEEE754_F64_MANTISSA1_MASK, IEEE754_F64_MANTISSA1_SHIFT, IEEE754_F64_SIGN_MASK, IEEE754_F64_SIGN_SHIFT, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_F32, NMFVAL_LEN_F64, NMLIB_WARNING, UNPACK64BIG, UNPACK64LITTLE, UNPACK64NATIVE, UNPACKBIG, UNPACKLITTLE, and UNPACKNATIVE.
Referenced by nmPackPointer(), nmUnpackFlatF64(), and nmUnpackITVF64().
| int nmUnpackP32 | ( | byte_t | buf[], |
| size_t | bufSize, | ||
| void * | pVal, | ||
| NMEndian_T | eEndian | ||
| ) |
Unpack a 32-bit pointer from the message buffer.
If the machine architecture has 64-bit pointers, then only the LSB 4 bytes are packed.
| [in] | buf | Input message buffer. |
| bufSize | Size of input buffer. | |
| [out] | pVal | Pointer to value to unpack (set). |
| eEndian | Unpacking order. See NMEndian_T. |
Definition at line 1648 of file nmLibPack.c.
References _NM_CHK_MEM, NMFVAL_LEN_P32, and UNPACKNATIVE.
Referenced by nmPackPointer(), nmUnpackFlatP32(), nmUnpackITVP32(), and nmUnpackPointer().
| int nmUnpackP64 | ( | byte_t | buf[], |
| size_t | bufSize, | ||
| void * | pVal, | ||
| NMEndian_T | eEndian | ||
| ) |
Unpack a 64-bit pointer from the message buffer.
If the machine architecture only supports 32-bit pointers, then the 4 MSBs are padded with 0's.
| [in] | buf | Input message buffer. |
| bufSize | Size of input buffer. | |
| [out] | pVal | Pointer to value to unpack (set). |
| eEndian | Unpacking order. See NMEndian_T. |
Definition at line 1678 of file nmLibPack.c.
References _NM_CHK_ARCH, _NM_CHK_MEM, NMFVAL_LEN_P32, NMFVAL_LEN_P64, NMLIB_WARNING, and UNPACK64NATIVE.
Referenced by nmPackPointer(), nmUnpackFlatP64(), nmUnpackITVP64(), and nmUnpackPointer().
| int nmUnpackS64 | ( | byte_t | buf[], |
| size_t | bufSize, | ||
| long long * | pVal, | ||
| NMEndian_T | eEndian | ||
| ) |
Unpack an signed 64-bit integer from the message buffer.
If the machine architecture only supports 32-bit long longs, then the 4 MSBs are truncated.
| [in] | buf | Input message buffer. |
| bufSize | Size of input buffer. | |
| [out] | pVal | Pointer to value to unpack (set). |
| eEndian | Unpacking order. See NMEndian_T. |
Definition at line 1391 of file nmLibPack.c.
References _NM_CHK_ARCH, _NM_CHK_MEM, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_S32, NMFVAL_LEN_S64, NMLIB_WARNING, UNPACK64BIG, UNPACK64LITTLE, UNPACK64NATIVE, UNPACKBIG, UNPACKLITTLE, and UNPACKNATIVE.
Referenced by nmPackPointer(), nmUnpackFlatS64(), nmUnpackITVS64(), nmUnpackLong(), and nmUnpackLongLong().
| int nmUnpackU16 | ( | byte_t | buf[], |
| size_t | bufSize, | ||
| ushort_t * | pVal, | ||
| NMEndian_T | eEndian | ||
| ) |
Unpack an unsigned 16-bit integer from the message buffer.
| [in] | buf | Input message buffer. |
| bufSize | Size of input buffer. | |
| [out] | pVal | Pointer to value to unpack (set). |
| eEndian | Unpacking order. See NMEndian_T. |
Definition at line 1256 of file nmLibPack.c.
References _NM_CHK_MEM, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_U16, UNPACKBIG, UNPACKLITTLE, and UNPACKNATIVE.
Referenced by nmGetITVMsgId(), nmPackPointer(), nmUnpackFlatU16(), nmUnpackITVMsg(), nmUnpackITVMsgDebug(), nmUnpackITVU16(), nmUnpackS16(), nmUnpackShort(), and nmUnpackUShort().
| int nmUnpackU32 | ( | byte_t | buf[], |
| size_t | bufSize, | ||
| uint_t * | pVal, | ||
| NMEndian_T | eEndian | ||
| ) |
Unpack an unsigned 32-bit integer from the message buffer.
| [in] | buf | Input message buffer. |
| bufSize | Size of input buffer. | |
| [out] | pVal | Pointer to value to unpack (set). |
| eEndian | Unpacking order. See NMEndian_T. |
Definition at line 1288 of file nmLibPack.c.
References _NM_CHK_MEM, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_U32, UNPACKBIG, UNPACKLITTLE, and UNPACKNATIVE.
Referenced by nmPackPointer(), nmUnpackFlatU32(), nmUnpackInt(), nmUnpackITVU32(), nmUnpackS32(), nmUnpackUInt(), and nmUnpackULong().
| int nmUnpackU64 | ( | byte_t | buf[], |
| size_t | bufSize, | ||
| ulonglong_t * | pVal, | ||
| NMEndian_T | eEndian | ||
| ) |
Unpack an unsigned 64-bit integer from the message buffer.
If the machine architecture only supports 32-bit unsigned long longs, then the 4 MSBs are truncated.
| [in] | buf | Input message buffer. |
| bufSize | Size of input buffer. | |
| [out] | pVal | Pointer to value to unpack (set). |
| eEndian | Unpacking order. See NMEndian_T. |
Definition at line 1320 of file nmLibPack.c.
References _NM_CHK_ARCH, _NM_CHK_MEM, NMEndianBig, NMEndianLittle, NMEndianNative, NMFVAL_LEN_U32, NMFVAL_LEN_U64, NMLIB_WARNING, UNPACK64BIG, UNPACK64LITTLE, UNPACK64NATIVE, UNPACKBIG, UNPACKLITTLE, and UNPACKNATIVE.
Referenced by nmPackPointer(), nmUnpackFlatU64(), nmUnpackITVU64(), nmUnpackULong(), and nmUnpackULongLong().
| int nmUnpackU8 | ( | byte_t | buf[], |
| size_t | bufSize, | ||
| byte_t * | pVal, | ||
| NMEndian_T | eEndian | ||
| ) |
Unpack an unsigned 8-bit byte from the message buffer.
| [in] | buf | Input message buffer. |
| bufSize | Size of input buffer. | |
| [out] | pVal | Pointer to value to unpack (set). |
| eEndian | Unpacking order. See NMEndian_T. |
Definition at line 1239 of file nmLibPack.c.
References _NM_CHK_MEM, and NMFVAL_LEN_U8.
Referenced by nmPackPointer(), nmUnpackBool(), nmUnpackByte(), nmUnpackChar(), nmUnpackFlatU8(), nmUnpackITVU8(), nmUnpackS8(), and nmUnpackSChar().
|
inlinestatic |
Pack an element into the message buffer in big-endian byte order.
Big-Endian Host Version
| [in] | p | Byte pointer to typecasted element to be packed. |
| size | Byte size of element to pack. | |
| [out] | buf | Output message buffer. |
Definition at line 135 of file nmLibPack.c.
|
inlinestatic |
Pack an element into the message buffer in little-endian byte order.
Big-Endian Host Version
| [in] | p | Byte pointer to typecasted element to be packed. |
| size | Byte size of element to pack. | |
| [out] | buf | Output message buffer. |
Definition at line 175 of file nmLibPack.c.
|
inlinestatic |
Unpack an element from the message buffer in big-endian byte order.
Big-Endian Host Version
| [in] | buf | Output message buffer. |
| [out] | p | Byte pointer to typecasted element to be unpacked (set). |
| size | Byte size of element to unpack. |
Definition at line 155 of file nmLibPack.c.
|
inlinestatic |
Unpack an element from the message buffer in little-endian byte order.
Big-Endian Host Version
| [in] | buf | Output message buffer. |
| [out] | p | Byte pointer to typecasted element to be unpacked (set). |
| size | Byte size of element to unpack. |
Definition at line 196 of file nmLibPack.c.
|
static |
± Infinity bit pattern for 32-bit floating-point numbers.
Definition at line 587 of file nmLibPack.c.
Referenced by nmUnpackF64().
|
static |
Not-a-Number bit pattern for 32-bit floating-point numbers.
Definition at line 566 of file nmLibPack.c.
Referenced by nmUnpackF64().
|
static |
± 0 bit pattern for 32-bit floating-point numbers.
Definition at line 608 of file nmLibPack.c.
Referenced by nmUnpackF64().
|
static |
± Infinity bit pattern for 64-bit floating-point numbers.
Definition at line 597 of file nmLibPack.c.
Referenced by nmPackF64().
|
static |
Not-a-Number bit pattern for 64-bit floating-point numbers.
Definition at line 576 of file nmLibPack.c.
Referenced by nmPackF64().
|
static |
± 0 bit pattern for 64-bit floating-point numbers.
Definition at line 618 of file nmLibPack.c.
Referenced by nmPackF64().