copy new memory functions that are used in stb_sprintf to metagen base

This commit is contained in:
Nikita Smith
2026-02-18 16:16:48 -08:00
parent 0e4c864b22
commit 64d0f9b68b
2 changed files with 55 additions and 4 deletions
@@ -281,6 +281,50 @@ memory_is_zero(void *ptr, U64 size){
return(result); return(result);
} }
internal void UBSAN_NO_ALIGN
memory_write16(void *ptr, U16 v)
{
MemoryCopy(ptr, &v, sizeof(v));
}
internal void UBSAN_NO_ALIGN
memory_write32(void *ptr, U32 v)
{
MemoryCopy(ptr, &v, sizeof(v));
}
internal U8 UBSAN_NO_ALIGN
memory_read8(void *ptr)
{
U8 result;
MemoryCopy(&result, ptr, sizeof(result));
return result;
}
internal U16 UBSAN_NO_ALIGN
memory_read16(void *ptr)
{
U16 result;
MemoryCopy(&result, ptr, sizeof(result));
return result;
}
internal U32 UBSAN_NO_ALIGN
memory_read32(void *ptr)
{
U32 result;
MemoryCopy(&result, ptr, sizeof(result));
return result;
}
internal U64 UBSAN_NO_ALIGN
memory_read64(void *ptr)
{
U64 result;
MemoryCopy(&result, ptr, sizeof(result));
return result;
}
//////////////////////////////// ////////////////////////////////
//~ rjf: Text 2D Coordinate/Range Functions //~ rjf: Text 2D Coordinate/Range Functions
+11 -4
View File
@@ -292,7 +292,7 @@ CheckNil(nil,p) ? \
# define ASAN_ENABLED 1 # define ASAN_ENABLED 1
# define ASAN_NO_ADDR __declspec(no_sanitize_address) # define ASAN_NO_ADDR __declspec(no_sanitize_address)
# else # else
# define ASAN_NO_ADDR # define UBSAN_NO_ALIGN
# endif # endif
#elif COMPILER_CLANG #elif COMPILER_CLANG
# if defined(__has_feature) # if defined(__has_feature)
@@ -300,9 +300,8 @@ CheckNil(nil,p) ? \
# define ASAN_ENABLED 1 # define ASAN_ENABLED 1
# endif # endif
# endif # endif
# define ASAN_NO_ADDR __attribute__((no_sanitize("address"))) # define ASAN_NO_ADDR __attribute__((no_sanitize("address")))
#else # define UBSAN_NO_ALIGN __attribute__((no_sanitize("alignment")))
# define ASAN_NO_ADDR
#endif #endif
#if ASAN_ENABLED #if ASAN_ENABLED
@@ -841,6 +840,14 @@ internal F32 sign_from_side_F32(Side side);
internal B32 memory_is_zero(void *ptr, U64 size); internal B32 memory_is_zero(void *ptr, U64 size);
internal void memory_write16(void *ptr, U16 v);
internal void memory_write32(void *ptr, U32 v);
internal U8 memory_read8(void *ptr);
internal U16 memory_read16(void *ptr);
internal U32 memory_read32(void *ptr);
internal U64 memory_read64(void *ptr);
//////////////////////////////// ////////////////////////////////
//~ rjf: Text 2D Coordinate/Range Functions //~ rjf: Text 2D Coordinate/Range Functions