summaryrefslogtreecommitdiff
path: root/include/sbi/sbi_byteorder.h
AgeCommit message (Collapse)Author
2025-07-20include: sbi: fix swap errors with newer gcc -Werror=sequence-pointBen Dooks
The BSWAPxx() macros are now throwing the following warnings with newer gcc versions. This is due to throwing an argument in that may be evaluated more than one (I think) and therefore things like the example below should be avoided. Fix by making a set of BSWAPxx() wrappers which specifically only evaluate 'x' once. In file included lib/sbi/sbi_mpxy.c:21: lib/sbi/sbi_mpxy.c: In function ‘sbi_mpxy_write_attrs’: ib/sbi/sbi_mpxy.c:632:63: error: operation on ‘mem_idx’ may be undefined [-Werror=sequence-point] 632 | attr_val = le32_to_cpu(mem_ptr[mem_idx++]); | ~~~~~~~^~ Signed-off-by: Ben Dooks <[email protected]> Reviewed-by: Rahul Pathak <[email protected]> Reviewed-by: Xiang W <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2024-04-05include: sbi: Support byteorder macros in assemblyVivian Wang
Avoid using C types and casts if sbi/sbi_byteorder.h is included in assembly code Signed-off-by: Vivian Wang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-01-10include: sbi: Introduce common endianess conversion macroHimanshu Chauhan
Introduce cpu_to_lle and lle_to_cpu macros which invoke correct word length cpu_to_le<64/32> conversion based on __riscv_xlen. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-02-09include: sbi: Fix BSWAPx() macros for big-endian hostAnup Patel
The BSWAPx() macros won't do any swapping for big-endian host because the EXTRACT_BYTE() macro will pickup bytes in reverse order. Also, the EXTRACT_BYTE() will generate compile error for constants. To fix this, we get remove the EXTRACT_BYTE() macro and re-write BSWAPx() using simple mask and shift operations. Fixes: 09b34d8cca51 ("include: Add support for byteorder/endianness conversion") Reported-by: Samuel Holland <[email protected]> Signed-off-by: Anup Patel <[email protected]>
2023-02-08include: Add support for byteorder/endianness conversionRahul Pathak
Define macros general byteorder conversion Define functions for endianness conversion from general byteorder conversion macros Signed-off-by: Rahul Pathak <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Sergey Matyukevich <[email protected]> Reviewed-by: Anup Patel <[email protected]>