2017-11-24 15:14:10 +01:00
|
|
|
/*
|
2019-08-03 19:43:48 +02:00
|
|
|
* This software is licensed under the terms of the MIT License.
|
2017-11-24 15:14:10 +01:00
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
2024-05-16 23:30:41 +02:00
|
|
|
* Copyright (c) 2011-2024, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
|
2017-11-24 15:14:10 +01:00
|
|
|
*/
|
|
|
|
|
2021-08-12 23:09:01 +02:00
|
|
|
#pragma once
|
2017-11-25 20:45:11 +01:00
|
|
|
#include "taisei.h"
|
2017-11-24 15:14:10 +01:00
|
|
|
|
2019-03-16 21:11:37 +01:00
|
|
|
#include <SDL.h>
|
|
|
|
|
2024-05-17 04:41:28 +02:00
|
|
|
// IWYU pragma: private, include "util.h"
|
|
|
|
|
2019-08-04 00:29:41 +02:00
|
|
|
void inherit_missing_pointers(uint num, void *dest[num], void *const base[num]) attr_nonnull(2, 3);
|
2019-01-23 21:10:43 +01:00
|
|
|
|
2019-11-12 01:58:22 +01:00
|
|
|
typedef union FloatBits {
|
|
|
|
float val;
|
|
|
|
uint32_t bits;
|
|
|
|
} FloatBits;
|
|
|
|
|
|
|
|
typedef union DoubleBits {
|
|
|
|
double val;
|
|
|
|
uint64_t bits;
|
|
|
|
} DoubleBits;
|
|
|
|
|
2019-08-03 18:47:21 +02:00
|
|
|
INLINE uint32_t float_to_bits(float f) {
|
2019-11-12 01:58:22 +01:00
|
|
|
return ((FloatBits) { .val = f }).bits;
|
2019-04-07 00:55:13 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 18:47:21 +02:00
|
|
|
INLINE float bits_to_float(uint32_t i) {
|
2019-11-12 01:58:22 +01:00
|
|
|
return ((FloatBits) { .bits = i }).val;
|
|
|
|
}
|
|
|
|
|
2019-11-13 00:52:55 +01:00
|
|
|
INLINE uint64_t double_to_bits(double d) {
|
|
|
|
return ((DoubleBits) { .val = d }).bits;
|
2019-11-12 01:58:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
INLINE double bits_to_double(uint64_t i) {
|
|
|
|
return ((DoubleBits) { .bits = i }).val;
|
2019-04-07 00:55:13 +02:00
|
|
|
}
|
|
|
|
|
2019-02-22 00:56:03 +01:00
|
|
|
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(*(arr)))
|
2023-04-28 21:51:40 +02:00
|
|
|
|
|
|
|
#define SWAP(_a, _b) ({ \
|
|
|
|
auto _swap_temp = _a; \
|
|
|
|
_a = _b; \
|
|
|
|
_b = _swap_temp; \
|
|
|
|
(void)0; \
|
|
|
|
})
|