MEM_VAL_COPY_GET_xxx()
These macros copy and decode data values from any CPU memory address to any other memory address.
Files
lib_mem.h
Prototypes
MEM_VAL_COPY_GET_INT08U_BIG(addr_dest, addr_src); MEM_VAL_COPY_GET_INT16U_BIG(addr_dest, addr_src); MEM_VAL_COPY_GET_INT32U_BIG(addr_dest, addr_src); MEM_VAL_COPY_GET_INTU_BIG(addr_dest, addr_src, val_size); MEM_VAL_COPY_GET_INT08U_LITTLE(addr_dest, addr_src); MEM_VAL_COPY_GET_INT16U_LITTLE(addr_dest, addr_src); MEM_VAL_COPY_GET_INT32U_LITTLE(addr_dest, addr_src); MEM_VAL_COPY_GET_INTU_LITTLE(addr_dest, addr_src, val_size); MEM_VAL_COPY_GET_INT08U(addr_dest, addr_src); MEM_VAL_COPY_GET_INT16U(addr_dest, addr_src); MEM_VAL_COPY_GET_INT32U(addr_dest, addr_src); MEM_VAL_COPY_GET_INTU(addr_dest, addr_src, val_size);
Arguments
addr_dest
Lowest CPU memory address to copy/decode source address’s data value.
addr_src
Lowest CPU memory address of the data value to copy/decode.
val_size
Number of data value octets to copy/decode.
Returned Value
None.
Required Configuration
None.
Notes / Warnings
CPU memory addresses/pointers not checked for NULL
nor overlapping memory addresses which may result in undefined copy behavior.
Copy/decode data values based on the values’ data-word order in CPU memory:
MEM_VAL_COPY_GET_xxx_BIG()
Decode big-endian data values — data words’ most significant octet at lowest memory address
MEM_VAL_COPY_GET_xxx_LITTLE()
Decode little-endian data values — data words’ least significant octet at lowest memory address
MEM_VAL_COPY_GET_xxx()
Decode data values using CPU’s native or configured data-word order
MEM_VAL_COPY_GET_xxx()
macros copy/decode data values without regard to CPU word-aligned addresses. Thus for processors that require data word alignment, data words can be copied/decoded to/from any CPU addresses, word-aligned or not, without generating data-word-alignment exceptions/faults.
MEM_VAL_COPY_GET_xxx()
macros are more efficient than MEM_VAL_GET_xxx()
macros and are also fully independent of CPU data-word-alignment and should be used whenever possible. Fixed-size copy MEM_VAL_COPY_GET_INTxxU_xxx()
macros are more efficient than dynamic-size copy MEM_VAL_COPY_GET_INTU_xxx()
macros and should be used whenever possible.
MEM_VAL_COPY_GET_xxx()
macros are not atomic operations and must not be used on any non-static (i.e., volatile) variables, registers, hardware, etc.; without the caller of the macros providing some form of additional protection (e.g. mutual exclusion).
Since octet-order copy/conversion are inverse operations, MEM_VAL_COPY_GET_xxx()
and MEM_VAL_COPY_SET_xxx()
memory data-copy get/set macros are inverse, but identical, operations and are provided in both forms for semantics and consistency.
Example Usage
CPU_INT16U *pmem; CPU_INT16U *pval; CPU_INT08U buf[SIZE]; pmem = &SomeAddr; /* Any CPU address */ pval = &SomeVal; /* Any CPU address */ MEM_VAL_COPY_GET_INT16U(pmem, pval); MEM_VAL_COPY_GET_INTU(&buf[0], pmem, sizeof(buf));