Banjo API 0.0.1
C99 game development API
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1
5
12#ifndef BJ_API_H
13#define BJ_API_H
14
15#include <stddef.h>
16#include <stdint.h>
17
21#define BJ_VERSION_MAJOR(version) (((version) >> 22U) & 0x3FFU)
22
26#define BJ_VERSION_MINOR(version) (((version) >> 12U) & 0x3FFU)
27
31#define BJ_VERSION_PATCH(version) ((version) & 0xFFFU)
32
38#define BJ_MAKE_VERSION(major, minor, patch) \
39 ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch)))
40
41#define BJ_VERSION_MAJOR_NUMBER 0
42#define BJ_VERSION_MINOR_NUMBER 1
43#define BJ_VERSION_PATCH_NUMBER 0
44
46#define BJ_VERSION BJ_MAKE_VERSION(BJ_VERSION_MAJOR_NUMBER, BJ_VERSION_MINOR_NUMBER, BJ_VERSION_PATCH_NUMBER)
47
49#define BJ_NAME "Banjo"
50
54#if defined(__EMSCRIPTEN__)
55# define BJ_OS_EMSCRIPTEN
56#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
57# define BJ_OS_WINDOWS
58#elif defined(__linux__) || defined(__gnu_linux__)
59# define BJ_OS_LINUX
60#elif __APPLE__
61# define BJ_OS_APPLE
62# include <TargetConditionals.h>
63# if TARGET_OS_IPHONE
64# define BJ_OS_IOS
65# elif TARGET_IPHONE_SIMULATOR
66# define BJ_OS_IOS
67# define BJ_OS_IOS_SIMULATOR
68# elif TARGET_OS_MAC
69# define BJ_OS_MACOS
70# define BJ_OS_UNIX
71# else
72# define BJ_OS_APPLE_UNKNOWN
73# endif
74#else
75# define BJ_OS_UNKNOWN
76#endif
77
78#if defined(__unix__)
79# define BJ_OS_UNIX
80#endif
82
88#if defined(BJ_COMPILER_DOXYGEN)
89# define BJ_COMPILER_NAME "Doxygen"
90# define BJ_COMPILER_VERSION 0
91#elif defined(__EMSCRIPTEN__)
92# include <emscripten/version.h>
93# define BJ_COMPILER_EMSCRIPTEN
94# define BJ_COMPILER_NAME "Emscripten"
95# define BJ_COMPILER_VERSION __EMSCRIPTEN_major__
96#elif defined(__GNUC__) && !defined(__clang__)
97# define BJ_COMPILER_GCC
98# define BJ_COMPILER_NAME "GCC"
99# define BJ_COMPILER_VERSION __GNUC__
100#elif defined(__clang__)
101# define BJ_COMPILER_CLANG
102# define BJ_COMPILER_NAME "Clang"
103# define BJ_COMPILER_VERSION __clang_major__
104#elif defined(_MSC_VER)
105# define BJ_COMPILER_MSVC
106# define BJ_COMPILER_NAME "MSVC"
107# define BJ_COMPILER_VERSION _MSC_VER
108#elif defined(__MINGW32__)
109# define BJ_COMPILER_MINGW
110# define BJ_COMPILER_NAME "MinGW"
111# define BJ_COMPILER_VERSION 0
112#else
113# define BJ_COMPILER_UNKNOWN
114# define BJ_COMPILER_NAME "Unknown"
115# define BJ_COMPILER_VERSION 0
116#endif
118
124#if defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
125# define BJ_BUILD_RELEASE
126#endif
129#if !defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
130# define BJ_BUILD_DEBUG
131#endif
132
134
138#if defined(BANJO_STATIC) || defined(BJ_COMPILER_DOXYGEN)
139# define BANJO_EXPORT
140# define BANJO_NO_EXPORT
141#else
142# ifdef _MSC_VER
143# ifndef BANJO_EXPORT
144# ifdef BANJO_EXPORTS
145# define BANJO_EXPORT __declspec(dllexport)
146# else
147# define BANJO_EXPORT __declspec( dllexport )
148# endif
149# endif
150# ifndef BANJO_NO_EXPORT
151# define BANJO_NO_EXPORT
152# endif
153# else
154# ifndef BANJO_EXPORT
155# ifdef BANJO_EXPORTS
156# define BANJO_EXPORT __attribute__((visibility("default")))
157# else
158# define BANJO_EXPORT __attribute__((visibility("default")))
159# endif
160# endif
161# ifndef BANJO_NO_EXPORT
162# define BANJO_NO_EXPORT __attribute__((visibility("hidden")))
163# endif
164# endif
165#endif
167
172#if defined(__cplusplus)
173 #if defined(__GNUC__) || defined(__clang__)
174 #define BJ_RESTRICT __restrict__
175 #elif defined(_MSC_VER)
176 #define BJ_RESTRICT __restrict
177 #else
178 #define BJ_RESTRICT /* nothing */
179 #endif
180#else
181 /* pure C (C99 or newer) */
182 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
183 #define BJ_RESTRICT restrict
184 #elif defined(__GNUC__) || defined(__clang__)
185 #define BJ_RESTRICT __restrict__
186 #elif defined(_MSC_VER)
187 #define BJ_RESTRICT __restrict
188 #else
189 #define BJ_RESTRICT /* nothing */
190 #endif
191#endif
193
202#if defined(_MSC_VER)
203 #if defined(__has_include)
204 #if __has_include(<sal.h>)
205 #include <sal.h>
206 #define BJ_CONST_ARRAY(T,n,name) _In_reads_(n) const T* BJ_RESTRICT name
207 #define BJ_ARRAY(T,n,name) _Out_writes_(n) T* BJ_RESTRICT name
208 #define BJ_CONST_ARRAY_2D(T,n,m,name) _In_reads_((n)*(m)) const T (* BJ_RESTRICT name)[m]
209 #define BJ_ARRAY_2D(T,n,m,name) _Out_writes_((n)*(m)) T (* BJ_RESTRICT name)[m]
210 #else
211 #define BJ_CONST_ARRAY(T,n,name) const T* BJ_RESTRICT name
212 #define BJ_ARRAY(T,n,name) T* BJ_RESTRICT name
213 #define BJ_CONST_ARRAY_2D(T,n,m,name) const T (* BJ_RESTRICT name)[m]
214 #define BJ_ARRAY_2D(T,n,m,name) T (* BJ_RESTRICT name)[m]
215 #endif
216 #else
217 #include <sal.h>
218 #define BJ_CONST_ARRAY(T,n,name) _In_reads_(n) const T* BJ_RESTRICT name
219 #define BJ_ARRAY(T,n,name) _Out_writes_(n) T* BJ_RESTRICT name
220 #define BJ_CONST_ARRAY_2D(T,n,m,name) _In_reads_((n)*(m)) const T (* BJ_RESTRICT name)[m]
221 #define BJ_ARRAY_2D(T,n,m,name) _Out_writes_((n)*(m)) T (* BJ_RESTRICT name)[m]
222 #endif
223#elif defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
224 #define BJ_CONST_ARRAY(T,n,name) const T name[BJ_RESTRICT static (n)]
225 #define BJ_ARRAY(T,n,name) T name[BJ_RESTRICT static (n)]
226 #define BJ_CONST_ARRAY_2D(T,n,m,name) const T name[BJ_RESTRICT static (n)][m]
227 #define BJ_ARRAY_2D(T,n,m,name) T name[BJ_RESTRICT static (n)][m]
228#else
229 #define BJ_CONST_ARRAY(T,n,name) const T* BJ_RESTRICT name
230 #define BJ_ARRAY(T,n,name) T* BJ_RESTRICT name
231 #define BJ_CONST_ARRAY_2D(T,n,m,name) const T (* BJ_RESTRICT name)[m]
232 #define BJ_ARRAY_2D(T,n,m,name) T (* BJ_RESTRICT name)[m]
233#endif
235
236
242#if defined(_MSC_VER)
243 #if defined(BJ_API_FORCE_INLINE)
244 #define BJ_INLINE __forceinline
245 #else
246 #if !defined(__cplusplus) && !defined(inline)
247 #define BJ_INLINE __inline
248 #else
249 #define BJ_INLINE inline
250 #endif
251 #endif
252#elif defined(__GNUC__) || defined(__clang__)
253 #if defined(BJ_API_FORCE_INLINE)
254 #define BJ_INLINE inline __attribute__((always_inline))
255 #else
256 #define BJ_INLINE inline
257 #endif
258#else
259 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
260 #define BJ_INLINE inline
261 #else
262 #define BJ_INLINE /* no inline available */
263 #endif
264#endif
266
276typedef uint32_t bj_bool;
277
285#define BJ_FALSE ((bj_bool)0)
286
294#define BJ_TRUE ((bj_bool)1)
295
314
324
325#endif /* BJ_API_H */
bj_bool feature_emscripten
Built with Emscripten support.
Definition api.h:304
bj_bool config_fastmath
Built with fast-math optimizations.
Definition api.h:312
uint32_t version
Packed API version (see BJ_VERSION).
Definition api.h:299
bj_bool feature_win32
Built with Win32 window support.
Definition api.h:303
bj_bool feature_x11
Built with X11 window support.
Definition api.h:305
const char * compiler_name
Compiler name string.
Definition api.h:300
const char * p_name
API name (see BJ_NAME).
Definition api.h:298
bj_bool debug
Non-zero if built with debug info.
Definition api.h:302
bj_bool config_checks_abort
Checks abort execution on failure.
Definition api.h:308
bj_bool config_pedantic
Extra runtime checks enabled.
Definition api.h:311
bj_bool feature_mme
Built with Windows MME audio.
Definition api.h:306
int compiler_version
Compiler version number.
Definition api.h:301
bj_bool feature_alsa
Built with ALSA audio.
Definition api.h:307
bj_bool config_checks_log
Checks log failures.
Definition api.h:309
bj_bool config_log_color
Colored log output enabled.
Definition api.h:310
#define BANJO_EXPORT
Definition api.h:139
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:276
const bj_build_info * bj_build_information(void)
Get runtime build information for the loaded Banjo binaries.
Structure holding build information of the binary.
Definition api.h:297