public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] shared/util: Add byte-swapping macros for constants
@ 2026-02-09 20:33 Bastien Nocera
  2026-02-09 20:33 ` [PATCH BlueZ 2/2] emulator: Fix compilation on big endian systems Bastien Nocera
  2026-02-09 21:42 ` [BlueZ,1/2] shared/util: Add byte-swapping macros for constants bluez.test.bot
  0 siblings, 2 replies; 6+ messages in thread
From: Bastien Nocera @ 2026-02-09 20:33 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

We can't use functions to populate constants, so add new helpers for
the various __bswap_constant_XX macros available for that purpose.
---
 src/shared/util.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/shared/util.h b/src/shared/util.h
index c480351d6e9f..8683684831c5 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -29,12 +29,24 @@
 #define cpu_to_le16(val) (val)
 #define cpu_to_le32(val) (val)
 #define cpu_to_le64(val) (val)
+#define le16_constant_to_cpu(val) (val)
+#define le32_constant_to_cpu(val) (val)
+#define le64_constant_to_cpu(val) (val)
+#define cpu_constant_to_le16(val) (val)
+#define cpu_constant_to_le32(val) (val)
+#define cpu_constant_to_le64(val) (val)
 #define be16_to_cpu(val) bswap_16(val)
 #define be32_to_cpu(val) bswap_32(val)
 #define be64_to_cpu(val) bswap_64(val)
 #define cpu_to_be16(val) bswap_16(val)
 #define cpu_to_be32(val) bswap_32(val)
 #define cpu_to_be64(val) bswap_64(val)
+#define be16_constant_to_cpu(val) __bswap_constant_16(val)
+#define be32_constant_to_cpu(val) __bswap_constant_32(val)
+#define be64_constant_to_cpu(val) __bswap_constant_64(val)
+#define cpu_constant_to_be16(val) __bswap_constant_16(val)
+#define cpu_constant_to_be32(val) __bswap_constant_32(val)
+#define cpu_constant_to_be64(val) __bswap_constant_64(val)
 #elif __BYTE_ORDER == __BIG_ENDIAN
 #define le16_to_cpu(val) bswap_16(val)
 #define le32_to_cpu(val) bswap_32(val)
@@ -42,12 +54,24 @@
 #define cpu_to_le16(val) bswap_16(val)
 #define cpu_to_le32(val) bswap_32(val)
 #define cpu_to_le64(val) bswap_64(val)
+#define le16_constant_to_cpu(val) __bswap_constant_16(val)
+#define le32_constant_to_cpu(val) __bswap_constant_32(val)
+#define le64_constant_to_cpu(val) __bswap_constant_64(val)
+#define cpu_constant_to_le16(val) __bswap_constant_16(val)
+#define cpu_constant_to_le32(val) __bswap_constant_32(val)
+#define cpu_constant_to_le64(val) __bswap_constant_64(val)
 #define be16_to_cpu(val) (val)
 #define be32_to_cpu(val) (val)
 #define be64_to_cpu(val) (val)
 #define cpu_to_be16(val) (val)
 #define cpu_to_be32(val) (val)
 #define cpu_to_be64(val) (val)
+#define be16_constant_to_cpu(val) (val)
+#define be32_constant_to_cpu(val) (val)
+#define be64_constant_to_cpu(val) (val)
+#define cpu_constant_to_be16(val) (val)
+#define cpu_constant_to_be32(val) (val)
+#define cpu_constant_to_be64(val) (val)
 #else
 #error "Unknown byte order"
 #endif
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-02-10  9:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-09 20:33 [PATCH BlueZ 1/2] shared/util: Add byte-swapping macros for constants Bastien Nocera
2026-02-09 20:33 ` [PATCH BlueZ 2/2] emulator: Fix compilation on big endian systems Bastien Nocera
2026-02-09 20:59   ` Luiz Augusto von Dentz
2026-02-09 21:36   ` Pauli Virtanen
2026-02-10  9:06     ` Bastien Nocera
2026-02-09 21:42 ` [BlueZ,1/2] shared/util: Add byte-swapping macros for constants bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox