Replace __attribute__ with a macro from types.h

This commit is contained in:
Alex 2023-04-07 05:22:14 +03:00
parent 7fa3e91a53
commit 98c137566d
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
22 changed files with 69 additions and 69 deletions

View File

@ -19,7 +19,7 @@
#include <cpu.hpp>
extern "C" __attribute__((naked, used, no_stack_protector)) void SystemCallHandlerStub()
extern "C" __naked __used __no_stack_protector void SystemCallHandlerStub()
{
}

View File

@ -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]; }

View File

@ -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)));
}

View File

@ -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
{

View File

@ -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
{

View File

@ -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[];

View File

@ -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);

View File

@ -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]; }

View File

@ -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
{

View File

@ -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[];

View File

@ -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++)

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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
{

View File

@ -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);

View File

@ -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
{

View File

@ -55,7 +55,7 @@ namespace NetworkARP
uint32_t SenderIP;
uint48_t TargetMAC : 48;
uint32_t TargetIP;
} __attribute__((packed));
} __packed;
struct DiscoveredAddress
{

View File

@ -42,7 +42,7 @@ namespace NetworkDHCP
uint8_t ServerHostName[64];
uint8_t BootFileName[128];
uint8_t Options[64];
} __attribute__((packed));
} __packed;
enum DHCPOperation
{

View File

@ -36,7 +36,7 @@ namespace NetworkEthernet
uint48_t DestinationMAC : 48;
uint48_t SourceMAC : 48;
uint16_t Type;
} __attribute__((packed));
} __packed;
struct EthernetPacket
{

View File

@ -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
{

View File

@ -31,7 +31,7 @@ namespace NetworkUDP
uint16_t DestinationPort;
uint16_t Length;
uint16_t Checksum;
} __attribute__((packed));
} __packed;
struct UDPPacket
{

View File

@ -217,7 +217,7 @@ namespace PCI
uint8_t StartBus;
uint8_t EndBus;
uint32_t Reserved;
} __attribute__((packed));
} __packed;
class PCI
{