From 27c862c215da8cd149b6332a09604c2f2395974a Mon Sep 17 00:00:00 2001 From: Quinn Date: Thu, 9 Oct 2025 11:59:59 +0200 Subject: [PATCH] rework `intdef.h` to not rely upon standard library headers by using predefined macros. --- src/util/intdef.h | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/util/intdef.h b/src/util/intdef.h index 36702e0..4ea423d 100644 --- a/src/util/intdef.h +++ b/src/util/intdef.h @@ -2,27 +2,26 @@ * Licensed under the MIT Licence. See LICENSE for details */ #pragma once -/* variable-width integer types */ -typedef unsigned int uint; // ≥16 bit unsigned integer -typedef unsigned long ulong; // ≥32 bit unsigned integer -typedef signed long long llong; // ≥64 bit signed integer -typedef unsigned long long ullong; // ≥64 bit unsigned integer +typedef signed long long int llong; +typedef unsigned short int ushort; +typedef unsigned int uint; +typedef unsigned long ulong; +typedef unsigned long long ullong; +typedef __INT8_TYPE__ i8; +typedef __INT16_TYPE__ i16; +typedef __INT32_TYPE__ i32; +typedef __INT64_TYPE__ i64; +typedef __UINT8_TYPE__ u8; +typedef __UINT16_TYPE__ u16; +typedef __UINT32_TYPE__ u32; +typedef __UINT64_TYPE__ u64; +typedef __SIZE_TYPE__ usize; +typedef __INTPTR_TYPE__ intptr; +typedef __UINTPTR_TYPE__ uintptr; -/* fixed-width integer types */ -#include -typedef int8_t i8; -typedef int16_t i16; -typedef int32_t i32; -typedef int64_t i64; -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; - -#include -typedef size_t usize; -typedef ssize_t ssize; - -/* floating point types */ -typedef float f32; // single-precision floating-point -typedef double f64; // double-precision floating-point +#if __SIZEOF_FLOAT__ == 4 +typedef float f32; +#endif +#if __SIZEOF_DOUBLE__ == 8 +typedef double f64; +#endif