Rename platform constants
This commit is contained in:
@@ -8,9 +8,9 @@
|
||||
#include "../../common/aliases/aliases.h"
|
||||
#include "../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define WAPP_ARRAY_MAGIC (u64)0x57415f415252
|
||||
|
||||
@@ -46,7 +46,7 @@ typedef enum {
|
||||
ARRAY_INIT_FILLED = 1 << 1,
|
||||
} ArrayInitFlags;
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wapp_array(TYPE, ...) ([&]() { \
|
||||
u64 capacity = _calc_array_capacity(TYPE, __VA_ARGS__); \
|
||||
\
|
||||
@@ -119,7 +119,7 @@ typedef enum {
|
||||
(TYPE){0} : \
|
||||
*((TYPE *)_array_pop((GenericArray)ARRAY, sizeof(TYPE))) \
|
||||
)
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define wapp_array_count(ARRAY) \
|
||||
(_array_count((GenericArray)ARRAY))
|
||||
@@ -209,8 +209,8 @@ GenericArray _array_alloc_capacity(const Allocator *allocator, u64 capacity, Arr
|
||||
GenericArray _array_from_preallocated_buffer(void *buffer, u64 buffer_size, ArrayInitFlags flags,
|
||||
u64 item_size);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !ARRAY_H
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include "../../common/aliases/aliases.h"
|
||||
#include "../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define WAPP_DBL_LIST_MAGIC (u64)0x57415f444c5354
|
||||
#define WAPP_DBL_NODE_MAGIC (u64)0x57415f444e44
|
||||
@@ -78,7 +78,7 @@ typedef GenericNode UptrNode;
|
||||
typedef GenericNode IptrNode;
|
||||
typedef GenericNode Str8Node;
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wapp_dbl_list(TYPE) \
|
||||
GenericList{WAPP_DBL_LIST_MAGIC, 0, sizeof(TYPE), nullptr, nullptr}
|
||||
#define _dbl_list_node(TYPE, ITEM_PTR) ([&]() { \
|
||||
@@ -97,7 +97,7 @@ typedef GenericNode Str8Node;
|
||||
&((GenericNode){.header = {.magic = WAPP_DBL_NODE_MAGIC, .item_size = sizeof(TYPE)}, \
|
||||
.item = ITEM_PTR}) \
|
||||
)
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define wapp_dbl_list_alloc(TYPE, ALLOCATOR) \
|
||||
(_dbl_list_alloc(ALLOCATOR, sizeof(TYPE)))
|
||||
@@ -177,8 +177,8 @@ GenericNode *_dbl_list_pop_back(GenericList *list, u64 item_size);
|
||||
GenericNode *_dbl_list_remove(GenericList *list, u64 index, u64 item_size);
|
||||
void _dbl_list_empty(GenericList *list, u64 item_size);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !DBL_LIST_H
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include "../../../common/platform/platform.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef void *(MemAllocFunc)(u64 size, void *alloc_obj);
|
||||
typedef void *(MemAllocAlignedFunc)(u64 size, u64 alignment, void *alloc_obj);
|
||||
@@ -27,14 +27,14 @@ struct Allocator {
|
||||
MemFreeFunc *free;
|
||||
};
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wapp_mem_allocator_invalid(ALLOCATOR) ([&]() { \
|
||||
Allocator alloc{}; \
|
||||
return memcmp(ALLOCATOR, &alloc, sizeof(Allocator)) == 0; \
|
||||
}())
|
||||
#else
|
||||
#define wapp_mem_allocator_invalid(ALLOCATOR) (memcmp(ALLOCATOR, &((Allocator){0}), sizeof(Allocator)) == 0)
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
void *wapp_mem_allocator_alloc(const Allocator *allocator, u64 size);
|
||||
void *wapp_mem_allocator_alloc_aligned(const Allocator *allocator, u64 size, u64 alignment);
|
||||
@@ -43,8 +43,8 @@ void *wapp_mem_allocator_realloc_aligned(const Allocator *allocator, void *ptr,
|
||||
u64 new_size, u64 alignment);
|
||||
void wapp_mem_allocator_free(const Allocator *allocator, void **ptr, u64 size);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !MEM_ALLOCATOR_H
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
void *wapp_mem_util_align_forward(void *ptr, u64 alignment);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !MEM_UTILS_H
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#include "../../common/aliases/aliases.h"
|
||||
#include "../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef struct {
|
||||
GenericArray items;
|
||||
@@ -40,7 +40,7 @@ typedef GenericQueue UptrQueue;
|
||||
typedef GenericQueue IptrQueue;
|
||||
typedef GenericQueue Str8Queue;
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wapp_queue(TYPE, CAPACITY) ([&]() { \
|
||||
wapp_persist GenericArray arr = wapp_array_with_capacity(TYPE, CAPACITY, ARRAY_INIT_FILLED); \
|
||||
wapp_persist GenericQueue queue = { \
|
||||
@@ -75,7 +75,7 @@ typedef GenericQueue Str8Queue;
|
||||
.back = 0, \
|
||||
.count = 0, \
|
||||
})
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define wapp_queue_capacity(QUEUE_PTR) (wapp_array_capacity((QUEUE_PTR)->items))
|
||||
#define wapp_queue_item_size(QUEUE_PTR) (wapp_array_item_size((QUEUE_PTR)->items))
|
||||
@@ -93,8 +93,8 @@ void _queue_push(GenericQueue *queue, void *item, u64 item_size);
|
||||
GenericQueue *_queue_push_alloc(const Allocator *allocator, GenericQueue *queue, void *item, u64 item_size);
|
||||
void *_queue_pop(GenericQueue *queue, u64 item_size);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !QUEUE_H
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include "../../mem/allocator/mem_allocator.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef struct Str8 Str8;
|
||||
struct Str8 {
|
||||
@@ -34,7 +34,7 @@ typedef const Str8 Str8RO;
|
||||
* Str8 stack buffers
|
||||
*/
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
// Uses a lambda to achieve the same behaviour achieved by the C macro
|
||||
#define wapp_str8_buf(CAPACITY) ([&](){ \
|
||||
wapp_persist c8 buf[CAPACITY] = {}; \
|
||||
@@ -70,7 +70,7 @@ typedef const Str8 Str8RO;
|
||||
#define wapp_str8_lit_ro_initialiser_list(STRING) {.capacity = sizeof(STRING) - 1, \
|
||||
.size = sizeof(STRING) - 1, \
|
||||
.buf = (c8 *)STRING}
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
/**
|
||||
* Str8 allocated buffers
|
||||
@@ -123,8 +123,8 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8R
|
||||
*/
|
||||
u64 wapp_str8_list_total_size(const Str8List *list);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !STR8_H
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
#include "../platform/platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(WAPP_PLATFORM_C) && WAPP_PLATFORM_C_VERSION >= WAPP_PLATFORM_C11_VERSION && !defined(WAPP_PLATFORM_APPLE)
|
||||
#if defined(WP_PLATFORM_C) && WP_PLATFORM_C_VERSION >= WP_PLATFORM_C11_VERSION && !defined(WP_PLATFORM_APPLE)
|
||||
#include <uchar.h>
|
||||
|
||||
#if WAPP_PLATFORM_C_VERSION >= WAPP_PLATFORM_C23_VERSION
|
||||
#if WP_PLATFORM_C_VERSION >= WP_PLATFORM_C23_VERSION
|
||||
typedef char8_t c8;
|
||||
#else
|
||||
typedef uint8_t c8;
|
||||
#endif // !WAPP_PLATFORM_C23_VERSION
|
||||
#endif // !WP_PLATFORM_C23_VERSION
|
||||
|
||||
typedef char16_t c16;
|
||||
typedef char32_t c32;
|
||||
@@ -21,7 +21,7 @@
|
||||
typedef uint8_t c8;
|
||||
typedef uint16_t c16;
|
||||
typedef uint32_t c32;
|
||||
#endif // !WAPP_PLATFORM_C
|
||||
#endif // !WP_PLATFORM_C
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
@@ -30,7 +30,7 @@ typedef uint64_t u64;
|
||||
|
||||
typedef uint8_t b8;
|
||||
|
||||
#ifndef WAPP_PLATFORM_CPP
|
||||
#ifndef WP_PLATFORM_CPP
|
||||
|
||||
#ifndef false
|
||||
#define false (b8)0
|
||||
@@ -40,7 +40,7 @@ typedef uint8_t b8;
|
||||
#define true (b8)1
|
||||
#endif // !true
|
||||
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef int8_t i8;
|
||||
typedef int16_t i16;
|
||||
@@ -58,10 +58,10 @@ typedef intptr_t iptr;
|
||||
#define wapp_intern static
|
||||
#define wapp_persist static
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wapp_class_mem static
|
||||
#define BEGIN_C_LINKAGE wapp_extern "C" {
|
||||
#define END_C_LINKAGE }
|
||||
#endif // WAPP_PLATFORM_CPP
|
||||
#endif // WP_PLATFORM_CPP
|
||||
|
||||
#endif // !ALIASES_H
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define wapp_static_assert(EXPR, MSG) wapp_extern char ASSERTION_FAILED[EXPR ? 1 : -1]
|
||||
|
||||
@@ -27,7 +27,7 @@ BEGIN_C_LINKAGE
|
||||
#define wapp_debug_assert(EXPR, MSG)
|
||||
#endif
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#ifdef WP_PLATFORM_WINDOWS
|
||||
#define __wapp_runtime_assert(EXPR, MSG) do { \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable:4127)) \
|
||||
@@ -42,7 +42,7 @@ BEGIN_C_LINKAGE
|
||||
__runtime_assert_failed(EXPR, MSG); \
|
||||
} \
|
||||
} while(false)
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
#endif // !WP_PLATFORM_WINDOWS
|
||||
|
||||
#define __runtime_assert_failed(EXPR, MSG) do { \
|
||||
fprintf( \
|
||||
@@ -54,8 +54,8 @@ BEGIN_C_LINKAGE
|
||||
abort(); \
|
||||
} while(false)
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !WAPP_ASSERT_H
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
#include "../aliases/aliases.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define KiB(SIZE) (((u64)SIZE) << 10)
|
||||
#define MiB(SIZE) (((u64)SIZE) << 20)
|
||||
@@ -50,7 +50,7 @@ BEGIN_C_LINKAGE
|
||||
#define wapp_is_power_of_two(NUM) ((NUM & (NUM - 1)) == 0)
|
||||
#define wapp_pointer_offset(PTR, OFFSET) ((void *)((uptr)(PTR) + (OFFSET)))
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
|
||||
#include <tuple>
|
||||
@@ -58,6 +58,6 @@ END_C_LINKAGE
|
||||
#define wapp_misc_utils_va_args_count(T, ...) (std::tuple_size<decltype(std::make_tuple(__VA_ARGS__))>::value)
|
||||
#else
|
||||
#define wapp_misc_utils_va_args_count(T, ...) (sizeof((T[]){__VA_ARGS__})/sizeof(T))
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !MISC_UTILS_H
|
||||
|
||||
@@ -4,110 +4,110 @@
|
||||
#define PLATFORM_H
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#define WAPP_PLATFORM_ANDROID
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#define WP_PLATFORM_ANDROID
|
||||
#define WP_PLATFORM_POSIX
|
||||
#elif defined(__FreeBSD__)
|
||||
#define WAPP_PLATFORM_FREE_BSD
|
||||
#define WAPP_PLATFORM_BSD
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#define WP_PLATFORM_FREE_BSD
|
||||
#define WP_PLATFORM_BSD
|
||||
#define WP_PLATFORM_POSIX
|
||||
#elif defined(__NetBSD__)
|
||||
#define WAPP_PLATFORM_NET_BSD
|
||||
#define WAPP_PLATFORM_BSD
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#define WP_PLATFORM_NET_BSD
|
||||
#define WP_PLATFORM_BSD
|
||||
#define WP_PLATFORM_POSIX
|
||||
#elif defined(__OpenBSD__)
|
||||
#define WAPP_PLATFORM_OPEN_BSD
|
||||
#define WAPP_PLATFORM_BSD
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#define WP_PLATFORM_OPEN_BSD
|
||||
#define WP_PLATFORM_BSD
|
||||
#define WP_PLATFORM_POSIX
|
||||
#elif defined(__DragonFly__)
|
||||
#define WAPP_PLATFORM_DRAGON_FLY
|
||||
#define WAPP_PLATFORM_BSD
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#define WP_PLATFORM_DRAGON_FLY
|
||||
#define WP_PLATFORM_BSD
|
||||
#define WP_PLATFORM_POSIX
|
||||
#elif defined(__bsdi__)
|
||||
#define WAPP_PLATFORM_BSD
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#define WP_PLATFORM_BSD
|
||||
#define WP_PLATFORM_POSIX
|
||||
#elif defined(__linux__) || defined(linux) || defined(__linux) || defined(__gnu_linux__)
|
||||
#define WAPP_PLATFORM_LINUX
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#define WP_PLATFORM_LINUX
|
||||
#define WP_PLATFORM_POSIX
|
||||
#elif defined(__GNU__) || defined(__gnu_hurd__)
|
||||
#define WAPP_PLATFORM_GNU
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#define WP_PLATFORM_GNU
|
||||
#define WP_PLATFORM_POSIX
|
||||
#elif defined(__APPLE__) || defined(__MACH__)
|
||||
#include <TargetConditionals.h>
|
||||
#if TARGET_OS_IPHONE
|
||||
#define WAPP_PLATFORM_IOS
|
||||
#define WAPP_PLATFORM_APPLE
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#define WP_PLATFORM_IOS
|
||||
#define WP_PLATFORM_APPLE
|
||||
#define WP_PLATFORM_POSIX
|
||||
#elif TARGET_OS_MAC
|
||||
#define WAPP_PLATFORM_MACOS
|
||||
#define WAPP_PLATFORM_APPLE
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#define WP_PLATFORM_MACOS
|
||||
#define WP_PLATFORM_APPLE
|
||||
#define WP_PLATFORM_POSIX
|
||||
#else
|
||||
#error "Unrecognised Apple platform"
|
||||
#endif
|
||||
#elif defined(_WIN64)
|
||||
#define WAPP_PLATFORM_WINDOWS64
|
||||
#define WAPP_PLATFORM_WINDOWS
|
||||
#define WP_PLATFORM_WINDOWS64
|
||||
#define WP_PLATFORM_WINDOWS
|
||||
#elif defined(_WIN32)
|
||||
#define WAPP_PLATFORM_WINDOWS32
|
||||
#define WAPP_PLATFORM_WINDOWS
|
||||
#define WP_PLATFORM_WINDOWS32
|
||||
#define WP_PLATFORM_WINDOWS
|
||||
#elif defined(__CYGWIN__)
|
||||
#define WAPP_PLATFORM_CYGWIN
|
||||
#define WAPP_PLATFORM_WINDOWS
|
||||
#define WP_PLATFORM_CYGWIN
|
||||
#define WP_PLATFORM_WINDOWS
|
||||
#elif defined(__unix__) || defined(__unix)
|
||||
#define WAPP_PLATFORM_UNIX
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#define WP_PLATFORM_UNIX
|
||||
#define WP_PLATFORM_POSIX
|
||||
#else
|
||||
#error "Unrecognised platform"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define WAPP_PLATFORM_CPP
|
||||
#define WAPP_PLATFORM_CPP_VERSION __cplusplus
|
||||
#define WAPP_PLATFORM_CPP98_VERSION 199711L
|
||||
#define WAPP_PLATFORM_CPP11_VERSION 201103L
|
||||
#define WAPP_PLATFORM_CPP14_VERSION 201402L
|
||||
#define WAPP_PLATFORM_CPP17_VERSION 201703L
|
||||
#define WAPP_PLATFORM_CPP20_VERSION 202002L
|
||||
#define WAPP_PLATFORM_CPP23_VERSION 202302L
|
||||
#define WP_PLATFORM_CPP
|
||||
#define WP_PLATFORM_CPP_VERSION __cplusplus
|
||||
#define WP_PLATFORM_CPP98_VERSION 199711L
|
||||
#define WP_PLATFORM_CPP11_VERSION 201103L
|
||||
#define WP_PLATFORM_CPP14_VERSION 201402L
|
||||
#define WP_PLATFORM_CPP17_VERSION 201703L
|
||||
#define WP_PLATFORM_CPP20_VERSION 202002L
|
||||
#define WP_PLATFORM_CPP23_VERSION 202302L
|
||||
|
||||
#if WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP98_VERSION
|
||||
#define WAPP_PLATFORM_CPP98
|
||||
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP11_VERSION
|
||||
#define WAPP_PLATFORM_CPP11
|
||||
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP14_VERSION
|
||||
#define WAPP_PLATFORM_CPP14
|
||||
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP17_VERSION
|
||||
#define WAPP_PLATFORM_CPP17
|
||||
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP20_VERSION
|
||||
#define WAPP_PLATFORM_CPP20
|
||||
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP23_VERSION
|
||||
#define WAPP_PLATFORM_CPP23
|
||||
#if WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP98_VERSION
|
||||
#define WP_PLATFORM_CPP98
|
||||
#elif WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP11_VERSION
|
||||
#define WP_PLATFORM_CPP11
|
||||
#elif WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP14_VERSION
|
||||
#define WP_PLATFORM_CPP14
|
||||
#elif WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP17_VERSION
|
||||
#define WP_PLATFORM_CPP17
|
||||
#elif WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP20_VERSION
|
||||
#define WP_PLATFORM_CPP20
|
||||
#elif WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP23_VERSION
|
||||
#define WP_PLATFORM_CPP23
|
||||
#else
|
||||
#error "Unrecognised C++ version"
|
||||
#endif
|
||||
#else
|
||||
#define WAPP_PLATFORM_C
|
||||
#define WP_PLATFORM_C
|
||||
|
||||
#if defined(__STDC_VERSION__)
|
||||
#define WAPP_PLATFORM_C_VERSION __STDC_VERSION__
|
||||
#define WAPP_PLATFORM_C99_VERSION 199901L
|
||||
#define WAPP_PLATFORM_C11_VERSION 201112L
|
||||
#define WAPP_PLATFORM_C17_VERSION 201710L
|
||||
#define WAPP_PLATFORM_C23_VERSION 202311L
|
||||
#define WP_PLATFORM_C_VERSION __STDC_VERSION__
|
||||
#define WP_PLATFORM_C99_VERSION 199901L
|
||||
#define WP_PLATFORM_C11_VERSION 201112L
|
||||
#define WP_PLATFORM_C17_VERSION 201710L
|
||||
#define WP_PLATFORM_C23_VERSION 202311L
|
||||
|
||||
#if WAPP_PLATFORM_C_VERSION == WAPP_PLATFORM_C99_VERSION
|
||||
#define WAPP_PLATFORM_C99
|
||||
#elif WAPP_PLATFORM_C_VERSION == WAPP_PLATFORM_C11_VERSION
|
||||
#define WAPP_PLATFORM_C11
|
||||
#elif WAPP_PLATFORM_C_VERSION == WAPP_PLATFORM_C17_VERSION
|
||||
#define WAPP_PLATFORM_C17
|
||||
#elif WAPP_PLATFORM_C_VERSION == WAPP_PLATFORM_C23_VERSION
|
||||
#define WAPP_PLATFORM_C23
|
||||
#if WP_PLATFORM_C_VERSION == WP_PLATFORM_C99_VERSION
|
||||
#define WP_PLATFORM_C99
|
||||
#elif WP_PLATFORM_C_VERSION == WP_PLATFORM_C11_VERSION
|
||||
#define WP_PLATFORM_C11
|
||||
#elif WP_PLATFORM_C_VERSION == WP_PLATFORM_C17_VERSION
|
||||
#define WP_PLATFORM_C17
|
||||
#elif WP_PLATFORM_C_VERSION == WP_PLATFORM_C23_VERSION
|
||||
#define WP_PLATFORM_C23
|
||||
#else
|
||||
#error "Unrecognised C version"
|
||||
#endif
|
||||
#else
|
||||
#define WAPP_PLATFORM_C89
|
||||
#define WP_PLATFORM_C89
|
||||
#endif
|
||||
#endif // !__cplusplus
|
||||
|
||||
|
||||
@@ -65,12 +65,12 @@ b8 wapp_mem_arena_init_allocated_custom(Arena **arena, u64 base_capacity, MemAll
|
||||
|
||||
b8 committed = (flags & WAPP_MEM_ALLOC_COMMIT) == WAPP_MEM_ALLOC_COMMIT;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#ifdef WP_PLATFORM_WINDOWS
|
||||
if (!committed) {
|
||||
wapp_os_mem_alloc(allocated, sizeof(Arena), WAPP_MEM_ACCESS_READ_WRITE, WAPP_MEM_ALLOC_COMMIT,
|
||||
WAPP_MEM_INIT_INITIALISED);
|
||||
}
|
||||
#endif // ifdef WAPP_PLATFORM_WINDOWS
|
||||
#endif // ifdef WP_PLATFORM_WINDOWS
|
||||
|
||||
if (!wapp_mem_arena_init_buffer(arena, allocated, alloc_size)) {
|
||||
wapp_mem_arena_destroy(arena);
|
||||
@@ -100,13 +100,13 @@ void *wapp_mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment) {
|
||||
|
||||
arena->offset = output + size;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#ifdef WP_PLATFORM_WINDOWS
|
||||
if (arena->type == ARENA_STORAGE_TYPE_ALLOCATED && !(arena->committed)) {
|
||||
wapp_os_mem_alloc(alloc_start, (uptr)(arena->offset) - (uptr)(alloc_start),
|
||||
WAPP_MEM_ACCESS_READ_WRITE, WAPP_MEM_ALLOC_COMMIT,
|
||||
WAPP_MEM_INIT_UNINITIALISED);
|
||||
}
|
||||
#endif // ifdef WAPP_PLATFORM_WINDOWS
|
||||
#endif // ifdef WP_PLATFORM_WINDOWS
|
||||
|
||||
memset(output, 0, size);
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef struct Arena Arena;
|
||||
|
||||
@@ -38,8 +38,8 @@ void wapp_mem_arena_temp_end(Arena *arena);
|
||||
void wapp_mem_arena_clear(Arena *arena);
|
||||
void wapp_mem_arena_destroy(Arena **arena);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !MEM_ARENA_H
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#include "../../../common/platform/platform.h"
|
||||
#include "../../../base/mem/allocator/mem_allocator.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define wapp_mem_arena_allocator_init(base_capacity) \
|
||||
(wapp_mem_arena_allocator_init_custom(base_capacity, WAPP_MEM_ALLOC_RESERVE, false))
|
||||
@@ -39,8 +39,8 @@ void wapp_mem_arena_allocator_temp_end(const Allocator *allocator);
|
||||
void wapp_mem_arena_allocator_clear(Allocator *allocator);
|
||||
void wapp_mem_arena_allocator_destroy(Allocator *allocator);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !MEM_ARENA_ALLOCATOR_H
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
#include "../../base/mem/allocator/mem_allocator.h"
|
||||
#include "../../base/strings/str8/str8.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
#ifdef WP_PLATFORM_POSIX
|
||||
#include <limits.h>
|
||||
#define WAPP_PATH_SEP '/'
|
||||
#define WAPP_PATH_MAX PATH_MAX
|
||||
#elif defined(WAPP_PLATFORM_WINDOWS)
|
||||
#elif defined(WP_PLATFORM_WINDOWS)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#define WAPP_PATH_SEP '\\'
|
||||
@@ -38,8 +38,8 @@ enum {
|
||||
u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts);
|
||||
Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !CPATH_H
|
||||
|
||||
+4
-4
@@ -7,9 +7,9 @@
|
||||
#include "../../common/aliases/aliases.h"
|
||||
#include "../../base/strings/str8/str8.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef struct WFile WFile;
|
||||
|
||||
@@ -70,8 +70,8 @@ wapp_extern i32 _file_close(WFile *file);
|
||||
wapp_extern i32 _file_rename(Str8RO *old_filepath, Str8RO *new_filepath);
|
||||
wapp_extern i32 _file_remove(Str8RO *filepath);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !FILE_H
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "file_posix.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
#ifdef WP_PLATFORM_POSIX
|
||||
|
||||
#include "../file.h"
|
||||
#include "../../cpath/cpath.h"
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "../../../base/array/array.h"
|
||||
#include "../../../base/strings/str8/str8.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_APPLE
|
||||
#ifdef WP_PLATFORM_APPLE
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define lseek64 lseek
|
||||
#endif // !WAPP_PLATFORM_APPLE
|
||||
#endif // !WP_PLATFORM_APPLE
|
||||
|
||||
#define __USE_LARGEFILE64
|
||||
#include <fcntl.h>
|
||||
@@ -131,4 +131,4 @@ i32 _file_remove(Str8RO *filepath) {
|
||||
return unlink((const char *)tmp);
|
||||
}
|
||||
|
||||
#endif // !WAPP_PLATFORM_POSIX
|
||||
#endif // !WP_PLATFORM_POSIX
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
#ifdef WP_PLATFORM_POSIX
|
||||
|
||||
#define END_OF_LINE "\n"
|
||||
|
||||
@@ -18,10 +18,10 @@ struct WFile {
|
||||
i32 fd;
|
||||
};
|
||||
|
||||
#endif // !WAPP_PLATFORM_POSIX
|
||||
#endif // !WP_PLATFORM_POSIX
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !FILE_POSIX_H
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "file_win.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#ifdef WP_PLATFORM_WINDOWS
|
||||
|
||||
#include "../file.h"
|
||||
#include "../../cpath/cpath.h"
|
||||
@@ -174,4 +174,4 @@ i32 _file_remove(Str8RO *filepath) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
#endif // !WP_PLATFORM_WINDOWS
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#ifdef WP_PLATFORM_WINDOWS
|
||||
|
||||
#define END_OF_LINE "\r\n"
|
||||
|
||||
@@ -22,10 +22,10 @@ struct WFile {
|
||||
HANDLE fh;
|
||||
};
|
||||
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
#endif // !WP_PLATFORM_WINDOWS
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !FILE_WIN_H
|
||||
|
||||
+2
-2
@@ -7,9 +7,9 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(WAPP_PLATFORM_WINDOWS)
|
||||
#if defined(WP_PLATFORM_WINDOWS)
|
||||
#include "win/mem_os_win.h"
|
||||
#elif defined(WAPP_PLATFORM_POSIX)
|
||||
#elif defined(WP_PLATFORM_POSIX)
|
||||
#include "posix/mem_os_posix.h"
|
||||
#else
|
||||
#error "Unrecognised platform"
|
||||
|
||||
+6
-6
@@ -8,13 +8,13 @@
|
||||
|
||||
#include "mem_os_ops.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#if defined(WAPP_PLATFORM_WINDOWS)
|
||||
#if defined(WP_PLATFORM_WINDOWS)
|
||||
#include "win/mem_os_win.h"
|
||||
#elif defined(WAPP_PLATFORM_POSIX)
|
||||
#elif defined(WP_PLATFORM_POSIX)
|
||||
#include "posix/mem_os_posix.h"
|
||||
#else
|
||||
#error "Unrecognised platform"
|
||||
@@ -26,8 +26,8 @@ void wapp_os_mem_free(void *ptr, u64 size);
|
||||
wapp_extern void *os_mem_allocate(void *addr, u64 size, MemAccess access, MemAllocFlags flags, MemInitType type);
|
||||
wapp_extern void os_mem_free(void *ptr, u64 size);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !MEM_OS_H
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
#include "../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef enum mem_access {
|
||||
WAPP_MEM_ACCESS_NONE,
|
||||
@@ -23,8 +23,8 @@ typedef enum mem_init_type {
|
||||
WAPP_MEM_INIT_INITIALISED,
|
||||
} MemInitType;
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !MEM_OS_OPS_H
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
#ifdef WP_PLATFORM_POSIX
|
||||
|
||||
#include "mem_os_posix.h"
|
||||
#include "../mem_os_ops.h"
|
||||
@@ -22,7 +22,7 @@ void *os_mem_allocate(void *addr, u64 size, MemAccess access, MemAllocFlags flag
|
||||
(void)type;
|
||||
i32 alloc_flags = flags | MAP_ANON | MAP_PRIVATE;
|
||||
|
||||
#if defined(WAPP_PLATFORM_LINUX) || defined(WAPP_PLATFORM_GNU) || defined(WAPP_PLATFORM_NET_BSD)
|
||||
#if defined(WP_PLATFORM_LINUX) || defined(WP_PLATFORM_GNU) || defined(WP_PLATFORM_NET_BSD)
|
||||
alloc_flags |= MAP_NORESERVE;
|
||||
#endif
|
||||
|
||||
@@ -33,4 +33,4 @@ void os_mem_free(void *ptr, u64 size) {
|
||||
munmap(ptr, size);
|
||||
}
|
||||
|
||||
#endif // !WAPP_PLATFORM_POSIX
|
||||
#endif // !WP_PLATFORM_POSIX
|
||||
|
||||
@@ -5,31 +5,31 @@
|
||||
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
#ifdef WP_PLATFORM_POSIX
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
typedef enum mem_alloc_flags {
|
||||
#if defined(WAPP_PLATFORM_LINUX) || defined(WAPP_PLATFORM_GNU)
|
||||
#if defined(WP_PLATFORM_LINUX) || defined(WP_PLATFORM_GNU)
|
||||
WAPP_MEM_ALLOC_RESERVE = 0,
|
||||
WAPP_MEM_ALLOC_COMMIT = MAP_POPULATE,
|
||||
#elif defined(WAPP_PLATFORM_FREE_BSD)
|
||||
#elif defined(WP_PLATFORM_FREE_BSD)
|
||||
WAPP_MEM_ALLOC_RESERVE = 0,
|
||||
WAPP_MEM_ALLOC_COMMIT = MAP_PREFAULT_READ,
|
||||
#elif defined(WAPP_PLATFORM_BSD) || defined(WAPP_PLATFORM_UNIX) || defined(WAPP_PLATFORM_APPLE)
|
||||
#elif defined(WP_PLATFORM_BSD) || defined(WP_PLATFORM_UNIX) || defined(WP_PLATFORM_APPLE)
|
||||
WAPP_MEM_ALLOC_RESERVE = 0,
|
||||
WAPP_MEM_ALLOC_COMMIT = 0,
|
||||
#endif
|
||||
} MemAllocFlags;
|
||||
|
||||
#endif // !WAPP_PLATFORM_POSIX
|
||||
#endif // !WP_PLATFORM_POSIX
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !MEM_OS_POSIX_H
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#ifdef WP_PLATFORM_WINDOWS
|
||||
|
||||
#include "mem_os_win.h"
|
||||
#include "../mem_os_ops.h"
|
||||
@@ -34,4 +34,4 @@ void os_mem_free(void *ptr, u64 size) {
|
||||
VirtualFree(ptr, size, MEM_RELEASE);
|
||||
}
|
||||
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
#endif // !WP_PLATFORM_WINDOWS
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#ifdef WP_PLATFORM_WINDOWS
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
@@ -20,10 +20,10 @@ typedef enum mem_alloc_flags {
|
||||
WAPP_MEM_ALLOC_COMMIT = MEM_COMMIT,
|
||||
} MemAllocFlags;
|
||||
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
#endif // !WP_PLATFORM_WINDOWS
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !MEM_OS_WIN_H
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
// TODO (Abdelrahman): This module needs rethinking
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define CMD_NO_EXIT(ERR) ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR})
|
||||
|
||||
@@ -22,8 +22,8 @@ CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_bu
|
||||
|
||||
wapp_extern CMDError get_output_status(FILE *fp, i32 *status_out);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !COMMANDER_H
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include "../../../common/platform/platform.h"
|
||||
#include "../../../common/misc/misc_utils.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef enum {
|
||||
SHELL_OUTPUT_DISCARD,
|
||||
@@ -35,8 +35,8 @@ struct CMDResult {
|
||||
wapp_misc_utils_reserve_padding(sizeof(b8) + sizeof(i32) + sizeof(CMDError));
|
||||
};
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !COMMANDER_OUTPUT_H
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "../../../../common/aliases/aliases.h"
|
||||
#include "../../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
#ifdef WP_PLATFORM_POSIX
|
||||
|
||||
#include "../commander_output.h"
|
||||
#include "../../utils/shell_utils.h"
|
||||
@@ -22,4 +22,4 @@ CMDError get_output_status(FILE *fp, i32 *status_out) {
|
||||
return SHELL_ERR_NO_ERROR;
|
||||
}
|
||||
|
||||
#endif // !WAPP_PLATFORM_POSIX
|
||||
#endif // !WP_PLATFORM_POSIX
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "../../../../common/aliases/aliases.h"
|
||||
#include "../../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#ifdef WP_PLATFORM_WINDOWS
|
||||
|
||||
#include "../commander_output.h"
|
||||
#include "../../utils/shell_utils.h"
|
||||
@@ -21,4 +21,4 @@ CMDError get_output_status(FILE *fp, i32 *status_out) {
|
||||
return SHELL_ERR_NO_ERROR;
|
||||
}
|
||||
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
#endif // !WP_PLATFORM_WINDOWS
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "../../../../common/platform/platform.h"
|
||||
#include "../../../../base/strings/str8/str8.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
#ifdef WP_PLATFORM_POSIX
|
||||
|
||||
#include "../terminal_colours.h"
|
||||
#include <stdio.h>
|
||||
@@ -33,4 +33,4 @@ void print_coloured_text(Str8RO *text, TerminalColour colour) {
|
||||
printf(WAPP_STR8_SPEC WAPP_STR8_SPEC, wapp_str8_varg(colours[colour]), wapp_str8_varg((*text)));
|
||||
}
|
||||
|
||||
#endif // !WAPP_PLATFORM_POSIX
|
||||
#endif // !WP_PLATFORM_POSIX
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#include "../../../common/platform/platform.h"
|
||||
#include "../../../base/strings/str8/str8.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
// TODO (Abdelrahman): Look into moving away from stdio in the implementation
|
||||
|
||||
@@ -19,8 +19,8 @@ void wapp_shell_termcolour_clear_colour(void);
|
||||
|
||||
wapp_extern void print_coloured_text(Str8RO *text, TerminalColour colour);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !TERM_COLOUR_H
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef enum {
|
||||
WAPP_TERM_COLOUR_FG_BLACK,
|
||||
@@ -32,8 +32,8 @@ typedef enum {
|
||||
COUNT_TERM_COLOUR,
|
||||
} TerminalColour;
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !TERMINAL_COLOURS_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "../../../../common/platform/platform.h"
|
||||
#include "../../../../base/strings/str8/str8.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#ifdef WP_PLATFORM_WINDOWS
|
||||
|
||||
#include "../terminal_colours.h"
|
||||
#include "../../../../common/misc/misc_utils.h"
|
||||
@@ -70,4 +70,4 @@ wapp_intern void init_data(TermcolourData *data) {
|
||||
data->current_colour = data->default_colour;
|
||||
}
|
||||
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
#endif // !WP_PLATFORM_WINDOWS
|
||||
|
||||
@@ -7,20 +7,20 @@
|
||||
#include "../../../common/platform/platform.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#ifdef WP_PLATFORM_WINDOWS
|
||||
#define wapp_shell_utils_popen _popen
|
||||
#define wapp_shell_utils_pclose _pclose
|
||||
#else
|
||||
#define wapp_shell_utils_popen popen
|
||||
#define wapp_shell_utils_pclose pclose
|
||||
#endif /* ifdef WAPP_PLATFORM_WINDOWS */
|
||||
#endif /* ifdef WP_PLATFORM_WINDOWS */
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !SHELL_UTILS_H
|
||||
|
||||
@@ -89,8 +89,8 @@ wapp_intern u64 split_mix_64(SplitMix64State *state) {
|
||||
return result ^ (result >> 31);
|
||||
}
|
||||
|
||||
#if defined(WAPP_PLATFORM_C) && WAPP_PLATFORM_C_VERSION >= WAPP_PLATFORM_C11_VERSION
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
#if defined(WP_PLATFORM_C) && WP_PLATFORM_C_VERSION >= WP_PLATFORM_C11_VERSION
|
||||
#ifdef WP_PLATFORM_POSIX
|
||||
wapp_intern void seed_os_generator(void) {
|
||||
struct timespec ts = {0};
|
||||
int result = clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
|
||||
@@ -117,7 +117,7 @@ wapp_intern u64 generate_random_number(void) {
|
||||
|
||||
return (((u64)n1) << 32 | (u64)n2);
|
||||
}
|
||||
#endif // !WAPP_PLATFORM_POSIX
|
||||
#endif // !WP_PLATFORM_POSIX
|
||||
#else
|
||||
wapp_intern void seed_os_generator(void) {
|
||||
time_t result = time(NULL);
|
||||
@@ -132,4 +132,4 @@ wapp_intern u64 generate_random_number(void) {
|
||||
|
||||
return (((u64)n1) << 32 | (u64)n2);
|
||||
}
|
||||
#endif // !WAPP_PLATFORM_C
|
||||
#endif // !WP_PLATFORM_C
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
#include "../../common/aliases/aliases.h"
|
||||
#include "../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef struct XOR256State XOR256State;
|
||||
struct XOR256State {
|
||||
@@ -23,8 +23,8 @@ u64 wapp_prng_xorshift_256(XOR256State *state);
|
||||
u64 wapp_prng_xorshift_256ss(XOR256State *state);
|
||||
u64 wapp_prng_xorshift_256p(XOR256State *state);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !XORSHIFT_H
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
#include "../../common/platform/platform.h"
|
||||
#include "../../base/strings/str8/str8.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
|
||||
#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
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define wapp_tester_run_tests(...) run_tests(__VA_ARGS__, NULL)
|
||||
|
||||
@@ -29,8 +29,8 @@ typedef TestFuncResult(TestFunc)(void);
|
||||
|
||||
void run_tests(TestFunc *func1, ...);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !TESTER_H
|
||||
|
||||
+6
-6
@@ -7,9 +7,9 @@
|
||||
#include "../common/platform/platform.h"
|
||||
#include "../base/strings/str8/str8.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define UUID_BUF_LENGTH 48
|
||||
#define WAPP_UUID_SPEC WAPP_STR8_SPEC
|
||||
@@ -22,7 +22,7 @@ struct WUUID {
|
||||
|
||||
// TODO (Abdelrahman): Update UUID implementation to work properly with C++ and tests for validation
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wapp_uuid_gen_uuid4() ([&](){ \
|
||||
wapp_persist WUUID uuid = wapp_uuid_create(); \
|
||||
return *(wapp_uuid_init_uuid4(&uuid)); \
|
||||
@@ -33,7 +33,7 @@ struct WUUID {
|
||||
|
||||
/* Low level UUID API */
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wapp_uuid_create() ([&](){ return WUUID{wapp_str8_buf(UUID_BUF_LENGTH)}; }())
|
||||
#else
|
||||
#define wapp_uuid_create() ((WUUID){.uuid = wapp_str8_buf(UUID_BUF_LENGTH)})
|
||||
@@ -43,8 +43,8 @@ struct WUUID {
|
||||
// Fails when passed a NULL pointer.
|
||||
WUUID *wapp_uuid_init_uuid4(WUUID *uuid);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !UUID_H
|
||||
|
||||
Reference in New Issue
Block a user