2018-09-26 17:39:17 +00:00
|
|
|
#include <stdarg.h>
|
2016-09-30 06:18:51 +00:00
|
|
|
|
2017-01-26 10:20:30 +00:00
|
|
|
#pragma once
|
2016-10-04 22:05:34 +00:00
|
|
|
|
2019-01-04 10:18:21 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define LOVR_EXPORT __declspec(dllexport)
|
|
|
|
#else
|
2019-04-20 23:17:49 +00:00
|
|
|
#define LOVR_EXPORT __attribute__((visibility("default")))
|
2019-01-18 16:44:03 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _Noreturn
|
|
|
|
#ifdef _WIN32
|
|
|
|
#define _Noreturn __declspec(noreturn)
|
|
|
|
#else
|
2019-01-06 11:25:00 +00:00
|
|
|
#define _Noreturn __attribute__((noreturn))
|
2019-01-18 16:44:03 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _Thread_local
|
|
|
|
#ifdef _WIN32
|
|
|
|
#define _Thread_local __declspec(thread)
|
|
|
|
#else
|
2019-01-06 11:25:00 +00:00
|
|
|
#define _Thread_local __thread
|
2018-12-13 03:35:18 +00:00
|
|
|
#endif
|
2019-01-18 16:44:03 +00:00
|
|
|
#endif
|
2018-12-13 03:35:18 +00:00
|
|
|
|
2018-12-10 07:36:02 +00:00
|
|
|
#define CHECK_SIZEOF(T) int(*_o)[sizeof(T)]=1
|
|
|
|
|
2018-09-27 18:45:43 +00:00
|
|
|
#define MAX(a, b) (a > b ? a : b)
|
|
|
|
#define MIN(a, b) (a < b ? a : b)
|
|
|
|
#define CLAMP(x, min, max) MAX(min, MIN(max, x))
|
2019-04-21 01:42:25 +00:00
|
|
|
#define ALIGN(p, n) ((uintptr_t) (p) & -n)
|
2018-11-25 02:04:27 +00:00
|
|
|
|
2019-04-05 12:08:03 +00:00
|
|
|
typedef struct Color { float r, g, b, a; } Color;
|
2017-08-02 08:25:56 +00:00
|
|
|
|
2018-09-26 17:39:17 +00:00
|
|
|
typedef void (*lovrErrorHandler)(void* userdata, const char* format, va_list args);
|
2019-01-06 11:25:00 +00:00
|
|
|
extern _Thread_local lovrErrorHandler lovrErrorCallback;
|
|
|
|
extern _Thread_local void* lovrErrorUserdata;
|
2017-08-10 07:08:29 +00:00
|
|
|
|
2018-09-26 17:39:17 +00:00
|
|
|
void lovrSetErrorCallback(lovrErrorHandler callback, void* context);
|
2019-01-06 11:25:00 +00:00
|
|
|
void _Noreturn lovrThrow(const char* format, ...);
|
2019-04-05 09:50:11 +00:00
|
|
|
|
|
|
|
#define lovrAssert(c, ...) if (!(c)) { lovrThrow(__VA_ARGS__); }
|