Replace __packed with __attribute__((__packed__)) in uapi headers
Linux uapi headers use __packed as an abbreviation for
__attribute__((__packed__)). In the upstream kernel headers this
is defined in linux/compiler_attributes.h, but it is not defined
in the uapi headers. Bionic defines it in sys/cdefs.h, which will
almost always provide the needed definition, but there are uapi
headers that use __packed and do not include any system headers
that would include sys/cdefs.h. Musl's sys/cdefs.h does not
define __packed, which leads to linker errors when __packed is
treated as a variable name.
Replace __packed with __attribute__((__packed__)) when importing
uapi headers to break the dependency on sys/cdefs.h.
Test: m USE_HOST_MUSL=true on oriole-userdebug in internal master
Change-Id: I45f80f4e5aec868b80ce8eb9d757a3e08ae3e1a9
diff --git a/libc/kernel/uapi/sound/asoc.h b/libc/kernel/uapi/sound/asoc.h
index eeb12b0..1940e5d 100644
--- a/libc/kernel/uapi/sound/asoc.h
+++ b/libc/kernel/uapi/sound/asoc.h
@@ -356,7 +356,7 @@
__le32 pcm_elems;
__le32 dai_link_elems;
struct snd_soc_tplg_private priv;
-} __packed;
+} __attribute__((__packed__));
struct snd_soc_tplg_stream_caps_v4 {
__le32 size;
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
@@ -372,7 +372,7 @@
__le32 period_size_max;
__le32 buffer_size_min;
__le32 buffer_size_max;
-} __packed;
+} __attribute__((__packed__));
struct snd_soc_tplg_pcm_v4 {
__le32 size;
char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
@@ -385,11 +385,11 @@
struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX];
__le32 num_streams;
struct snd_soc_tplg_stream_caps_v4 caps[2];
-} __packed;
+} __attribute__((__packed__));
struct snd_soc_tplg_link_config_v4 {
__le32 size;
__le32 id;
struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX];
__le32 num_streams;
-} __packed;
+} __attribute__((__packed__));
#endif
diff --git a/libc/kernel/uapi/sound/asound.h b/libc/kernel/uapi/sound/asound.h
index 7f496d9..6e325e9 100644
--- a/libc/kernel/uapi/sound/asound.h
+++ b/libc/kernel/uapi/sound/asound.h
@@ -605,7 +605,7 @@
__u32 tv_nsec;
__u64 tv_sec;
__u8 data[SNDRV_RAWMIDI_FRAMING_DATA_LENGTH];
-} __packed;
+} __attribute__((__packed__));
struct snd_rawmidi_params {
int stream;
size_t buffer_size;
diff --git a/libc/kernel/uapi/sound/skl-tplg-interface.h b/libc/kernel/uapi/sound/skl-tplg-interface.h
index 387d168..6dd9655 100644
--- a/libc/kernel/uapi/sound/skl-tplg-interface.h
+++ b/libc/kernel/uapi/sound/skl-tplg-interface.h
@@ -111,7 +111,7 @@
__u32 param_id;
__u32 max;
char params[];
-} __packed;
+} __attribute__((__packed__));
enum skl_tkn_dir {
SKL_DIR_IN,
SKL_DIR_OUT
@@ -123,7 +123,7 @@
struct skl_dfw_v4_module_pin {
__u16 module_id;
__u16 instance_id;
-} __packed;
+} __attribute__((__packed__));
struct skl_dfw_v4_module_fmt {
__u32 channels;
__u32 freq;
@@ -133,21 +133,21 @@
__u32 interleaving_style;
__u32 sample_type;
__u32 ch_map;
-} __packed;
+} __attribute__((__packed__));
struct skl_dfw_v4_module_caps {
__u32 set_params : 2;
__u32 rsvd : 30;
__u32 param_id;
__u32 caps_size;
__u32 caps[HDA_SST_CFG_MAX];
-} __packed;
+} __attribute__((__packed__));
struct skl_dfw_v4_pipe {
__u8 pipe_id;
__u8 pipe_priority;
__u16 conn_type : 4;
__u16 rsvd : 4;
__u16 memory_pages : 8;
-} __packed;
+} __attribute__((__packed__));
struct skl_dfw_v4_module {
char uuid[SKL_UUID_STR_SZ];
__u16 module_id;
@@ -181,5 +181,5 @@
struct skl_dfw_v4_module_pin in_pin[MAX_IN_QUEUE];
struct skl_dfw_v4_module_pin out_pin[MAX_OUT_QUEUE];
struct skl_dfw_v4_module_caps caps;
-} __packed;
+} __attribute__((__packed__));
#endif
diff --git a/libc/kernel/uapi/sound/sof/fw.h b/libc/kernel/uapi/sound/sof/fw.h
index c36c2b9..97b7de3 100644
--- a/libc/kernel/uapi/sound/sof/fw.h
+++ b/libc/kernel/uapi/sound/sof/fw.h
@@ -46,7 +46,7 @@
enum snd_sof_fw_blk_type type;
__u32 size;
__u32 offset;
-} __packed;
+} __attribute__((__packed__));
enum snd_sof_fw_mod_type {
SOF_FW_BASE = 0,
SOF_FW_MODULE = 1,
@@ -55,11 +55,11 @@
enum snd_sof_fw_mod_type type;
__u32 size;
__u32 num_blocks;
-} __packed;
+} __attribute__((__packed__));
struct snd_sof_fw_header {
unsigned char sig[SND_SOF_FW_SIG_SIZE];
__u32 file_size;
__u32 num_modules;
__u32 abi;
-} __packed;
+} __attribute__((__packed__));
#endif
diff --git a/libc/kernel/uapi/sound/sof/header.h b/libc/kernel/uapi/sound/sof/header.h
index a1a13db..7514550 100644
--- a/libc/kernel/uapi/sound/sof/header.h
+++ b/libc/kernel/uapi/sound/sof/header.h
@@ -26,7 +26,7 @@
__u32 abi;
__u32 reserved[4];
__u32 data[];
-} __packed;
+} __attribute__((__packed__));
#define SOF_MANIFEST_DATA_TYPE_NHLT 1
struct sof_manifest_tlv {
__le32 type;