From 94a694bc31f89cec150b23189fb51d0c63d183dc Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 30 Mar 2023 00:00:56 -0700 Subject: [PATCH] compiler.h: remove _aligned_attribute This abstraction layer serves no purpose. Just use __attribute__((aligned(n))) directly. --- include/wimlib/compiler.h | 4 ---- include/wimlib/decompress_common.h | 2 +- include/wimlib/inode.h | 2 +- include/wimlib/xattr.h | 2 +- src/dentry.c | 2 +- src/header.c | 4 ++-- src/lzms_compress.c | 4 ++-- src/lzx_compress.c | 6 +++--- src/lzx_decompress.c | 2 +- src/tagged_items.c | 2 +- src/test_support.c | 2 +- src/win32_apply.c | 10 +++++----- src/win32_capture.c | 13 +++++++------ src/xpress_decompress.c | 2 +- 14 files changed, 27 insertions(+), 30 deletions(-) diff --git a/include/wimlib/compiler.h b/include/wimlib/compiler.h index d164184d..2013cd12 100644 --- a/include/wimlib/compiler.h +++ b/include/wimlib/compiler.h @@ -77,10 +77,6 @@ * struct itself may be misaligned. */ #define _packed_attribute __attribute__((packed)) -/* Declare that the annotated variable, or variables of the annotated type, are - * to be aligned on n-byte boundaries. */ -#define _aligned_attribute(n) __attribute__((aligned(n))) - /* Declare that pointers to the annotated type may alias other pointers. */ #define _may_alias_attribute __attribute__((may_alias)) diff --git a/include/wimlib/decompress_common.h b/include/wimlib/decompress_common.h index c4291267..46fce94f 100644 --- a/include/wimlib/decompress_common.h +++ b/include/wimlib/decompress_common.h @@ -403,7 +403,7 @@ read_huffsym(struct input_bitstream *is, const u16 decode_table[], #define DECODE_TABLE(name, num_syms, table_bits, max_codeword_len) \ u16 name[DECODE_TABLE_SIZE((num_syms), (table_bits), \ (max_codeword_len))] \ - _aligned_attribute(DECODE_TABLE_ALIGNMENT) + __attribute__((aligned(DECODE_TABLE_ALIGNMENT))) /* * Declare the temporary "working_space" array needed for building the decode diff --git a/include/wimlib/inode.h b/include/wimlib/inode.h index 56b177e8..23b304ee 100644 --- a/include/wimlib/inode.h +++ b/include/wimlib/inode.h @@ -229,7 +229,7 @@ struct wim_inode { /* Optional extra data for a WIM inode */ struct wim_inode_extra { size_t size; /* Size of the extra data in bytes */ - u8 data[] _aligned_attribute(8); /* The extra data */ + u8 data[] __attribute__((aligned(8))); /* The extra data */ }; /* diff --git a/include/wimlib/xattr.h b/include/wimlib/xattr.h index 2d297245..13fb21b8 100644 --- a/include/wimlib/xattr.h +++ b/include/wimlib/xattr.h @@ -98,7 +98,7 @@ struct wimlib_xattr_entry_old { /* u8 value[0]; */ /* then zero-padded to a 4-byte boundary */ -} _aligned_attribute(4); +} __attribute__((aligned(4))); static inline size_t old_xattr_entry_size(const struct wimlib_xattr_entry_old *entry) diff --git a/src/dentry.c b/src/dentry.c index 42241ef2..3e09993c 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -194,7 +194,7 @@ struct wim_dentry_on_disk { * field) after 8-byte alignment, then the remaining space will be a * variable-length list of tagged metadata items. See tagged_items.c * for more information. */ - /* u8 tagged_items[] _aligned_attribute(8); */ + /* u8 tagged_items[] __attribute__((aligned(8))); */ } _packed_attribute; /* If num_extra_streams != 0, then there are that many extra stream diff --git a/src/header.c b/src/header.c index 3424edad..b5cd441a 100644 --- a/src/header.c +++ b/src/header.c @@ -62,7 +62,7 @@ int read_wim_header(WIMStruct *wim, struct wim_header *hdr) { - struct wim_header_disk disk_hdr _aligned_attribute(8); + struct wim_header_disk disk_hdr __attribute__((aligned(8))); struct filedes *in_fd = &wim->in_fd; const tchar *filename = wim->filename; int ret; @@ -170,7 +170,7 @@ int write_wim_header(const struct wim_header *hdr, struct filedes *out_fd, off_t offset) { - struct wim_header_disk disk_hdr _aligned_attribute(8); + struct wim_header_disk disk_hdr __attribute__((aligned(8))); int ret; disk_hdr.magic = cpu_to_le64(hdr->magic); diff --git a/src/lzms_compress.c b/src/lzms_compress.c index 6843859b..5056cb30 100644 --- a/src/lzms_compress.c +++ b/src/lzms_compress.c @@ -198,7 +198,7 @@ struct lzms_adaptive_state { u8 lz_rep_states[LZMS_NUM_LZ_REP_DECISIONS]; u8 delta_state; u8 delta_rep_states[LZMS_NUM_DELTA_REP_DECISIONS]; -} _aligned_attribute(64); +} __attribute__((aligned(64))); /* * This structure represents a byte position in the preprocessed input data and @@ -251,7 +251,7 @@ struct lzms_optimum_node { * maintained per-position and are only updated occasionally. */ struct lzms_adaptive_state state; -} _aligned_attribute(64); +} __attribute__((aligned(64))); /* The main compressor structure */ struct lzms_compressor { diff --git a/src/lzx_compress.c b/src/lzx_compress.c index 453f97d4..430e0dd4 100644 --- a/src/lzx_compress.c +++ b/src/lzx_compress.c @@ -287,7 +287,7 @@ struct lzx_sequence { u32 adjusted_offset_and_mainsym; #define SEQ_MAINSYM_BITS 10 #define SEQ_MAINSYM_MASK (((u32)1 << SEQ_MAINSYM_BITS) - 1) -} _aligned_attribute(8); +} __attribute__((aligned(8))); /* * This structure represents a byte position in the input buffer and a node in @@ -333,7 +333,7 @@ struct lzx_optimum_node { # define OPTIMUM_GAP_MATCH 0x80000000 #endif -} _aligned_attribute(8); +} __attribute__((aligned(8))); /* The cost model for near-optimal parsing */ struct lzx_costs { @@ -1315,7 +1315,7 @@ lzx_should_end_block(struct lzx_block_split_stats *stats) */ struct lzx_lru_queue { u64 R; -} _aligned_attribute(8); +} __attribute__((aligned(8))); #define LZX_QUEUE_OFFSET_SHIFT 21 #define LZX_QUEUE_OFFSET_MASK (((u64)1 << LZX_QUEUE_OFFSET_SHIFT) - 1) diff --git a/src/lzx_decompress.c b/src/lzx_decompress.c index 5747d327..bd63da78 100644 --- a/src/lzx_decompress.c +++ b/src/lzx_decompress.c @@ -115,7 +115,7 @@ struct lzx_decompressor { * bits of aligned offset blocks */ u8 extra_offset_bits_minus_aligned[LZX_MAX_OFFSET_SLOTS]; -} _aligned_attribute(DECODE_TABLE_ALIGNMENT); +} __attribute__((aligned(DECODE_TABLE_ALIGNMENT))); /* Read a Huffman-encoded symbol using the precode. */ static forceinline unsigned diff --git a/src/tagged_items.c b/src/tagged_items.c index 69eb6404..9343e020 100644 --- a/src/tagged_items.c +++ b/src/tagged_items.c @@ -48,7 +48,7 @@ struct tagged_item_header { u8 data[0]; /* then zero-padded to an 8-byte boundary */ -} _aligned_attribute(8); +} __attribute__((aligned(8))); /* * Retrieve from @inode the first metadata item that is tagged with @tag and diff --git a/src/test_support.c b/src/test_support.c index 91cb468c..a3434d5d 100644 --- a/src/test_support.c +++ b/src/test_support.c @@ -569,7 +569,7 @@ set_random_metadata(struct wim_inode *inode, struct generation_context *ctx) /* Security descriptor */ if (randbool()) { - char desc[8192] _aligned_attribute(8); + char desc[8192] __attribute__((aligned(8))); size_t size; size = generate_random_security_descriptor(desc, ctx); diff --git a/src/win32_apply.c b/src/win32_apply.c index 5011efff..70211cd3 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -1244,7 +1244,7 @@ remove_conflicting_short_name(const struct wim_dentry *dentry, struct win32_appl HANDLE h; size_t bufsize = offsetof(FILE_NAME_INFORMATION, FileName) + (13 * sizeof(wchar_t)); - u8 buf[bufsize] _aligned_attribute(8); + u8 buf[bufsize] __attribute__((aligned(8))); bool retried = false; FILE_NAME_INFORMATION *info = (FILE_NAME_INFORMATION *)buf; @@ -1326,7 +1326,7 @@ set_short_name(HANDLE h, const struct wim_dentry *dentry, size_t bufsize = offsetof(FILE_NAME_INFORMATION, FileName) + max(dentry->d_short_name_nbytes, sizeof(wchar_t)) + sizeof(wchar_t); - u8 buf[bufsize] _aligned_attribute(8); + u8 buf[bufsize] __attribute__((aligned(8))); FILE_NAME_INFORMATION *info = (FILE_NAME_INFORMATION *)buf; NTSTATUS status; bool tried_to_remove_existing = false; @@ -1634,7 +1634,7 @@ create_empty_streams(const struct wim_dentry *dentry, if (strm->stream_type == STREAM_TYPE_REPARSE_POINT && ctx->common.supported_features.reparse_points) { - u8 buf[REPARSE_DATA_OFFSET] _aligned_attribute(8); + u8 buf[REPARSE_DATA_OFFSET] __attribute__((aligned(8))); struct reparse_buffer_disk *rpbuf = (struct reparse_buffer_disk *)buf; complete_reparse_point(rpbuf, inode, 0); @@ -1843,7 +1843,7 @@ create_link(HANDLE h, const struct wim_dentry *dentry, size_t bufsize = offsetof(FILE_LINK_INFORMATION, FileName) + ctx->pathbuf.Length + sizeof(wchar_t); - u8 buf[bufsize] _aligned_attribute(8); + u8 buf[bufsize] __attribute__((aligned(8))); FILE_LINK_INFORMATION *info = (FILE_LINK_INFORMATION *)buf; NTSTATUS status; @@ -2832,7 +2832,7 @@ set_xattrs(HANDLE h, const struct wim_inode *inode, struct win32_apply_ctx *ctx) u32 len; const struct wim_xattr_entry *entry; size_t bufsize = 0; - u8 _buf[1024] _aligned_attribute(4); + u8 _buf[1024] __attribute__((aligned(4))); u8 *buf = _buf; FILE_FULL_EA_INFORMATION *ea, *ea_prev; NTSTATUS status; diff --git a/src/win32_capture.c b/src/win32_capture.c index f9fae537..331a0dce 100644 --- a/src/win32_capture.c +++ b/src/win32_capture.c @@ -330,7 +330,7 @@ read_winnt_stream_prefix(const struct windows_file *file, }; HANDLE h; NTSTATUS status; - u8 buf[BUFFER_SIZE] _aligned_attribute(8); + u8 buf[BUFFER_SIZE] __attribute__((aligned(8))); u64 bytes_remaining; int ret; @@ -512,7 +512,7 @@ winnt_get_short_name(HANDLE h, struct wim_dentry *dentry) * course has to create its own handle. */ NTSTATUS status; IO_STATUS_BLOCK iosb; - u8 buf[128] _aligned_attribute(8); + u8 buf[128] __attribute__((aligned(8))); const FILE_NAME_INFORMATION *info; status = NtQueryInformationFile(h, &iosb, buf, sizeof(buf), @@ -537,7 +537,7 @@ winnt_load_security_descriptor(HANDLE h, struct wim_inode *inode, struct winnt_scan_ctx *ctx) { SECURITY_INFORMATION requestedInformation; - u8 _buf[4096] _aligned_attribute(8); + u8 _buf[4096] __attribute__((aligned(8))); u8 *buf; ULONG bufsize; ULONG len_needed; @@ -705,7 +705,7 @@ winnt_load_xattrs(HANDLE h, struct wim_inode *inode, { IO_STATUS_BLOCK iosb; NTSTATUS status; - u8 _buf[1024] _aligned_attribute(4); + u8 _buf[1024] __attribute__((aligned(4))); u8 *buf = _buf; const FILE_FULL_EA_INFORMATION *ea; struct wim_xattr_entry *entry; @@ -1331,7 +1331,7 @@ winnt_scan_data_streams(HANDLE h, struct wim_inode *inode, u64 file_size, struct winnt_scan_ctx *ctx) { int ret; - u8 _buf[4096] _aligned_attribute(8); + u8 _buf[4096] __attribute__((aligned(8))); u8 *buf; size_t bufsize; IO_STATUS_BLOCK iosb; @@ -1654,7 +1654,8 @@ get_file_info(HANDLE h, struct file_info *info) static void get_volume_information(HANDLE h, struct winnt_scan_ctx *ctx) { - u8 _attr_info[sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 128] _aligned_attribute(8); + u8 _attr_info[sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 128] + __attribute__((aligned(8))); FILE_FS_ATTRIBUTE_INFORMATION *attr_info = (void *)_attr_info; FILE_FS_VOLUME_INFORMATION vol_info; struct file_info file_info; diff --git a/src/xpress_decompress.c b/src/xpress_decompress.c index d6e606cb..5d7d5086 100644 --- a/src/xpress_decompress.c +++ b/src/xpress_decompress.c @@ -84,7 +84,7 @@ struct xpress_decompressor { }; DECODE_TABLE_WORKING_SPACE(working_space, XPRESS_NUM_SYMBOLS, XPRESS_MAX_CODEWORD_LEN); -} _aligned_attribute(DECODE_TABLE_ALIGNMENT); +} __attribute__((aligned(DECODE_TABLE_ALIGNMENT))); static int xpress_decompress(const void *restrict compressed_data, size_t compressed_size, -- 2.43.0