diff options
| author | Fabrice <fabrice@schaub-dev.xyz> | 2026-04-16 09:39:32 +0200 |
|---|---|---|
| committer | Fabrice <fabrice@schaub-dev.xyz> | 2026-04-16 09:39:32 +0200 |
| commit | 2e348c8925ecbd627404a387100b9ad300041ad5 (patch) | |
| tree | d84df5b93c0e0dd5379a217d3c9eccecc6e480ee /omni | |
init
Diffstat (limited to 'omni')
| -rw-r--r-- | omni/BUILD.bazel | 10 | ||||
| -rw-r--r-- | omni/int.h | 56 | ||||
| -rw-r--r-- | omni/platform.h | 96 |
3 files changed, 162 insertions, 0 deletions
diff --git a/omni/BUILD.bazel b/omni/BUILD.bazel new file mode 100644 index 0000000..8e29939 --- /dev/null +++ b/omni/BUILD.bazel @@ -0,0 +1,10 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "omni_impl", + hdrs = [ + ":int.h", + ":platform.h" + ], + visibility = ["//visibility:public"] +) diff --git a/omni/int.h b/omni/int.h new file mode 100644 index 0000000..ce27730 --- /dev/null +++ b/omni/int.h @@ -0,0 +1,56 @@ +#ifndef OMNI_INT_H +#define OMNI_INT_H + +#include <stdint.h> + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +typedef int8_t i8; +typedef int16_t i16; +typedef int32_t i32; +typedef int64_t i64; + +typedef float f32; +typedef double f64; + +#define U8_MAX UINT8_MAX +#define U16_MAX UINT16_MAX +#define U32_MAX UINT32_MAX +#define U64_MAX UINT64_MAX + +#define I8_MIN INT8_MIN +#define I16_MIN INT16_MIN +#define I32_MIN INT32_MIN +#define I64_MIN INT64_MIN + +#define I8_MAX INT8_MAX +#define I16_MAX INT16_MAX +#define I32_MAX INT32_MAX +#define I64_MAX INT64_MAX + +#if UINTPTR_MAX == UINT64_MAX +typedef u64 usize; +typedef i64 isize; + +#define USIZE_MAX UINT64_MAX + +#define ISIZE_MIN INT64_MIN +#define ISIZE_MAX INT64_MAX + +#elif UINTPTR_MAX == UINT32_MAX +typedef u32 usize; +typedef i32 isize; + +#define USIZE_MAX UINT32_MAX + +#define ISIZE_MIN INT32_MIN +#define ISIZE_MAX INT32_MAX + +#else +#error "target is not supported" +#endif + +#endif diff --git a/omni/platform.h b/omni/platform.h new file mode 100644 index 0000000..593b79c --- /dev/null +++ b/omni/platform.h @@ -0,0 +1,96 @@ +#ifndef OMNI_PLATFORM_H +#define OMNI_PLATFORM_H + +/* + * + * COMPILER INFORMATION + * + */ + +#undef OMNI_CC_MSVC +#undef OMNI_CC_GNU + +#if defined(_MSC_VER) +#define OMNI_CC_MSVC +#endif + +#if defined(__GNUC__) || defined(__clang__) +#define OMNI_CC_GNU +#endif + + +#if !defined(OMNI_CC_GNU) && !defined(OMNI_CC_MSVC) +#error "compiler not supported" +#endif + +/* + * + * TARGET ARCHITECTURE INFORMATION + * + */ + +#undef OMNI_ARCH_X86 +#undef OMNI_ARCH_ARM +#undef OMNI_ARCH_64BIT +#undef OMNI_ARCH_32BIT + +#if defined(__i386__) || defined(_M_IX86) +#define OMNI_ARCH_X86 +#define OMNI_ARCH_32BIT +#endif + +#if defined(__x86_64__) || defined(_M_X64) +#define OMNI_ARCH_X86 +#define OMNI_ARCH_64BIT +#endif + +#if defined(__arm__) || defined(_M_ARM) +#define OMNI_ARCH_ARM +#define OMNI_ARCH_32BIT +#endif + +#if defined(__aarch64__) || defined(_M_ARM64) || defined(__arm64__) +#define OMNI_ARCH_ARM +#define OMNI_ARCH_64BIT +#endif + +#if !defined(OMNI_ARCH_X86) && !defined(OMNI_ARCH_ARM) +#error "target architecture is not supported" +#endif + +/* + * + * TARGET OS INFORMATION + * + */ + +#undef OMNI_OS_WIN +#undef OMNI_OS_LINUX +#undef OMNI_OS_FREEBSD +#undef OMNI_OS_OSX + +#if defined(_WIN32) || defined(_WIN64) +#define OMNI_OS_WIN +#endif + +#if defined(__linux__) +#define OMNI_OS_LINUX +#define OMNI_OS_UNIX +#endif + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#define OMNI_OS_FREEBSD +#define OMNI_OS_UNIX +#endif + +#if defined(__APPLE__) && defined(__MACH__) +#define OMNI_OS_OSX +#define OMNI_OS_UNIX +#endif + +#if !defined(OMNI_OS_UNIX) && !defined(OMNI_OS_WIN) +#error "target os not supported" +#endif + +#endif + |
