* [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
* [PATCH BlueZ 2/2] emulator: Fix compilation on big endian systems
2026-02-09 20:33 [PATCH BlueZ 1/2] shared/util: Add byte-swapping macros for constants Bastien Nocera
@ 2026-02-09 20:33 ` Bastien Nocera
2026-02-09 20:59 ` Luiz Augusto von Dentz
2026-02-09 21:36 ` Pauli Virtanen
2026-02-09 21:42 ` [BlueZ,1/2] shared/util: Add byte-swapping macros for constants bluez.test.bot
1 sibling, 2 replies; 6+ messages in thread
From: Bastien Nocera @ 2026-02-09 20:33 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Pauli Virtanen
Use new helper macros for byteswapping constants.
This fixes the build on big endian systems like s390x:
emulator/bthost.c: In function ‘bthost_setup_sco’:
./src/shared/util.h:43:26: error: initializer element is not constant
43 | #define cpu_to_le32(val) bswap_32(val)
| ^~~~~~~~
etc.
Fixes: 85888a8357ea ("bthost: add bthost_setup_sco() and accept
incoming eSCO")
---
emulator/bthost.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/emulator/bthost.c b/emulator/bthost.c
index d09ad1e76c50..37865f61bc52 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -3562,18 +3562,18 @@ int bthost_setup_sco(struct bthost *bthost, uint16_t acl_handle,
{
static const struct bt_hci_cmd_setup_sync_conn settings[] = {
{
- .tx_bandwidth = cpu_to_le32(0x00001f40),
- .rx_bandwidth = cpu_to_le32(0x00001f40),
- .max_latency = cpu_to_le16(0x000a),
+ .tx_bandwidth = cpu_constant_to_le32(0x00001f40),
+ .rx_bandwidth = cpu_constant_to_le32(0x00001f40),
+ .max_latency = cpu_constant_to_le16(0x000a),
.retrans_effort = 0x01,
- .voice_setting = cpu_to_le16(BT_VOICE_CVSD_16BIT),
+ .voice_setting = cpu_constant_to_le16(BT_VOICE_CVSD_16BIT),
},
{
- .tx_bandwidth = cpu_to_le32(0x00001f40),
- .rx_bandwidth = cpu_to_le32(0x00001f40),
- .max_latency = cpu_to_le16(0x000d),
+ .tx_bandwidth = cpu_constant_to_le32(0x00001f40),
+ .rx_bandwidth = cpu_constant_to_le32(0x00001f40),
+ .max_latency = cpu_constant_to_le16(0x000d),
.retrans_effort = 0x02,
- .voice_setting = cpu_to_le16(BT_VOICE_TRANSPARENT),
+ .voice_setting = cpu_constant_to_le16(BT_VOICE_TRANSPARENT),
}
};
struct bt_hci_cmd_setup_sync_conn cmd;
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH BlueZ 2/2] emulator: Fix compilation on big endian systems
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
1 sibling, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2026-02-09 20:59 UTC (permalink / raw)
To: Bastien Nocera; +Cc: linux-bluetooth, Pauli Virtanen
Hi Bastien,
On Mon, Feb 9, 2026 at 3:34 PM Bastien Nocera <hadess@hadess.net> wrote:
>
> Use new helper macros for byteswapping constants.
>
> This fixes the build on big endian systems like s390x:
>
> emulator/bthost.c: In function ‘bthost_setup_sco’:
> ./src/shared/util.h:43:26: error: initializer element is not constant
> 43 | #define cpu_to_le32(val) bswap_32(val)
> | ^~~~~~~~
> etc.
>
> Fixes: 85888a8357ea ("bthost: add bthost_setup_sco() and accept
> incoming eSCO")
> ---
> emulator/bthost.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/emulator/bthost.c b/emulator/bthost.c
> index d09ad1e76c50..37865f61bc52 100644
> --- a/emulator/bthost.c
> +++ b/emulator/bthost.c
> @@ -3562,18 +3562,18 @@ int bthost_setup_sco(struct bthost *bthost, uint16_t acl_handle,
> {
> static const struct bt_hci_cmd_setup_sync_conn settings[] = {
> {
> - .tx_bandwidth = cpu_to_le32(0x00001f40),
> - .rx_bandwidth = cpu_to_le32(0x00001f40),
> - .max_latency = cpu_to_le16(0x000a),
> + .tx_bandwidth = cpu_constant_to_le32(0x00001f40),
> + .rx_bandwidth = cpu_constant_to_le32(0x00001f40),
> + .max_latency = cpu_constant_to_le16(0x000a),
> .retrans_effort = 0x01,
> - .voice_setting = cpu_to_le16(BT_VOICE_CVSD_16BIT),
> + .voice_setting = cpu_constant_to_le16(BT_VOICE_CVSD_16BIT),
> },
> {
> - .tx_bandwidth = cpu_to_le32(0x00001f40),
> - .rx_bandwidth = cpu_to_le32(0x00001f40),
> - .max_latency = cpu_to_le16(0x000d),
> + .tx_bandwidth = cpu_constant_to_le32(0x00001f40),
> + .rx_bandwidth = cpu_constant_to_le32(0x00001f40),
> + .max_latency = cpu_constant_to_le16(0x000d),
> .retrans_effort = 0x02,
> - .voice_setting = cpu_to_le16(BT_VOICE_TRANSPARENT),
> + .voice_setting = cpu_constant_to_le16(BT_VOICE_TRANSPARENT),
> }
Perhaps we should change the above, I don't think it is really useful
to have a table like this can then do memcpy, instead we can probably
just use a switch (setting) and then initialize the values in the cmd
directly, that way we can use the regular method of converting since
it would not be required to be a constant.
> };
> struct bt_hci_cmd_setup_sync_conn cmd;
> --
> 2.52.0
>
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH BlueZ 2/2] emulator: Fix compilation on big endian systems
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
1 sibling, 1 reply; 6+ messages in thread
From: Pauli Virtanen @ 2026-02-09 21:36 UTC (permalink / raw)
To: Bastien Nocera, linux-bluetooth
Hi,
ma, 2026-02-09 kello 21:33 +0100, Bastien Nocera kirjoitti:
> Use new helper macros for byteswapping constants.
>
> This fixes the build on big endian systems like s390x:
>
> emulator/bthost.c: In function ‘bthost_setup_sco’:
> ./src/shared/util.h:43:26: error: initializer element is not constant
> 43 | #define cpu_to_le32(val) bswap_32(val)
> | ^~~~~~~~
> etc.
>
> Fixes: 85888a8357ea ("bthost: add bthost_setup_sco() and accept
> incoming eSCO")
> ---
> emulator/bthost.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/emulator/bthost.c b/emulator/bthost.c
> index d09ad1e76c50..37865f61bc52 100644
> --- a/emulator/bthost.c
> +++ b/emulator/bthost.c
> @@ -3562,18 +3562,18 @@ int bthost_setup_sco(struct bthost *bthost,
> uint16_t acl_handle,
> {
> static const struct bt_hci_cmd_setup_sync_conn settings[] =
> {
Removing the "static" here would be another way to fix it, as it
doesn't really need to be static here.
> {
> - .tx_bandwidth = cpu_to_le32(0x00001f40),
> - .rx_bandwidth = cpu_to_le32(0x00001f40),
> - .max_latency = cpu_to_le16(0x000a),
> + .tx_bandwidth =
> cpu_constant_to_le32(0x00001f40),
> + .rx_bandwidth =
> cpu_constant_to_le32(0x00001f40),
> + .max_latency = cpu_constant_to_le16(0x000a),
> .retrans_effort = 0x01,
> - .voice_setting =
> cpu_to_le16(BT_VOICE_CVSD_16BIT),
> + .voice_setting =
> cpu_constant_to_le16(BT_VOICE_CVSD_16BIT),
> },
> {
> - .tx_bandwidth = cpu_to_le32(0x00001f40),
> - .rx_bandwidth = cpu_to_le32(0x00001f40),
> - .max_latency = cpu_to_le16(0x000d),
> + .tx_bandwidth =
> cpu_constant_to_le32(0x00001f40),
> + .rx_bandwidth =
> cpu_constant_to_le32(0x00001f40),
> + .max_latency = cpu_constant_to_le16(0x000d),
> .retrans_effort = 0x02,
> - .voice_setting =
> cpu_to_le16(BT_VOICE_TRANSPARENT),
> + .voice_setting =
> cpu_constant_to_le16(BT_VOICE_TRANSPARENT),
> }
> };
> struct bt_hci_cmd_setup_sync_conn cmd;
--
Pauli Virtanen
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [BlueZ,1/2] shared/util: Add byte-swapping macros for constants
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 21:42 ` bluez.test.bot
1 sibling, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2026-02-09 21:42 UTC (permalink / raw)
To: linux-bluetooth, hadess
[-- Attachment #1: Type: text/plain, Size: 1689 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1052425
---Test result---
Test Summary:
CheckPatch PENDING 0.45 seconds
GitLint PENDING 0.51 seconds
BuildEll PASS 20.62 seconds
BluezMake PASS 676.16 seconds
MakeCheck PASS 18.46 seconds
MakeDistcheck PASS 250.39 seconds
CheckValgrind PASS 299.39 seconds
CheckSmatch WARNING 357.87 seconds
bluezmakeextell PASS 186.11 seconds
IncrementalBuild PENDING 0.46 seconds
ScanBuild PASS 1046.68 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
emulator/bthost.c:700:28: warning: Variable length array is used.emulator/bthost.c:701:32: warning: Variable length array is used.emulator/bthost.c:918:28: warning: Variable length array is used.emulator/bthost.c:952:28: warning: Variable length array is used.emulator/bthost.c:953:32: warning: Variable length array is used.
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH BlueZ 2/2] emulator: Fix compilation on big endian systems
2026-02-09 21:36 ` Pauli Virtanen
@ 2026-02-10 9:06 ` Bastien Nocera
0 siblings, 0 replies; 6+ messages in thread
From: Bastien Nocera @ 2026-02-10 9:06 UTC (permalink / raw)
To: Pauli Virtanen, linux-bluetooth
On Mon, 2026-02-09 at 21:36 +0000, Pauli Virtanen wrote:
> Hi,
>
> ma, 2026-02-09 kello 21:33 +0100, Bastien Nocera kirjoitti:
> > Use new helper macros for byteswapping constants.
> >
> > This fixes the build on big endian systems like s390x:
> >
> > emulator/bthost.c: In function ‘bthost_setup_sco’:
> > ./src/shared/util.h:43:26: error: initializer element is not
> > constant
> > 43 | #define cpu_to_le32(val) bswap_32(val)
> > | ^~~~~~~~
> > etc.
> >
> > Fixes: 85888a8357ea ("bthost: add bthost_setup_sco() and accept
> > incoming eSCO")
> > ---
> > emulator/bthost.c | 16 ++++++++--------
> > 1 file changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/emulator/bthost.c b/emulator/bthost.c
> > index d09ad1e76c50..37865f61bc52 100644
> > --- a/emulator/bthost.c
> > +++ b/emulator/bthost.c
> > @@ -3562,18 +3562,18 @@ int bthost_setup_sco(struct bthost *bthost,
> > uint16_t acl_handle,
> > {
> > static const struct bt_hci_cmd_setup_sync_conn settings[]
> > =
> > {
>
> Removing the "static" here would be another way to fix it, as it
> doesn't really need to be static here.
That looks like it's enough indeed, let me respin a patch.
^ permalink raw reply [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