diff options
| author | 2024-10-06 13:32:00 -0400 | |
|---|---|---|
| committer | 2024-10-06 13:32:00 -0400 | |
| commit | e6710f5ad898b54a4ae74d57858ba1287f0ef8bf (patch) | |
| tree | 8c6903227735f59e8a821cca8b4aa4e0a1a6816b | |
| parent | c682feffb0a6cde943687587721f2603b3846ceb (diff) | |
| download | libalabaster-e6710f5ad898b54a4ae74d57858ba1287f0ef8bf.tar.gz libalabaster-e6710f5ad898b54a4ae74d57858ba1287f0ef8bf.tar.bz2 libalabaster-e6710f5ad898b54a4ae74d57858ba1287f0ef8bf.zip | |
lib: Cleanup types and assert sizeof(int) = 4
Signed-off-by: Andrew Opalach <andrew@akon.city>
| -rw-r--r-- | include/al/types.h | 34 | ||||
| -rw-r--r-- | src/lib.c | 7 |
2 files changed, 15 insertions, 26 deletions
diff --git a/include/al/types.h b/include/al/types.h index c164127..3a04539 100644 --- a/include/al/types.h +++ b/include/al/types.h @@ -17,40 +17,22 @@ #define _XOPEN_SOURCE 500 #endif -#if _WIN32 || _WIN64 -#if _WIN64 -#define PTR_IS_64 -#else -#define PTR_IS_32 -#endif -#elif __GNUC__ -#if __x86_64__ || __ppc64__ -#define PTR_IS_64 -#else -#define PTR_IS_32 -#endif -#elif UINTPTR_MAX > UINT_MAX -#define PTR_IS_64 -#else -#define PTR_IS_32 -#endif - -#include <stdint.h> #include <stddef.h> #include <stdbool.h> -#include <sys/types.h> +#include <stdint.h> #include <float.h> +#include <sys/types.h> -typedef uint8_t u8; -typedef int8_t s8; +typedef int8_t s8; +typedef uint8_t u8; +typedef int16_t s16; typedef uint16_t u16; -typedef int16_t s16; +typedef int32_t s32; typedef uint32_t u32; -typedef int32_t s32; +typedef int64_t s64; typedef uint64_t u64; -typedef int64_t s64; -typedef float f32; +typedef float f32; typedef double f64; #ifdef _MSC_VER @@ -1,5 +1,12 @@ #include "../include/al/lib.h" +// https://forum.vcfed.org/index.php?threads/c-item-size-check-at-compile-time.1244920/ +#define AL_ASSERT_TYPE_SIZE(type, size) \ + typedef char type##__size_test[( !!(sizeof(type) == size) )*2-1] + +AL_ASSERT_TYPE_SIZE(int, 4); +AL_ASSERT_TYPE_SIZE(unsigned, 4); + #if AL_USE_STDLIB static void *(*_al_malloc)(size_t) = malloc; static void *(*_al_calloc)(size_t, size_t) = calloc; |