From 76d7d478a9e5ad10b76e246367779216fbd0fb60 Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Thu, 22 Aug 2024 21:00:07 -0500 Subject: core: add headers for basic types and export macros Add header files that contain basic type information as well as export macros for systems that use a specific export line for linking, e.g. Windows. Signed-off-by: Danny Holman --- include/rune_math.h | 37 +++++++++++++++++++++++++++++++++++++ include/rune_types.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 include/rune_math.h create mode 100644 include/rune_types.h diff --git a/include/rune_math.h b/include/rune_math.h new file mode 100644 index 0000000..25bf4fd --- /dev/null +++ b/include/rune_math.h @@ -0,0 +1,37 @@ +#ifndef RUNE_MATH_H +#define RUNE_MATH_H + +struct vec2 { + float x; + float y; +}; + +struct vec3 { + float x; + float y; + float z; +}; + +struct vec4 { + float x; + float y; + float z; + float w; +}; + +struct mat3 { + struct vec3 v[3]; +}; + +struct mat4 { + struct vec3 v[4]; +}; + +struct quat { + float x; + float y; + float z; + float w; +}; + +#endif diff --git a/include/rune_types.h b/include/rune_types.h new file mode 100644 index 0000000..8fada14 --- /dev/null +++ b/include/rune_types.h @@ -0,0 +1,40 @@ +#ifndef RUNE_TYPES_H +#define RUNE_TYPES_H + +#include +#include + +#if defined(__clang__) || defined(__gcc__) + #define STATIC_ASSERT _Static_assert +#else + #define STATIC_ASSERT static_assert +#endif + +STATIC_ASSERT(sizeof(uint8_t) == 1, "Expected uint8_t to be 1 byte"); +STATIC_ASSERT(sizeof(uint16_t) == 2, "Expected uint16_t to be 2 bytes"); +STATIC_ASSERT(sizeof(uint32_t) == 4, "Expected uint32_t to be 4 bytes"); +STATIC_ASSERT(sizeof(uint64_t) == 8, "Expected uint64_t to be 8 bytes"); + +STATIC_ASSERT(sizeof(int8_t) == 1, "Expected int8_t to be 1 byte"); +STATIC_ASSERT(sizeof(int16_t) == 2, "Expected int16_t to be 2 bytes"); +STATIC_ASSERT(sizeof(int32_t) == 4, "Expected int32_t to be 4 bytes"); +STATIC_ASSERT(sizeof(int64_t) == 8, "Expected int64_t to be 8 bytes"); + +STATIC_ASSERT(sizeof(float) == 4, "Expected float to be 4 bytes"); +STATIC_ASSERT(sizeof(double) == 8, "Expected double to be 8 bytes"); + +#ifdef REXPORT + #ifdef _MSC_VER + #define RAPI __declspec(dllexport) + #else + #define RAPI __attribute__((visibility("default"))) + #endif +#else + #ifdef _MSC_VER + #define RAPI __declspec(dllexport) + #else + #define RAPI + #endif +#endif + +#endif -- cgit v1.2.3