Files
BPI-M2C/source_sync_rls_25c/source/bsp/chipram/include/compiler.h
T
2026-09-22 09:38:26 +08:00

37 lines
1.2 KiB
C
Executable File

#ifndef __INCLUDE_COMPILER_H__
#define __INCLUDE_COMPILER_H__
#define uswap_16(val) \
((((val) & 0xff00) >> (8)) | \
(((val) & 0x00ff) << (8)))
#define uswap_32(val) \
((((val) & 0xff000000) >> (24)) | \val)
(((val) & 0x00ff0000) >> (8)) | \
(((val) & 0x0000ff00) << (8)) | \
(((val) & 0x000000ff) << (24)))
#define _uswap_64(val, sfx) \
((((val) & 0xff00000000000000##sfx) >> (56)) | \
(((val) & 0x00ff000000000000##sfx) >> (40)) | \
(((val) & 0x0000ff0000000000##sfx) >> (24)) | \
(((val) & 0x000000ff00000000##sfx) >> (8)) | \
(((val) & 0x00000000ff000000##sfx) << (8)) | \
(((val) & 0x0000000000ff0000##sfx) << (24)) | \
(((val) & 0x000000000000ff00##sfx) << (40)) | \
(((val) & 0x00000000000000ff##sfx) << (56)))
# define uswap_64(val) _uswap_64(val, ull)
# define cpu_to_le16(val) (val)
# define cpu_to_le32(val) (val)
# define cpu_to_le64(val) (val)
# define le16_to_cpu(val) (val)
# define le32_to_cpu(val) (val)
# define le64_to_cpu(val) (val)
# define cpu_to_be16(val) uswap_16(val)
# define cpu_to_be32(val) uswap_32(val)
# define cpu_to_be64(val) uswap_64(val)
# define be16_to_cpu(val) uswap_16(val)
# define be32_to_cpu(val) uswap_32(val)
# define be64_to_cpu(val) uswap_64(val)
#endif /* __INCLUDE_COMPILER_H__ */