From 98c137566dbb6d28653af3d040c6dc7b26fbb643 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 7 Apr 2023 05:22:14 +0300 Subject: [PATCH] Replace __attribute__ with a macro from types.h --- Architecture/aarch64/SystemCalls.cpp | 2 +- .../aarch64/cpu/SymmetricMultiprocessing.cpp | 2 +- .../DifferentiatedSystemDescriptionTable.cpp | 2 +- Architecture/amd64/acpi.hpp | 22 +++++++++---------- Architecture/amd64/cpu/apic.hpp | 12 +++++----- Architecture/amd64/cpu/gdt.hpp | 16 +++++++------- Architecture/amd64/cpu/idt.hpp | 4 ++-- .../i386/cpu/SymmetricMultiprocessing.cpp | 2 +- Architecture/i386/cpu/apic.hpp | 12 +++++----- Architecture/i386/cpu/gdt.hpp | 16 +++++++------- Core/StackGuard.cpp | 10 ++++----- Library/Convert.cpp | 2 +- include/cpu.hpp | 10 ++++----- include/disk.hpp | 8 +++---- include/filesystem/fat.hpp | 2 +- include/memory.hpp | 4 ++-- include/net/arp.hpp | 2 +- include/net/dhcp.hpp | 2 +- include/net/eth.hpp | 2 +- include/net/ntp.hpp | 2 +- include/net/udp.hpp | 2 +- include/pci.hpp | 2 +- 22 files changed, 69 insertions(+), 69 deletions(-) diff --git a/Architecture/aarch64/SystemCalls.cpp b/Architecture/aarch64/SystemCalls.cpp index cfbfddb..aea8637 100644 --- a/Architecture/aarch64/SystemCalls.cpp +++ b/Architecture/aarch64/SystemCalls.cpp @@ -19,7 +19,7 @@ #include -extern "C" __attribute__((naked, used, no_stack_protector)) void SystemCallHandlerStub() +extern "C" __naked __used __no_stack_protector void SystemCallHandlerStub() { } diff --git a/Architecture/aarch64/cpu/SymmetricMultiprocessing.cpp b/Architecture/aarch64/cpu/SymmetricMultiprocessing.cpp index e664ae7..f6c89b9 100644 --- a/Architecture/aarch64/cpu/SymmetricMultiprocessing.cpp +++ b/Architecture/aarch64/cpu/SymmetricMultiprocessing.cpp @@ -26,7 +26,7 @@ volatile bool CPUEnabled = false; #pragma GCC diagnostic ignored "-Wmissing-field-initializers" -static __attribute__((aligned(PAGE_SIZE))) CPUData CPUs[MAX_CPU] = {0}; +static __aligned(0x1000) CPUData CPUs[MAX_CPU] = {0}; CPUData *GetCPU(uint64_t id) { return &CPUs[id]; } diff --git a/Architecture/amd64/DifferentiatedSystemDescriptionTable.cpp b/Architecture/amd64/DifferentiatedSystemDescriptionTable.cpp index 2d86b2b..3515ba5 100644 --- a/Architecture/amd64/DifferentiatedSystemDescriptionTable.cpp +++ b/Architecture/amd64/DifferentiatedSystemDescriptionTable.cpp @@ -36,7 +36,7 @@ namespace ACPI { - __attribute__((always_inline)) inline bool IsCanonical(uint64_t Address) + __always_inline inline bool IsCanonical(uint64_t Address) { return ((Address <= 0x00007FFFFFFFFFFF) || ((Address >= 0xFFFF800000000000) && (Address <= 0xFFFFFFFFFFFFFFFF))); } diff --git a/Architecture/amd64/acpi.hpp b/Architecture/amd64/acpi.hpp index e4931dd..f3b7093 100644 --- a/Architecture/amd64/acpi.hpp +++ b/Architecture/amd64/acpi.hpp @@ -41,7 +41,7 @@ namespace ACPI uint32_t OEMRevision; uint32_t CreatorID; uint32_t CreatorRevision; - } __attribute__((packed)); + } __packed; struct GenericAddressStructure { @@ -50,13 +50,13 @@ namespace ACPI uint8_t BitOffset; uint8_t AccessSize; uint64_t Address; - } __attribute__((packed)); + } __packed; struct MCFGHeader { struct ACPIHeader Header; uint64_t Reserved; - } __attribute__((packed)); + } __packed; struct HPETHeader { @@ -71,7 +71,7 @@ namespace ACPI uint8_t HPETNumber; uint16_t MinimumTick; uint8_t PageProtection; - } __attribute__((packed)); + } __packed; struct FADTHeader { @@ -127,7 +127,7 @@ namespace ACPI struct GenericAddressStructure X_PMTimerBlock; struct GenericAddressStructure X_GPE0Block; struct GenericAddressStructure X_GPE1Block; - } __attribute__((packed)); + } __packed; struct BGRTHeader { @@ -181,7 +181,7 @@ namespace ACPI uint32_t LocalControllerAddress; uint32_t Flags; char Entries[]; - } __attribute__((packed)); + } __packed; ACPIHeader *XSDT = nullptr; MCFGHeader *MCFG = nullptr; @@ -209,7 +209,7 @@ namespace ACPI { uint8_t Type; uint8_t Length; - } __attribute__((packed)); + } __packed; struct MADTIOApic { @@ -218,7 +218,7 @@ namespace ACPI uint8_t reserved; uint32_t Address; uint32_t GSIBase; - } __attribute__((packed)); + } __packed; struct MADTIso { @@ -227,7 +227,7 @@ namespace ACPI uint8_t IRQSource; uint32_t GSI; uint16_t Flags; - } __attribute__((packed)); + } __packed; struct MADTNmi { @@ -235,7 +235,7 @@ namespace ACPI uint8_t processor; uint16_t flags; uint8_t lint; - } __attribute__((packed)); + } __packed; struct LocalAPIC { @@ -243,7 +243,7 @@ namespace ACPI uint8_t ACPIProcessorId; uint8_t APICId; uint32_t Flags; - } __attribute__((packed)); + } __packed; struct LAPIC { diff --git a/Architecture/amd64/cpu/apic.hpp b/Architecture/amd64/cpu/apic.hpp index 00970d2..e93c33a 100644 --- a/Architecture/amd64/cpu/apic.hpp +++ b/Architecture/amd64/cpu/apic.hpp @@ -170,7 +170,7 @@ namespace APIC uint64_t Reserved2 : 14; }; uint64_t raw; - } __attribute__((packed)) LVTTimer; + } __packed LVTTimer; typedef union { @@ -190,7 +190,7 @@ namespace APIC uint64_t Reserved1 : 19; }; uint64_t raw; - } __attribute__((packed)) Spurious; + } __packed Spurious; typedef union { @@ -239,7 +239,7 @@ namespace APIC uint64_t Reserved2 : 12; }; uint64_t raw; - } __attribute__((packed)) InterruptCommandRegisterLow; + } __packed InterruptCommandRegisterLow; typedef union { @@ -251,7 +251,7 @@ namespace APIC uint64_t Destination : 8; }; uint64_t raw; - } __attribute__((packed)) InterruptCommandRegisterHigh; + } __packed InterruptCommandRegisterHigh; typedef union { @@ -298,7 +298,7 @@ namespace APIC uint64_t High; } split; uint64_t raw; - } __attribute__((packed)) IOAPICRedirectEntry; + } __packed IOAPICRedirectEntry; typedef union { @@ -310,7 +310,7 @@ namespace APIC uint64_t Reserved2 : 8; }; uint64_t raw; - } __attribute__((packed)) IOAPICVersion; + } __packed IOAPICVersion; class APIC { diff --git a/Architecture/amd64/cpu/gdt.hpp b/Architecture/amd64/cpu/gdt.hpp index 7a6d9d6..03b5699 100644 --- a/Architecture/amd64/cpu/gdt.hpp +++ b/Architecture/amd64/cpu/gdt.hpp @@ -68,7 +68,7 @@ namespace GlobalDescriptorTable * @details This bit must be 1 for all valid descriptors. */ uint8_t P : 1; - } __attribute__((packed)); + } __packed; uint8_t Raw; }; @@ -85,7 +85,7 @@ namespace GlobalDescriptorTable * @details If the long mode bit is set, the segment is in 64-bit long mode. */ uint8_t L : 1; - } __attribute__((packed)); + } __packed; uint8_t Raw; }; @@ -101,18 +101,18 @@ namespace GlobalDescriptorTable /* HIGH */ uint32_t BaseUpper; uint32_t Reserved; - } __attribute__((packed)) TaskStateSegmentEntry; + } __packed TaskStateSegmentEntry; typedef struct _TaskStateSegment { - uint32_t Reserved0 __attribute__((aligned(16))); + uint32_t Reserved0 __aligned(0x10); uint64_t StackPointer[3]; uint64_t Reserved1; uint64_t InterruptStackTable[7]; uint64_t Reserved2; uint16_t Reserved3; uint16_t IOMapBaseAddressOffset; - } __attribute__((packed)) TaskStateSegment; + } __packed TaskStateSegment; typedef struct _GlobalDescriptorTableEntry { @@ -128,7 +128,7 @@ namespace GlobalDescriptorTable GlobalDescriptorTableFlags Flags; /** @brief High Base */ uint8_t BaseHigh; - } __attribute__((packed)) GlobalDescriptorTableEntry; + } __packed GlobalDescriptorTableEntry; typedef struct _GlobalDescriptorTableEntries { @@ -138,7 +138,7 @@ namespace GlobalDescriptorTable GlobalDescriptorTableEntry UserData; GlobalDescriptorTableEntry UserCode; TaskStateSegmentEntry TaskStateSegment; - } __attribute__((packed)) GlobalDescriptorTableEntries; + } __packed GlobalDescriptorTableEntries; typedef struct _GlobalDescriptorTableDescriptor { @@ -146,7 +146,7 @@ namespace GlobalDescriptorTable uint16_t Length; /** @brief GDT entries address */ GlobalDescriptorTableEntries *Entries; - } __attribute__((packed)) GlobalDescriptorTableDescriptor; + } __packed GlobalDescriptorTableDescriptor; extern void *CPUStackPointer[]; extern TaskStateSegment tss[]; diff --git a/Architecture/amd64/cpu/idt.hpp b/Architecture/amd64/cpu/idt.hpp index 34590b1..15b10d8 100644 --- a/Architecture/amd64/cpu/idt.hpp +++ b/Architecture/amd64/cpu/idt.hpp @@ -48,13 +48,13 @@ namespace InterruptDescriptorTable uint64_t Present : 1; uint64_t BaseHigh : 48; uint64_t Reserved3 : 32; - } __attribute__((packed)) InterruptDescriptorTableEntry; + } __packed InterruptDescriptorTableEntry; typedef struct _InterruptDescriptorTableDescriptor { uint16_t Length; InterruptDescriptorTableEntry *Entries; - } __attribute__((packed)) InterruptDescriptorTableDescriptor; + } __packed InterruptDescriptorTableDescriptor; void SetEntry(uint8_t Index, void (*Base)(), InterruptDescriptorTableFlags Attribute, uint8_t InterruptStackTable, InterruptDescriptorTableFlags Ring, uint16_t SegmentSelector); void Init(int Core); diff --git a/Architecture/i386/cpu/SymmetricMultiprocessing.cpp b/Architecture/i386/cpu/SymmetricMultiprocessing.cpp index 06b25c3..a60692f 100644 --- a/Architecture/i386/cpu/SymmetricMultiprocessing.cpp +++ b/Architecture/i386/cpu/SymmetricMultiprocessing.cpp @@ -27,7 +27,7 @@ volatile bool CPUEnabled = false; #pragma GCC diagnostic ignored "-Wmissing-field-initializers" -static __attribute__((aligned(PAGE_SIZE))) CPUData CPUs[MAX_CPU] = {0}; +static __aligned(0x1000) CPUData CPUs[MAX_CPU] = {0}; CPUData *GetCPU(uint64_t id) { return &CPUs[id]; } diff --git a/Architecture/i386/cpu/apic.hpp b/Architecture/i386/cpu/apic.hpp index ac3f321..24887b4 100644 --- a/Architecture/i386/cpu/apic.hpp +++ b/Architecture/i386/cpu/apic.hpp @@ -170,7 +170,7 @@ namespace APIC uint64_t Reserved2 : 14; }; uint64_t raw; - } __attribute__((packed)) LVTTimer; + } __packed LVTTimer; typedef union { @@ -190,7 +190,7 @@ namespace APIC uint64_t Reserved1 : 19; }; uint64_t raw; - } __attribute__((packed)) Spurious; + } __packed Spurious; typedef union { @@ -239,7 +239,7 @@ namespace APIC uint64_t Reserved2 : 12; }; uint64_t raw; - } __attribute__((packed)) InterruptCommandRegisterLow; + } __packed InterruptCommandRegisterLow; typedef union { @@ -251,7 +251,7 @@ namespace APIC uint64_t Destination : 8; }; uint64_t raw; - } __attribute__((packed)) InterruptCommandRegisterHigh; + } __packed InterruptCommandRegisterHigh; typedef union { @@ -298,7 +298,7 @@ namespace APIC uint64_t High; } split; uint64_t raw; - } __attribute__((packed)) IOAPICRedirectEntry; + } __packed IOAPICRedirectEntry; typedef union { @@ -310,7 +310,7 @@ namespace APIC uint64_t Reserved2 : 8; }; uint64_t raw; - } __attribute__((packed)) IOAPICVersion; + } __packed IOAPICVersion; class APIC { diff --git a/Architecture/i386/cpu/gdt.hpp b/Architecture/i386/cpu/gdt.hpp index 9f9ce7e..94f8262 100644 --- a/Architecture/i386/cpu/gdt.hpp +++ b/Architecture/i386/cpu/gdt.hpp @@ -68,7 +68,7 @@ namespace GlobalDescriptorTable * @details This bit must be 1 for all valid descriptors. */ uint8_t P : 1; - } __attribute__((packed)); + } __packed; uint8_t Raw; }; @@ -85,7 +85,7 @@ namespace GlobalDescriptorTable * @details If the long mode bit is set, the segment is in 64-bit long mode. */ uint8_t L : 1; - } __attribute__((packed)); + } __packed; uint8_t Raw; }; @@ -101,17 +101,17 @@ namespace GlobalDescriptorTable /* HIGH */ uint32_t BaseUpper; uint32_t Reserved; - } __attribute__((packed)) TaskStateSegmentEntry; + } __packed TaskStateSegmentEntry; typedef struct _TaskStateSegment { - uint32_t Reserved0 __attribute__((aligned(16))); + uint32_t Reserved0 __aligned(0x10); uint64_t StackPointer[3]; uint64_t Reserved1; uint64_t InterruptStackTable[7]; uint16_t Reserved2; uint16_t IOMapBaseAddressOffset; - } __attribute__((packed)) TaskStateSegment; + } __packed TaskStateSegment; typedef struct _GlobalDescriptorTableEntry { @@ -127,7 +127,7 @@ namespace GlobalDescriptorTable GlobalDescriptorTableFlags Flags; /** @brief High Base */ uint8_t BaseHigh; - } __attribute__((packed)) GlobalDescriptorTableEntry; + } __packed GlobalDescriptorTableEntry; typedef struct _GlobalDescriptorTableEntries { @@ -137,7 +137,7 @@ namespace GlobalDescriptorTable GlobalDescriptorTableEntry UserData; GlobalDescriptorTableEntry UserCode; TaskStateSegmentEntry TaskStateSegment; - } __attribute__((packed)) GlobalDescriptorTableEntries; + } __packed GlobalDescriptorTableEntries; typedef struct _GlobalDescriptorTableDescriptor { @@ -145,7 +145,7 @@ namespace GlobalDescriptorTable uint16_t Length; /** @brief GDT entries address */ GlobalDescriptorTableEntries *Entries; - } __attribute__((packed)) GlobalDescriptorTableDescriptor; + } __packed GlobalDescriptorTableDescriptor; extern void *CPUStackPointer[]; extern TaskStateSegment tss[]; diff --git a/Core/StackGuard.cpp b/Core/StackGuard.cpp index 17ed961..1ce5944 100644 --- a/Core/StackGuard.cpp +++ b/Core/StackGuard.cpp @@ -21,9 +21,9 @@ #include "../kernel.h" -/* EXTERNC */ __attribute__((weak)) uintptr_t __stack_chk_guard = 0; +/* EXTERNC */ __weak uintptr_t __stack_chk_guard = 0; -EXTERNC __attribute__((weak, no_stack_protector)) uintptr_t __stack_chk_guard_init(void) +EXTERNC __weak __no_stack_protector uintptr_t __stack_chk_guard_init(void) { int MaxRetries = 0; #if UINTPTR_MAX == UINT32_MAX @@ -44,7 +44,7 @@ Retry: #endif } -EXTERNC __attribute__((constructor, no_stack_protector)) void __guard_setup(void) +EXTERNC __constructor __no_stack_protector void __guard_setup(void) { debug("StackGuard: __guard_setup"); if (__stack_chk_guard == 0) @@ -52,7 +52,7 @@ EXTERNC __attribute__((constructor, no_stack_protector)) void __guard_setup(void debug("Stack guard value: %ld", __stack_chk_guard); } -EXTERNC __attribute__((weak, noreturn, no_stack_protector)) void __stack_chk_fail(void) +EXTERNC __weak __noreturn __no_stack_protector void __stack_chk_fail(void) { TaskingPanic(); for (short i = 0; i < 10; i++) @@ -80,7 +80,7 @@ EXTERNC __attribute__((weak, noreturn, no_stack_protector)) void __stack_chk_fai } // https://github.com/gcc-mirror/gcc/blob/master/libssp/ssp.c -EXTERNC __attribute__((weak, noreturn, no_stack_protector)) void __chk_fail(void) +EXTERNC __weak __noreturn __no_stack_protector void __chk_fail(void) { TaskingPanic(); for (short i = 0; i < 10; i++) diff --git a/Library/Convert.cpp b/Library/Convert.cpp index 3acf34e..a1d2bc3 100644 --- a/Library/Convert.cpp +++ b/Library/Convert.cpp @@ -745,7 +745,7 @@ EXTERNC int log2(unsigned int n) return log + (n >> 1); } -EXTERNC void __chk_fail(void) __attribute__((__noreturn__)); +EXTERNC void __chk_fail(void) __noreturn; __noreturn __always_inline static inline void __convert_chk_fail(void) { diff --git a/include/cpu.hpp b/include/cpu.hpp index 4ce07dc..cc011eb 100644 --- a/include/cpu.hpp +++ b/include/cpu.hpp @@ -308,7 +308,7 @@ namespace CPU uint32_t Reserved2 : 32; }; uint32_t raw; - } __attribute__((packed)) EFER; + } __packed EFER; // ! TODO: UNTESTED! typedef union DR7 @@ -377,7 +377,7 @@ namespace CPU uint8_t st[8][16]; /** @brief XMM registers */ uint8_t xmm[16][16]; - } __attribute__((packed)); + } __packed; /** * @brief CPUID @@ -445,7 +445,7 @@ namespace CPU uint32_t ApicBaseHi : 32; }; uint64_t raw; - } __attribute__((packed)) APIC_BASE; + } __packed APIC_BASE; typedef union { @@ -555,7 +555,7 @@ namespace CPU uint64_t Reserved2 : 32; }; uint64_t raw; - } __attribute__((packed)) EFER; + } __packed EFER; // ! TODO: UNTESTED! typedef union DR7 @@ -674,7 +674,7 @@ namespace CPU uint8_t st[8][16]; /** @brief XMM registers */ uint8_t xmm[16][16]; - } __attribute__((packed)); + } __packed; SafeFunction static inline void lgdt(void *gdt) { diff --git a/include/disk.hpp b/include/disk.hpp index c40e14a..b357dc8 100644 --- a/include/disk.hpp +++ b/include/disk.hpp @@ -51,7 +51,7 @@ namespace Disk uint8_t CHSLast[3]; uint32_t LBAFirst; uint32_t Sectors; - } __attribute__((packed)); + } __packed; struct MasterBootRecord { @@ -60,7 +60,7 @@ namespace Disk uint16_t Reserved; MasterBootRecordPartition Partitions[4]; uint8_t Signature[2]; - } __attribute__((packed)); + } __packed; struct GUIDPartitionTablePartition { @@ -72,7 +72,7 @@ namespace Disk uint64_t EndLBA; uint64_t Attributes; char Label[72]; - } __attribute__((packed)); + } __packed; struct GUIDPartitionTable { @@ -91,7 +91,7 @@ namespace Disk uint32_t PartCount; uint32_t EntrySize; uint32_t PartCRC32; - } __attribute__((packed)); + } __packed; struct PartitionTable { diff --git a/include/filesystem/fat.hpp b/include/filesystem/fat.hpp index f3420aa..7781a40 100644 --- a/include/filesystem/fat.hpp +++ b/include/filesystem/fat.hpp @@ -66,7 +66,7 @@ namespace VirtualFileSystem uint32_t HiddenSectors; /** @brief Large sector count. This field is set if there are more than 65535 sectors in the volume, resulting in a value which does not fit in the Number of Sectors entry at 0x13. */ uint32_t Sectors32; - } __attribute__((__packed__)); + } __packed; FatType GetFATType(BIOSParameterBlock *bpb); FAT(void *partition); diff --git a/include/memory.hpp b/include/memory.hpp index 1938205..31f6e08 100644 --- a/include/memory.hpp +++ b/include/memory.hpp @@ -436,7 +436,7 @@ namespace Memory struct PageTable4 { PageMapLevel4 Entries[511]; - } __attribute__((aligned(0x1000))); + } __aligned(0x1000); struct __packed PageMapLevel5 { @@ -446,7 +446,7 @@ namespace Memory struct PageTable5 { PageMapLevel5 Entries[511]; - } __attribute__((aligned(0x1000))); + } __aligned(0x1000); class Physical { diff --git a/include/net/arp.hpp b/include/net/arp.hpp index a5bc973..ecc9f30 100644 --- a/include/net/arp.hpp +++ b/include/net/arp.hpp @@ -55,7 +55,7 @@ namespace NetworkARP uint32_t SenderIP; uint48_t TargetMAC : 48; uint32_t TargetIP; - } __attribute__((packed)); + } __packed; struct DiscoveredAddress { diff --git a/include/net/dhcp.hpp b/include/net/dhcp.hpp index 9fce8d1..6cca532 100644 --- a/include/net/dhcp.hpp +++ b/include/net/dhcp.hpp @@ -42,7 +42,7 @@ namespace NetworkDHCP uint8_t ServerHostName[64]; uint8_t BootFileName[128]; uint8_t Options[64]; - } __attribute__((packed)); + } __packed; enum DHCPOperation { diff --git a/include/net/eth.hpp b/include/net/eth.hpp index 8709ce5..4719695 100644 --- a/include/net/eth.hpp +++ b/include/net/eth.hpp @@ -36,7 +36,7 @@ namespace NetworkEthernet uint48_t DestinationMAC : 48; uint48_t SourceMAC : 48; uint16_t Type; - } __attribute__((packed)); + } __packed; struct EthernetPacket { diff --git a/include/net/ntp.hpp b/include/net/ntp.hpp index 2fd8494..20b79f7 100644 --- a/include/net/ntp.hpp +++ b/include/net/ntp.hpp @@ -139,7 +139,7 @@ namespace NetworkNTP * @note Only when the NTP authentication scheme is used */ // uint32_t MessageAuthenticationCode; - } __attribute__((packed)); + } __packed; class NTP : public NetworkUDP::UDPEvents { diff --git a/include/net/udp.hpp b/include/net/udp.hpp index 36aaeaa..7e95243 100644 --- a/include/net/udp.hpp +++ b/include/net/udp.hpp @@ -31,7 +31,7 @@ namespace NetworkUDP uint16_t DestinationPort; uint16_t Length; uint16_t Checksum; - } __attribute__((packed)); + } __packed; struct UDPPacket { diff --git a/include/pci.hpp b/include/pci.hpp index cf03ef0..24bfd1d 100644 --- a/include/pci.hpp +++ b/include/pci.hpp @@ -217,7 +217,7 @@ namespace PCI uint8_t StartBus; uint8_t EndBus; uint32_t Reserved; - } __attribute__((packed)); + } __packed; class PCI {