diff options
| author | Amlal <amlalelmahrouss@icloud.com> | 2024-05-11 06:43:54 +0000 |
|---|---|---|
| committer | Amlal <amlalelmahrouss@icloud.com> | 2024-05-11 06:43:54 +0000 |
| commit | ca675beb41dba8d7d16c5793b55d1672f38be3b4 (patch) | |
| tree | c995ada42729ac2059a0ed87a4539d1a7e10b14a /Kernel/NewKit/Macros.hpp | |
| parent | 2b4a4792abf51487ab4a16106f9376f43acf381a (diff) | |
| parent | bc57a29a24b98b00ba17710ba84ec2188ab73504 (diff) | |
Merged in MHR-23 (pull request #12)
MHR-23: Merge work.
Diffstat (limited to 'Kernel/NewKit/Macros.hpp')
| -rw-r--r-- | Kernel/NewKit/Macros.hpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/Kernel/NewKit/Macros.hpp b/Kernel/NewKit/Macros.hpp new file mode 100644 index 00000000..7e9dc759 --- /dev/null +++ b/Kernel/NewKit/Macros.hpp @@ -0,0 +1,98 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#ifndef KIB +#define KIB(X) ((X) / 1024) +#endif + +#ifndef MIB +#define MIB(X) ((UInt64)KIB(X) / 1024) +#endif + +#ifndef GIB +#define GIB(X) ((UInt64)MIB(X) / 1024) +#endif + +#ifndef TIB +#define TIB(X) ((UInt64)GIB(X) / 1024) +#endif + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) \ + (((sizeof(a) / sizeof(*(a))) / \ + (static_cast<NewOS::Size>(!(sizeof(a) % sizeof(*(a))))))) +#endif + +#ifndef ALIGN +#define ALIGN(X) __attribute__((aligned(X))) +#endif // #ifndef ALIGN + +#ifndef ATTRIBUTE +#define ATTRIBUTE(X) __attribute__((X)) +#endif // #ifndef ATTRIBUTE + +#ifndef __MAHROUSS__ +#define __MAHROUSS__ (202401) +#endif // !__MAHROUSS__ + +#ifndef EXTERN_C +#define EXTERN_C extern "C" +#endif + +#ifndef MAKE_ENUM +#define MAKE_ENUM(NAME) \ + enum NAME \ + { +#endif + +#ifndef END_ENUM +#define END_ENUM() \ + } \ + ; +#endif + +#ifndef MAKE_STRING_ENUM +#define MAKE_STRING_ENUM(NAME) \ + namespace NAME \ + { +#endif + +#ifndef ENUM_STRING +#define ENUM_STRING(NAME, VAL) inline constexpr const char* NAME = VAL +#endif + +#ifndef END_STRING_ENUM +#define END_STRING_ENUM() } +#endif + +#ifndef Alloca +#define Alloca(Sz) __builtin_alloca(Sz) +#endif // #ifndef Alloca + +#ifndef CANT_REACH +#define CANT_REACH() __builtin_unreachable() +#endif + +#define kBadPtr 0xFBFBFBFBFBFBFBFB +#define kMaxAddr 0xFFFFFFFFFFFFFFFF +#define kPathLen 255 + +#define PACKED ATTRIBUTE(packed) +#define NO_EXEC ATTRIBUTE(noexec) + +#define EXTERN extern +#define STATIC static + +#define CONST const + +#define STRINGIFY(X) #X +#define NEWOS_UNUSED(X) ((void)X) + +#ifndef RGB +#define RGB(R, G, B) (UInt32)(0x##R##G##B) +#endif // !RGB |
