Prefix static macros
This commit is contained in:
@@ -54,12 +54,12 @@
|
||||
#define uptr uintptr_t
|
||||
#define iptr intptr_t
|
||||
|
||||
#define external extern
|
||||
#define internal static
|
||||
#define persistent static
|
||||
#define wapp_extern extern
|
||||
#define wapp_intern static
|
||||
#define wapp_persist static
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#define class_mem static
|
||||
#define wapp_class_mem static
|
||||
#define BEGIN_C_LINKAGE extern "C" {
|
||||
#define END_C_LINKAGE }
|
||||
#endif // WAPP_PLATFORM_CPP
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
File *wapp_file_open(Str8RO *filepath, FileAccessMode mode) {
|
||||
persistent const char *modes[FILE_ACCESS_MODE_COUNT] = {
|
||||
wapp_persist const char *modes[FILE_ACCESS_MODE_COUNT] = {
|
||||
[WAPP_FA_MODE_R] = "r",
|
||||
[WAPP_FA_MODE_W] = "w",
|
||||
[WAPP_FA_MODE_A] = "a",
|
||||
@@ -27,7 +27,7 @@ File *wapp_file_open(Str8RO *filepath, FileAccessMode mode) {
|
||||
[WAPP_FA_MODE_WBX] = "wbx",
|
||||
[WAPP_FA_MODE_WBX_EX] = "wbx+",
|
||||
};
|
||||
persistent c8 tmp[WAPP_PATH_MAX] = {0};
|
||||
wapp_persist c8 tmp[WAPP_PATH_MAX] = {0};
|
||||
wapp_debug_assert(filepath->size < WAPP_PATH_MAX, "`filepath` exceeds max path limit.");
|
||||
|
||||
memset(tmp, 0, WAPP_PATH_MAX);
|
||||
|
@@ -5,10 +5,10 @@
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../os/mem/mem_os.h"
|
||||
|
||||
internal inline void *mem_arena_alloc(u64 size, void *alloc_obj);
|
||||
internal inline void *mem_arena_alloc_aligned(u64 size, u64 alignment, void *alloc_obj);
|
||||
internal inline void *mem_arena_realloc(void *ptr, u64 old_size, u64 new_size, void *alloc_obj);
|
||||
internal inline void *mem_arena_realloc_aligned(void *ptr, u64 old_size, u64 new_size, u64 alignment,
|
||||
wapp_intern inline void *mem_arena_alloc(u64 size, void *alloc_obj);
|
||||
wapp_intern inline void *mem_arena_alloc_aligned(u64 size, u64 alignment, void *alloc_obj);
|
||||
wapp_intern inline void *mem_arena_realloc(void *ptr, u64 old_size, u64 new_size, void *alloc_obj);
|
||||
wapp_intern inline void *mem_arena_realloc_aligned(void *ptr, u64 old_size, u64 new_size, u64 alignment,
|
||||
void *alloc_obj);
|
||||
|
||||
|
||||
@@ -37,22 +37,22 @@ void wapp_mem_arena_allocator_destroy(Allocator *allocator) {
|
||||
}
|
||||
|
||||
|
||||
internal inline void *mem_arena_alloc(u64 size, void *alloc_obj) {
|
||||
wapp_intern inline void *mem_arena_alloc(u64 size, void *alloc_obj) {
|
||||
Arena *arena = (Arena *)alloc_obj;
|
||||
return wapp_mem_arena_alloc(arena, size);
|
||||
}
|
||||
|
||||
internal inline void *mem_arena_alloc_aligned(u64 size, u64 alignment, void *alloc_obj) {
|
||||
wapp_intern inline void *mem_arena_alloc_aligned(u64 size, u64 alignment, void *alloc_obj) {
|
||||
Arena *arena = (Arena *)alloc_obj;
|
||||
return wapp_mem_arena_alloc_aligned(arena, size, alignment);
|
||||
}
|
||||
|
||||
internal inline void *mem_arena_realloc(void *ptr, u64 old_size, u64 new_size, void *alloc_obj) {
|
||||
wapp_intern inline void *mem_arena_realloc(void *ptr, u64 old_size, u64 new_size, void *alloc_obj) {
|
||||
Arena *arena = (Arena *)alloc_obj;
|
||||
return wapp_mem_arena_realloc(arena, ptr, old_size, new_size);
|
||||
}
|
||||
|
||||
internal inline void *mem_arena_realloc_aligned(void *ptr, u64 old_size, u64 new_size, u64 alignment,
|
||||
wapp_intern inline void *mem_arena_realloc_aligned(void *ptr, u64 old_size, u64 new_size, u64 alignment,
|
||||
void *alloc_obj) {
|
||||
Arena *arena = (Arena *)alloc_obj;
|
||||
return wapp_mem_arena_realloc_aligned(arena, ptr, old_size, new_size, alignment);
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include "../../../common/assert/assert.h"
|
||||
#include <stddef.h>
|
||||
|
||||
internal b32 is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
|
||||
wapp_intern b32 is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
|
||||
|
||||
void *wapp_mem_util_align_forward(void *ptr, u64 alignment) {
|
||||
wapp_debug_assert(ptr != NULL, "`ptr` should not be NULL");
|
||||
|
@@ -23,8 +23,8 @@ BEGIN_C_LINKAGE
|
||||
void *wapp_mem_util_alloc(void *addr, u64 size, MemAccess access, MemAllocFlags flags, MemInitType type);
|
||||
void wapp_mem_util_free(void *ptr, u64 size);
|
||||
|
||||
external void *mem_util_allocate(void *addr, u64 size, MemAccess access, MemAllocFlags flags, MemInitType type);
|
||||
external void mem_util_free(void *ptr, u64 size);
|
||||
wapp_extern void *mem_util_allocate(void *addr, u64 size, MemAccess access, MemAllocFlags flags, MemInitType type);
|
||||
wapp_extern void mem_util_free(void *ptr, u64 size);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include "../mem_os_ops.h"
|
||||
#include <sys/mman.h>
|
||||
|
||||
internal const i32 access_types[] = {
|
||||
wapp_intern const i32 access_types[] = {
|
||||
[WAPP_MEM_ACCESS_NONE] = PROT_NONE,
|
||||
[WAPP_MEM_ACCESS_READ_ONLY] = PROT_READ,
|
||||
[WAPP_MEM_ACCESS_EXEC_ONLY] = PROT_EXEC,
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#include <Windows.h>
|
||||
#include <memoryapi.h>
|
||||
|
||||
internal const i32 access_types[] = {
|
||||
wapp_intern const i32 access_types[] = {
|
||||
[WAPP_MEM_ACCESS_NONE] = PAGE_NOACCESS,
|
||||
[WAPP_MEM_ACCESS_READ_ONLY] = PAGE_READONLY,
|
||||
[WAPP_MEM_ACCESS_EXEC_ONLY] = PAGE_EXECUTE,
|
||||
|
@@ -17,8 +17,8 @@
|
||||
#define CMD_BUF_LEN 8192
|
||||
#define OUT_BUF_LEN 4096
|
||||
|
||||
internal inline CMDResult execute_command(Str8RO *cmd, CMDOutHandling out_handling, Str8 *out_buf);
|
||||
internal inline CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str8 *out_buf);
|
||||
wapp_intern inline CMDResult execute_command(Str8RO *cmd, CMDOutHandling out_handling, Str8 *out_buf);
|
||||
wapp_intern inline CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str8 *out_buf);
|
||||
|
||||
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd) {
|
||||
if (!cmd) {
|
||||
@@ -43,7 +43,7 @@ CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_bu
|
||||
return output;
|
||||
}
|
||||
|
||||
internal inline CMDResult execute_command(Str8RO *cmd, CMDOutHandling out_handling, Str8 *out_buf) {
|
||||
wapp_intern inline CMDResult execute_command(Str8RO *cmd, CMDOutHandling out_handling, Str8 *out_buf) {
|
||||
char cmd_buf[CMD_BUF_LEN] = {0};
|
||||
wapp_str8_copy_to_cstr(cmd_buf, cmd, CMD_BUF_LEN);
|
||||
|
||||
@@ -83,7 +83,7 @@ EXECUTE_COMMAND_CLOSE:
|
||||
return output;
|
||||
}
|
||||
|
||||
internal inline CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str8 *out_buf) {
|
||||
wapp_intern inline CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str8 *out_buf) {
|
||||
Str8 out = wapp_str8_buf(OUT_BUF_LEN);
|
||||
|
||||
out.size = fread((void *)out.buf, sizeof(u8), out.capacity, fp);
|
||||
|
@@ -18,7 +18,7 @@ BEGIN_C_LINKAGE
|
||||
|
||||
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd);
|
||||
|
||||
external CMDError get_output_status(FILE *fp, i32 *status_out);
|
||||
wapp_extern CMDError get_output_status(FILE *fp, i32 *status_out);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include "../terminal_colours.h"
|
||||
#include <stdio.h>
|
||||
|
||||
internal Str8RO colours[COUNT_TERM_COLOUR] = {
|
||||
wapp_intern Str8RO colours[COUNT_TERM_COLOUR] = {
|
||||
[WAPP_TERM_COLOUR_FG_BLACK] = wapp_str8_lit_ro_initialiser_list("\033[30m"),
|
||||
[WAPP_TERM_COLOUR_FG_RED] = wapp_str8_lit_ro_initialiser_list("\033[31m"),
|
||||
[WAPP_TERM_COLOUR_FG_GREEN] = wapp_str8_lit_ro_initialiser_list("\033[32m"),
|
||||
|
@@ -15,7 +15,7 @@ BEGIN_C_LINKAGE
|
||||
void wapp_shell_termcolour_print_text(Str8RO *text, TerminalColour colour);
|
||||
void wapp_shell_termcolour_clear_colour(void);
|
||||
|
||||
external void print_coloured_text(Str8RO *text, TerminalColour colour);
|
||||
wapp_extern void print_coloured_text(Str8RO *text, TerminalColour colour);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
|
@@ -22,9 +22,9 @@ struct termcolour_data {
|
||||
wapp_misc_utils_padding_size(sizeof(HANDLE) + sizeof(WORD) + sizeof(WORD));
|
||||
};
|
||||
|
||||
internal void init_data(TermcolourData *data);
|
||||
wapp_intern void init_data(TermcolourData *data);
|
||||
|
||||
internal WORD colours[COUNT_TERM_COLOUR] = {
|
||||
wapp_intern WORD colours[COUNT_TERM_COLOUR] = {
|
||||
[WAPP_TERM_COLOUR_FG_BLACK] = 0,
|
||||
[WAPP_TERM_COLOUR_FG_RED] = FOREGROUND_RED,
|
||||
[WAPP_TERM_COLOUR_FG_GREEN] = FOREGROUND_GREEN,
|
||||
@@ -44,7 +44,7 @@ internal WORD colours[COUNT_TERM_COLOUR] = {
|
||||
};
|
||||
|
||||
void print_coloured_text(Str8RO *text, TerminalColour colour) {
|
||||
persistent TermcolourData data = {0};
|
||||
wapp_persist TermcolourData data = {0};
|
||||
if (data.handle == 0) {
|
||||
init_data(&data);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ void print_coloured_text(Str8RO *text, TerminalColour colour) {
|
||||
printf(WAPP_STR8_SPEC, wapp_str8_varg((*text)));
|
||||
}
|
||||
|
||||
internal void init_data(TermcolourData *data) {
|
||||
wapp_intern void init_data(TermcolourData *data) {
|
||||
// create handle
|
||||
data->handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
|
@@ -37,7 +37,7 @@ BEGIN_C_LINKAGE
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#define wapp_void_ptr_array(...) ([&]() { \
|
||||
persistent void * buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(void *, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist void * buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(void *, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return VoidPArray{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(void *, __VA_ARGS__), \
|
||||
@@ -46,7 +46,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_void_ptr_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent void * buf[CAPACITY] = {}; \
|
||||
wapp_persist void * buf[CAPACITY] = {}; \
|
||||
return VoidPArray{buf, 0, CAPACITY, sizeof(void *)}; \
|
||||
}())
|
||||
#define wapp_void_ptr_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -54,7 +54,7 @@ BEGIN_C_LINKAGE
|
||||
void *{} \
|
||||
)
|
||||
#define wapp_str8_array(...) ([&]() { \
|
||||
persistent Str8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(Str8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist Str8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(Str8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return Str8Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(Str8, __VA_ARGS__), \
|
||||
@@ -63,7 +63,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_str8_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent Str8 buf[CAPACITY] = {}; \
|
||||
wapp_persist Str8 buf[CAPACITY] = {}; \
|
||||
return Str8Array{buf, 0, CAPACITY, sizeof(Str8)}; \
|
||||
}())
|
||||
#define wapp_str8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -71,7 +71,7 @@ BEGIN_C_LINKAGE
|
||||
Str8{} \
|
||||
)
|
||||
#define wapp_b32_array(...) ([&]() { \
|
||||
persistent b32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist b32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return B32Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(b32, __VA_ARGS__), \
|
||||
@@ -80,7 +80,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_b32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent b32 buf[CAPACITY] = {}; \
|
||||
wapp_persist b32 buf[CAPACITY] = {}; \
|
||||
return B32Array{buf, 0, CAPACITY, sizeof(b32)}; \
|
||||
}())
|
||||
#define wapp_b32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -88,7 +88,7 @@ BEGIN_C_LINKAGE
|
||||
b32{} \
|
||||
)
|
||||
#define wapp_char_array(...) ([&]() { \
|
||||
persistent char buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist char buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return CharArray{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(char, __VA_ARGS__), \
|
||||
@@ -97,7 +97,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_char_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent char buf[CAPACITY] = {}; \
|
||||
wapp_persist char buf[CAPACITY] = {}; \
|
||||
return CharArray{buf, 0, CAPACITY, sizeof(char)}; \
|
||||
}())
|
||||
#define wapp_char_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -105,7 +105,7 @@ BEGIN_C_LINKAGE
|
||||
char{} \
|
||||
)
|
||||
#define wapp_c8_array(...) ([&]() { \
|
||||
persistent c8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist c8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return C8Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(c8, __VA_ARGS__), \
|
||||
@@ -114,7 +114,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_c8_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent c8 buf[CAPACITY] = {}; \
|
||||
wapp_persist c8 buf[CAPACITY] = {}; \
|
||||
return C8Array{buf, 0, CAPACITY, sizeof(c8)}; \
|
||||
}())
|
||||
#define wapp_c8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -122,7 +122,7 @@ BEGIN_C_LINKAGE
|
||||
c8{} \
|
||||
)
|
||||
#define wapp_c16_array(...) ([&]() { \
|
||||
persistent c16 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c16, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist c16 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c16, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return C16Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(c16, __VA_ARGS__), \
|
||||
@@ -131,7 +131,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_c16_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent c16 buf[CAPACITY] = {}; \
|
||||
wapp_persist c16 buf[CAPACITY] = {}; \
|
||||
return C16Array{buf, 0, CAPACITY, sizeof(c16)}; \
|
||||
}())
|
||||
#define wapp_c16_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -139,7 +139,7 @@ BEGIN_C_LINKAGE
|
||||
c16{} \
|
||||
)
|
||||
#define wapp_c32_array(...) ([&]() { \
|
||||
persistent c32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist c32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return C32Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(c32, __VA_ARGS__), \
|
||||
@@ -148,7 +148,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_c32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent c32 buf[CAPACITY] = {}; \
|
||||
wapp_persist c32 buf[CAPACITY] = {}; \
|
||||
return C32Array{buf, 0, CAPACITY, sizeof(c32)}; \
|
||||
}())
|
||||
#define wapp_c32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -156,7 +156,7 @@ BEGIN_C_LINKAGE
|
||||
c32{} \
|
||||
)
|
||||
#define wapp_i8_array(...) ([&]() { \
|
||||
persistent i8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist i8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return I8Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(i8, __VA_ARGS__), \
|
||||
@@ -165,7 +165,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_i8_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent i8 buf[CAPACITY] = {}; \
|
||||
wapp_persist i8 buf[CAPACITY] = {}; \
|
||||
return I8Array{buf, 0, CAPACITY, sizeof(i8)}; \
|
||||
}())
|
||||
#define wapp_i8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -173,7 +173,7 @@ BEGIN_C_LINKAGE
|
||||
i8{} \
|
||||
)
|
||||
#define wapp_i16_array(...) ([&]() { \
|
||||
persistent i16 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i16, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist i16 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i16, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return I16Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(i16, __VA_ARGS__), \
|
||||
@@ -182,7 +182,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_i16_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent i16 buf[CAPACITY] = {}; \
|
||||
wapp_persist i16 buf[CAPACITY] = {}; \
|
||||
return I16Array{buf, 0, CAPACITY, sizeof(i16)}; \
|
||||
}())
|
||||
#define wapp_i16_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -190,7 +190,7 @@ BEGIN_C_LINKAGE
|
||||
i16{} \
|
||||
)
|
||||
#define wapp_i32_array(...) ([&]() { \
|
||||
persistent i32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist i32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return I32Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(i32, __VA_ARGS__), \
|
||||
@@ -199,7 +199,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_i32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent i32 buf[CAPACITY] = {}; \
|
||||
wapp_persist i32 buf[CAPACITY] = {}; \
|
||||
return I32Array{buf, 0, CAPACITY, sizeof(i32)}; \
|
||||
}())
|
||||
#define wapp_i32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -207,7 +207,7 @@ BEGIN_C_LINKAGE
|
||||
i32{} \
|
||||
)
|
||||
#define wapp_i64_array(...) ([&]() { \
|
||||
persistent i64 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i64, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist i64 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i64, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return I64Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(i64, __VA_ARGS__), \
|
||||
@@ -216,7 +216,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_i64_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent i64 buf[CAPACITY] = {}; \
|
||||
wapp_persist i64 buf[CAPACITY] = {}; \
|
||||
return I64Array{buf, 0, CAPACITY, sizeof(i64)}; \
|
||||
}())
|
||||
#define wapp_i64_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -224,7 +224,7 @@ BEGIN_C_LINKAGE
|
||||
i64{} \
|
||||
)
|
||||
#define wapp_u8_array(...) ([&]() { \
|
||||
persistent u8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist u8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return U8Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(u8, __VA_ARGS__), \
|
||||
@@ -233,7 +233,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_u8_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent u8 buf[CAPACITY] = {}; \
|
||||
wapp_persist u8 buf[CAPACITY] = {}; \
|
||||
return U8Array{buf, 0, CAPACITY, sizeof(u8)}; \
|
||||
}())
|
||||
#define wapp_u8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -241,7 +241,7 @@ BEGIN_C_LINKAGE
|
||||
u8{} \
|
||||
)
|
||||
#define wapp_u16_array(...) ([&]() { \
|
||||
persistent u16 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u16, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist u16 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u16, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return U16Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(u16, __VA_ARGS__), \
|
||||
@@ -250,7 +250,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_u16_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent u16 buf[CAPACITY] = {}; \
|
||||
wapp_persist u16 buf[CAPACITY] = {}; \
|
||||
return U16Array{buf, 0, CAPACITY, sizeof(u16)}; \
|
||||
}())
|
||||
#define wapp_u16_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -258,7 +258,7 @@ BEGIN_C_LINKAGE
|
||||
u16{} \
|
||||
)
|
||||
#define wapp_u32_array(...) ([&]() { \
|
||||
persistent u32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist u32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return U32Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(u32, __VA_ARGS__), \
|
||||
@@ -267,7 +267,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_u32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent u32 buf[CAPACITY] = {}; \
|
||||
wapp_persist u32 buf[CAPACITY] = {}; \
|
||||
return U32Array{buf, 0, CAPACITY, sizeof(u32)}; \
|
||||
}())
|
||||
#define wapp_u32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -275,7 +275,7 @@ BEGIN_C_LINKAGE
|
||||
u32{} \
|
||||
)
|
||||
#define wapp_u64_array(...) ([&]() { \
|
||||
persistent u64 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u64, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist u64 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u64, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return U64Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(u64, __VA_ARGS__), \
|
||||
@@ -284,7 +284,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_u64_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent u64 buf[CAPACITY] = {}; \
|
||||
wapp_persist u64 buf[CAPACITY] = {}; \
|
||||
return U64Array{buf, 0, CAPACITY, sizeof(u64)}; \
|
||||
}())
|
||||
#define wapp_u64_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -292,7 +292,7 @@ BEGIN_C_LINKAGE
|
||||
u64{} \
|
||||
)
|
||||
#define wapp_f32_array(...) ([&]() { \
|
||||
persistent f32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist f32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return F32Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(f32, __VA_ARGS__), \
|
||||
@@ -301,7 +301,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_f32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent f32 buf[CAPACITY] = {}; \
|
||||
wapp_persist f32 buf[CAPACITY] = {}; \
|
||||
return F32Array{buf, 0, CAPACITY, sizeof(f32)}; \
|
||||
}())
|
||||
#define wapp_f32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -309,7 +309,7 @@ BEGIN_C_LINKAGE
|
||||
f32{} \
|
||||
)
|
||||
#define wapp_f64_array(...) ([&]() { \
|
||||
persistent f64 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f64, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist f64 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f64, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return F64Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(f64, __VA_ARGS__), \
|
||||
@@ -318,7 +318,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_f64_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent f64 buf[CAPACITY] = {}; \
|
||||
wapp_persist f64 buf[CAPACITY] = {}; \
|
||||
return F64Array{buf, 0, CAPACITY, sizeof(f64)}; \
|
||||
}())
|
||||
#define wapp_f64_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -326,7 +326,7 @@ BEGIN_C_LINKAGE
|
||||
f64{} \
|
||||
)
|
||||
#define wapp_f128_array(...) ([&]() { \
|
||||
persistent f128 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f128, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist f128 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f128, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return F128Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(f128, __VA_ARGS__), \
|
||||
@@ -335,7 +335,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_f128_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent f128 buf[CAPACITY] = {}; \
|
||||
wapp_persist f128 buf[CAPACITY] = {}; \
|
||||
return F128Array{buf, 0, CAPACITY, sizeof(f128)}; \
|
||||
}())
|
||||
#define wapp_f128_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -343,7 +343,7 @@ BEGIN_C_LINKAGE
|
||||
f128{} \
|
||||
)
|
||||
#define wapp_iptr_array(...) ([&]() { \
|
||||
persistent iptr buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(iptr, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist iptr buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(iptr, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return IptrArray{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(iptr, __VA_ARGS__), \
|
||||
@@ -352,7 +352,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_iptr_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent iptr buf[CAPACITY] = {}; \
|
||||
wapp_persist iptr buf[CAPACITY] = {}; \
|
||||
return IptrArray{buf, 0, CAPACITY, sizeof(iptr)}; \
|
||||
}())
|
||||
#define wapp_iptr_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
@@ -360,7 +360,7 @@ BEGIN_C_LINKAGE
|
||||
iptr{} \
|
||||
)
|
||||
#define wapp_uptr_array(...) ([&]() { \
|
||||
persistent uptr buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(uptr, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
wapp_persist uptr buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(uptr, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return UptrArray{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(uptr, __VA_ARGS__), \
|
||||
@@ -369,7 +369,7 @@ BEGIN_C_LINKAGE
|
||||
}; \
|
||||
}())
|
||||
#define wapp_uptr_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent uptr buf[CAPACITY] = {}; \
|
||||
wapp_persist uptr buf[CAPACITY] = {}; \
|
||||
return UptrArray{buf, 0, CAPACITY, sizeof(uptr)}; \
|
||||
}())
|
||||
#define wapp_uptr_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
|
@@ -8,26 +8,26 @@
|
||||
#include "../../common/platform/platform.h"
|
||||
#include <stddef.h>
|
||||
|
||||
internal VoidPList void_ptr_node_to_list(VoidPNode *node);
|
||||
internal Str8List str8_node_to_list(Str8Node *node);
|
||||
internal B32List b32_node_to_list(B32Node *node);
|
||||
internal CharList char_node_to_list(CharNode *node);
|
||||
internal C8List c8_node_to_list(C8Node *node);
|
||||
internal C16List c16_node_to_list(C16Node *node);
|
||||
internal C32List c32_node_to_list(C32Node *node);
|
||||
internal I8List i8_node_to_list(I8Node *node);
|
||||
internal I16List i16_node_to_list(I16Node *node);
|
||||
internal I32List i32_node_to_list(I32Node *node);
|
||||
internal I64List i64_node_to_list(I64Node *node);
|
||||
internal U8List u8_node_to_list(U8Node *node);
|
||||
internal U16List u16_node_to_list(U16Node *node);
|
||||
internal U32List u32_node_to_list(U32Node *node);
|
||||
internal U64List u64_node_to_list(U64Node *node);
|
||||
internal F32List f32_node_to_list(F32Node *node);
|
||||
internal F64List f64_node_to_list(F64Node *node);
|
||||
internal F128List f128_node_to_list(F128Node *node);
|
||||
internal IptrList iptr_node_to_list(IptrNode *node);
|
||||
internal UptrList uptr_node_to_list(UptrNode *node);
|
||||
wapp_intern VoidPList void_ptr_node_to_list(VoidPNode *node);
|
||||
wapp_intern Str8List str8_node_to_list(Str8Node *node);
|
||||
wapp_intern B32List b32_node_to_list(B32Node *node);
|
||||
wapp_intern CharList char_node_to_list(CharNode *node);
|
||||
wapp_intern C8List c8_node_to_list(C8Node *node);
|
||||
wapp_intern C16List c16_node_to_list(C16Node *node);
|
||||
wapp_intern C32List c32_node_to_list(C32Node *node);
|
||||
wapp_intern I8List i8_node_to_list(I8Node *node);
|
||||
wapp_intern I16List i16_node_to_list(I16Node *node);
|
||||
wapp_intern I32List i32_node_to_list(I32Node *node);
|
||||
wapp_intern I64List i64_node_to_list(I64Node *node);
|
||||
wapp_intern U8List u8_node_to_list(U8Node *node);
|
||||
wapp_intern U16List u16_node_to_list(U16Node *node);
|
||||
wapp_intern U32List u32_node_to_list(U32Node *node);
|
||||
wapp_intern U64List u64_node_to_list(U64Node *node);
|
||||
wapp_intern F32List f32_node_to_list(F32Node *node);
|
||||
wapp_intern F64List f64_node_to_list(F64Node *node);
|
||||
wapp_intern F128List f128_node_to_list(F128Node *node);
|
||||
wapp_intern IptrList iptr_node_to_list(IptrNode *node);
|
||||
wapp_intern UptrList uptr_node_to_list(UptrNode *node);
|
||||
|
||||
VoidPNode *wapp_void_ptr_list_get(const VoidPList *list, u64 index) {
|
||||
wapp_runtime_assert(index < list->node_count, "`index` is out of bounds");
|
||||
@@ -3489,7 +3489,7 @@ void wapp_uptr_list_empty(UptrList *list) {
|
||||
}
|
||||
}
|
||||
|
||||
internal VoidPList void_ptr_node_to_list(VoidPNode *node) {
|
||||
wapp_intern VoidPList void_ptr_node_to_list(VoidPNode *node) {
|
||||
VoidPList output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3505,7 +3505,7 @@ internal VoidPList void_ptr_node_to_list(VoidPNode *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal Str8List str8_node_to_list(Str8Node *node) {
|
||||
wapp_intern Str8List str8_node_to_list(Str8Node *node) {
|
||||
Str8List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3521,7 +3521,7 @@ internal Str8List str8_node_to_list(Str8Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal B32List b32_node_to_list(B32Node *node) {
|
||||
wapp_intern B32List b32_node_to_list(B32Node *node) {
|
||||
B32List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3537,7 +3537,7 @@ internal B32List b32_node_to_list(B32Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal CharList char_node_to_list(CharNode *node) {
|
||||
wapp_intern CharList char_node_to_list(CharNode *node) {
|
||||
CharList output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3553,7 +3553,7 @@ internal CharList char_node_to_list(CharNode *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal C8List c8_node_to_list(C8Node *node) {
|
||||
wapp_intern C8List c8_node_to_list(C8Node *node) {
|
||||
C8List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3569,7 +3569,7 @@ internal C8List c8_node_to_list(C8Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal C16List c16_node_to_list(C16Node *node) {
|
||||
wapp_intern C16List c16_node_to_list(C16Node *node) {
|
||||
C16List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3585,7 +3585,7 @@ internal C16List c16_node_to_list(C16Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal C32List c32_node_to_list(C32Node *node) {
|
||||
wapp_intern C32List c32_node_to_list(C32Node *node) {
|
||||
C32List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3601,7 +3601,7 @@ internal C32List c32_node_to_list(C32Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal I8List i8_node_to_list(I8Node *node) {
|
||||
wapp_intern I8List i8_node_to_list(I8Node *node) {
|
||||
I8List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3617,7 +3617,7 @@ internal I8List i8_node_to_list(I8Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal I16List i16_node_to_list(I16Node *node) {
|
||||
wapp_intern I16List i16_node_to_list(I16Node *node) {
|
||||
I16List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3633,7 +3633,7 @@ internal I16List i16_node_to_list(I16Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal I32List i32_node_to_list(I32Node *node) {
|
||||
wapp_intern I32List i32_node_to_list(I32Node *node) {
|
||||
I32List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3649,7 +3649,7 @@ internal I32List i32_node_to_list(I32Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal I64List i64_node_to_list(I64Node *node) {
|
||||
wapp_intern I64List i64_node_to_list(I64Node *node) {
|
||||
I64List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3665,7 +3665,7 @@ internal I64List i64_node_to_list(I64Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal U8List u8_node_to_list(U8Node *node) {
|
||||
wapp_intern U8List u8_node_to_list(U8Node *node) {
|
||||
U8List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3681,7 +3681,7 @@ internal U8List u8_node_to_list(U8Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal U16List u16_node_to_list(U16Node *node) {
|
||||
wapp_intern U16List u16_node_to_list(U16Node *node) {
|
||||
U16List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3697,7 +3697,7 @@ internal U16List u16_node_to_list(U16Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal U32List u32_node_to_list(U32Node *node) {
|
||||
wapp_intern U32List u32_node_to_list(U32Node *node) {
|
||||
U32List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3713,7 +3713,7 @@ internal U32List u32_node_to_list(U32Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal U64List u64_node_to_list(U64Node *node) {
|
||||
wapp_intern U64List u64_node_to_list(U64Node *node) {
|
||||
U64List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3729,7 +3729,7 @@ internal U64List u64_node_to_list(U64Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal F32List f32_node_to_list(F32Node *node) {
|
||||
wapp_intern F32List f32_node_to_list(F32Node *node) {
|
||||
F32List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3745,7 +3745,7 @@ internal F32List f32_node_to_list(F32Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal F64List f64_node_to_list(F64Node *node) {
|
||||
wapp_intern F64List f64_node_to_list(F64Node *node) {
|
||||
F64List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3761,7 +3761,7 @@ internal F64List f64_node_to_list(F64Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal F128List f128_node_to_list(F128Node *node) {
|
||||
wapp_intern F128List f128_node_to_list(F128Node *node) {
|
||||
F128List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3777,7 +3777,7 @@ internal F128List f128_node_to_list(F128Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal IptrList iptr_node_to_list(IptrNode *node) {
|
||||
wapp_intern IptrList iptr_node_to_list(IptrNode *node) {
|
||||
IptrList output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
@@ -3793,7 +3793,7 @@ internal IptrList iptr_node_to_list(IptrNode *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
internal UptrList uptr_node_to_list(UptrNode *node) {
|
||||
wapp_intern UptrList uptr_node_to_list(UptrNode *node) {
|
||||
UptrList output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
|
@@ -37,14 +37,14 @@ typedef const Str8 Str8RO;
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
// Uses a lambda to achieve the same behaviour achieved by the C macro
|
||||
#define wapp_str8_buf(CAPACITY) ([&](){ \
|
||||
persistent c8 buf[CAPACITY] = {}; \
|
||||
wapp_persist c8 buf[CAPACITY] = {}; \
|
||||
memset(buf, 0, CAPACITY); \
|
||||
return Str8{CAPACITY, 0, buf}; \
|
||||
}())
|
||||
|
||||
// Uses a lambda to achieve the same behaviour achieved by the C macro
|
||||
#define wapp_str8_lit(STRING) ([&]() { \
|
||||
persistent c8 buf[sizeof(STRING) * 2] = {}; \
|
||||
wapp_persist c8 buf[sizeof(STRING) * 2] = {}; \
|
||||
memcpy(buf, STRING, sizeof(STRING)); \
|
||||
return Str8{(sizeof(STRING) - 1) * 2, sizeof(STRING) - 1, buf}; \
|
||||
}())
|
||||
@@ -121,11 +121,11 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8R
|
||||
*/
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#define wapp_str8_node_from_cstr(STRING) wapp_str8_list_node([&]() { \
|
||||
persistent Str8 str = wapp_str8_lit(STRING); \
|
||||
wapp_persist Str8 str = wapp_str8_lit(STRING); \
|
||||
return &str; \
|
||||
}())
|
||||
#define wapp_str8_node_from_str8(STRING) wapp_str8_list_node([&]() { \
|
||||
persistent Str8 str = STRING; \
|
||||
wapp_persist Str8 str = STRING; \
|
||||
return &str; \
|
||||
}())
|
||||
#else
|
||||
|
@@ -12,13 +12,13 @@ struct split_mix_64_state {
|
||||
u64 seed;
|
||||
};
|
||||
|
||||
internal u64 rol64(u64 x, u64 bits);
|
||||
internal u64 split_mix_64(SplitMix64State *state);
|
||||
internal void seed_os_generator(void);
|
||||
internal u64 generate_random_number(void);
|
||||
wapp_intern u64 rol64(u64 x, u64 bits);
|
||||
wapp_intern u64 split_mix_64(SplitMix64State *state);
|
||||
wapp_intern void seed_os_generator(void);
|
||||
wapp_intern u64 generate_random_number(void);
|
||||
|
||||
XOR256State wapp_prng_xorshift_init_state(void) {
|
||||
persistent b32 seeded = false;
|
||||
wapp_persist b32 seeded = false;
|
||||
if (!seeded) {
|
||||
seeded = true;
|
||||
seed_os_generator();
|
||||
@@ -75,11 +75,11 @@ u64 wapp_prng_xorshift_256p(XOR256State *state) {
|
||||
return result;
|
||||
}
|
||||
|
||||
internal u64 rol64(u64 x, u64 bits) {
|
||||
wapp_intern u64 rol64(u64 x, u64 bits) {
|
||||
return (x << bits) | (x >> (64 - bits));
|
||||
}
|
||||
|
||||
internal u64 split_mix_64(SplitMix64State *state) {
|
||||
wapp_intern u64 split_mix_64(SplitMix64State *state) {
|
||||
state->seed += 0x9E3779B97f4A7C15;
|
||||
|
||||
u64 result = state->seed;
|
||||
@@ -91,7 +91,7 @@ internal u64 split_mix_64(SplitMix64State *state) {
|
||||
|
||||
#if defined(WAPP_PLATFORM_C) && WAPP_PLATFORM_C_VERSION >= WAPP_PLATFORM_C11_VERSION
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
internal void seed_os_generator(void) {
|
||||
wapp_intern void seed_os_generator(void) {
|
||||
struct timespec ts = {0};
|
||||
int result = clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
|
||||
wapp_runtime_assert(result == 0, "Invalid seed value");
|
||||
@@ -99,11 +99,11 @@ internal void seed_os_generator(void) {
|
||||
srand48(ts.tv_nsec);
|
||||
}
|
||||
|
||||
internal u64 generate_random_number(void) {
|
||||
wapp_intern u64 generate_random_number(void) {
|
||||
return lrand48();
|
||||
}
|
||||
#else
|
||||
internal void seed_os_generator(void) {
|
||||
wapp_intern void seed_os_generator(void) {
|
||||
struct timespec ts = {0};
|
||||
int result = timespec_get(&ts, TIME_UTC);
|
||||
wapp_runtime_assert(result != 0, "Invalid seed value");
|
||||
@@ -111,7 +111,7 @@ internal void seed_os_generator(void) {
|
||||
srand(ts.tv_nsec);
|
||||
}
|
||||
|
||||
internal u64 generate_random_number(void) {
|
||||
wapp_intern u64 generate_random_number(void) {
|
||||
i32 n1 = rand();
|
||||
i32 n2 = rand();
|
||||
|
||||
@@ -119,14 +119,14 @@ internal u64 generate_random_number(void) {
|
||||
}
|
||||
#endif // !WAPP_PLATFORM_POSIX
|
||||
#else
|
||||
internal void seed_os_generator(void) {
|
||||
wapp_intern void seed_os_generator(void) {
|
||||
time_t result = time(NULL);
|
||||
wapp_runtime_assert(result != (time_t)(-1), "Invalid seed value");
|
||||
|
||||
srand(result);
|
||||
}
|
||||
|
||||
internal u64 generate_random_number(void) {
|
||||
wapp_intern u64 generate_random_number(void) {
|
||||
i32 n1 = rand();
|
||||
i32 n2 = rand();
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
internal void handle_test_result(TestFuncResult result);
|
||||
wapp_intern void handle_test_result(TestFuncResult result);
|
||||
|
||||
void run_tests(TestFunc *func1, ...) {
|
||||
printf("\n");
|
||||
@@ -32,7 +32,7 @@ void run_tests(TestFunc *func1, ...) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
internal void handle_test_result(TestFuncResult result) {
|
||||
wapp_intern void handle_test_result(TestFuncResult result) {
|
||||
TerminalColour colour;
|
||||
Str8 result_text = wapp_str8_buf(64);
|
||||
|
||||
|
@@ -15,8 +15,8 @@ struct uuid4 {
|
||||
u64 low;
|
||||
};
|
||||
|
||||
internal UUID4 generate_uuid4(void);
|
||||
internal void uuid4_to_uuid(const UUID4* uuid4, UUID *uuid);
|
||||
wapp_intern UUID4 generate_uuid4(void);
|
||||
wapp_intern void uuid4_to_uuid(const UUID4* uuid4, UUID *uuid);
|
||||
|
||||
UUID *wapp_uuid_init_uuid4(UUID *uuid) {
|
||||
wapp_debug_assert(uuid != NULL, "`uuid` should not be NULL");
|
||||
@@ -27,9 +27,9 @@ UUID *wapp_uuid_init_uuid4(UUID *uuid) {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
internal UUID4 generate_uuid4(void) {
|
||||
persistent XOR256State state = {0};
|
||||
persistent b32 initialised = false;
|
||||
wapp_intern UUID4 generate_uuid4(void) {
|
||||
wapp_persist XOR256State state = {0};
|
||||
wapp_persist b32 initialised = false;
|
||||
|
||||
if (!initialised) {
|
||||
initialised = true;
|
||||
@@ -47,7 +47,7 @@ internal UUID4 generate_uuid4(void) {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
internal void uuid4_to_uuid(const UUID4* uuid4, UUID *uuid) {
|
||||
wapp_intern void uuid4_to_uuid(const UUID4* uuid4, UUID *uuid) {
|
||||
u64 grp1 = uuid4->high >> 32;
|
||||
u64 grp2 = (uuid4->high << 32) >> 48;
|
||||
u64 grp3 = (uuid4->high << 48) >> 48;
|
||||
|
Reference in New Issue
Block a user