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