bswap: Add st24_be_p() to store 24 bits in big-endian order
Commit 14180d6221
("bswap: Add the ability to store to an
unaligned 24 bit field") added st24_le_p() for little
endianness, add st24_be_p() equivalent for bit one.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240621075607.17902-1-philmd@linaro.org>
This commit is contained in:
parent
c9ba79baca
commit
4fbeddb088
@ -38,12 +38,14 @@ static inline void bswap64s(uint64_t *s)
|
||||
#if HOST_BIG_ENDIAN
|
||||
#define be_bswap(v, size) (v)
|
||||
#define le_bswap(v, size) glue(__builtin_bswap, size)(v)
|
||||
#define be_bswap24(v) (v)
|
||||
#define le_bswap24(v) bswap24(v)
|
||||
#define be_bswaps(v, size)
|
||||
#define le_bswaps(p, size) \
|
||||
do { *p = glue(__builtin_bswap, size)(*p); } while (0)
|
||||
#else
|
||||
#define le_bswap(v, size) (v)
|
||||
#define be_bswap24(v) bswap24(v)
|
||||
#define le_bswap24(v) (v)
|
||||
#define be_bswap(v, size) glue(__builtin_bswap, size)(v)
|
||||
#define le_bswaps(v, size)
|
||||
@ -357,6 +359,11 @@ static inline void stw_be_p(void *ptr, uint16_t v)
|
||||
stw_he_p(ptr, be_bswap(v, 16));
|
||||
}
|
||||
|
||||
static inline void st24_be_p(void *ptr, uint32_t v)
|
||||
{
|
||||
st24_he_p(ptr, be_bswap24(v));
|
||||
}
|
||||
|
||||
static inline void stl_be_p(void *ptr, uint32_t v)
|
||||
{
|
||||
stl_he_p(ptr, be_bswap(v, 32));
|
||||
|
Loading…
Reference in New Issue
Block a user