gs_types.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef __GS_TYPES_H__
  2. #define __GS_TYPES_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdlib.h> // malloc, realloc, free ( for now )
  7. #include <stdint.h> // standard types
  8. #include <limits.h> // INT32_MAX, UINT32_MAX
  9. #include <string.h> // memset
  10. #include <float.h> // FLT_MAX
  11. #include <time.h>
  12. #include <ctype.h>
  13. #define _inline static inline
  14. #define _local_persist static
  15. #define _global static
  16. #if ( defined _WIN32 || defined _WIN64 )
  17. #define _force_inline static __forceinline
  18. #elif ( defined __APPLE__ || defined _APPLE )
  19. #define _force_inline static __attribute__((always_inline))
  20. #else
  21. #define _force_inline _inline
  22. #endif
  23. /*============================================================
  24. // Resource Declarations
  25. ============================================================*/
  26. #define gs_resource( type )\
  27. gs_resource_##type
  28. // Strongly typed declarations for resource handles (slot array handles)
  29. #define gs_declare_resource_type( type )\
  30. typedef struct gs_resource( type ) {\
  31. u32 id;\
  32. } gs_resource( type );\
  33. #define gs_resource_invalid( type )\
  34. (gs_resource( type )){ u32_max }
  35. /*============================================================
  36. // Result
  37. ============================================================*/
  38. typedef enum
  39. {
  40. gs_result_success,
  41. gs_result_in_progress,
  42. gs_result_incomplete,
  43. gs_result_failure
  44. } gs_result;
  45. /*============================================================
  46. // Primitives
  47. ============================================================*/
  48. #ifndef __cplusplus
  49. #define false 0
  50. #define true 1
  51. #endif
  52. typedef size_t usize;
  53. #ifdef __cplusplus
  54. typedef bool b8;
  55. #else
  56. typedef _Bool b8;
  57. #endif
  58. typedef uint8_t u8;
  59. typedef int8_t s8;
  60. typedef uint16_t u16;
  61. typedef int16_t s16;
  62. typedef uint32_t u32;
  63. typedef int32_t s32;
  64. typedef s32 b32;
  65. typedef uint64_t u64;
  66. typedef int64_t s64;
  67. typedef float f32;
  68. typedef double f64;
  69. typedef const char* const_str;
  70. #define u16_max UINT16_MAX
  71. #define u32_max UINT32_MAX
  72. #define s32_max INT32_MAX
  73. #define f32_max FLT_MAX
  74. #define f32_min FLT_MIN
  75. #ifdef __cplusplus
  76. }
  77. #endif // c++
  78. #endif // __GS_TYPES_H__