Compare commits
No commits in common. "2c556e12f12a0470de52b669b87f851c2c0c7d9a" and "99a9cd10f57649c11f8ff8a15b9c79bad45de45e" have entirely different histories.
2c556e12f1
...
99a9cd10f5
33
build.ps1
33
build.ps1
@ -1,33 +0,0 @@
|
|||||||
Param(
|
|
||||||
[switch]$Release
|
|
||||||
)
|
|
||||||
|
|
||||||
$Compiler = "cl.exe"
|
|
||||||
$GeneralFlags = "/Wall /WX /wd4996"
|
|
||||||
$LibraryFlags = "/LD"
|
|
||||||
$IncludeDirs = Get-ChildItem -Path src -Recurse -Directory -ErrorAction SilentlyContinue -Force | %{$("/I " + '"' + $_.FullName + '"')}
|
|
||||||
$SrcFiles = Get-ChildItem -Path src -Recurse -Filter *.c -ErrorAction SilentlyContinue -Force | %{$('"' + $_.FullName + '"')}
|
|
||||||
|
|
||||||
If ($Release -eq $True) {
|
|
||||||
$GeneralFlags += " /O2 /Og"
|
|
||||||
$BuildType = "release"
|
|
||||||
} Else {
|
|
||||||
$GeneralFlags += " /Zi /Od /fsanitize=address"
|
|
||||||
$BuildType = "debug"
|
|
||||||
}
|
|
||||||
|
|
||||||
$BuildDir = "./libwapp-build/windows-$BuildType"
|
|
||||||
$ObjDir = "$BuildDir/objects"
|
|
||||||
$OutDir = "$BuildDir/output"
|
|
||||||
$OutBasename = "libwapp"
|
|
||||||
$Objects = "/Fo:$ObjDir/"
|
|
||||||
$Outputs = "/Fd:$OutDir/$OutBasename /Fe:$OutDir/$OutBasename"
|
|
||||||
|
|
||||||
If (Test-Path $BuildDir) {
|
|
||||||
Remove-Item $BuildDir -Recurse -Force
|
|
||||||
}
|
|
||||||
|
|
||||||
mkdir -p $ObjDir > $null
|
|
||||||
mkdir -p $OutDir > $null
|
|
||||||
|
|
||||||
Invoke-Expression "$Compiler $GeneralFlags $LibraryFlags $IncludeDirs $SrcFiles $Objects $Outputs"
|
|
@ -1,7 +1,6 @@
|
|||||||
#include "mem_arena.h"
|
#include "mem_arena.h"
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include "mem_utils.h"
|
#include "mem_utils.h"
|
||||||
#include "misc_utils.h"
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -19,10 +18,6 @@ struct arena {
|
|||||||
u8 *offset;
|
u8 *offset;
|
||||||
u64 capacity;
|
u64 capacity;
|
||||||
bool committed;
|
bool committed;
|
||||||
|
|
||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
|
||||||
wapp_misc_utils_padding_size(sizeof(u8 *) * 2 + sizeof(u64) + sizeof(bool));
|
|
||||||
#endif // ifdef WAPP_PLATFORM_WINDOWS
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// PUBLIC API
|
// PUBLIC API
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(WAPP_PLATFORM_WINDOWS)
|
#if defined(WAPP_PLATFORM_WINDOWS)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <memoryapi.h>
|
#include <memoryapi.h>
|
||||||
|
|
||||||
@ -96,7 +95,7 @@ void wapp_mem_util_free(void *ptr, u64 size) {
|
|||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
#ifdef WAPP_PLATFORM_WINDOWS
|
||||||
internal inline void *alloc_windows(void *addr, u64 size, MemAccess access,
|
internal inline void *alloc_windows(void *addr, u64 size, MemAccess access,
|
||||||
MemAllocFlags flags) {
|
MemAllocFlags flags) {
|
||||||
return VirtualAlloc(addr, (SIZE_T)size, flags, access_types[access]);
|
return VirtualAlloc2(addr, NULL, (SIZE_T)size, flags, access_types[access]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
#if defined(WAPP_PLATFORM_WINDOWS)
|
#if defined(WAPP_PLATFORM_WINDOWS)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <memoryapi.h>
|
#include <memoryapi.h>
|
||||||
#elif defined(WAPP_PLATFORM_POSIX)
|
#elif defined(WAPP_PLATFORM_POSIX)
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
#ifndef MISC_UTILS_H
|
|
||||||
#define MISC_UTILS_H
|
|
||||||
|
|
||||||
#include "aliases.h"
|
|
||||||
|
|
||||||
#define wapp_misc_utils_padding_size(SIZE) \
|
|
||||||
u8 reserved_padding[sizeof(void *) - ((SIZE) % sizeof(void *))]
|
|
||||||
|
|
||||||
#endif // !MISC_UTILS_H
|
|
@ -1,7 +1,6 @@
|
|||||||
#include "dstr.h"
|
#include "dstr.h"
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include "mem_arena.h"
|
#include "mem_arena.h"
|
||||||
#include "platform.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -14,12 +13,7 @@
|
|||||||
struct dstr {
|
struct dstr {
|
||||||
u64 capacity;
|
u64 capacity;
|
||||||
u64 size;
|
u64 size;
|
||||||
|
|
||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
|
||||||
char *buf;
|
|
||||||
#else
|
|
||||||
char buf[];
|
char buf[];
|
||||||
#endif // WAPP_PLATFORM_WINDOWS
|
|
||||||
};
|
};
|
||||||
|
|
||||||
String *wapp_dstr_with_capacity(u64 capacity, Arena *arena) {
|
String *wapp_dstr_with_capacity(u64 capacity, Arena *arena) {
|
||||||
@ -103,19 +97,8 @@ StringUpdate wapp_dstr_concat(String **dst, const char *src, Arena *arena) {
|
|||||||
|
|
||||||
u64 new_length = (*dst)->size + src_length;
|
u64 new_length = (*dst)->size + src_length;
|
||||||
|
|
||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
|
||||||
char *str =
|
|
||||||
wapp_mem_util_alloc(NULL, new_length + 1, WAPP_MEM_ACCESS_READ_WRITE,
|
|
||||||
WAPP_MEM_ALLOC_RESERVE | WAPP_MEM_ALLOC_COMMIT,
|
|
||||||
WAPP_MEM_INIT_INITIALISED);
|
|
||||||
|
|
||||||
if (!str) {
|
|
||||||
return (StringUpdate){.updated = false, .str = *dst};
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
char str[new_length + 1];
|
char str[new_length + 1];
|
||||||
memset(str, 0, new_length + 1);
|
memset(str, 0, new_length + 1);
|
||||||
#endif
|
|
||||||
|
|
||||||
strncpy(str, (*dst)->buf, (*dst)->size);
|
strncpy(str, (*dst)->buf, (*dst)->size);
|
||||||
strncat(str, src, new_length + 1 - (*dst)->size);
|
strncat(str, src, new_length + 1 - (*dst)->size);
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include "mem_arena.h"
|
#include "mem_arena.h"
|
||||||
#include "misc_utils.h"
|
|
||||||
#include "platform.h"
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -15,12 +13,8 @@ typedef struct dstr String;
|
|||||||
|
|
||||||
typedef struct string_update StringUpdate;
|
typedef struct string_update StringUpdate;
|
||||||
struct string_update {
|
struct string_update {
|
||||||
String *str;
|
|
||||||
bool updated;
|
bool updated;
|
||||||
|
String *str;
|
||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
|
||||||
wapp_misc_utils_padding_size(sizeof(bool) + sizeof(String *));
|
|
||||||
#endif // WAPP_PLATFORM_WINDOWS
|
|
||||||
};
|
};
|
||||||
|
|
||||||
String *wapp_dstr_with_capacity(u64 capacity, Arena *arena);
|
String *wapp_dstr_with_capacity(u64 capacity, Arena *arena);
|
||||||
|
@ -15,17 +15,15 @@ void run_tests(TestFunc *func1, ...) {
|
|||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, func1);
|
va_start(args, func1);
|
||||||
|
|
||||||
TestFunc *func = va_arg(args, TestFunc *);
|
TestFunc *func = NULL;
|
||||||
|
|
||||||
while (func) {
|
while ((func = va_arg(args, TestFunc *))) {
|
||||||
TestFuncResult result = func();
|
TestFuncResult result = func();
|
||||||
print_test_result(result);
|
print_test_result(result);
|
||||||
|
|
||||||
if (!result.passed) {
|
if (!result.passed) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
func = va_arg(args, TestFunc *);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
@ -1,26 +1,20 @@
|
|||||||
#ifndef TESTER_H
|
#ifndef TESTER_H
|
||||||
#define TESTER_H
|
#define TESTER_H
|
||||||
|
|
||||||
#include "misc_utils.h"
|
|
||||||
#include "platform.h"
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
#define wapp_tester_result(PASSED) \
|
#define wapp_tester_result(test_passed) \
|
||||||
((TestFuncResult){.name = __func__, .passed = PASSED})
|
((TestFuncResult){.name = __func__, .passed = test_passed})
|
||||||
#define wapp_tester_run_tests(...) run_tests(__VA_ARGS__, NULL)
|
#define wapp_tester_run_tests(...) run_tests(__VA_ARGS__, NULL)
|
||||||
|
|
||||||
typedef struct test_func_result TestFuncResult;
|
typedef struct test_func_result TestFuncResult;
|
||||||
struct test_func_result {
|
struct test_func_result {
|
||||||
const char *name;
|
const char *name;
|
||||||
bool passed;
|
bool passed;
|
||||||
|
|
||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
|
||||||
wapp_misc_utils_padding_size(sizeof(const char *) + sizeof(bool));
|
|
||||||
#endif // WAPP_PLATFORM_WINDOWS
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef TestFuncResult(TestFunc)(void);
|
typedef TestFuncResult(TestFunc)(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user