Update preprocessor macros

This commit is contained in:
Rafal Kupiec 2024-02-28 23:11:45 +01:00
parent 632bb30b64
commit 4b34f7db4b
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 21 additions and 10 deletions

View File

@ -18,6 +18,7 @@
#define XTFASTCALL __fastcall #define XTFASTCALL __fastcall
#define XTINLINE __inline #define XTINLINE __inline
#define XTASSEMBLY __attribute__((naked)) #define XTASSEMBLY __attribute__((naked))
#define XTINTERRUPT __attribute__((interrupt))
/* Variable modifiers */ /* Variable modifiers */
#define CONST const #define CONST const
@ -43,13 +44,18 @@
/* Number of bits per byte */ /* Number of bits per byte */
#define BITS_PER_BYTE 8 #define BITS_PER_BYTE 8
/* Preprocessor macros for defining a structure alignment, packing and segment */ /* Preprocessor macros for defining an additional compiler attributes */
#define ALIGN(x) __attribute__((aligned(x))) #define ALIGN(Alignment) __attribute__((aligned(Alignment)))
#define PACK __attribute__((packed)) #define PACK __attribute__((packed))
#define SEGMENT(segment) __attribute__((section(segment))) #define SEGMENT(Segment) __attribute__((section(Segment)))
#define USED __attribute__((__used__))
/* Macro for calculating size of an array */ /* Macro for calculating size of an array */
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x)) #define ARRAY_SIZE(Array) (sizeof(Array) / sizeof(*Array))
/* Macro for concatenating two strings */
#define CONCAT_STRING(Str1, Str2) Str1##Str2
#define CONCATENATE(Str1, Str2) CONCAT_STRING(Str1, Str2)
/* Macro for accessing the base address of a structure from a structure member */ /* Macro for accessing the base address of a structure from a structure member */
#define CONTAIN_RECORD(Address, Type, Field) ((Type *)(((ULONG_PTR)Address) - (ULONG_PTR)(&(((Type *)0)->Field)))) #define CONTAIN_RECORD(Address, Type, Field) ((Type *)(((ULONG_PTR)Address) - (ULONG_PTR)(&(((Type *)0)->Field))))
@ -73,10 +79,10 @@
#define PAGE_OFFSET(VirtualAddress) ((ULONG)((ULONG_PTR)VirtualAddress & MM_PAGE_MASK)) #define PAGE_OFFSET(VirtualAddress) ((ULONG)((ULONG_PTR)VirtualAddress & MM_PAGE_MASK))
/* Macro for rounding down */ /* Macro for rounding down */
#define ROUND_DOWN(X, Alignment) ((X) & ~((Alignment) - 1)) #define ROUND_DOWN(Value, Alignment) ((Value) & ~((Alignment) - 1))
/* Macro for rounding up */ /* Macro for rounding up */
#define ROUND_UP(X, Alignment) ROUND_DOWN((X) + (Alignment - 1), Alignment) #define ROUND_UP(Value, Alignment) ROUND_DOWN((Value) + (Alignment - 1), Alignment)
/* Macros for defining signatures built from ASCII characters */ /* Macros for defining signatures built from ASCII characters */
#define SIGNATURE16(A, B) ((A) | (B << 8)) #define SIGNATURE16(A, B) ((A) | (B << 8))
@ -86,6 +92,13 @@
/* XT size to pages conversion macro */ /* XT size to pages conversion macro */
#define SIZE_TO_PAGES(Size) (((Size) >> MM_PAGE_SHIFT) + (((Size) & (MM_PAGE_MASK)) ? 1 : 0)) #define SIZE_TO_PAGES(Size) (((Size) >> MM_PAGE_SHIFT) + (((Size) & (MM_PAGE_MASK)) ? 1 : 0))
/* Macros for concatenating strings */
#define STRINGIFY(String...) STRINGIZE(String)
#define STRINGIZE(String...) #String
/* Macro for generating unique identifiers */
#define UNIQUE(Prefix) CONCATENATE(CONCATENATE(__UNIQUE_ID_, Prefix), __COUNTER__)
/* Variadic ABI functions */ /* Variadic ABI functions */
typedef __builtin_va_list VA_LIST, *PVA_LIST; typedef __builtin_va_list VA_LIST, *PVA_LIST;
#define VA_ARG(Marker, Type) ((sizeof (Type) < sizeof(UINT_PTR)) ? \ #define VA_ARG(Marker, Type) ((sizeof (Type) < sizeof(UINT_PTR)) ? \

View File

@ -11,10 +11,8 @@
/* Preprocessor macros for including arch-specific headers */ /* Preprocessor macros for including arch-specific headers */
#define _ARCH_STRINGIZE(x) _INCL_STRINGIZE(x) #define ARCH_COMMON(header) STRINGIFY(../_ARCH_COMMON/header)
#define _INCL_STRINGIZE(x) #x #define ARCH_HEADER(header) STRINGIFY(_ARCH/header)
#define ARCH_COMMON(header) _ARCH_STRINGIZE(../_ARCH_COMMON/header)
#define ARCH_HEADER(header) _ARCH_STRINGIZE(_ARCH/header)
/* Architecture specific definitions */ /* Architecture specific definitions */
#if defined(__i386__) || defined(__i686__) #if defined(__i386__) || defined(__i686__)