From 7ea1d4b2b13053963001c7348b1f8eec8233c377 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Tue, 29 Nov 2022 05:19:35 +0400 Subject: [PATCH] Rewrite macros (#121) --- .gitignore | 1 + ChangeLog | 7 +++ README.md | 3 +- bindings/mruby/src/dynarg.h | 11 +++- bindings/ruby/ext/default/assert.c | 2 +- bindings/ruby/ext/default/dynarg.h | 11 +++- bindings/ruby/ext/default/ntoa.c | 16 +++--- bindings/ruby/ext/default/printf.c | 2 +- examples/Makefile.am | 8 +++ examples/macro_packing.c | 25 ++++++++ include/kernaux/arch/i386.h | 16 +++--- include/kernaux/asm/x86.h | 13 +++-- include/kernaux/drivers/shutdown.h | 4 +- include/kernaux/elf.h | 8 +-- include/kernaux/macro.h | 52 ++++++++++++----- include/kernaux/mbr.h | 6 +- include/kernaux/multiboot2.h.in | 76 ++++++++++++------------- src/drivers/console.c | 4 +- src/drivers/framebuffer.c | 3 +- src/drivers/shutdown.c | 2 +- tests/multiboot2_header_example2.h | 2 +- tests/multiboot2_info_example2.h | 2 +- tests/printf_gen.jinja | 3 +- tests/test_memmap.c | 5 +- tests/test_multiboot2_info_helpers.c | 6 +- tests/test_multiboot2_info_validation.c | 60 +++++++++---------- tests/test_pfa_assert.c | 10 ++-- 27 files changed, 222 insertions(+), 136 deletions(-) create mode 100644 examples/macro_packing.c diff --git a/.gitignore b/.gitignore index 06373609..28708de1 100644 --- a/.gitignore +++ b/.gitignore @@ -111,6 +111,7 @@ /examples/generic_mutex /examples/macro_bits /examples/macro_container_of +/examples/macro_packing /examples/memmap /examples/ntoa /examples/panic diff --git a/ChangeLog b/ChangeLog index 5edaf275..d6a0adea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2022-11-29 Alex Kotov + + * include/kernaux/macro.h: Rename macro "KERNAUX_PACKING_ATTR" to + "KERNAUX_PACKED" + * include/kernaux/macro.h: Add macros "KERNAUX_UNUSED", "KERNAUX_NORETURN", + "KERNAUX_RETURNS_TWICE", "KERNAUX_ASM" + 2022-11-26 Alex Kotov libkernaux 0.5.0 released diff --git a/README.md b/README.md index 783e1d85..91a18d6f 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,8 @@ zero). Work-in-progress APIs can change at any time. * Basic features * [Feature macros](/include/kernaux/version.h.in) (*work in progress*) - * [Macros](/include/kernaux/macro.h) (*non-breaking since* **0.5.0**) + * [Macros](/include/kernaux/macro.h) (*non-breaking since* **?.?.?**) + * [Example: packing](/examples/macro_packing.c) * [Example: CONTAINER_OF](/examples/macro_container_of.c) * [Example: BITS](/examples/macro_bits.c) * [Assertions](/include/kernaux/assert.h) (*non-breaking since* **0.4.0**) diff --git a/bindings/mruby/src/dynarg.h b/bindings/mruby/src/dynarg.h index e6f70c0e..239751ee 100644 --- a/bindings/mruby/src/dynarg.h +++ b/bindings/mruby/src/dynarg.h @@ -7,6 +7,10 @@ extern "C" { #include +#include + +#include + struct DynArg { bool use_dbl; double dbl; @@ -16,8 +20,11 @@ struct DynArg { long long ll; const char *str; unsigned long long ull; - } __attribute__((packed)) arg; -}; + } KERNAUX_PACKED arg; +} +KERNAUX_PACKED; + +#include struct DynArg DynArg_create(); void DynArg_init(struct DynArg *dynarg); diff --git a/bindings/ruby/ext/default/assert.c b/bindings/ruby/ext/default/assert.c index ac7d56cb..b4a33408 100644 --- a/bindings/ruby/ext/default/assert.c +++ b/bindings/ruby/ext/default/assert.c @@ -40,7 +40,7 @@ VALUE rb_KernAux_assert_cb_EQ(const VALUE self, const VALUE assert_cb_rb) } VALUE rb_KernAux_assert_do( - const VALUE self_rb __attribute__((unused)), + const VALUE self_rb KERNAUX_UNUSED, VALUE file_rb, const VALUE line_rb, VALUE msg_rb diff --git a/bindings/ruby/ext/default/dynarg.h b/bindings/ruby/ext/default/dynarg.h index e6f70c0e..239751ee 100644 --- a/bindings/ruby/ext/default/dynarg.h +++ b/bindings/ruby/ext/default/dynarg.h @@ -7,6 +7,10 @@ extern "C" { #include +#include + +#include + struct DynArg { bool use_dbl; double dbl; @@ -16,8 +20,11 @@ struct DynArg { long long ll; const char *str; unsigned long long ull; - } __attribute__((packed)) arg; -}; + } KERNAUX_PACKED arg; +} +KERNAUX_PACKED; + +#include struct DynArg DynArg_create(); void DynArg_init(struct DynArg *dynarg); diff --git a/bindings/ruby/ext/default/ntoa.c b/bindings/ruby/ext/default/ntoa.c index 251243da..208ea24f 100644 --- a/bindings/ruby/ext/default/ntoa.c +++ b/bindings/ruby/ext/default/ntoa.c @@ -138,7 +138,7 @@ VALUE rb_KernAux_itoa(const int argc, const VALUE *argv, const VALUE self) } VALUE rb_KernAux_utoa2( - const VALUE self_rb __attribute__((unused)), + const VALUE self_rb KERNAUX_UNUSED, const VALUE number_rb ) { const uint64_t number = NUM2ULL(number_rb); @@ -151,7 +151,7 @@ VALUE rb_KernAux_utoa2( } VALUE rb_KernAux_itoa2( - const VALUE self_rb __attribute__((unused)), + const VALUE self_rb KERNAUX_UNUSED, const VALUE number_rb ) { const int64_t number = NUM2LL(number_rb); @@ -161,7 +161,7 @@ VALUE rb_KernAux_itoa2( } VALUE rb_KernAux_utoa8( - const VALUE self_rb __attribute__((unused)), + const VALUE self_rb KERNAUX_UNUSED, const VALUE number_rb ) { const uint64_t number = NUM2ULL(number_rb); @@ -174,7 +174,7 @@ VALUE rb_KernAux_utoa8( } VALUE rb_KernAux_itoa8( - const VALUE self_rb __attribute__((unused)), + const VALUE self_rb KERNAUX_UNUSED, const VALUE number_rb ) { const int64_t number = NUM2LL(number_rb); @@ -184,7 +184,7 @@ VALUE rb_KernAux_itoa8( } VALUE rb_KernAux_utoa10( - const VALUE self_rb __attribute__((unused)), + const VALUE self_rb KERNAUX_UNUSED, const VALUE number_rb ) { const uint64_t number = NUM2ULL(number_rb); @@ -197,7 +197,7 @@ VALUE rb_KernAux_utoa10( } VALUE rb_KernAux_itoa10( - const VALUE self_rb __attribute__((unused)), + const VALUE self_rb KERNAUX_UNUSED, const VALUE number_rb ) { const int64_t number = NUM2LL(number_rb); @@ -207,7 +207,7 @@ VALUE rb_KernAux_itoa10( } VALUE rb_KernAux_utoa16( - const VALUE self_rb __attribute__((unused)), + const VALUE self_rb KERNAUX_UNUSED, const VALUE number_rb ) { const uint64_t number = NUM2ULL(number_rb); @@ -220,7 +220,7 @@ VALUE rb_KernAux_utoa16( } VALUE rb_KernAux_itoa16( - const VALUE self_rb __attribute__((unused)), + const VALUE self_rb KERNAUX_UNUSED, const VALUE number_rb ) { const int64_t number = NUM2LL(number_rb); diff --git a/bindings/ruby/ext/default/printf.c b/bindings/ruby/ext/default/printf.c index bed82fae..873b6b06 100644 --- a/bindings/ruby/ext/default/printf.c +++ b/bindings/ruby/ext/default/printf.c @@ -68,7 +68,7 @@ void init_printf() VALUE rb_KernAux_snprintf1( const int argc, const VALUE *const argv_rb, - const VALUE self __attribute__((unused)) + const VALUE self KERNAUX_UNUSED ) { if (argc < 2 || argc > 5) rb_raise(rb_eArgError, "expected 2, 3, 4 or 5 args"); diff --git a/examples/Makefile.am b/examples/Makefile.am index d3f56ac5..550b7ebe 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -53,6 +53,14 @@ TESTS += macro_container_of macro_container_of_LDADD = $(top_builddir)/libkernaux.la macro_container_of_SOURCES = main.c macro_container_of.c +################# +# macro_packing # +################# + +TESTS += macro_packing +macro_packing_LDADD = $(top_builddir)/libkernaux.la +macro_packing_SOURCES = main.c macro_packing.c + ########## # memmap # ########## diff --git a/examples/macro_packing.c b/examples/macro_packing.c new file mode 100644 index 00000000..eaf38bd8 --- /dev/null +++ b/examples/macro_packing.c @@ -0,0 +1,25 @@ +#include + +#include +#include + +struct Foo { + uint8_t a; + uint32_t b; +}; + +#include + +struct Bar { + uint8_t a; + uint32_t b; +} +KERNAUX_PACKED; + +#include + +void example_main() +{ + assert(sizeof(struct Foo) > 5); + assert(sizeof(struct Bar) == 5); +} diff --git a/include/kernaux/arch/i386.h b/include/kernaux/arch/i386.h index 277f1390..748adae9 100644 --- a/include/kernaux/arch/i386.h +++ b/include/kernaux/arch/i386.h @@ -60,7 +60,7 @@ struct KernAux_Arch_I386_DTR { uint16_t size; uint32_t offset; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_DTR, 6); @@ -83,7 +83,7 @@ struct KernAux_Arch_I386_DTE { unsigned gran : 1; unsigned base_high : 8; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; // Interrupt descriptor table entry // TODO: validate this according to spec @@ -94,7 +94,7 @@ typedef struct KernAux_Arch_I386_IDTE { uint8_t flags; uint16_t offset_high; } -KERNAUX_PACKING_ATTR +KERNAUX_PACKED *KernAux_Arch_I386_IDTE; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_DTE, 8); @@ -153,7 +153,7 @@ struct KernAux_Arch_I386_TSS { uint16_t _zero11; uint16_t io_map_base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_TSS, 104); @@ -171,7 +171,7 @@ struct KernAux_Arch_I386_PDE { unsigned available1 : 4; unsigned addr : 20; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_PDE, 4); @@ -190,7 +190,7 @@ struct KernAux_Arch_I386_PTE { unsigned available : 3; unsigned addr : 20; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_PDE, 4); @@ -198,7 +198,7 @@ KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_PDE, 4); struct KernAux_Arch_I386_PageDir { struct KernAux_Arch_I386_PDE pdes[KERNAUX_ARCH_I386_PAGE_DIR_ENTRIES_COUNT]; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_PageDir, KERNAUX_ARCH_I386_PAGE_SIZE); @@ -206,7 +206,7 @@ KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_PageDir, KERNAUX_ARCH_I386_PAG struct KernAux_Arch_I386_PageTable { struct KernAux_Arch_I386_PTE ptes[KERNAUX_ARCH_I386_PAGE_TABLE_ENTRIES_COUNT]; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_PageTable, KERNAUX_ARCH_I386_PAGE_SIZE); diff --git a/include/kernaux/asm/x86.h b/include/kernaux/asm/x86.h index c225fb4b..f7365e78 100644 --- a/include/kernaux/asm/x86.h +++ b/include/kernaux/asm/x86.h @@ -6,6 +6,7 @@ extern "C" { #endif #include +#include #include @@ -20,37 +21,37 @@ inline static void kernaux_asm_x86_outportd(uint16_t port, uint32_t value); uint8_t kernaux_asm_x86_inportb(const uint16_t port) { register uint8_t result; - __asm__ volatile("inb %1, %0" : "=a" (result) : "dN" (port)); + KERNAUX_ASM("inb %1, %0" : "=a" (result) : "dN" (port)); return result; } uint16_t kernaux_asm_x86_inportw(const uint16_t port) { register uint16_t result; - __asm__ volatile("inw %1, %0" : "=a" (result) : "dN" (port)); + KERNAUX_ASM("inw %1, %0" : "=a" (result) : "dN" (port)); return result; } uint32_t kernaux_asm_x86_inportd(const uint16_t port) { register uint32_t result; - __asm__ volatile("inl %1, %0" : "=a" (result) : "dN" (port)); + KERNAUX_ASM("inl %1, %0" : "=a" (result) : "dN" (port)); return result; } void kernaux_asm_x86_outportb(const uint16_t port, const uint8_t value) { - __asm__ volatile("outb %1, %0" : : "dN" (port), "a" (value)); + KERNAUX_ASM("outb %1, %0" : : "dN" (port), "a" (value)); } void kernaux_asm_x86_outportw(const uint16_t port, const uint16_t value) { - __asm__ volatile("outw %1, %0" : : "dN" (port), "a" (value)); + KERNAUX_ASM("outw %1, %0" : : "dN" (port), "a" (value)); } void kernaux_asm_x86_outportd(const uint16_t port, const uint32_t value) { - __asm__ volatile("outl %1, %0" : : "dN" (port), "a" (value)); + KERNAUX_ASM("outl %1, %0" : : "dN" (port), "a" (value)); } #ifdef __cplusplus diff --git a/include/kernaux/drivers/shutdown.h b/include/kernaux/drivers/shutdown.h index 353bf8cf..4be02ddb 100644 --- a/include/kernaux/drivers/shutdown.h +++ b/include/kernaux/drivers/shutdown.h @@ -5,7 +5,9 @@ extern "C" { #endif -__attribute__((noreturn)) +#include + +KERNAUX_NORETURN void kernaux_drivers_shutdown_halt(); void kernaux_drivers_shutdown_poweroff(); diff --git a/include/kernaux/elf.h b/include/kernaux/elf.h index 05bb3188..5fde2266 100644 --- a/include/kernaux/elf.h +++ b/include/kernaux/elf.h @@ -36,7 +36,7 @@ struct KernAux_ELF_Header { unsigned sect_entr_num : 16; unsigned sect_names_idx : 16; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_ELF_Header, 52); @@ -50,7 +50,7 @@ struct KernAux_ELF_ProgramEntry { unsigned flags : 32; unsigned align : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_ELF_ProgramEntry, 32); @@ -66,7 +66,7 @@ struct KernAux_ELF_SectionEntry { unsigned alignment : 32; unsigned ent_size : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_ELF_SectionEntry, 40); @@ -74,7 +74,7 @@ struct KernAux_ELF_RelocationEntry { unsigned virt_addr : 32; unsigned info : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_ELF_RelocationEntry, 8); diff --git a/include/kernaux/macro.h b/include/kernaux/macro.h index 0c35c90e..a6e8217d 100644 --- a/include/kernaux/macro.h +++ b/include/kernaux/macro.h @@ -8,17 +8,25 @@ extern "C" { #include #include -#define KERNAUX_EOF (-1) +/********************* + * Language features * + *********************/ -#define KERNAUX_CONTAINER_OF(ptr, type, member) \ - ((type*)((uintptr_t)(ptr) - offsetof(type, member))) +#define KERNAUX_UNUSED __attribute__((unused)) +#define KERNAUX_NORETURN __attribute__((noreturn)) +#define KERNAUX_RETURNS_TWICE __attribute__((returns_twice)) -#define KERNAUX_BITS(n) (1u << (n)) +#ifdef __TINYC__ +# define KERNAUX_PACKED +#else +# define KERNAUX_PACKED __attribute__((packed)) +#endif -#define KERNAUX_BITS8(n) ((uint8_t )(((uint8_t )1) << (n))) -#define KERNAUX_BITS16(n) ((uint16_t)(((uint16_t)1) << (n))) -#define KERNAUX_BITS32(n) ((uint32_t)(((uint32_t)1) << (n))) -#define KERNAUX_BITS64(n) ((uint64_t)(((uint64_t)1) << (n))) +#define KERNAUX_ASM(...) do { __asm__ __volatile__(__VA_ARGS__); } while (0) + +/************** + * Visibility * + **************/ #ifdef KERNAUX_ACCESS_PRIVATE # define KERNAUX_PRIVATE_FIELD(id) id @@ -33,11 +41,9 @@ extern "C" { # endif #endif // KERNAUX_ACCESS_PRIVATE -#ifdef __TINYC__ -# define KERNAUX_PACKING_ATTR -#else -# define KERNAUX_PACKING_ATTR __attribute__((packed)) -#endif +/********************* + * Static assertions * + *********************/ #define KERNAUX_STATIC_TEST_STRUCT_SIZE(name, size) \ __attribute__((unused)) \ @@ -46,6 +52,26 @@ _kernaux_static_test_struct_size_##name[ \ sizeof(struct name) == (size) ? 1 : -1 \ ] +/***************** + * Simple values * + *****************/ + +#define KERNAUX_EOF (-1) + +/********************* + * Calculated values * + *********************/ + +#define KERNAUX_CONTAINER_OF(ptr, type, member) \ + ((type*)((uintptr_t)(ptr) - offsetof(type, member))) + +#define KERNAUX_BITS(n) (1u << (n)) + +#define KERNAUX_BITS8(n) ((uint8_t )(((uint8_t )1) << (n))) +#define KERNAUX_BITS16(n) ((uint16_t)(((uint16_t)1) << (n))) +#define KERNAUX_BITS32(n) ((uint32_t)(((uint32_t)1) << (n))) +#define KERNAUX_BITS64(n) ((uint64_t)(((uint64_t)1) << (n))) + #ifdef __cplusplus } #endif diff --git a/include/kernaux/mbr.h b/include/kernaux/mbr.h index 04f9e1a8..4ffc15fe 100644 --- a/include/kernaux/mbr.h +++ b/include/kernaux/mbr.h @@ -27,7 +27,7 @@ struct KernAux_Mbr_Entry { uint32_t first_sector_lba_addr; uint32_t sectors_count; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Mbr_Entry, 16); @@ -37,7 +37,7 @@ struct KernAux_Mbr_Info { struct KernAux_Mbr_Entry entries[KERNAUX_MBR_ENTRIES]; uint16_t magic; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE( KernAux_Mbr_Info, @@ -48,7 +48,7 @@ struct KernAux_Mbr { uint8_t bootstrap[KERNAUX_MBR_BOOTSTRAP_SIZE]; struct KernAux_Mbr_Info info; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE( KernAux_Mbr, diff --git a/include/kernaux/multiboot2.h.in b/include/kernaux/multiboot2.h.in index b2a38db3..660b193c 100644 --- a/include/kernaux/multiboot2.h.in +++ b/include/kernaux/multiboot2.h.in @@ -58,7 +58,7 @@ struct KernAux_Multiboot2_Header { unsigned total_size : 32; unsigned checksum : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_Header, 16); @@ -81,7 +81,7 @@ struct KernAux_Multiboot2_HTagBase { unsigned flags : 16; unsigned size : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTagBase, 8); @@ -93,7 +93,7 @@ struct KernAux_Multiboot2_Info { unsigned total_size : 32; unsigned reserved1 : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_Info, 8); @@ -126,7 +126,7 @@ struct KernAux_Multiboot2_ITagBase { enum KernAux_Multiboot2_ITag type : 32; unsigned size : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITagBase, 8); @@ -150,7 +150,7 @@ struct KernAux_Multiboot2_ITag_MemoryMap_EntryBase { unsigned type : 32; unsigned reserved1 : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_MemoryMap_EntryBase, 24); @@ -163,7 +163,7 @@ struct KernAux_Multiboot2_HTag_None { // size = 8 struct KernAux_Multiboot2_HTagBase base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTag_None, 8); @@ -172,7 +172,7 @@ struct KernAux_Multiboot2_HTag_InfoReq { // size > 8 struct KernAux_Multiboot2_HTagBase base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTag_InfoReq, 8); @@ -186,7 +186,7 @@ struct KernAux_Multiboot2_HTag_Addr { unsigned load_end_addr : 32; unsigned bss_end_addr : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTag_Addr, 24); @@ -197,7 +197,7 @@ struct KernAux_Multiboot2_HTag_EntryAddr { unsigned entry_addr : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTag_EntryAddr, 12); @@ -208,7 +208,7 @@ struct KernAux_Multiboot2_HTag_Flags { unsigned console_flags : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTag_Flags, 12); @@ -221,7 +221,7 @@ struct KernAux_Multiboot2_HTag_Framebuffer { unsigned height : 32; unsigned depth : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTag_Framebuffer, 20); @@ -230,7 +230,7 @@ struct KernAux_Multiboot2_HTag_ModuleAlign { // size = 8 struct KernAux_Multiboot2_HTagBase base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTag_ModuleAlign, 8); @@ -239,7 +239,7 @@ struct KernAux_Multiboot2_HTag_EFIBootServices { // size = 8 struct KernAux_Multiboot2_HTagBase base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTag_EFIBootServices, 8); @@ -250,7 +250,7 @@ struct KernAux_Multiboot2_HTag_EFII386EntryAddr { unsigned entry_addr : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTag_EFII386EntryAddr, 12); @@ -261,7 +261,7 @@ struct KernAux_Multiboot2_HTag_EFIAmd64EntryAddr { unsigned entry_addr : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTag_EFIAmd64EntryAddr, 12); @@ -275,7 +275,7 @@ struct KernAux_Multiboot2_HTag_RelocatableHeader { unsigned align : 32; enum KernAux_Multiboot2_HTag_RelocatableHeader_Preference preferences : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_HTag_RelocatableHeader, 24); @@ -288,7 +288,7 @@ struct KernAux_Multiboot2_ITag_None { // size = 8 struct KernAux_Multiboot2_ITagBase base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_None, 8); @@ -297,7 +297,7 @@ struct KernAux_Multiboot2_ITag_BootCmdLine { // size > 8 struct KernAux_Multiboot2_ITagBase base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_BootCmdLine, 8); @@ -306,7 +306,7 @@ struct KernAux_Multiboot2_ITag_BootLoaderName { // size > 8 struct KernAux_Multiboot2_ITagBase base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_BootLoaderName, 8); @@ -318,7 +318,7 @@ struct KernAux_Multiboot2_ITag_Module { unsigned mod_start : 32; unsigned mod_end : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_Module, 16); @@ -330,7 +330,7 @@ struct KernAux_Multiboot2_ITag_BasicMemoryInfo { unsigned mem_lower : 32; unsigned mem_upper : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_BasicMemoryInfo, 16); @@ -343,7 +343,7 @@ struct KernAux_Multiboot2_ITag_BIOSBootDevice { unsigned partition : 32; unsigned sub_partition : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_BIOSBootDevice, 20); @@ -355,7 +355,7 @@ struct KernAux_Multiboot2_ITag_MemoryMap { unsigned entry_size : 32; unsigned entry_version : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_MemoryMap, 16); @@ -371,7 +371,7 @@ struct KernAux_Multiboot2_ITag_VBEInfo { unsigned char vbe_control_info[512]; unsigned char vbe_mode_info[256]; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_VBEInfo, 784); @@ -388,7 +388,7 @@ struct KernAux_Multiboot2_ITag_FramebufferInfo { unsigned framebuffer_type : 8; unsigned reserved1 : 8; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_FramebufferInfo, 31); @@ -402,7 +402,7 @@ struct KernAux_Multiboot2_ITag_ELFSymbols { unsigned shndx : 16; unsigned reserved1 : 16; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_ELFSymbols, 16); @@ -421,7 +421,7 @@ struct KernAux_Multiboot2_ITag_APMTable { unsigned cseg_16_len : 16; unsigned dseg_len : 16; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_APMTable, 28); @@ -432,7 +432,7 @@ struct KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr { unsigned pointer : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_EFI32bitSystemTablePtr, 12); @@ -443,7 +443,7 @@ struct KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr { unsigned long long pointer : 64; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_EFI64bitSystemTablePtr, 16); @@ -456,7 +456,7 @@ struct KernAux_Multiboot2_ITag_SMBIOSTables { unsigned minor : 8; unsigned char reserved1[6]; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_SMBIOSTables, 16); @@ -465,7 +465,7 @@ struct KernAux_Multiboot2_ITag_ACPIOldRSDP { // size > 8 struct KernAux_Multiboot2_ITagBase base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_ACPIOldRSDP, 8); @@ -474,7 +474,7 @@ struct KernAux_Multiboot2_ITag_ACPINewRSDP { // size > 8 struct KernAux_Multiboot2_ITagBase base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_ACPINewRSDP, 8); @@ -483,7 +483,7 @@ struct KernAux_Multiboot2_ITag_NetworkingInfo { // size > 8 struct KernAux_Multiboot2_ITagBase base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_NetworkingInfo, 8); @@ -495,7 +495,7 @@ struct KernAux_Multiboot2_ITag_EFIMemoryMap { unsigned descriptor_size : 32; unsigned descriptor_version : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Multiboot2_ITag_EFIMemoryMap, 16); @@ -504,7 +504,7 @@ struct KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated { // size = 8 struct KernAux_Multiboot2_ITagBase base; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE( KernAux_Multiboot2_ITag_EFIBootServicesNotTerminated, @@ -518,7 +518,7 @@ struct KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr { unsigned pointer : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE( KernAux_Multiboot2_ITag_EFI32bitImageHandlePtr, @@ -532,7 +532,7 @@ struct KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr { unsigned long long pointer : 64; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE( KernAux_Multiboot2_ITag_EFI64bitImageHandlePtr, @@ -546,7 +546,7 @@ struct KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr { unsigned load_base_addr : 32; } -KERNAUX_PACKING_ATTR; +KERNAUX_PACKED; KERNAUX_STATIC_TEST_STRUCT_SIZE( KernAux_Multiboot2_ITag_ImageLoadBasePhysAddr, diff --git a/src/drivers/console.c b/src/drivers/console.c index e4831261..49839a3c 100644 --- a/src/drivers/console.c +++ b/src/drivers/console.c @@ -22,7 +22,7 @@ static void file_putc(char c, void *arg); #endif -void kernaux_drivers_console_putc(const char c __attribute__((unused))) +void kernaux_drivers_console_putc(const char c KERNAUX_UNUSED) { #ifdef ASM_X86 kernaux_asm_x86_outportb(0x3f8, c); @@ -68,7 +68,7 @@ void kernaux_drivers_console_write(const char *const data, const size_t size) } #ifdef WITH_PRINTF -void file_putc(char c, void *arg __attribute__((unused))) +void file_putc(char c, void *arg KERNAUX_UNUSED) { kernaux_drivers_console_putc(c); } diff --git a/src/drivers/framebuffer.c b/src/drivers/framebuffer.c index c25bb09f..106863bf 100644 --- a/src/drivers/framebuffer.c +++ b/src/drivers/framebuffer.c @@ -3,6 +3,7 @@ #endif #include +#include -__attribute__((unused)) +KERNAUX_UNUSED static const int foobar = 0; diff --git a/src/drivers/shutdown.c b/src/drivers/shutdown.c index c25ad304..f0975751 100644 --- a/src/drivers/shutdown.c +++ b/src/drivers/shutdown.c @@ -9,7 +9,7 @@ void kernaux_drivers_shutdown_halt() { #ifdef ASM_X86 // Disable interrupts - __asm__ __volatile__("cli"); + KERNAUX_ASM("cli"); #endif volatile int x = 0; diff --git a/tests/multiboot2_header_example2.h b/tests/multiboot2_header_example2.h index cc6538b9..6bd4af92 100644 --- a/tests/multiboot2_header_example2.h +++ b/tests/multiboot2_header_example2.h @@ -34,7 +34,7 @@ static const struct { struct KernAux_Multiboot2_HTag_RelocatableHeader tag_relocatable_header; struct KernAux_Multiboot2_HTag_None tag_none; -} KERNAUX_PACKING_ATTR multiboot2_header_example2 = { +} KERNAUX_PACKED multiboot2_header_example2 = { .multiboot2_header = { .magic = KERNAUX_MULTIBOOT2_HEADER_MAGIC, .arch = KERNAUX_MULTIBOOT2_HEADER_ARCH_I386, diff --git a/tests/multiboot2_info_example2.h b/tests/multiboot2_info_example2.h index 3a3883b8..fe9c1dcc 100644 --- a/tests/multiboot2_info_example2.h +++ b/tests/multiboot2_info_example2.h @@ -105,7 +105,7 @@ static const struct { uint8_t _align11[4]; struct KernAux_Multiboot2_ITag_None tag_none; -} KERNAUX_PACKING_ATTR multiboot2_info_example2 = { +} KERNAUX_PACKED multiboot2_info_example2 = { .multiboot2_info = { .total_size = sizeof(multiboot2_info_example2), .reserved1 = 0, diff --git a/tests/printf_gen.jinja b/tests/printf_gen.jinja index 3b4127d4..a30db42d 100644 --- a/tests/printf_gen.jinja +++ b/tests/printf_gen.jinja @@ -4,6 +4,7 @@ #define KERNAUX_ACCESS_PROTECTED +#include #include #include @@ -19,7 +20,7 @@ static const char *const data = "foobar"; static char buffer[BUFFER_SIZE]; static size_t buffer_index; -static void test_putc(char c, __attribute__((unused)) void *arg) +static void test_putc(char c, KERNAUX_UNUSED void *arg) { if (buffer_index >= BUFFER_SIZE) { printf("Buffer overflow!\n"); diff --git a/tests/test_memmap.c b/tests/test_memmap.c index 00d72ca5..5ec44fe4 100644 --- a/tests/test_memmap.c +++ b/tests/test_memmap.c @@ -5,6 +5,7 @@ #define KERNAUX_ACCESS_PRIVATE #include +#include #include #include @@ -21,8 +22,8 @@ static const char *assert_last_file = NULL; static void assert_cb( const char *const file, - __attribute__((unused)) const int line, - __attribute__((unused)) const char *const msg + const int line KERNAUX_UNUSED, + const char *const msg KERNAUX_UNUSED ) { ++assert_count_ctr; assert_last_file = file; diff --git a/tests/test_multiboot2_info_helpers.c b/tests/test_multiboot2_info_helpers.c index 42a7b663..536aefd4 100644 --- a/tests/test_multiboot2_info_helpers.c +++ b/tests/test_multiboot2_info_helpers.c @@ -15,7 +15,7 @@ static const struct { struct KernAux_Multiboot2_Info multiboot2_info; struct KernAux_Multiboot2_ITag_None tag_none; -} KERNAUX_PACKING_ATTR multiboot2_without_boot_cmd_line = { +} KERNAUX_PACKED multiboot2_without_boot_cmd_line = { .multiboot2_info = { .total_size = sizeof(multiboot2_without_boot_cmd_line), .reserved1 = 0, @@ -39,7 +39,7 @@ static const struct { unsigned char _align1[2]; struct KernAux_Multiboot2_ITag_None tag_none; -} KERNAUX_PACKING_ATTR multiboot2_with_some_boot_cmd_line = { +} KERNAUX_PACKED multiboot2_with_some_boot_cmd_line = { .multiboot2_info = { .total_size = sizeof(multiboot2_with_some_boot_cmd_line), .reserved1 = 0, @@ -81,7 +81,7 @@ static const struct { unsigned char _align2[3]; struct KernAux_Multiboot2_ITag_None tag_none; -} KERNAUX_PACKING_ATTR multiboot2_with_two_boot_cmd_lines = { +} KERNAUX_PACKED multiboot2_with_two_boot_cmd_lines = { .multiboot2_info = { .total_size = sizeof(multiboot2_with_two_boot_cmd_lines), .reserved1 = 0, diff --git a/tests/test_multiboot2_info_validation.c b/tests/test_multiboot2_info_validation.c index d0a1396d..8ccd9ebd 100644 --- a/tests/test_multiboot2_info_validation.c +++ b/tests/test_multiboot2_info_validation.c @@ -44,7 +44,7 @@ static const struct KernAux_Multiboot2_ITag_None tag_none_invalid_size = { static const struct { struct KernAux_Multiboot2_ITag_BootCmdLine tag; char cmdline[1]; -} KERNAUX_PACKING_ATTR tag_boot_cmd_line_with_empty_cmdline_valid = { +} KERNAUX_PACKED tag_boot_cmd_line_with_empty_cmdline_valid = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE, @@ -57,7 +57,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_BootCmdLine tag; char cmdline[14]; -} KERNAUX_PACKING_ATTR tag_boot_cmd_line_with_some_cmdline_valid = { +} KERNAUX_PACKED tag_boot_cmd_line_with_some_cmdline_valid = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE, @@ -70,7 +70,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_BootCmdLine tag; char cmdline[1]; -} KERNAUX_PACKING_ATTR tag_boot_cmd_line_invalid_type = { +} KERNAUX_PACKED tag_boot_cmd_line_invalid_type = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_NONE, @@ -83,7 +83,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_BootCmdLine tag; char cmdline[1]; -} KERNAUX_PACKING_ATTR tag_boot_cmd_line_with_empty_cmdline_invalid_size = { +} KERNAUX_PACKED tag_boot_cmd_line_with_empty_cmdline_invalid_size = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE, @@ -96,7 +96,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_BootCmdLine tag; char cmdline[14]; -} KERNAUX_PACKING_ATTR tag_boot_cmd_line_with_some_cmdline_invalid_size = { +} KERNAUX_PACKED tag_boot_cmd_line_with_some_cmdline_invalid_size = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_BOOT_CMD_LINE, @@ -113,7 +113,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_BootLoaderName tag; char name[1]; -} KERNAUX_PACKING_ATTR tag_boot_loader_name_with_empty_name_valid = { +} KERNAUX_PACKED tag_boot_loader_name_with_empty_name_valid = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_BOOT_LOADER_NAME, @@ -126,7 +126,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_BootLoaderName tag; char name[14]; -} KERNAUX_PACKING_ATTR tag_boot_loader_name_with_some_name_valid = { +} KERNAUX_PACKED tag_boot_loader_name_with_some_name_valid = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_BOOT_LOADER_NAME, @@ -139,7 +139,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_BootLoaderName tag; char name[1]; -} KERNAUX_PACKING_ATTR tag_boot_loader_name_invalid_type = { +} KERNAUX_PACKED tag_boot_loader_name_invalid_type = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_NONE, @@ -152,7 +152,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_BootLoaderName tag; char name[1]; -} KERNAUX_PACKING_ATTR tag_boot_loader_name_with_empty_name_invalid_size = { +} KERNAUX_PACKED tag_boot_loader_name_with_empty_name_invalid_size = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_BOOT_LOADER_NAME, @@ -165,7 +165,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_BootLoaderName tag; char name[14]; -} KERNAUX_PACKING_ATTR tag_boot_loader_name_with_some_name_invalid_size = { +} KERNAUX_PACKED tag_boot_loader_name_with_some_name_invalid_size = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_BOOT_LOADER_NAME, @@ -182,7 +182,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_Module tag; char cmdline[1]; -} KERNAUX_PACKING_ATTR tag_module_with_empty_name_valid = { +} KERNAUX_PACKED tag_module_with_empty_name_valid = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_MODULE, @@ -197,7 +197,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_Module tag; char cmdline[14]; -} KERNAUX_PACKING_ATTR tag_module_with_some_name_valid = { +} KERNAUX_PACKED tag_module_with_some_name_valid = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_MODULE, @@ -212,7 +212,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_Module tag; char cmdline[1]; -} KERNAUX_PACKING_ATTR tag_module_invalid_type = { +} KERNAUX_PACKED tag_module_invalid_type = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_NONE, @@ -227,7 +227,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_Module tag; char cmdline[1]; -} KERNAUX_PACKING_ATTR tag_module_with_empty_name_invalid_size = { +} KERNAUX_PACKED tag_module_with_empty_name_invalid_size = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_MODULE, @@ -242,7 +242,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_Module tag; char cmdline[14]; -} KERNAUX_PACKING_ATTR tag_module_with_some_name_invalid_size = { +} KERNAUX_PACKED tag_module_with_some_name_invalid_size = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_MODULE, @@ -257,7 +257,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_Module tag; char cmdline[14]; -} KERNAUX_PACKING_ATTR tag_module_with_equal_start_end_invalid = { +} KERNAUX_PACKED tag_module_with_equal_start_end_invalid = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_MODULE, @@ -272,7 +272,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_Module tag; char cmdline[14]; -} KERNAUX_PACKING_ATTR tag_module_with_reversed_start_end_invalid = { +} KERNAUX_PACKED tag_module_with_reversed_start_end_invalid = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_MODULE, @@ -372,7 +372,7 @@ tag_memory_map_with_empty_data_valid = { static const struct { struct KernAux_Multiboot2_ITag_MemoryMap tag; unsigned char data[8 * 2]; -} KERNAUX_PACKING_ATTR tag_memory_map_with_some_small_data_items_valid = { +} KERNAUX_PACKED tag_memory_map_with_some_small_data_items_valid = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_MEMORY_MAP, @@ -386,7 +386,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_MemoryMap tag; unsigned char data[64 * 2]; -} KERNAUX_PACKING_ATTR tag_memory_map_with_some_large_data_items_valid = { +} KERNAUX_PACKED tag_memory_map_with_some_large_data_items_valid = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_MEMORY_MAP, @@ -420,7 +420,7 @@ tag_memory_map_with_empty_data_invalid_size = { static const struct { struct KernAux_Multiboot2_ITag_MemoryMap tag; unsigned char data[64 * 2 + 1]; -} KERNAUX_PACKING_ATTR tag_memory_map_with_some_large_data_items_invalid_size = { +} KERNAUX_PACKED tag_memory_map_with_some_large_data_items_invalid_size = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_MEMORY_MAP, @@ -454,7 +454,7 @@ tag_memory_map_with_empty_data_invalid_entry_size_not_mul8 = { static const struct { struct KernAux_Multiboot2_ITag_MemoryMap tag; unsigned char data[9 * 2]; -} KERNAUX_PACKING_ATTR tag_memory_map_with_some_small_data_items_invalid_entry_size_not_mul8 = { +} KERNAUX_PACKED tag_memory_map_with_some_small_data_items_invalid_entry_size_not_mul8 = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_MEMORY_MAP, @@ -468,7 +468,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_ITag_MemoryMap tag; unsigned char data[63 * 2]; -} KERNAUX_PACKING_ATTR tag_memory_map_with_some_large_data_items_invalid_entry_size_not_mul8 = { +} KERNAUX_PACKED tag_memory_map_with_some_large_data_items_invalid_entry_size_not_mul8 = { .tag = { .base = { .type = KERNAUX_MULTIBOOT2_ITAG_MEMORY_MAP, @@ -548,7 +548,7 @@ tag_elf_symbols_with_zero_ent_size_valid = { static const struct { struct KernAux_Multiboot2_Info multiboot2_info; struct KernAux_Multiboot2_ITag_None tag_none; -} KERNAUX_PACKING_ATTR multiboot2_empty_valid = { +} KERNAUX_PACKED multiboot2_empty_valid = { .multiboot2_info = { .total_size = 8 + 8, .reserved1 = 0, @@ -565,7 +565,7 @@ static const struct { struct KernAux_Multiboot2_Info multiboot2_info; struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info; struct KernAux_Multiboot2_ITag_None tag_none; -} KERNAUX_PACKING_ATTR multiboot2_with_some_additional_tag_valid = { +} KERNAUX_PACKED multiboot2_with_some_additional_tag_valid = { .multiboot2_info = { .total_size = 8 + 16 + 8, .reserved1 = 0, @@ -592,7 +592,7 @@ static const struct { struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device; unsigned char _align1[4]; struct KernAux_Multiboot2_ITag_None tag_none; -} KERNAUX_PACKING_ATTR multiboot2_with_more_additional_tags_valid = { +} KERNAUX_PACKED multiboot2_with_more_additional_tags_valid = { .multiboot2_info = { .total_size = 8 + 16 + (20 + 4) + 8, .reserved1 = 0, @@ -625,7 +625,7 @@ static const struct { static const struct { struct KernAux_Multiboot2_Info multiboot2_info; struct KernAux_Multiboot2_ITag_None tag_none; -} KERNAUX_PACKING_ATTR multiboot2_empty_invalid_size = { +} KERNAUX_PACKED multiboot2_empty_invalid_size = { .multiboot2_info = { .total_size = 8, .reserved1 = 0, @@ -647,7 +647,7 @@ multiboot2_without_none_tag_invalid = { static const struct { struct KernAux_Multiboot2_Info multiboot2_info; struct KernAux_Multiboot2_ITag_BasicMemoryInfo tag_basic_memory_info; -} KERNAUX_PACKING_ATTR multiboot2_with_invalid_last_tag_invalid = { +} KERNAUX_PACKED multiboot2_with_invalid_last_tag_invalid = { .multiboot2_info = { .total_size = 8 + 16, .reserved1 = 0, @@ -669,7 +669,7 @@ static const struct { struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device; unsigned char _align1[4]; struct KernAux_Multiboot2_ITag_None tag_none2; -} KERNAUX_PACKING_ATTR multiboot2_with_early_none_tag_invalid = { +} KERNAUX_PACKED multiboot2_with_early_none_tag_invalid = { .multiboot2_info = { .total_size = 8 + 16 + 8 + (20 + 4) + 8, .reserved1 = 0, @@ -711,7 +711,7 @@ static const struct { struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device; unsigned char _align1[4]; struct KernAux_Multiboot2_ITag_None tag_none; -} KERNAUX_PACKING_ATTR multiboot2_with_more_additional_tags_invalid_size_too_big = { +} KERNAUX_PACKED multiboot2_with_more_additional_tags_invalid_size_too_big = { .multiboot2_info = { .total_size = 8 + 16 + (20 + 4) + 8 + 1, .reserved1 = 0, @@ -747,7 +747,7 @@ static const struct { struct KernAux_Multiboot2_ITag_BIOSBootDevice tag_bios_boot_device; unsigned char _align1[4]; struct KernAux_Multiboot2_ITag_None tag_none; -} KERNAUX_PACKING_ATTR multiboot2_with_more_additional_tags_invalid_size_too_small = { +} KERNAUX_PACKED multiboot2_with_more_additional_tags_invalid_size_too_small = { .multiboot2_info = { .total_size = 8 + 16 + (20 + 4) + 8 - 1, .reserved1 = 0, diff --git a/tests/test_pfa_assert.c b/tests/test_pfa_assert.c index 00ae6977..885217f7 100644 --- a/tests/test_pfa_assert.c +++ b/tests/test_pfa_assert.c @@ -3,6 +3,7 @@ #endif #include +#include #include #include @@ -14,12 +15,9 @@ static unsigned int count = 0; static jmp_buf jmpbuf; static void assert_cb( - __attribute__((unused)) - const char *const file, - __attribute__((unused)) - const int line, - __attribute__((unused)) - const char *const str + const char *const file KERNAUX_UNUSED, + const int line KERNAUX_UNUSED, + const char *const str KERNAUX_UNUSED ) { ++count; longjmp(jmpbuf, 1);