This commit is contained in:
nub31
2025-09-07 00:08:31 +02:00
parent 4f55956fee
commit 8cc90d6f2f
4 changed files with 34 additions and 36 deletions

View File

@@ -9,12 +9,6 @@ typedef struct
size_t length;
} memory_region_t;
typedef struct
{
memory_region_t* regions;
size_t num_regions;
} memory_map_t;
#define USABLE_REGION_SIZE 32
static memory_region_t usable_regions[USABLE_REGION_SIZE];

View File

@@ -1,13 +1,15 @@
#pragma once
#include <arch.h>
#include <printf.h>
// In arch code, make sure arch_api.panic is set up befire calling
// In arch code, make sure arch_api.panic and arch_api.console.putchar is set up befire calling
static inline void assert(bool condition, const char* msg)
{
#if DEBUG
if (!condition)
{
printf(msg);
arch_api.panic();
}
#endif

View File

@@ -31,41 +31,43 @@ typedef signed int i32;
typedef unsigned long long u64;
typedef signed long long i64;
#define INT8_MIN (-128)
#define INT8_MAX 127
#define UINT8_MAX 0xff
#define I8_MIN (-128)
#define I8_MAX 127
#define INT16_MIN (-32768)
#define INT16_MAX 32767
#define U8_MIN 0x0
#define U8_MAX 0xff
#define UINT16_MIN 0x0
#define UINT16_MAX 0xffff
#define I16_MIN (-32768)
#define I16_MAX 32767
#define INT32_MIN (-2147483647 - 1)
#define INT32_MAX 2147483647
#define U16_MIN 0x0
#define U16_MAX 0xffff
#define UINT32_MIN 0x0
#define UINT32_MAX 0xffffffffU
#define I32_MIN (-2147483647 - 1)
#define I32_MAX 2147483647
#define INT64_MIN (-9223372036854775807LL - 1)
#define INT64_MAX 9223372036854775807LL
#define U32_MIN 0x0
#define U32_MAX 0xffffffffU
#define UINT64_MIN 0x0
#define UINT64_MAX 0xffffffffffffffffULL
#define I64_MIN (-9223372036854775807LL - 1)
#define I64_MAX 9223372036854775807LL
#define INT8_C(x) x
#define UINT8_C(x) x##U
#define U64_MIN 0x0
#define U64_MAX 0xffffffffffffffffULL
#define INT16_C(x) x
#define UINT16_C(x) x##U
#define I8_C(x) x
#define U8_C(x) x##U
#define INT32_C(x) x
#define UINT32_C(x) x##U
#define I16_C(x) x
#define U16_C(x) x##U
#define INT64_C(x) x##LL
#define UINT64_C(x) x##ULL
#define I32_C(x) x
#define U32_C(x) x##U
#define KiB(count) (count * UINT64_C(count))
#define MiB(count) (KiB(count) * UINT64_C(count))
#define GiB(count) (MiB(count) * UINT64_C(count))
#define TiB(count) (GiB(count) * UINT64_C(count))
#define I64_C(x) x##LL
#define U64_C(x) x##ULL
#define KiB(count) (U64_C(count) * U64_C(1024))
#define MiB(count) (U64_C(count) * U64_C(1024) * U64_C(1024))
#define GiB(count) (U64_C(count) * U64_C(1024) * U64_C(1024) * U64_C(1024))
#define TiB(count) (U64_C(count) * U64_C(1024) * U64_C(1024) * U64_C(1024) * U64_C(1024))

View File

@@ -34,7 +34,7 @@ void itoa64(i64 value, char* buffer)
if (value < 0)
{
negative = 1;
if (value == INT64_MIN)
if (value == I64_MIN)
{
const char* min_str = "9223372036854775808";
for (i = 0; min_str[i] != '\0'; i++)
@@ -54,7 +54,7 @@ void itoa64(i64 value, char* buffer)
return;
}
if (!(negative && value == INT64_MIN))
if (!(negative && value == I64_MIN))
{
while (value > 0)
{