diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-08-26 06:49:42 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-08-26 06:49:42 -0700 |
commit | 80e1285c1051201d1ca33207635b908b64cef293 (patch) | |
tree | 0a6f8f695a0fc269eb90a08d14e95a44de26dd9b /tests/012/cadr.tl | |
parent | 0efaa0c628db9b62f3a3d20d07cd3c2e4cbda3ca (diff) | |
download | txr-80e1285c1051201d1ca33207635b908b64cef293.tar.gz txr-80e1285c1051201d1ca33207635b908b64cef293.tar.bz2 txr-80e1285c1051201d1ca33207635b908b64cef293.zip |
ffi: improve support for big/little-endian types.
Instead of byte reads/writes, we use byte order swapping.
Reads and writes that are aligned take place as a single
data transfer, which makes it possible to use these
be/le types for accessing hardware registers. This is useful
in systems where the host processor accesses the bus
in opposite endian relative to some peripheral.
Moreover, when the functions match the local endian, we just
use the native get/put functions via #define macro
redirection.
The source code size is reduced.
* ffi.c (ffi_swap_u16, ffi_swap_u32, ffi_swap_u64,
ffi_swap_i16, ffi_swap_i32, ffi_swap_i64): New static functions.
(ffi_swap_i16_put, ffi_swap_i16_get, ffi_swap_u16_put,
ffi_swap_u16_get, ffi_swap_i32_put, ffi_swap_i32_get,
ffi_swap_u32_put, ffi_swap_u32_get, ffi_swap_i64_put,
ffi_swap_i64_get, ffi_swap_u64_put, ffi_swap_u64_get): New
static functions.
(ffi_be_i16_put, ffi_be_i16_get, ffi_be_u16_put,
ffi_be_u16_get, ffi_be_i32_put, ffi_be_i32_get,
ffi_be_u32_put, ffi_be_u32_get, ffi_be_i64_put,
ffi_be_i64_get, ffi_be_u64_put, ffi_be_u64_get,
ffi_le_i16_put, ffi_le_i16_get, ffi_le_u16_put,
ffi_le_u16_get, ffi_le_i32_put, ffi_le_i32_get,
ffi_le_u32_put, ffi_le_u32_get, ffi_le_i64_put,
ffi_le_i64_get, ffi_le_u64_put, ffi_le_u64_get): Functions
deleted, replaced by same-named #define macros to redirect to
the native functions or the _swap_ functions based on the
endian.
(ffi_be_i16_rput, ffi_be_i16_rget, ffi_be_u16_rput,
ffi_be_u16_rget, ffi_be_i32_rput, ffi_be_i32_rget,
ffi_be_u32_rput, ffi_be_u32_rget, ffi_le_i16_rput,
ffi_le_i16_rget, ffi_le_u16_rput, ffi_le_u16_rget,
ffi_le_i32_rput, ffi_le_i32_rget, ffi_le_u32_rput,
ffi_le_u32_rget): Functions wrapped with #if in case these
exact width types don't exist.
(ffi_init_types): Wrap some exact-width-type type definitions
with #if in case the types don't exist.
Diffstat (limited to 'tests/012/cadr.tl')
0 files changed, 0 insertions, 0 deletions