Cleanup headers

This commit is contained in:
doylet 2025-11-10 22:11:50 +11:00
parent 70e4a3fa1d
commit 0d55b5d459
44 changed files with 236 additions and 122 deletions

View File

@ -1,6 +1,8 @@
#define DN_BASE_CPP #define DN_BASE_CPP
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#endif
DN_API bool DN_MemEq(void const *lhs, DN_USize lhs_size, void const *rhs, DN_USize rhs_size) DN_API bool DN_MemEq(void const *lhs, DN_USize lhs_size, void const *rhs, DN_USize rhs_size)
{ {
@ -16,7 +18,7 @@ DN_API bool DN_MemEq(void const *lhs, DN_USize lhs_size, void const *rhs, DN_USi
#include <cpuid.h> #include <cpuid.h>
#endif #endif
static DN_CPUFeatureDecl g_dn_cpu_feature_decl[DN_CPUFeature_Count]; DN_CPUFeatureDecl g_dn_cpu_feature_decl[DN_CPUFeature_Count];
DN_API DN_U64 DN_AtomicSetValue64(DN_U64 volatile *target, DN_U64 value) DN_API DN_U64 DN_AtomicSetValue64(DN_U64 volatile *target, DN_U64 value)
{ {

View File

@ -1,7 +1,9 @@
#if !defined(DN_BASE_H) #if !defined(DN_BASE_H)
#define DN_BASE_H #define DN_BASE_H
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#endif
// NOTE: Macros // NOTE: Macros
#define DN_Stringify(x) #x #define DN_Stringify(x) #x

View File

@ -1,8 +1,10 @@
#define DN_ASYNC_CPP #define DN_ASYNC_CPP
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#include "../dn_os_inc.h" #include "../dn_os_inc.h"
#include "dn_async.h" #include "dn_async.h"
#endif
static DN_I32 DN_ASYNC_ThreadEntryPoint_(DN_OSThread *thread) static DN_I32 DN_ASYNC_ThreadEntryPoint_(DN_OSThread *thread)
{ {

View File

@ -1,8 +1,10 @@
#if !defined(DN_ASYNC_H) #if !defined(DN_ASYNC_H)
#define DN_ASYNC_H #define DN_ASYNC_H
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#include "../dn_os_inc.h" #include "../dn_os_inc.h"
#endif
enum DN_ASYNCPriority enum DN_ASYNCPriority
{ {

View File

@ -1,3 +1,9 @@
#define DN_BIN_PACK_CPP
#if defined(_CLANGD)
#include "dn_bin_pack.h"
#endif
DN_API void DN_BinPack_U64(DN_BinPack *pack, DN_BinPackMode mode, DN_U64 *item) DN_API void DN_BinPack_U64(DN_BinPack *pack, DN_BinPackMode mode, DN_U64 *item)
{ {
DN_U64 const VALUE_MASK = 0b0111'1111; DN_U64 const VALUE_MASK = 0b0111'1111;

View File

@ -1,6 +1,10 @@
#if !defined(DN_BIN_PACK_H) #if !defined(DN_BIN_PACK_H)
#define DN_BIN_PACK_H #define DN_BIN_PACK_H
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#endif
#if !defined(DN_BASE_INC_H) #if !defined(DN_BASE_INC_H)
#error dn_base_inc.h must be included before this #error dn_base_inc.h must be included before this
#endif #endif

View File

@ -1,6 +1,12 @@
#if !defined(DN_CGEN_H) #if !defined(DN_CGEN_H)
#define DN_CGEN_H #define DN_CGEN_H
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#include "../dn_os_inc.h"
#include "../Standalone/dn_cpp_file.h"
#endif
#if !defined(DN_NO_METADESK) #if !defined(DN_NO_METADESK)
#if !defined(_CRT_SECURE_NO_WARNINGS) #if !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS

View File

@ -1,4 +1,8 @@
#define DN_CSV_CPP
#if defined(_CLANGD)
#include "dn_csv.h" #include "dn_csv.h"
#endif
static DN_CSVTokeniser DN_CSV_TokeniserInit(DN_Str8 string, char delimiter) static DN_CSVTokeniser DN_CSV_TokeniserInit(DN_Str8 string, char delimiter)
{ {

View File

@ -1,6 +1,10 @@
#if !defined(DN_CSV_H) #if !defined(DN_CSV_H)
#define DN_CSV_H #define DN_CSV_H
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#endif
enum DN_CSVSerialise enum DN_CSVSerialise
{ {
DN_CSVSerialise_Read, DN_CSVSerialise_Read,

View File

@ -1,3 +1,8 @@
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#include "../dn_os_inc.h"
#endif
DN_MSVC_WARNING_PUSH DN_MSVC_WARNING_PUSH
DN_MSVC_WARNING_DISABLE(4702) // unreachable code DN_MSVC_WARNING_DISABLE(4702) // unreachable code
void DN_Demo() void DN_Demo()

View File

@ -1,5 +1,9 @@
#define DN_HASH_CPP #define DN_HASH_CPP
#if defined(_CLANGD)
#include "dn_hash.h"
#endif
/* /*
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //
@ -17,33 +21,33 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
*/ */
// NOTE: DN_FNV1A ////////////////////////////////////////////////////////////////////////////////// // NOTE: DN_FNV1A
// Default values recommended by: http://isthe.com/chongo/tech/comp/fnv/ // Default values recommended by: http://isthe.com/chongo/tech/comp/fnv/
DN_API uint32_t DN_FNV1A32_Iterate(void const *bytes, DN_USize size, uint32_t hash) DN_API DN_U32 DN_FNV1A32_Iterate(void const *bytes, DN_USize size, DN_U32 hash)
{ {
auto buffer = DN_Cast(uint8_t const *)bytes; auto buffer = DN_Cast(DN_U8 const *)bytes;
for (DN_USize i = 0; i < size; i++) for (DN_USize i = 0; i < size; i++)
hash = (buffer[i] ^ hash) * 16777619 /*FNV Prime*/; hash = (buffer[i] ^ hash) * 16777619 /*FNV Prime*/;
return hash; return hash;
} }
DN_API uint32_t DN_FNV1A32_Hash(void const *bytes, DN_USize size) DN_API DN_U32 DN_FNV1A32_Hash(void const *bytes, DN_USize size)
{ {
uint32_t result = DN_FNV1A32_Iterate(bytes, size, DN_FNV1A32_SEED); DN_U32 result = DN_FNV1A32_Iterate(bytes, size, DN_FNV1A32_SEED);
return result; return result;
} }
DN_API uint64_t DN_FNV1A64_Iterate(void const *bytes, DN_USize size, uint64_t hash) DN_API DN_U64 DN_FNV1A64_Iterate(void const *bytes, DN_USize size, DN_U64 hash)
{ {
auto buffer = DN_Cast(uint8_t const *)bytes; auto buffer = DN_Cast(DN_U8 const *)bytes;
for (DN_USize i = 0; i < size; i++) for (DN_USize i = 0; i < size; i++)
hash = (buffer[i] ^ hash) * 1099511628211 /*FNV Prime*/; hash = (buffer[i] ^ hash) * 1099511628211 /*FNV Prime*/;
return hash; return hash;
} }
DN_API uint64_t DN_FNV1A64_Hash(void const *bytes, DN_USize size) DN_API DN_U64 DN_FNV1A64_Hash(void const *bytes, DN_USize size)
{ {
uint64_t result = DN_FNV1A64_Iterate(bytes, size, DN_FNV1A64_SEED); DN_U64 result = DN_FNV1A64_Iterate(bytes, size, DN_FNV1A64_SEED);
return result; return result;
} }
@ -60,12 +64,12 @@ DN_API uint64_t DN_FNV1A64_Hash(void const *bytes, DN_USize size)
// Block read - if your platform needs to do endian-swapping or can only // Block read - if your platform needs to do endian-swapping or can only
// handle aligned reads, do the conversion here // handle aligned reads, do the conversion here
DN_FORCE_INLINE uint32_t DN_MurmurHash3_GetBlock32(uint32_t const *p, int i) DN_FORCE_INLINE DN_U32 DN_MurmurHash3_GetBlock32(DN_U32 const *p, int i)
{ {
return p[i]; return p[i];
} }
DN_FORCE_INLINE uint64_t DN_MurmurHash3_GetBlock64(uint64_t const *p, int i) DN_FORCE_INLINE DN_U64 DN_MurmurHash3_GetBlock64(DN_U64 const *p, int i)
{ {
return p[i]; return p[i];
} }
@ -73,7 +77,7 @@ DN_FORCE_INLINE uint64_t DN_MurmurHash3_GetBlock64(uint64_t const *p, int i)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Finalization mix - force all bits of a hash block to avalanche // Finalization mix - force all bits of a hash block to avalanche
DN_FORCE_INLINE uint32_t DN_MurmurHash3_FMix32(uint32_t h) DN_FORCE_INLINE DN_U32 DN_MurmurHash3_FMix32(DN_U32 h)
{ {
h ^= h >> 16; h ^= h >> 16;
h *= 0x85ebca6b; h *= 0x85ebca6b;
@ -83,7 +87,7 @@ DN_FORCE_INLINE uint32_t DN_MurmurHash3_FMix32(uint32_t h)
return h; return h;
} }
DN_FORCE_INLINE uint64_t DN_MurmurHash3_FMix64(uint64_t k) DN_FORCE_INLINE DN_U64 DN_MurmurHash3_FMix64(DN_U64 k)
{ {
k ^= k >> 33; k ^= k >> 33;
k *= 0xff51afd7ed558ccd; k *= 0xff51afd7ed558ccd;
@ -93,24 +97,24 @@ DN_FORCE_INLINE uint64_t DN_MurmurHash3_FMix64(uint64_t k)
return k; return k;
} }
DN_API uint32_t DN_MurmurHash3_x86U32(void const *key, int len, uint32_t seed) DN_API DN_U32 DN_MurmurHash3_x86U32(void const *key, int len, DN_U32 seed)
{ {
const uint8_t *data = (const uint8_t *)key; const DN_U8 *data = (const DN_U8 *)key;
const int nblocks = len / 4; const int nblocks = len / 4;
uint32_t h1 = seed; DN_U32 h1 = seed;
const uint32_t c1 = 0xcc9e2d51; const DN_U32 c1 = 0xcc9e2d51;
const uint32_t c2 = 0x1b873593; const DN_U32 c2 = 0x1b873593;
//---------- //----------
// body // body
const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4); const DN_U32 *blocks = (const DN_U32 *)(data + nblocks * 4);
for (int i = -nblocks; i; i++) for (int i = -nblocks; i; i++)
{ {
uint32_t k1 = DN_MurmurHash3_GetBlock32(blocks, i); DN_U32 k1 = DN_MurmurHash3_GetBlock32(blocks, i);
k1 *= c1; k1 *= c1;
k1 = DN_MMH3_ROTL32(k1, 15); k1 = DN_MMH3_ROTL32(k1, 15);
@ -124,9 +128,9 @@ DN_API uint32_t DN_MurmurHash3_x86U32(void const *key, int len, uint32_t seed)
//---------- //----------
// tail // tail
const uint8_t *tail = (const uint8_t *)(data + nblocks * 4); const DN_U8 *tail = (const DN_U8 *)(data + nblocks * 4);
uint32_t k1 = 0; DN_U32 k1 = 0;
switch (len & 3) switch (len & 3)
{ {
@ -152,26 +156,26 @@ DN_API uint32_t DN_MurmurHash3_x86U32(void const *key, int len, uint32_t seed)
return h1; return h1;
} }
DN_API DN_MurmurHash3 DN_MurmurHash3_x64U128(void const *key, int len, uint32_t seed) DN_API DN_MurmurHash3 DN_MurmurHash3_x64U128(void const *key, int len, DN_U32 seed)
{ {
const uint8_t *data = (const uint8_t *)key; const DN_U8 *data = (const DN_U8 *)key;
const int nblocks = len / 16; const int nblocks = len / 16;
uint64_t h1 = seed; DN_U64 h1 = seed;
uint64_t h2 = seed; DN_U64 h2 = seed;
const uint64_t c1 = 0x87c37b91114253d5; const DN_U64 c1 = 0x87c37b91114253d5;
const uint64_t c2 = 0x4cf5ad432745937f; const DN_U64 c2 = 0x4cf5ad432745937f;
//---------- //----------
// body // body
const uint64_t *blocks = (const uint64_t *)(data); const DN_U64 *blocks = (const DN_U64 *)(data);
for (int i = 0; i < nblocks; i++) for (int i = 0; i < nblocks; i++)
{ {
uint64_t k1 = DN_MurmurHash3_GetBlock64(blocks, i * 2 + 0); DN_U64 k1 = DN_MurmurHash3_GetBlock64(blocks, i * 2 + 0);
uint64_t k2 = DN_MurmurHash3_GetBlock64(blocks, i * 2 + 1); DN_U64 k2 = DN_MurmurHash3_GetBlock64(blocks, i * 2 + 1);
k1 *= c1; k1 *= c1;
k1 = DN_MMH3_ROTL64(k1, 31); k1 = DN_MMH3_ROTL64(k1, 31);
@ -195,48 +199,48 @@ DN_API DN_MurmurHash3 DN_MurmurHash3_x64U128(void const *key, int len, uint32_t
//---------- //----------
// tail // tail
const uint8_t *tail = (const uint8_t *)(data + nblocks * 16); const DN_U8 *tail = (const DN_U8 *)(data + nblocks * 16);
uint64_t k1 = 0; DN_U64 k1 = 0;
uint64_t k2 = 0; DN_U64 k2 = 0;
switch (len & 15) switch (len & 15)
{ {
case 15: case 15:
k2 ^= ((uint64_t)tail[14]) << 48; k2 ^= ((DN_U64)tail[14]) << 48;
case 14: case 14:
k2 ^= ((uint64_t)tail[13]) << 40; k2 ^= ((DN_U64)tail[13]) << 40;
case 13: case 13:
k2 ^= ((uint64_t)tail[12]) << 32; k2 ^= ((DN_U64)tail[12]) << 32;
case 12: case 12:
k2 ^= ((uint64_t)tail[11]) << 24; k2 ^= ((DN_U64)tail[11]) << 24;
case 11: case 11:
k2 ^= ((uint64_t)tail[10]) << 16; k2 ^= ((DN_U64)tail[10]) << 16;
case 10: case 10:
k2 ^= ((uint64_t)tail[9]) << 8; k2 ^= ((DN_U64)tail[9]) << 8;
case 9: case 9:
k2 ^= ((uint64_t)tail[8]) << 0; k2 ^= ((DN_U64)tail[8]) << 0;
k2 *= c2; k2 *= c2;
k2 = DN_MMH3_ROTL64(k2, 33); k2 = DN_MMH3_ROTL64(k2, 33);
k2 *= c1; k2 *= c1;
h2 ^= k2; h2 ^= k2;
case 8: case 8:
k1 ^= ((uint64_t)tail[7]) << 56; k1 ^= ((DN_U64)tail[7]) << 56;
case 7: case 7:
k1 ^= ((uint64_t)tail[6]) << 48; k1 ^= ((DN_U64)tail[6]) << 48;
case 6: case 6:
k1 ^= ((uint64_t)tail[5]) << 40; k1 ^= ((DN_U64)tail[5]) << 40;
case 5: case 5:
k1 ^= ((uint64_t)tail[4]) << 32; k1 ^= ((DN_U64)tail[4]) << 32;
case 4: case 4:
k1 ^= ((uint64_t)tail[3]) << 24; k1 ^= ((DN_U64)tail[3]) << 24;
case 3: case 3:
k1 ^= ((uint64_t)tail[2]) << 16; k1 ^= ((DN_U64)tail[2]) << 16;
case 2: case 2:
k1 ^= ((uint64_t)tail[1]) << 8; k1 ^= ((DN_U64)tail[1]) << 8;
case 1: case 1:
k1 ^= ((uint64_t)tail[0]) << 0; k1 ^= ((DN_U64)tail[0]) << 0;
k1 *= c1; k1 *= c1;
k1 = DN_MMH3_ROTL64(k1, 31); k1 = DN_MMH3_ROTL64(k1, 31);
k1 *= c2; k1 *= c2;

View File

@ -1,6 +1,10 @@
#if !defined(DN_HASH_H) #if !defined(DN_HASH_H)
#define DN_HASH_H #define DN_HASH_H
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#endif
/* /*
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //

View File

@ -1,5 +1,9 @@
#define DN_HELPERS_CPP #define DN_HELPERS_CPP
#if defined(_CLANGD)
#include "dn_helpers.h"
#endif
/* /*
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //

View File

@ -1,6 +1,11 @@
#if !defined(DN_HELPERS_H) #if !defined(DN_HELPERS_H)
#define DN_HELPERS_H #define DN_HELPERS_H
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#include "dn_math.h"
#endif
#if !defined(DN_BASE_H) #if !defined(DN_BASE_H)
#error dn_base_inc.h must be included before this #error dn_base_inc.h must be included before this
#endif #endif

View File

@ -1,6 +1,11 @@
#if !defined(DN_JSON_H) #if !defined(DN_JSON_H)
#define DN_JSON_H #define DN_JSON_H
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#include "../External/json.h"
#endif
#if !defined(SHEREDOM_JSON_H_INCLUDED) #if !defined(SHEREDOM_JSON_H_INCLUDED)
#error Sheredom json.h (github.com/sheredom/json.h) must be included before this file #error Sheredom json.h (github.com/sheredom/json.h) must be included before this file
#endif #endif

View File

@ -1,6 +1,8 @@
#define DN_MATH_CPP #define DN_MATH_CPP
#if defined(_CLANGD)
#include "dn_math.h" #include "dn_math.h"
#endif
DN_API bool operator==(DN_V2I32 lhs, DN_V2I32 rhs) DN_API bool operator==(DN_V2I32 lhs, DN_V2I32 rhs)
{ {

View File

@ -1,7 +1,9 @@
#if !defined(DN_MATH_H) #if !defined(DN_MATH_H)
#define DN_MATH_H #define DN_MATH_H
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#endif
DN_MSVC_WARNING_PUSH DN_MSVC_WARNING_PUSH
DN_MSVC_WARNING_DISABLE(4201) // warning C4201: nonstandard extension used: nameless struct/union DN_MSVC_WARNING_DISABLE(4201) // warning C4201: nonstandard extension used: nameless struct/union

View File

@ -1,7 +1,8 @@
#define DN_NET_CURL_CPP #define DN_NET_CURL_CPP
#include "../dn_base_inc.h" #if defined(_CLANGD)
#include "../dn_os_inc.h" #include "dn_net.h"
#endif
DN_Str8 DN_NET_Str8FromResponseState(DN_NETResponseState state) DN_Str8 DN_NET_Str8FromResponseState(DN_NETResponseState state)
{ {

View File

@ -1,8 +1,10 @@
#if !defined(DN_NET_H) #if !defined(DN_NET_H)
#define DN_NET_H #define DN_NET_H
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#include "../dn_os_inc.h" #include "../dn_os_inc.h"
#endif
enum DN_NETRequestType enum DN_NETRequestType
{ {

View File

@ -1,5 +1,9 @@
#define DN_NET_CURL_CPP
#if defined(_CLANGD)
#include "dn_net.h" #include "dn_net.h"
#include "dn_net_curl.h" #include "dn_net_curl.h"
#endif
struct DN_NETCurlRequest struct DN_NETCurlRequest
{ {

View File

@ -1,7 +1,9 @@
#if !defined(DN_NET_CURL_H) #if !defined(DN_NET_CURL_H)
#define DN_NET_CURL_H #define DN_NET_CURL_H
#if defined(_CLANGD)
#include "dn_net.h" #include "dn_net.h"
#endif
struct DN_NETCurlCore struct DN_NETCurlCore
{ {

View File

@ -6,8 +6,10 @@
#include <emscripten/fetch.h> #include <emscripten/fetch.h>
#include <emscripten/websocket.h> #include <emscripten/websocket.h>
#if defined(_CLANGD)
#include "dn_net.h" #include "dn_net.h"
#include "dn_net_emscripten.h" #include "dn_net_emscripten.h"
#endif
struct DN_NETEmcWSEvent struct DN_NETEmcWSEvent
{ {

View File

@ -1,7 +1,9 @@
#if !defined(DN_NET_EMSCRIPTEN_H) #if !defined(DN_NET_EMSCRIPTEN_H)
#define DN_NET_EMSCRIPTEN_H #define DN_NET_EMSCRIPTEN_H
#if defined(_CLANGD)
#include "dn_net.h" #include "dn_net.h"
#endif
DN_NETInterface DN_NET_EmcInterface(); DN_NETInterface DN_NET_EmcInterface();
void DN_NET_EmcInit (DN_NETCore *net, char *base, DN_U64 base_size); void DN_NET_EmcInit (DN_NETCore *net, char *base, DN_U64 base_size);

View File

@ -1,3 +1,8 @@
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#include "../dn_os_inc.h"
#endif
#if !defined(DN_UT_H) #if !defined(DN_UT_H)
#error dn_utest.h must be included before this #error dn_utest.h must be included before this
#endif #endif

View File

@ -1,5 +1,9 @@
#define DN_TYPE_INFO_CPP #define DN_TYPE_INFO_CPP
#if defined(_CLANGD)
#include "dn_type_info.h"
#endif
/* /*
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //
@ -22,7 +26,7 @@ DN_TypeGetField DN_Type_GetField(DN_TypeInfo const *type_info, DN_Str8 name)
DN_TypeGetField result = {}; DN_TypeGetField result = {};
for (DN_USize index = 0; index < type_info->fields_count; index++) { for (DN_USize index = 0; index < type_info->fields_count; index++) {
DN_TypeField const *type_field = type_info->fields + index; DN_TypeField const *type_field = type_info->fields + index;
if (type_field->name == name) { if (DN_Str8Eq(type_field->name, name)) {
result.success = true; result.success = true;
result.index = index; result.index = index;
result.field = DN_Cast(DN_TypeField *)type_field; result.field = DN_Cast(DN_TypeField *)type_field;

View File

@ -1,6 +1,10 @@
#if !defined(DN_TYPE_INFO_H) #if !defined(DN_TYPE_INFO_H)
#define DN_TYPE_INFO_H #define DN_TYPE_INFO_H
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#endif
/* /*
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //

View File

@ -1,7 +1,9 @@
#define DN_OS_CPP #define DN_OS_CPP
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#include "../dn_os_inc.h" #include "../dn_os_inc.h"
#endif
#if defined(DN_PLATFORM_POSIX) #if defined(DN_PLATFORM_POSIX)
#include <sys/sysinfo.h> // get_nprocs #include <sys/sysinfo.h> // get_nprocs

View File

@ -1,8 +1,10 @@
#if !defined(DN_OS_H) #if !defined(DN_OS_H)
#define DN_OS_H #define DN_OS_H
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#include "../dn_os_inc.h" #include "../dn_os_inc.h"
#endif
#include <new> // operator new #include <new> // operator new
@ -33,6 +35,8 @@
#include <emscripten/fetch.h> // emscripten_fetch (for DN_OSHttpResponse) #include <emscripten/fetch.h> // emscripten_fetch (for DN_OSHttpResponse)
#endif #endif
extern DN_CPUFeatureDecl g_dn_cpu_feature_decl[DN_CPUFeature_Count];
// NOTE: DN_OSDate ///////////////////////////////////////////////////////////////////////////////// // NOTE: DN_OSDate /////////////////////////////////////////////////////////////////////////////////
struct DN_OSDateTimeStr8 struct DN_OSDateTimeStr8
{ {

View File

@ -1,7 +1,10 @@
#define DN_OS_ALLOCATOR_CPP #define DN_OS_ALLOCATOR_CPP
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#include "../dn_os_inc.h" #include "../dn_os_inc.h"
#include "../dn_inc.h"
#endif
static void *DN_ArenaBasicAllocFromOSHeap(DN_USize size) static void *DN_ArenaBasicAllocFromOSHeap(DN_USize size)
{ {

View File

@ -1,6 +1,10 @@
#if !defined(DN_OS_ALLOCATOR_H) #if !defined(DN_OS_ALLOCATOR_H)
#define DN_OS_ALLOCATOR_H #define DN_OS_ALLOCATOR_H
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#endif
DN_API DN_Arena DN_ArenaFromHeap(DN_U64 size, DN_ArenaFlags flags); DN_API DN_Arena DN_ArenaFromHeap(DN_U64 size, DN_ArenaFlags flags);
DN_API DN_Arena DN_ArenaFromVMem(DN_U64 reserve, DN_U64 commit, DN_ArenaFlags flags); DN_API DN_Arena DN_ArenaFromVMem(DN_U64 reserve, DN_U64 commit, DN_ArenaFlags flags);

View File

@ -1,5 +1,7 @@
#define DN_OS_CONTAINERS_CPP #define DN_OS_CONTAINERS_CPP
#include "dn_os_containers.h"
/* /*
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //

View File

@ -1,7 +1,11 @@
#if !defined(DN_OS_CONTAINERS_H) #if !defined(DN_OS_CONTAINERS_H)
#define DN_OS_CONTAINERS_H #define DN_OS_CONTAINERS_H
// NOTE: DN_VArray ///////////////////////////////////////////////////////////////////////////////// #if defined(_CLANGD)
#include "../dn_base_inc.h"
#endif
// NOTE: DN_VArray
// TODO(doyle): Add an API for shrinking the array by decomitting pages back to the OS. // TODO(doyle): Add an API for shrinking the array by decomitting pages back to the OS.
template <typename T> struct DN_VArray template <typename T> struct DN_VArray
{ {

View File

@ -1,9 +1,14 @@
#define DN_OS_POSIX_CPP #define DN_OS_POSIX_CPP
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#include "../dn_os_inc.h"
#endif
#include <dirent.h> // readdir, opendir, closedir #include <dirent.h> // readdir, opendir, closedir
#include <sys/statvfs.h> #include <sys/statvfs.h>
// NOTE: DN_OSMem ////////////////////////////////////////////////////////////////////////////////// // NOTE: DN_OSMem
static DN_U32 DN_OS_MemConvertPageToOSFlags_(DN_U32 protect) static DN_U32 DN_OS_MemConvertPageToOSFlags_(DN_U32 protect)
{ {
DN_Assert((protect & ~DN_MemPage_All) == 0); DN_Assert((protect & ~DN_MemPage_All) == 0);

View File

@ -1,4 +1,9 @@
#pragma once #if !defined(DN_OS_POSIX_H)
#define DN_OS_POSIX_H
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#endif
#include <pthread.h> #include <pthread.h>
#include <semaphore.h> #include <semaphore.h>
@ -76,3 +81,4 @@ struct DN_POSIXCore
DN_API void DN_Posix_Init(DN_POSIXCore *posix); DN_API void DN_Posix_Init(DN_POSIXCore *posix);
DN_API void DN_Posix_ThreadSetName(DN_Str8 name); DN_API void DN_Posix_ThreadSetName(DN_Str8 name);
DN_API DN_POSIXProcSelfStatus DN_Posix_ProcSelfStatus(); DN_API DN_POSIXProcSelfStatus DN_Posix_ProcSelfStatus();
#endif // !defined(DN_OS_POSIX_H)

View File

@ -7,7 +7,7 @@ enum DN_OSPrintDest
DN_OSPrintDest_Err, DN_OSPrintDest_Err,
}; };
// NOTE: Print Macros ////////////////////////////////////////////////////////////////////////////// // NOTE: Print Macros
#define DN_OS_PrintOut(string) DN_OS_Print(DN_OSPrintDest_Out, string) #define DN_OS_PrintOut(string) DN_OS_Print(DN_OSPrintDest_Out, string)
#define DN_OS_PrintOutF(fmt, ...) DN_OS_PrintF(DN_OSPrintDest_Out, fmt, ##__VA_ARGS__) #define DN_OS_PrintOutF(fmt, ...) DN_OS_PrintF(DN_OSPrintDest_Out, fmt, ##__VA_ARGS__)
#define DN_OS_PrintOutFV(fmt, args) DN_OS_PrintFV(DN_OSPrintDest_Out, fmt, args) #define DN_OS_PrintOutFV(fmt, args) DN_OS_PrintFV(DN_OSPrintDest_Out, fmt, args)
@ -40,7 +40,7 @@ enum DN_OSPrintDest
#define DN_OS_PrintErrLnFStyle(style, fmt, ...) DN_OS_PrintLnFStyle(DN_OSPrintDest_Err, style, fmt, ##__VA_ARGS__) #define DN_OS_PrintErrLnFStyle(style, fmt, ...) DN_OS_PrintLnFStyle(DN_OSPrintDest_Err, style, fmt, ##__VA_ARGS__)
#define DN_OS_PrintErrLnFVStyle(style, fmt, args) DN_OS_PrintLnFVStyle(DN_OSPrintDest_Err, style, fmt, args); #define DN_OS_PrintErrLnFVStyle(style, fmt, args) DN_OS_PrintLnFVStyle(DN_OSPrintDest_Err, style, fmt, args);
// NOTE: Print ///////////////////////////////////////////////////////////////////////////////////// // NOTE: Print
DN_API void DN_OS_Print (DN_OSPrintDest dest, DN_Str8 string); DN_API void DN_OS_Print (DN_OSPrintDest dest, DN_Str8 string);
DN_API void DN_OS_PrintF (DN_OSPrintDest dest, DN_FMT_ATTRIB char const *fmt, ...); DN_API void DN_OS_PrintF (DN_OSPrintDest dest, DN_FMT_ATTRIB char const *fmt, ...);
DN_API void DN_OS_PrintFV (DN_OSPrintDest dest, DN_FMT_ATTRIB char const *fmt, va_list args); DN_API void DN_OS_PrintFV (DN_OSPrintDest dest, DN_FMT_ATTRIB char const *fmt, va_list args);

View File

@ -1,7 +1,9 @@
#define DN_OS_STRING_CPP #define DN_OS_STRING_CPP
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#include "../dn_os_inc.h" #include "../dn_os_inc.h"
#endif
// NOTE: DN_Str8 // NOTE: DN_Str8
DN_API DN_Str8 DN_Str8FromFmtArenaFrame(DN_FMT_ATTRIB char const *fmt, ...) DN_API DN_Str8 DN_Str8FromFmtArenaFrame(DN_FMT_ATTRIB char const *fmt, ...)

View File

@ -1,10 +1,12 @@
#if !defined(DN_OS_STRING_H) #if !defined(DN_OS_STRING_H)
#define DN_OS_STRING_H #define DN_OS_STRING_H
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#include "../dn_os_inc.h" #include "../dn_os_inc.h"
#endif
// NOTE: DN_Str8 /////////////////////////////////////////////////////////////////////////////////// // NOTE: DN_Str8
DN_API DN_Str8 DN_Str8FromFmtVArenaFrame (DN_FMT_ATTRIB char const *fmt, va_list args); DN_API DN_Str8 DN_Str8FromFmtVArenaFrame (DN_FMT_ATTRIB char const *fmt, va_list args);
DN_API DN_Str8 DN_Str8FromFmtArenaFrame (DN_FMT_ATTRIB char const *fmt, ...); DN_API DN_Str8 DN_Str8FromFmtArenaFrame (DN_FMT_ATTRIB char const *fmt, ...);

View File

@ -1,5 +1,9 @@
#define DN_OS_TLSCPP #define DN_OS_TLSCPP
#if defined(_CLANGD)
#include "dn_os_tls.h"
#endif
// NOTE: DN_OSTLS //////////////////////////////////////////////////////////////////////////////////// // NOTE: DN_OSTLS ////////////////////////////////////////////////////////////////////////////////////
DN_OSTLSTMem::DN_OSTLSTMem(DN_OSTLS *tls, DN_U8 arena_index, DN_OSTLSPushTMem push_tmem) DN_OSTLSTMem::DN_OSTLSTMem(DN_OSTLS *tls, DN_U8 arena_index, DN_OSTLSPushTMem push_tmem)
{ {

View File

@ -1,10 +1,12 @@
#if !defined(DN_OS_TLS_H) #if !defined(DN_OS_TLS_H)
#define DN_OS_TLS_H #define DN_OS_TLS_H
#if defined(_CLANGD)
#include "../dn_base_inc.h" #include "../dn_base_inc.h"
#include "../dn_os_inc.h" #include "../dn_os_inc.h"
#endif
// NOTE: DN_OSErrSink ///////////////////////////////////////////////////////////////////////////// // NOTE: DN_OSErrSink
enum DN_OSErrSinkMode enum DN_OSErrSinkMode
{ {
DN_OSErrSinkMode_Nil, // Default behaviour to accumulate errors into the sink DN_OSErrSinkMode_Nil, // Default behaviour to accumulate errors into the sink

View File

@ -1,6 +1,11 @@
#if !defined(DN_OS_WIN32_H) #if !defined(DN_OS_WIN32_H)
#define DN_OS_WIN32_H #define DN_OS_WIN32_H
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#include "dn_os_windows.h"
#endif
struct DN_W32Error struct DN_W32Error
{ {
unsigned long code; unsigned long code;

View File

@ -1,6 +1,10 @@
#if !defined(DN_OS_WINDOWS_H) #if !defined(DN_OS_WINDOWS_H)
#define DN_OS_WINDOWS_H #define DN_OS_WINDOWS_H
#if defined(_CLANGD)
#include "../dn_base_inc.h"
#endif
#if defined(DN_COMPILER_MSVC) || defined(DN_COMPILER_CLANG_CL) #if defined(DN_COMPILER_MSVC) || defined(DN_COMPILER_CLANG_CL)
#pragma comment(lib, "bcrypt") #pragma comment(lib, "bcrypt")
#pragma comment(lib, "winhttp") #pragma comment(lib, "winhttp")

View File

@ -1,31 +0,0 @@
#if defined(_CLANDG)
#include "dn_base_inc.h"
#include "dn_core_inc.h"
#include "dn_os_inc.h"
#include "Standalone/dn_cpp_file.h"
#include "Standalone/dn_keccak.h"
#include "Standalone/dn_utest.h"
#include "Extra/dn_cgen.h"
#include "Extra/dn_csv.h"
#include "Extra/dn_hash.h"
#include "Extra/dn_helpers.h"
#include "Extra/dn_json.h"
#include "Extra/dn_math.h"
#include "Extra/dn_type_info.h"
#include "Extra/dn_cgen.cpp"
#include "Extra/dn_csv.cpp"
#include "Extra/dn_hash.cpp"
#include "Extra/dn_helpers.cpp"
#include "Extra/dn_json.cpp"
#include "Extra/dn_math.cpp"
#include "Extra/dn_tests.cpp"
#include "Extra/dn_type_info.cpp"
#include "dn_base_inc.cpp"
#include "dn_core_inc.cpp"
#include "dn_os_inc.cpp"
#endif

View File

@ -1,6 +1,8 @@
#define DN_INC_CPP #define DN_INC_CPP
#if defined(_CLANGD)
#include "dn_inc.h" #include "dn_inc.h"
#endif
DN_Core *g_dn_; DN_Core *g_dn_;

View File

@ -1,6 +1,11 @@
#if !defined(DN_INC_H) #if !defined(DN_INC_H)
#define DN_INC_H #define DN_INC_H
#if defined(_CLANGD)
#include "dn_base_inc.h"
#include "dn_os_inc.h"
#endif
struct DN_InitArgs struct DN_InitArgs
{ {
DN_U64 os_tls_reserve; DN_U64 os_tls_reserve;