Always reserve padding for structs that need it
This commit is contained in:
@@ -86,8 +86,8 @@ typedef Str8 *Str8Array;
|
||||
#else
|
||||
#define _stack_array(TYPE, SIZE) struct {ArrayHeader header; \
|
||||
TYPE items[SIZE]; \
|
||||
wapp_misc_utils_padding_size(sizeof(ArrayHeader) + \
|
||||
sizeof(TYPE) * SIZE);}
|
||||
wapp_misc_utils_reserve_padding(sizeof(ArrayHeader) + \
|
||||
sizeof(TYPE) * SIZE);}
|
||||
#define wapp_array(TYPE, ...) \
|
||||
(TYPE *)( \
|
||||
(_stack_array(TYPE, _calc_array_capacity(TYPE, __VA_ARGS__))){ \
|
||||
|
||||
@@ -23,7 +23,7 @@ BEGIN_C_LINKAGE
|
||||
#define PB(SIZE) (TB(SIZE) * 1000llu)
|
||||
#define EB(SIZE) (PB(SIZE) * 1000llu)
|
||||
|
||||
#define wapp_misc_utils_padding_size(SIZE) u8 reserved_padding[sizeof(void *) - ((SIZE) % sizeof(void *))]
|
||||
#define wapp_misc_utils_reserve_padding(SIZE) u8 reserved_padding[sizeof(void *) - ((SIZE) % sizeof(void *))]
|
||||
|
||||
#define U64_RSHIFT_OR_1(X) (((u64)X) | (((u64)X) >> 1))
|
||||
#define U64_RSHIFT_OR_2(X) (((u64)X) | (((u64)X) >> 2))
|
||||
|
||||
@@ -23,9 +23,7 @@ struct Arena {
|
||||
u64 capacity;
|
||||
b8 committed;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
wapp_misc_utils_padding_size(sizeof(u8 *) * 2 + sizeof(u64) + sizeof(b8));
|
||||
#endif // ifdef WAPP_PLATFORM_WINDOWS
|
||||
wapp_misc_utils_reserve_padding(sizeof(u8 *) * 2 + sizeof(u64) + sizeof(b8));
|
||||
};
|
||||
|
||||
b8 wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, b8 zero_buffer) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
#include "../../../common/misc/misc_utils.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
@@ -31,10 +32,7 @@ struct CMDResult {
|
||||
CMDError error;
|
||||
b8 exited;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#include "../../../common/misc/misc_utils.h"
|
||||
wapp_misc_utils_padding_size(sizeof(b8) + sizeof(i32) + sizeof(CMDError));
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
wapp_misc_utils_reserve_padding(sizeof(b8) + sizeof(i32) + sizeof(CMDError));
|
||||
};
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
|
||||
@@ -19,7 +19,7 @@ struct TermcolourData {
|
||||
WORD default_colour;
|
||||
WORD current_colour;
|
||||
|
||||
wapp_misc_utils_padding_size(sizeof(HANDLE) + sizeof(WORD) + sizeof(WORD));
|
||||
wapp_misc_utils_reserve_padding(sizeof(HANDLE) + sizeof(WORD) + sizeof(WORD));
|
||||
};
|
||||
|
||||
wapp_intern void init_data(TermcolourData *data);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
|
||||
#define wapp_tester_result(PASSED) (TestFuncResult{wapp_str8_lit_ro(__func__), PASSED})
|
||||
#define wapp_tester_result(PASSED) (TestFuncResult{wapp_str8_lit_ro(__func__), PASSED, {}})
|
||||
#else
|
||||
#define wapp_tester_result(PASSED) ((TestFuncResult){.name = wapp_str8_lit_ro(__func__), .passed = PASSED})
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
@@ -22,9 +22,7 @@ struct TestFuncResult {
|
||||
Str8 name;
|
||||
b8 passed;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
wapp_misc_utils_padding_size(sizeof(Str8RO) + sizeof(b8));
|
||||
#endif // WAPP_PLATFORM_WINDOWS
|
||||
wapp_misc_utils_reserve_padding(sizeof(Str8) + sizeof(b8));
|
||||
};
|
||||
|
||||
typedef TestFuncResult(TestFunc)(void);
|
||||
|
||||
Reference in New Issue
Block a user