2017-11-24 16:14:10 +02:00
|
|
|
/*
|
2019-08-03 20:43:48 +03:00
|
|
|
* This software is licensed under the terms of the MIT License.
|
2017-11-24 16:14:10 +02:00
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
2019-01-23 22:10:43 +02:00
|
|
|
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
|
2019-07-03 21:00:56 +03:00
|
|
|
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
|
2017-11-24 16:14:10 +02:00
|
|
|
*/
|
|
|
|
|
2019-01-23 22:10:43 +02:00
|
|
|
#ifndef IGUARD_util_crap_h
|
|
|
|
#define IGUARD_util_crap_h
|
|
|
|
|
2017-11-25 21:45:11 +02:00
|
|
|
#include "taisei.h"
|
2017-11-24 16:14:10 +02:00
|
|
|
|
2019-03-16 22:11:37 +02:00
|
|
|
#include <SDL.h>
|
|
|
|
|
2019-08-04 01:29:41 +03:00
|
|
|
void* memdup(const void *src, size_t size) attr_returns_allocated attr_nonnull(1);
|
|
|
|
void inherit_missing_pointers(uint num, void *dest[num], void *const base[num]) attr_nonnull(2, 3);
|
2019-01-09 05:25:10 +02:00
|
|
|
bool is_main_thread(void);
|
2019-01-23 22:10:43 +02:00
|
|
|
|
2019-11-12 02:58:22 +02:00
|
|
|
typedef union FloatBits {
|
|
|
|
float val;
|
|
|
|
uint32_t bits;
|
|
|
|
} FloatBits;
|
|
|
|
|
|
|
|
typedef union DoubleBits {
|
|
|
|
double val;
|
|
|
|
uint64_t bits;
|
|
|
|
} DoubleBits;
|
|
|
|
|
2019-08-03 19:47:21 +03:00
|
|
|
INLINE uint32_t float_to_bits(float f) {
|
2019-11-12 02:58:22 +02:00
|
|
|
return ((FloatBits) { .val = f }).bits;
|
2019-04-07 01:55:13 +03:00
|
|
|
}
|
|
|
|
|
2019-08-03 19:47:21 +03:00
|
|
|
INLINE float bits_to_float(uint32_t i) {
|
2019-11-12 02:58:22 +02:00
|
|
|
return ((FloatBits) { .bits = i }).val;
|
|
|
|
}
|
|
|
|
|
2019-11-13 01:52:55 +02:00
|
|
|
INLINE uint64_t double_to_bits(double d) {
|
|
|
|
return ((DoubleBits) { .val = d }).bits;
|
2019-11-12 02:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
INLINE double bits_to_double(uint64_t i) {
|
|
|
|
return ((DoubleBits) { .bits = i }).val;
|
2019-04-07 01:55:13 +03:00
|
|
|
}
|
|
|
|
|
2019-03-16 22:11:37 +02:00
|
|
|
extern SDL_threadID main_thread_id;
|
|
|
|
|
2019-02-22 01:56:03 +02:00
|
|
|
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(*(arr)))
|
|
|
|
|
2019-01-23 22:10:43 +02:00
|
|
|
#endif // IGUARD_util_crap_h
|