fix read-only macro in debug mode
This commit is contained in:
parent
f399c093ca
commit
77fd98baaa
11
src/common.h
11
src/common.h
@ -162,9 +162,14 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
|
||||
#define INTERNAL static
|
||||
#define GLOBAL static
|
||||
|
||||
/* Storage specifiers */
|
||||
#pragma section(".roglob", read)
|
||||
#define READONLY __declspec(allocate(".roglob"))
|
||||
/* Read-only */
|
||||
#if OS_WINDOWS
|
||||
# define READONLY __declspec(allocate(".rdata"))
|
||||
#elif OS_MAC
|
||||
#define READONLY __attribute((section("__TEXT,__const")))
|
||||
#else
|
||||
#define READONLY __attribute((section(".rodata")))
|
||||
#endif
|
||||
|
||||
/* Markup */
|
||||
#define UNUSED void
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "entity.h"
|
||||
#include "math.h"
|
||||
|
||||
/* Accessed via entity_nil() */
|
||||
READONLY struct entity _g_entity_nil = {
|
||||
.rel_xform = XFORM_IDENT,
|
||||
.world_xform = XFORM_IDENT,
|
||||
|
||||
@ -116,8 +116,11 @@ struct entity_prop_array {
|
||||
* Nil
|
||||
* ========================== */
|
||||
|
||||
INLINE struct entity *entity_nil(void)
|
||||
{
|
||||
extern READONLY struct entity _g_entity_nil;
|
||||
INLINE READONLY struct entity *entity_nil(void) { return &_g_entity_nil; }
|
||||
return &_g_entity_nil;
|
||||
}
|
||||
|
||||
/* ========================== *
|
||||
* Property helpers
|
||||
|
||||
@ -22,7 +22,7 @@ GLOBAL struct {
|
||||
b32 file_valid;
|
||||
} G = { 0 }, DEBUG_ALIAS(G, G_log);
|
||||
|
||||
GLOBAL READONLY const struct log_level_settings g_log_level_settings[LOG_LEVEL_COUNT] = {
|
||||
GLOBAL READONLY struct log_level_settings g_log_level_settings[LOG_LEVEL_COUNT] = {
|
||||
[LOG_LEVEL_CRITICAL] = {
|
||||
STR_NOCAST("CRITICAL"),
|
||||
0xFFFF00FF
|
||||
|
||||
20
src/math.h
20
src/math.h
@ -133,8 +133,8 @@ INLINE u64 math_pow_u64(u64 base, u8 exp) {
|
||||
* https://github.com/freebsd/freebsd-src/blob/main/lib/msun/src/e_logf.c */
|
||||
INLINE f32 math_ln(f32 x)
|
||||
{
|
||||
static const f32 ln2_hi = 6.9313812256e-01;
|
||||
static const f32 ln2_lo = 9.0580006145e-06;
|
||||
LOCAL_PERSIST const f32 ln2_hi = 6.9313812256e-01;
|
||||
LOCAL_PERSIST const f32 ln2_lo = 9.0580006145e-06;
|
||||
|
||||
i32 x_int = *(u32 *)&x;
|
||||
|
||||
@ -202,14 +202,14 @@ INLINE f32 math_ln(f32 x)
|
||||
* https://github.com/freebsd/freebsd-src/blob/main/lib/msun/src/e_expf.c */
|
||||
INLINE f32 math_exp(f32 x)
|
||||
{
|
||||
static const f32 half[2] = { 0.5, -0.5 };
|
||||
static const f32 o_threshold = 8.8721679688e+01;
|
||||
static const f32 u_threshold = -1.0397208405e+02;
|
||||
static const f32 ln2_hi[2] = { 6.9314575195e-01, -6.9314575195e-01 };
|
||||
static const f32 ln2_lo[2] = { 1.4286067653e-06, -1.4286067653e-06 };
|
||||
static const f32 inv_ln2 = 1.4426950216e+00;
|
||||
static const f32 huge = 1.0e+30;
|
||||
static const f32 two_m100 = 7.8886090522e-31;
|
||||
LOCAL_PERSIST const f32 half[2] = { 0.5, -0.5 };
|
||||
LOCAL_PERSIST const f32 o_threshold = 8.8721679688e+01;
|
||||
LOCAL_PERSIST const f32 u_threshold = -1.0397208405e+02;
|
||||
LOCAL_PERSIST const f32 ln2_hi[2] = { 6.9314575195e-01, -6.9314575195e-01 };
|
||||
LOCAL_PERSIST const f32 ln2_lo[2] = { 1.4286067653e-06, -1.4286067653e-06 };
|
||||
LOCAL_PERSIST const f32 inv_ln2 = 1.4426950216e+00;
|
||||
LOCAL_PERSIST const f32 huge = 1.0e+30;
|
||||
LOCAL_PERSIST const f32 two_m100 = 7.8886090522e-31;
|
||||
|
||||
u32 x_uint = *(u32 *)&x;
|
||||
i32 x_sign_bit = (x_uint >> 31) & 1;
|
||||
|
||||
20
src/uni.c
20
src/uni.c
@ -4,17 +4,17 @@
|
||||
* utf8
|
||||
* ========================== */
|
||||
|
||||
GLOBAL READONLY u8 g_utf8_lens[32] = {
|
||||
struct uni_decode_utf8_result uni_decode_utf8(struct string str)
|
||||
{
|
||||
LOCAL_PERSIST const u8 lengths[32] = {
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,2,2,2,2,3,3,4,5
|
||||
};
|
||||
|
||||
struct uni_decode_utf8_result uni_decode_utf8(struct string str)
|
||||
{
|
||||
u32 codepoint = U32_MAX;
|
||||
u32 advance = 0;
|
||||
if (str.len > 0) {
|
||||
u8 c0 = str.text[0];
|
||||
u8 utf8_len = g_utf8_lens[c0 >> 3];
|
||||
u8 utf8_len = lengths[c0 >> 3];
|
||||
|
||||
advance = 1;
|
||||
switch (utf8_len) {
|
||||
@ -25,7 +25,7 @@ struct uni_decode_utf8_result uni_decode_utf8(struct string str)
|
||||
case 2: {
|
||||
if (str.len >= 2) {
|
||||
u8 c1 = str.text[1];
|
||||
if (g_utf8_lens[c1 >> 3] == 0) {
|
||||
if (lengths[c1 >> 3] == 0) {
|
||||
codepoint = (c1 & 0x3F) << 0;
|
||||
codepoint |= (c0 & 0x1F) << 6;
|
||||
advance = 2;
|
||||
@ -37,8 +37,8 @@ struct uni_decode_utf8_result uni_decode_utf8(struct string str)
|
||||
if (str.len >= 3) {
|
||||
u8 c1 = str.text[1];
|
||||
u8 c2 = str.text[2];
|
||||
if (g_utf8_lens[c1 >> 3] == 0 &&
|
||||
g_utf8_lens[c2 >> 3] == 0) {
|
||||
if (lengths[c1 >> 3] == 0 &&
|
||||
lengths[c2 >> 3] == 0) {
|
||||
codepoint = (c2 & 0x3F) << 0;
|
||||
codepoint |= (c1 & 0x3F) << 6;
|
||||
codepoint |= (c0 & 0x0F) << 12;
|
||||
@ -52,9 +52,9 @@ struct uni_decode_utf8_result uni_decode_utf8(struct string str)
|
||||
u8 c1 = str.text[1];
|
||||
u8 c2 = str.text[2];
|
||||
u8 c3 = str.text[3];
|
||||
if (g_utf8_lens[c1 >> 3] == 0 &&
|
||||
g_utf8_lens[c2 >> 3] == 0 &&
|
||||
g_utf8_lens[c3 >> 3] == 0) {
|
||||
if (lengths[c1 >> 3] == 0 &&
|
||||
lengths[c2 >> 3] == 0 &&
|
||||
lengths[c3 >> 3] == 0) {
|
||||
codepoint = (c3 & 0x3F) << 0;
|
||||
codepoint |= (c2 & 0x3F) << 6;
|
||||
codepoint |= (c1 & 0x3F) << 12;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user