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/linux/psp-sev.h b/libc/kernel/uapi/linux/psp-sev.h
index 6c4f73d..8c9ec80 100644
--- a/libc/kernel/uapi/linux/psp-sev.h
+++ b/libc/kernel/uapi/linux/psp-sev.h
@@ -66,37 +66,37 @@
__u32 flags;
__u8 build;
__u32 guest_count;
-} __packed;
+} __attribute__((__packed__));
#define SEV_STATUS_FLAGS_CONFIG_ES 0x0100
struct sev_user_data_pek_csr {
__u64 address;
__u32 length;
-} __packed;
+} __attribute__((__packed__));
struct sev_user_data_pek_cert_import {
__u64 pek_cert_address;
__u32 pek_cert_len;
__u64 oca_cert_address;
__u32 oca_cert_len;
-} __packed;
+} __attribute__((__packed__));
struct sev_user_data_pdh_cert_export {
__u64 pdh_cert_address;
__u32 pdh_cert_len;
__u64 cert_chain_address;
__u32 cert_chain_len;
-} __packed;
+} __attribute__((__packed__));
struct sev_user_data_get_id {
__u8 socket1[64];
__u8 socket2[64];
-} __packed;
+} __attribute__((__packed__));
struct sev_user_data_get_id2 {
__u64 address;
__u32 length;
-} __packed;
+} __attribute__((__packed__));
struct sev_issue_cmd {
__u32 cmd;
__u64 data;
__u32 error;
-} __packed;
+} __attribute__((__packed__));
#define SEV_IOC_TYPE 'S'
#define SEV_ISSUE_CMD _IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd)
#endif