prefix cia defines with underscore

This commit is contained in:
flysand7 2023-07-25 16:31:34 +11:00
parent c8a6a65509
commit 4c2ed6e7e4
3 changed files with 16 additions and 22 deletions

View File

@ -7,39 +7,39 @@
#define NULL ((void *)0) #define NULL ((void *)0)
// Platform macros // Platform macros
#define CIA_LINUX 1 #define _CIA_LINUX 1
#define CIA_WINDOWS 2 #define _CIA_WINDOWS 2
#define CIA_ANDROID 3 #define _CIA_ANDROID 3
// Platform detection // Platform detection
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#define CIA_OS CIA_WINDOWS #define _CIA_OS _CIA_WINDOWS
#if !defined(_WIN64) #if !defined(_WIN64)
#error "32-bit windows is not supported" #error "32-bit windows is not supported"
#endif #endif
#elif __APPLE__ #elif __APPLE__
#error "Apple OS's not supported and will never be unless you want to write the support for it" #error "Apple OS's not supported and will never be unless you want to write the support for it"
#elif __ANDROID__ #elif __ANDROID__
#define CIA_OS CIA_ANDROID #define _CIA_OS _CIA_ANDROID
#elif __linux__ #elif __linux__
#define CIA_OS CIA_LINUX #define _CIA_OS _CIA_LINUX
#else #else
#error "Unable to detect the OS" #error "Unable to detect the OS"
#endif #endif
// Convenience platform checking macros // Convenience platform checking macros
#define os_is_linux() (CIA_OS == CIA_LINUX) #define _CIA_OS_LINUX() (_CIA_OS == _CIA_LINUX)
#define os_is_windows() (CIA_OS == CIA_WINDOWS) #define _CIA_OS_WINDOWS() (_CIA_OS == _CIA_WINDOWS)
#define os_is_android() (CIA_OS == CIA_ANDROID) #define _CIA_OS_ANDROID() (_CIA_OS == _CIA_ANDROID)
// Assert commonly-accepted platform-invariant sizes // Assert commonly-accepted platform-invariant sizes
static_assert(sizeof(char) == 1, "Char isn't 1 bytes long"); 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(short) == 2, "Short isn't 2 bytes long");
static_assert(sizeof(int) == 4, "Int isn't 4 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"); static_assert(sizeof(long long int) == 8, "Long long isn't 8 bytes long");
#if os_is_linux() #if _CIA_OS_LINUX()
static_assert(sizeof(long) == 8, "Long on linux isn't 8 bytes"); static_assert(sizeof(long) == 8, "Long on linux isn't 8 bytes");
#elif os_is_windows() #elif _CIA_OS_WINDOWS()
static_assert(sizeof(long) == 4, "Long on windows isn't 4 bytes"); static_assert(sizeof(long) == 4, "Long on windows isn't 4 bytes");
#endif #endif
@ -50,16 +50,16 @@ typedef signed short int16_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
typedef signed int int32_t; typedef signed int int32_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
#if os_is_linux() #if _CIA_OS_LINUX()
typedef signed long int64_t; typedef signed long int64_t;
typedef unsigned long uint64_t; typedef unsigned long uint64_t;
#elif os_is_windows() #elif _CIA_OS_WINDOWS()
typedef signed long long int64_t; typedef signed long long int64_t;
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
#else #else
#error "Platform not implemented" #error "Platform not implemented"
#endif #endif
// stdbool.h // stdbool.h
typedef _Bool bool; typedef _Bool bool;
#define true ((bool)1) #define true ((bool)1)

View File

@ -1,7 +1,7 @@
#include <cia_definitions.h> #include <cia_definitions.h>
#if os_is_linux() #if _CIA_OS_LINUX()
#include "linux/syscall.c" #include "linux/syscall.c"
#include "linux/errno.c" #include "linux/errno.c"
#include "linux/entry.c" #include "linux/entry.c"
@ -9,6 +9,6 @@
#include "linux/tinyrt.iface.h" #include "linux/tinyrt.iface.h"
#include "tinyrt.h" #include "tinyrt.h"
#include "linux/tinyrt.c" #include "linux/tinyrt.c"
#elif os_is_windows() #elif _CIA_OS_WINDOWS()
#error "Not implemented yet" #error "Not implemented yet"
#endif #endif

View File

@ -1,6 +1,4 @@
#if os_is_linux()
// Standard handles file descriptors // Standard handles file descriptors
#define STDIN_FILENO 0 #define STDIN_FILENO 0
#define STDOUT_FILENO 1 #define STDOUT_FILENO 1
@ -179,7 +177,3 @@ static inline i64 syscall_arch_prctl_set(int code, u64 value) {
static inline i64 syscall_arch_prctl_get(int code, u64 *value) { static inline i64 syscall_arch_prctl_get(int code, u64 *value) {
return __syscall2(SYS_arch_prctl, code, (i64)value); return __syscall2(SYS_arch_prctl, code, (i64)value);
} }
#else
#error "syscall.h should only be included in LINUX code"
#endif