Commit: 9552e14d27258c9178e2061c9d14588e1744b076
Parent: fa440c98b5670e2d55bf0f4d0bf06002c4b4eef2
Author: Randy Palamar
Date: Tue, 27 Jan 2026 14:11:43 -0700
util: remove stdint.h/stddef.h
these are not that useful and in the case of glibc, include a
bunch of extra garbage when it is unexpected.
Diffstat:
| M | opengl.h | | | 8 | ++++---- |
| M | util.c | | | 6 | +++--- |
| M | util.h | | | 54 | ++++++++++++++++++++++++++++++++---------------------- |
3 files changed, 39 insertions(+), 29 deletions(-)
diff --git a/opengl.h b/opengl.h
@@ -71,10 +71,10 @@
#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
-typedef char GLchar;
-typedef ptrdiff_t GLsizeiptr;
-typedef ptrdiff_t GLintptr;
-typedef uint64_t GLuint64;
+typedef char GLchar;
+typedef i64 GLsizeiptr;
+typedef i64 GLintptr;
+typedef u64 GLuint64;
typedef struct __GLsync *GLsync;
/* X(name, ret, params) */
diff --git a/util.c b/util.c
@@ -37,7 +37,7 @@ memory_copy_non_temporal(void *restrict dest, void *restrict src, uz n)
assume(((u64)dest & 63) == 0);
assume(((u64)src & 63) == 0);
assume(((u64)n & 63) == 0);
- uint8_t *s = src, *d = dest;
+ u8 *s = src, *d = dest;
#if defined(__AVX512BW__)
{
@@ -97,7 +97,7 @@ arena_from_memory(void *memory, u64 size)
function void *
align_pointer_up(void *p, uz alignment)
{
- uz padding = -(uintptr_t)p & (alignment - 1);
+ uz padding = -(u64)p & (alignment - 1);
void *result = (u8 *)p + padding;
return result;
}
@@ -178,7 +178,7 @@ function Arena
sub_arena_end(Arena *a, iz len, uz align)
{
Arena result;
- result.beg = (u8 *)((uintptr_t)(a->end - len) & ~(align - 1)),
+ result.beg = (u8 *)((u64)(a->end - len) & ~(align - 1)),
result.end = a->end,
a->end = result.beg;
diff --git a/util.h b/util.h
@@ -4,8 +4,36 @@
#include "compiler.h"
-#include <stddef.h>
-#include <stdint.h>
+#if COMPILER_MSVC
+ typedef unsigned __int64 u64;
+ typedef signed __int64 i64;
+ typedef unsigned __int32 u32;
+ typedef signed __int32 i32;
+ typedef unsigned __int16 u16;
+ typedef signed __int16 i16;
+ typedef unsigned __int8 u8;
+ typedef signed __int8 i8;
+#else
+ typedef __UINT64_TYPE__ u64;
+ typedef __INT64_TYPE__ i64;
+ typedef __UINT32_TYPE__ u32;
+ typedef __INT32_TYPE__ i32;
+ typedef __UINT16_TYPE__ u16;
+ typedef __INT16_TYPE__ i16;
+ typedef __UINT8_TYPE__ u8;
+ typedef __INT8_TYPE__ i8;
+#endif
+
+typedef char c8;
+typedef u8 b8;
+typedef u16 b16;
+typedef u32 b32;
+typedef float f32;
+typedef double f64;
+typedef i64 iz;
+typedef u64 uz;
+typedef i64 iptr;
+typedef u64 uptr;
#ifndef asm
#define asm __asm__
@@ -47,8 +75,8 @@
#define ASSERT assert
#if ASAN_ACTIVE
- void __asan_poison_memory_region(void *, ptrdiff_t);
- void __asan_unpoison_memory_region(void *, ptrdiff_t);
+ void __asan_poison_memory_region(void *, i64);
+ void __asan_unpoison_memory_region(void *, i64);
#define asan_poison_region(region, size) __asan_poison_memory_region((region), (size))
#define asan_unpoison_region(region, size) __asan_unpoison_memory_region((region), (size))
#else
@@ -163,24 +191,6 @@
#define PI (3.14159265358979323846f)
#endif
-typedef char c8;
-typedef uint8_t u8;
-typedef int8_t i8;
-typedef int16_t i16;
-typedef uint16_t u16;
-typedef uint16_t b16;
-typedef int32_t i32;
-typedef uint32_t u32;
-typedef int64_t i64;
-typedef uint64_t u64;
-typedef uint32_t b32;
-typedef float f32;
-typedef double f64;
-typedef ptrdiff_t iz;
-typedef size_t uz;
-typedef ptrdiff_t iptr;
-typedef size_t uptr;
-
#include "intrinsics.c"
typedef alignas(16) union {