ciabatta/include/cia-def.h

51 lines
1.4 KiB
C
Raw Normal View History

2023-07-22 14:30:04 +00:00
#pragma once
2023-07-22 16:28:16 +00:00
// Pre-C23 keyword macros and stddef
2023-07-22 14:30:04 +00:00
#define static_assert _Static_assert
2023-07-25 05:24:19 +00:00
#define noreturn _Noreturn
2023-07-22 16:28:16 +00:00
#define NULL ((void *)0)
2023-07-22 14:30:04 +00:00
// Assert commonly-accepted platform-invariant sizes
static_assert(sizeof(char) == 1, "Char isn't 1 bytes long");
static_assert(sizeof(short) == 2, "Short isn't 2 bytes long");
static_assert(sizeof(int) == 4, "Int isn't 4 bytes long");
static_assert(sizeof(long long int) == 8, "Long long isn't 8 bytes long");
#if defined(_CIA_OS_LINUX)
2023-07-22 14:30:04 +00:00
static_assert(sizeof(long) == 8, "Long on linux isn't 8 bytes");
#elif defined(_CIA_OS_WINDOWS)
2023-07-22 14:30:04 +00:00
static_assert(sizeof(long) == 4, "Long on windows isn't 4 bytes");
#endif
// stdint.h type definitions
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
#if defined(_CIA_OS_LINUX)
2023-07-22 14:30:04 +00:00
typedef signed long int64_t;
typedef unsigned long uint64_t;
#elif defined(_CIA_OS_WINDOWS)
2023-07-22 14:30:04 +00:00
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#else
#error "Platform not implemented"
#endif
2023-07-25 05:31:34 +00:00
2023-07-23 15:33:12 +00:00
// stdbool.h
typedef _Bool bool;
#define true ((bool)1)
#define false ((bool)0)
2023-07-22 14:30:04 +00:00
// Short type definitions
typedef int8_t i8;
typedef uint8_t u8;
typedef int16_t i16;
typedef uint16_t u16;
typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;