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/ndctl.h b/libc/kernel/uapi/linux/ndctl.h
index f6b9f7f..7e0d560 100644
--- a/libc/kernel/uapi/linux/ndctl.h
+++ b/libc/kernel/uapi/linux/ndctl.h
@@ -22,33 +22,33 @@
struct nd_cmd_dimm_flags {
__u32 status;
__u32 flags;
-} __packed;
+} __attribute__((__packed__));
struct nd_cmd_get_config_size {
__u32 status;
__u32 config_size;
__u32 max_xfer;
-} __packed;
+} __attribute__((__packed__));
struct nd_cmd_get_config_data_hdr {
__u32 in_offset;
__u32 in_length;
__u32 status;
__u8 out_buf[];
-} __packed;
+} __attribute__((__packed__));
struct nd_cmd_set_config_hdr {
__u32 in_offset;
__u32 in_length;
__u8 in_buf[];
-} __packed;
+} __attribute__((__packed__));
struct nd_cmd_vendor_hdr {
__u32 opcode;
__u32 in_length;
__u8 in_buf[];
-} __packed;
+} __attribute__((__packed__));
struct nd_cmd_vendor_tail {
__u32 status;
__u32 out_length;
__u8 out_buf[];
-} __packed;
+} __attribute__((__packed__));
struct nd_cmd_ars_cap {
__u64 address;
__u64 length;
@@ -57,7 +57,7 @@
__u32 clear_err_unit;
__u16 flags;
__u16 reserved;
-} __packed;
+} __attribute__((__packed__));
struct nd_cmd_ars_start {
__u64 address;
__u64 length;
@@ -66,7 +66,7 @@
__u8 reserved[5];
__u32 status;
__u32 scrub_time;
-} __packed;
+} __attribute__((__packed__));
struct nd_cmd_ars_status {
__u32 status;
__u32 out_length;
@@ -82,15 +82,15 @@
__u32 reserved;
__u64 err_address;
__u64 length;
- } __packed records[];
-} __packed;
+ } __attribute__((__packed__)) records[];
+} __attribute__((__packed__));
struct nd_cmd_clear_error {
__u64 address;
__u64 length;
__u32 status;
__u8 reserved[4];
__u64 cleared;
-} __packed;
+} __attribute__((__packed__));
enum {
ND_CMD_IMPLEMENTED = 0,
ND_CMD_ARS_CAP = 1,