NeKernel dev
Loading...
Searching...
No Matches
Macros.h
Go to the documentation of this file.
1/* -------------------------------------------
2
3Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
4
5File: Macros.h
6Purpose: libsci Macros header.
7
8------------------------------------------- */
9
10#pragma once
11
12/***********************************************************************************/
15/***********************************************************************************/
16
17#include <hint/CompilerHint.h>
18
19#define ATTRIBUTE(X) __attribute__((X))
20
21#define IMPORT_CXX extern "C++"
22#define IMPORT_C extern "C"
23
24#define DEPRECATED ATTRIBUTE(deprecated)
25
26#define EXIT_SUCCESS (0)
27#define EXIT_FAILURE (1)
28
29#define FILE_MAX_LEN (256)
30
31#ifndef BOOL
32#define BOOL bool
33#endif
34
35typedef bool Bool;
36typedef bool Boolean;
37typedef void Void;
38
39#ifndef __cplusplus
40#define true (1)
41#define false (0)
42#endif
43
44#define YES true
45#define NO false
46
47typedef __UINT64_TYPE__ UInt64;
48typedef __UINT32_TYPE__ UInt32;
49typedef __UINT16_TYPE__ UInt16;
50typedef __UINT8_TYPE__ UInt8;
51
52typedef __SIZE_TYPE__ SizeT;
53
54typedef __INT64_TYPE__ SInt64;
55typedef __INT32_TYPE__ SInt32;
56typedef __INT16_TYPE__ SInt16;
57typedef __INT8_TYPE__ SInt8;
58
59typedef void* VoidPtr;
60typedef __UINTPTR_TYPE__ UIntPtr;
61typedef char Char;
62
63#ifdef __cplusplus
64typedef decltype(nullptr) nullPtr;
65typedef nullPtr NullPtr;
66
67#define LIBSYS_COPY_DELETE(KLASS) \
68 KLASS& operator=(const KLASS&) = delete; \
69 KLASS(const KLASS&) = delete;
70
71#define LIBSYS_COPY_DEFAULT(KLASS) \
72 KLASS& operator=(const KLASS&) = default; \
73 KLASS(const KLASS&) = default;
74
75#define LIBSYS_MOVE_DELETE(KLASS) \
76 KLASS& operator=(KLASS&&) = delete; \
77 KLASS(KLASS&&) = delete;
78
79#define LIBSYS_MOVE_DEFAULT(KLASS) \
80 KLASS& operator=(KLASS&&) = default; \
81 KLASS(KLASS&&) = default;
82
83#endif
84
85#define MUST_PASS(X) _rtl_assert(X, __FILE__)
86
87#ifndef ARRAY_SIZE
88#define ARRAY_SIZE(X) \
89 (((sizeof(X) / sizeof(*(X))) / (static_cast<SizeT>(!(sizeof(X) % sizeof(*(X)))))))
90#endif
91
92#ifndef KIB
93#define KIB(X) (UInt64)((X) / 1024)
94#endif
95
96#ifndef kib_cast
97#define kib_cast(X) (UInt64)((X) *1024)
98#endif
99
100#ifndef MIB
101#define MIB(X) (UInt64)((UInt64) KIB(X) / 1024)
102#endif
103
104#ifndef mib_cast
105#define mib_cast(X) (UInt64)((UInt64) kib_cast(X) * 1024)
106#endif
107
108#ifndef GIB
109#define GIB(X) (UInt64)((UInt64) MIB(X) / 1024)
110#endif
111
112#ifndef gib_cast
113#define gib_cast(X) (UInt64)((UInt64) mib_cast(X) * 1024)
114#endif
115
116#ifndef TIB
117#define TIB(X) (UInt64)((UInt64) GIB(X) / 1024)
118#endif
119
120#ifndef tib_cast
121#define tib_cast(X) ((UInt64) gib_cast(X) * 1024)
122#endif
123
124#define LIBSYS_UNUSED(X) ((void) X)
125
126IMPORT_C void _rtl_assert(Bool expr, const Char* origin);
__UINT32_TYPE__ UInt32
Definition Macros.h:48
__UINT16_TYPE__ UInt16
Definition Macros.h:49
void * VoidPtr
Definition Macros.h:59
__INT64_TYPE__ SInt64
Definition Macros.h:54
__INT8_TYPE__ SInt8
Definition Macros.h:57
__INT16_TYPE__ SInt16
Definition Macros.h:56
#define IMPORT_C
Definition Macros.h:22
IMPORT_C void _rtl_assert(Bool expr, const Char *origin)
Definition SystemCalls.cc:87
__INT32_TYPE__ SInt32
Definition Macros.h:55
__UINT8_TYPE__ UInt8
Definition Macros.h:50