From: Eric Biggers Date: Thu, 30 Mar 2023 07:00:56 +0000 (-0700) Subject: compiler.h: remove _packed_attribute X-Git-Tag: v1.14.0~45 X-Git-Url: https://wimlib.net/git/?a=commitdiff_plain;h=16a8ddcea30625100698362ca2e78304cfbfe8dd;p=wimlib compiler.h: remove _packed_attribute This abstraction layer serves no purpose. Just use __attribute__((packed)) directly. --- diff --git a/include/wimlib/compiler.h b/include/wimlib/compiler.h index 2013cd12..612c058c 100644 --- a/include/wimlib/compiler.h +++ b/include/wimlib/compiler.h @@ -73,10 +73,6 @@ /* Prefetch into L1 cache for write. */ #define prefetchw(addr) __builtin_prefetch((addr), 1) -/* Declare that the members of the annotated struct are tightly packed, and the - * struct itself may be misaligned. */ -#define _packed_attribute __attribute__((packed)) - /* Declare that pointers to the annotated type may alias other pointers. */ #define _may_alias_attribute __attribute__((may_alias)) diff --git a/include/wimlib/header.h b/include/wimlib/header.h index 7ef67736..49ccf0b2 100644 --- a/include/wimlib/header.h +++ b/include/wimlib/header.h @@ -102,15 +102,15 @@ struct wim_header_disk { * if the WIM has no integrity table. * * Note the integrity_table_reshdr here is 4-byte aligned even though it - * would ordinarily be 8-byte aligned--- hence, the _packed_attribute on - * this structure is essential. */ + * would ordinarily be 8-byte aligned--- hence, the + * __attribute__((packed)) on this structure is essential. */ struct wim_reshdr_disk integrity_table_reshdr; /* +0x94: Unused bytes. */ u8 unused[60]; /* +0xd0 (208) */ -} _packed_attribute; +} __attribute__((packed)); /* * Arbitrarily limit the maximum number of images to 65535, to prevent huge diff --git a/include/wimlib/reparse.h b/include/wimlib/reparse.h index fcc63424..99d466c5 100644 --- a/include/wimlib/reparse.h +++ b/include/wimlib/reparse.h @@ -14,8 +14,8 @@ struct blob_table; * On-disk format of a reparse point buffer. See: * https://msdn.microsoft.com/en-us/library/dd541671.aspx * - * Note: we are not using _packed_attribute for this structure, so only cast to - * this if properly aligned! + * Note: we are not using __attribute__((packed)) for this structure, so only + * cast to this if properly aligned! */ struct reparse_buffer_disk { le32 rptag; diff --git a/include/wimlib/resource.h b/include/wimlib/resource.h index 0985c4f3..8924b807 100644 --- a/include/wimlib/resource.h +++ b/include/wimlib/resource.h @@ -72,7 +72,7 @@ struct wim_reshdr_disk { /* Uncompressed size of the resource, in bytes. */ le64 uncompressed_size; -} _packed_attribute; +} __attribute__((packed)); /* In-memory version of a WIM resource header (`struct wim_reshdr_disk'). */ struct wim_reshdr { @@ -158,7 +158,7 @@ struct alt_chunk_table_header_disk { /* This header is directly followed by a table of compressed sizes of * the chunks (4 bytes per entry). */ -} _packed_attribute; +} __attribute__((packed)); static inline unsigned int get_chunk_entry_size(u64 res_size, bool is_alt) @@ -321,12 +321,12 @@ struct pwm_blob_hdr { u8 hash[SHA1_HASH_SIZE]; /* +16 */ le32 flags; /* +36 */ /* +40 */ -} _packed_attribute; +} __attribute__((packed)); /* Header that precedes each chunk of a compressed resource in a pipable WIM. */ struct pwm_chunk_hdr { le32 compressed_size; -} _packed_attribute; +} __attribute__((packed)); #endif /* _WIMLIB_RESOURCE_H */ diff --git a/include/wimlib/security_descriptor.h b/include/wimlib/security_descriptor.h index e7fd62c7..f5c5a34c 100644 --- a/include/wimlib/security_descriptor.h +++ b/include/wimlib/security_descriptor.h @@ -58,7 +58,7 @@ typedef struct { /* Offset of Discretionary Access Control List (DACL) in security * descriptor, or 0 if no DACL is present */ le32 dacl_offset; -} _packed_attribute wimlib_SECURITY_DESCRIPTOR_RELATIVE; +} __attribute__((packed)) wimlib_SECURITY_DESCRIPTOR_RELATIVE; #define wimlib_SE_OWNER_DEFAULTED 0x0001 #define wimlib_SE_GROUP_DEFAULTED 0x0002 @@ -85,7 +85,7 @@ typedef struct { u8 identifier_authority[6]; le32 sub_authority[]; -} _packed_attribute wimlib_SID; +} __attribute__((packed)) wimlib_SID; /* Header of a Windows NT access control list */ typedef struct { @@ -104,7 +104,7 @@ typedef struct { /* padding */ le16 sbz2; -} _packed_attribute wimlib_ACL; +} __attribute__((packed)) wimlib_ACL; #define wimlib_ACCESS_ALLOWED_ACE_TYPE 0 #define wimlib_ACCESS_DENIED_ACE_TYPE 1 @@ -120,27 +120,27 @@ typedef struct { /* Size of the access control entry, including this header */ le16 size; -} _packed_attribute wimlib_ACE_HEADER; +} __attribute__((packed)) wimlib_ACE_HEADER; /* Windows NT access control entry to grant rights to a user or group */ typedef struct { wimlib_ACE_HEADER hdr; le32 mask; wimlib_SID sid; -} _packed_attribute wimlib_ACCESS_ALLOWED_ACE; +} __attribute__((packed)) wimlib_ACCESS_ALLOWED_ACE; /* Windows NT access control entry to deny rights to a user or group */ typedef struct { wimlib_ACE_HEADER hdr; le32 mask; wimlib_SID sid; -} _packed_attribute wimlib_ACCESS_DENIED_ACE; +} __attribute__((packed)) wimlib_ACCESS_DENIED_ACE; /* Windows NT access control entry to audit access to the object */ typedef struct { wimlib_ACE_HEADER hdr; le32 mask; wimlib_SID sid; -} _packed_attribute wimlib_SYSTEM_AUDIT_ACE; +} __attribute__((packed)) wimlib_SYSTEM_AUDIT_ACE; #endif /* _WIMLIB_SECURITY_DESCRIPTOR_H */ diff --git a/include/wimlib/wof.h b/include/wimlib/wof.h index 292b7168..b19319dd 100644 --- a/include/wimlib/wof.h +++ b/include/wimlib/wof.h @@ -248,7 +248,7 @@ struct wim_provider_rpdata { /* Byte offset of the file's unnamed data stream in the WIM. */ le64 unnamed_data_stream_offset_in_wim; -} _packed_attribute; +} __attribute__((packed)); /* WIM-specific information about a WIM data source */ struct WimOverlay_dat_entry_1 { @@ -277,7 +277,7 @@ struct WimOverlay_dat_entry_1 { /* GUID of the WIM file (copied from the WIM header, offset +0x18). */ u8 guid[16]; -} _packed_attribute; +} __attribute__((packed)); /* * Format of file: "\System Volume Information\WimOverlay.dat" @@ -308,7 +308,7 @@ struct WimOverlay_dat_header { le64 next_data_source_id; struct WimOverlay_dat_entry_1 entry_1s[]; -} _packed_attribute; +} __attribute__((packed)); /* Location information about a WIM data source */ struct WimOverlay_dat_entry_2 { @@ -414,8 +414,8 @@ struct WimOverlay_dat_entry_2 { /* Null-terminated path to WIM file. Begins with \ but does * *not* include drive letter! */ utf16lechar wim_file_name[]; - } _packed_attribute; -} _packed_attribute; + } __attribute__((packed)); +} __attribute__((packed)); static _unused_attribute void wof_check_structs(void) diff --git a/include/wimlib/xattr.h b/include/wimlib/xattr.h index 13fb21b8..074fed9d 100644 --- a/include/wimlib/xattr.h +++ b/include/wimlib/xattr.h @@ -40,7 +40,7 @@ struct wim_xattr_entry { /* u8 value[0]; */ /* no padding at end! */ -} _packed_attribute; +} __attribute__((packed)); static inline size_t xattr_entry_size(const struct wim_xattr_entry *entry) diff --git a/src/blob_table.c b/src/blob_table.c index d562e2c6..294f9503 100644 --- a/src/blob_table.c +++ b/src/blob_table.c @@ -585,7 +585,7 @@ struct blob_descriptor_disk { /* SHA-1 message digest of the uncompressed data of this blob, or all * zeroes if this blob is of zero length. */ u8 hash[SHA1_HASH_SIZE]; -} _packed_attribute; +} __attribute__((packed)); /* Given a nonempty run of consecutive blob descriptors with the SOLID flag set, * count how many specify resources (as opposed to blobs within those diff --git a/src/dentry.c b/src/dentry.c index 3e09993c..bf81d9a8 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -155,10 +155,10 @@ struct wim_dentry_on_disk { le32 reparse_tag; le16 rp_reserved; le16 rp_flags; - } _packed_attribute reparse; + } __attribute__((packed)) reparse; struct { le64 hard_link_group_id; - } _packed_attribute nonreparse; + } __attribute__((packed)) nonreparse; }; /* Number of extra stream entries that directly follow this dentry @@ -196,7 +196,7 @@ struct wim_dentry_on_disk { * for more information. */ /* u8 tagged_items[] __attribute__((aligned(8))); */ -} _packed_attribute; +} __attribute__((packed)); /* If num_extra_streams != 0, then there are that many extra stream * entries following the dentry, starting on the next 8-byte aligned * boundary. They are not counted in the 'length' field of the dentry. @@ -226,7 +226,7 @@ struct wim_extra_stream_entry_on_disk { * the null terminator. There is a null terminator character if * @name_nbytes != 0; i.e., if this stream is named. */ utf16lechar name[]; -} _packed_attribute; +} __attribute__((packed)); static void do_dentry_set_name(struct wim_dentry *dentry, utf16lechar *name, diff --git a/src/integrity.c b/src/integrity.c index e0d4447c..ce07acc6 100644 --- a/src/integrity.c +++ b/src/integrity.c @@ -52,7 +52,7 @@ struct integrity_table { u32 num_entries; u32 chunk_size; u8 sha1sums[][20]; -} _packed_attribute; +} __attribute__((packed)); static int calculate_chunk_sha1(struct filedes *in_fd, size_t this_chunk_size, diff --git a/src/registry.c b/src/registry.c index 0f753e8c..bdf4dc8f 100644 --- a/src/registry.c +++ b/src/registry.c @@ -46,7 +46,7 @@ struct regf { le32 total_hbin_size; /* Total size of all hbins */ le32 f3[1013]; u8 hbin_area[0]; /* Start of hbin area */ -} _packed_attribute; +} __attribute__((packed)); /* Cell header */ @@ -56,7 +56,7 @@ struct cell { /* Magic characters which identify the cell type */ le16 magic; -} _packed_attribute; +} __attribute__((packed)); /* NK cell - represents a registry key */ struct nk { @@ -84,7 +84,7 @@ struct nk { le16 name_size; le16 unknown_0x4E; char name[0]; -} _packed_attribute; +} __attribute__((packed)); /* Subkey list cell. There are four types. LF, LH, and LI cells reference * subkey NK cells directly, while RI cells reference other subkey lists. All @@ -99,13 +99,13 @@ struct subkey_list { struct cell base; le16 num_offsets; le32 elements[0]; -} _packed_attribute; +} __attribute__((packed)); /* Value list cell - contains a list of value references */ struct value_list { le32 size; le32 vk_offsets[0]; -} _packed_attribute; +} __attribute__((packed)); /* VK cell - contains a value's data, or a reference to it */ struct vk { diff --git a/src/security.c b/src/security.c index f674fa9a..c447e501 100644 --- a/src/security.c +++ b/src/security.c @@ -37,7 +37,7 @@ struct wim_security_data_disk { le32 total_length; le32 num_entries; le64 sizes[]; -} _packed_attribute; +} __attribute__((packed)); struct wim_security_data * new_wim_security_data(void)