From 1324c39372bc36ca658375e5f8b64530554ba79d Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 3 Apr 2023 13:48:39 -0700 Subject: [PATCH] Add put_unaligned_leXX() for userspace Signed-off-by: Zach Brown --- utils/src/util.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/src/util.h b/utils/src/util.h index 0c49d4ca..17853b51 100644 --- a/utils/src/util.h +++ b/utils/src/util.h @@ -99,6 +99,16 @@ emit_get_unaligned_le(16) emit_get_unaligned_le(32) emit_get_unaligned_le(64) +#define emit_put_unaligned_le(nr) \ +static inline void put_unaligned_le##nr(u##nr val, void *buf) \ +{ \ + __le##nr x = cpu_to_le##nr(val); \ + memcpy(buf, &x, sizeof(x)); \ +} +emit_put_unaligned_le(16) +emit_put_unaligned_le(32) +emit_put_unaligned_le(64) + /* * return -1,0,+1 based on the memcmp comparison of the minimum of their * two lengths. If their min shared bytes are equal but the lengths