diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-23 04:07:12 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-23 04:07:12 +0200 |
| commit | fc67c4af554189c941c811486a0b2b21aa3f54ea (patch) | |
| tree | ddc7677c3bb1072c9b9fb85618b75c8ee172b377 /dev/kernel/NeKit/Macros.h | |
| parent | fbd1f65a2cd30b3b4ed3da236398ddcfc437ac47 (diff) | |
feat!(kernel): Rename NewKit to NeKit.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/NeKit/Macros.h')
| -rw-r--r-- | dev/kernel/NeKit/Macros.h | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/dev/kernel/NeKit/Macros.h b/dev/kernel/NeKit/Macros.h new file mode 100644 index 00000000..5147863a --- /dev/null +++ b/dev/kernel/NeKit/Macros.h @@ -0,0 +1,148 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +/***********************************************************************************/ +/// @file NeKit/Macros.h +/// @brief Core Types and Macros. +/***********************************************************************************/ + +#ifndef KIB +#define KIB(X) (Kernel::UInt64)((X) / 1024) +#endif + +#ifndef kib_cast +#define kib_cast(X) (Kernel::UInt64)((X) *1024) +#endif + +#ifndef MIB +#define MIB(X) (Kernel::UInt64)((Kernel::UInt64) KIB(X) / 1024) +#endif + +#ifndef mib_cast +#define mib_cast(X) (Kernel::UInt64)((Kernel::UInt64) kib_cast(X) * 1024) +#endif + +#ifndef GIB +#define GIB(X) (Kernel::UInt64)((Kernel::UInt64) MIB(X) / 1024) +#endif + +#ifndef gib_cast +#define gib_cast(X) (Kernel::UInt64)((Kernel::UInt64) mib_cast(X) * 1024) +#endif + +#ifndef TIB +#define TIB(X) (Kernel::UInt64)((Kernel::UInt64) GIB(X) / 1024) +#endif + +#ifndef tib_cast +#define tib_cast(X) ((Kernel::UInt64) gib_cast(X) * 1024) +#endif + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) \ + (((sizeof(a) / sizeof(*(a))) / (static_cast<Kernel::Size>(!(sizeof(a) % sizeof(*(a))))))) +#endif + +#define DEPRECATED ATTRIBUTE(deprecated) + +#ifndef ALIGN +#define ALIGN(X) __attribute__((aligned(X))) +#endif // #ifndef ALIGN + +#ifndef ATTRIBUTE +#define ATTRIBUTE(...) __attribute__((__VA_ARGS__)) +#endif // #ifndef ATTRIBUTE + +#ifndef __NE_VER__ +#define __NE_VER__ (2024) +#endif // !__NE_VER__ + +#ifndef EXTERN +#define EXTERN extern +#endif + +#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* e##NAME = VAL +#endif + +#ifndef END_STRING_ENUM +#define END_STRING_ENUM() } +#endif + +#ifndef RTL_ALLOCA +#define RTL_ALLOCA(sz) __builtin_alloca(sz) +#endif // #ifndef RTL_ALLOCA + +#ifndef CANT_REACH +#define CANT_REACH() __builtin_unreachable() +#endif + +#define kInvalidAddress 0xFBFBFBFBFBFBFBFB +#define kBadAddress 0x0000000000000000 +#define kMaxAddr 0xFFFFFFFFFFFFFFFF +#define kPathLen 0x100 + +#define PACKED ATTRIBUTE(packed) +#define NO_EXEC ATTRIBUTE(noexec) + +#define EXTERN extern +#define STATIC static + +#define CONST const + +#define STRINGIFY(X) #X +#define NE_UNUSED(X) ((Kernel::Void) X) + +#ifndef RGB +#define RGB(R, G, B) ((Kernel::UInt32)((0xFF << 24) | ((R) << 16) | ((G) << 8) | (B))) +#endif // !RGB + +#ifdef __NE_AMD64__ +#define dbg_break_point() asm volatile("int $3") +#else +#define dbg_break_point() ((Kernel::Void) 0) +#endif + +#define RTL_ENDIAN(address, value) \ + (((reinterpret_cast<Kernel::Char*>(address)[0]) == (value)) ? (Kernel::Endian::kEndianBig) \ + : (Kernel::Endian::kEndianLittle)) + +#define Yes true +#define No false + +#define YES true +#define NO false + +#define TRUE true +#define FALSE false + +#define BOOL Kernel::Boolean + +#ifdef RTL_INIT_OBJECT +#undef RTL_INIT_OBJECT +#endif // ifdef RTL_INIT_OBJECT + +#define RTL_INIT_OBJECT(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__) |
