meta layer progress
This commit is contained in:
parent
0324866b9c
commit
20a21d31d4
@ -1,52 +1,40 @@
|
|||||||
/* TODO: Remove this */
|
|
||||||
#define RtcIsEnabled 1
|
|
||||||
#define UnoptimizedIsEnabled 1
|
|
||||||
#define AsanIsEnabled 0
|
|
||||||
#define CrtlibIsEnabled 1
|
|
||||||
#define DebinfoEnabled 1
|
|
||||||
#define DeveloperIsEnabled 1
|
|
||||||
#define ProfilingIsEnabled 0
|
|
||||||
#define UnoptimizedIsEnabled 1
|
|
||||||
#define TestsAreEnabled 0
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Compiler feature flags
|
//~ Compiler flag checks
|
||||||
|
|
||||||
/* Compile definition defaults */
|
|
||||||
#ifndef RtcIsEnabled
|
#ifndef RtcIsEnabled
|
||||||
# define RtcIsEnabled 0
|
# error Missing compile time definition for 'RtcIsEnabled'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef AsanIsEnabled
|
#ifndef AsanIsEnabled
|
||||||
# define AsanIsEnabled 0
|
# error Missing compile time definition for 'AsanIsEnabled'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CrtlibIsEnabled
|
#ifndef CrtlibIsEnabled
|
||||||
# define CrtlibIsEnabled 0
|
# error Missing compile time definition for 'CrtlibIsEnabled'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DebinfoEnabled
|
#ifndef DebinfoEnabled
|
||||||
# define DebinfoEnabled 0
|
# error Missing compile time definition for 'DebinfoEnabled'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DeveloperIsEnabled
|
#ifndef DeveloperIsEnabled
|
||||||
# define DeveloperIsEnabled 0
|
# error Missing compile time definition for 'DeveloperIsEnabled'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ProfilingIsEnabled
|
#ifndef ProfilingIsEnabled
|
||||||
# define ProfilingIsEnabled 0
|
# error Missing compile time definition for 'ProfilingIsEnabled'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef UnoptimizedIsEnabled
|
#ifndef UnoptimizedIsEnabled
|
||||||
# define UnoptimizedIsEnabled 0
|
# error Missing compile time definition for 'UnoptimizedIsEnabled'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TestsAreEnabled
|
#ifndef TestsAreEnabled
|
||||||
# define TestsAreEnabled 0
|
# error Missing compile time definition for 'TestsAreEnabled'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IncbinRawDir
|
#ifndef IncbinRawDir
|
||||||
# define IncbinDir ""
|
# error Missing compile time definition for 'IncbinRawDir'
|
||||||
#else
|
#else
|
||||||
# define IncbinDir Stringize(IncbinRawDir)
|
# define IncbinDir Stringize(IncbinRawDir)
|
||||||
#endif
|
#endif
|
||||||
@ -74,7 +62,7 @@
|
|||||||
# define LanguageIsGpu 0
|
# define LanguageIsGpu 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//- Operating system
|
//- Platform system
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
# define PlatformIsWindows 1
|
# define PlatformIsWindows 1
|
||||||
# define PlatformIsMac 0
|
# define PlatformIsMac 0
|
||||||
@ -535,7 +523,7 @@ StaticAssert(sizeof(Atomic32Padded) == 64 && alignof(Atomic32Padded) == 64);
|
|||||||
StaticAssert(sizeof(Atomic64Padded) == 64 && alignof(Atomic64Padded) == 64);
|
StaticAssert(sizeof(Atomic64Padded) == 64 && alignof(Atomic64Padded) == 64);
|
||||||
|
|
||||||
#if PlatformIsWindows
|
#if PlatformIsWindows
|
||||||
//- 8 bit atomics operations
|
//- 8 bit atomic operations
|
||||||
ForceInline i8 Atomic8Fetch(Atomic8 *x) { return (i8)_InterlockedCompareExchange8((char *)&x->_v, 0, 0); }
|
ForceInline i8 Atomic8Fetch(Atomic8 *x) { return (i8)_InterlockedCompareExchange8((char *)&x->_v, 0, 0); }
|
||||||
ForceInline i8 Atomic8FetchSet(Atomic8 *x, i8 e) { return (i8)_InterlockedExchange8((char *)&x->_v, e); }
|
ForceInline i8 Atomic8FetchSet(Atomic8 *x, i8 e) { return (i8)_InterlockedExchange8((char *)&x->_v, e); }
|
||||||
ForceInline i8 Atomic8FetchTestSet(Atomic8 *x, i8 c, i8 e) { return (i8)_InterlockedCompareExchange8((char *)&x->_v, e, c); }
|
ForceInline i8 Atomic8FetchTestSet(Atomic8 *x, i8 c, i8 e) { return (i8)_InterlockedCompareExchange8((char *)&x->_v, e, c); }
|
||||||
@ -569,7 +557,6 @@ ForceInline i64 Atomic64FetchAdd(Atomic64 *x, i64 a) { return (i64)_InterlockedE
|
|||||||
//~ Ticket mutex
|
//~ Ticket mutex
|
||||||
|
|
||||||
#if LanguageIsC
|
#if LanguageIsC
|
||||||
|
|
||||||
Struct(TicketMutex)
|
Struct(TicketMutex)
|
||||||
{
|
{
|
||||||
Atomic64Padded ticket;
|
Atomic64Padded ticket;
|
||||||
|
|||||||
@ -210,7 +210,8 @@ u64 PowU64(u64 base, u8 exp)
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// if (base == -1) {
|
// if (base == -1)
|
||||||
|
// {
|
||||||
// return 1 - 2 * (exp & 1);
|
// return 1 - 2 * (exp & 1);
|
||||||
// }
|
// }
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -453,7 +453,7 @@ StringListNode *PushStringToList(Arena *arena, StringList *l, String s)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
String StringFromStringList(Arena *arena, StringList l, String separator)
|
String StringFromList(Arena *arena, StringList l, String separator)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = ZI;
|
||||||
result.text = PushDry(arena, u8);
|
result.text = PushDry(arena, u8);
|
||||||
@ -471,6 +471,34 @@ String StringFromStringList(Arena *arena, StringList l, String separator)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ Trimming helpers
|
||||||
|
|
||||||
|
String TrimLeft(String s, String pattern)
|
||||||
|
{
|
||||||
|
String result = s;
|
||||||
|
while (StringStartsWith(result, pattern))
|
||||||
|
{
|
||||||
|
result.text += pattern.len;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String TrimRight(String s, String pattern)
|
||||||
|
{
|
||||||
|
String result = s;
|
||||||
|
while (StringEndsWith(result, pattern))
|
||||||
|
{
|
||||||
|
result.len -= pattern.len;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String Trim(String s, String pattern)
|
||||||
|
{
|
||||||
|
return TrimLeft(TrimRight(s, pattern), pattern);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Formatting
|
//~ Formatting
|
||||||
|
|
||||||
|
|||||||
@ -103,11 +103,18 @@ b32 StringContains(String str, String substring);
|
|||||||
b32 StringStartsWith(String str, String substring);
|
b32 StringStartsWith(String str, String substring);
|
||||||
b32 StringEndsWith(String str, String substring);
|
b32 StringEndsWith(String str, String substring);
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ Trimming helpers
|
||||||
|
|
||||||
|
String TrimLeft(String s, String pattern);
|
||||||
|
String TrimRight(String s, String pattern);
|
||||||
|
String Trim(String s, String pattern);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ String list helpers
|
//~ String list helpers
|
||||||
|
|
||||||
StringListNode *PushStringToList(Arena *arena, StringList *l, String s);
|
StringListNode *PushStringToList(Arena *arena, StringList *l, String s);
|
||||||
String StringFromStringList(Arena *arena, StringList l, String separator);
|
String StringFromList(Arena *arena, StringList l, String separator);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Formatting
|
//~ Formatting
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Uid types
|
//~ Uid types
|
||||||
|
|
||||||
Struct(Uid) {
|
Struct(Uid)
|
||||||
|
{
|
||||||
u64 hi;
|
u64 hi;
|
||||||
u64 lo;
|
u64 lo;
|
||||||
};
|
};
|
||||||
|
|||||||
167
src/meta/meta.c
167
src/meta/meta.c
@ -1,5 +1,44 @@
|
|||||||
/* TODO: Move decls to meta.h */
|
/* TODO: Move decls to meta.h */
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ Metaprogram default compiler definitions
|
||||||
|
|
||||||
|
#ifndef RtcIsEnabled
|
||||||
|
# define RtcIsEnabled 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UnoptimizedIsEnabled
|
||||||
|
# define UnoptimizedIsEnabled 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef AsanIsEnabled
|
||||||
|
# define AsanIsEnabled 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CrtlibIsEnabled
|
||||||
|
# define CrtlibIsEnabled 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DebinfoEnabled
|
||||||
|
# define DebinfoEnabled 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DeveloperIsEnabled
|
||||||
|
# define DeveloperIsEnabled 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ProfilingIsEnabled
|
||||||
|
# define ProfilingIsEnabled 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UnoptimizedIsEnabled
|
||||||
|
# define UnoptimizedIsEnabled 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TestsAreEnabled
|
||||||
|
# define TestsAreEnabled 0
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Includes
|
//~ Includes
|
||||||
|
|
||||||
@ -427,6 +466,7 @@ Struct(L_TopoItemList)
|
|||||||
Struct(L_Topo)
|
Struct(L_Topo)
|
||||||
{
|
{
|
||||||
L_TopoItemList c_includes;
|
L_TopoItemList c_includes;
|
||||||
|
L_TopoItemList startup_functions;
|
||||||
L_TopoItemList errors;
|
L_TopoItemList errors;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -522,7 +562,7 @@ L_Topo L_TopoFromLayerName(Arena *arena, StringList starting_layer_names, String
|
|||||||
if (cycle->blob->names.count > 0) name = cycle->blob->names.first->s;
|
if (cycle->blob->names.count > 0) name = cycle->blob->names.first->s;
|
||||||
PushStringToList(scratch.arena, &cycle_names_list, name);
|
PushStringToList(scratch.arena, &cycle_names_list, name);
|
||||||
}
|
}
|
||||||
String cycle_names_str = StringFromStringList(scratch.arena, cycle_names_list, Lit(" -> "));
|
String cycle_names_str = StringFromList(scratch.arena, cycle_names_list, Lit(" -> "));
|
||||||
String name = ZI;
|
String name = ZI;
|
||||||
String token_file = ZI;
|
String token_file = ZI;
|
||||||
i64 token_pos = 0;
|
i64 token_pos = 0;
|
||||||
@ -618,6 +658,13 @@ L_Topo L_TopoFromLayerName(Arena *arena, StringList starting_layer_names, String
|
|||||||
for (Node *n = first_post; n; n = n->next)
|
for (Node *n = first_post; n; n = n->next)
|
||||||
{
|
{
|
||||||
L_Blob *blob = n->blob;
|
L_Blob *blob = n->blob;
|
||||||
|
/* Errors */
|
||||||
|
for (L_BlobItem *bitem = blob->errors.first; bitem; bitem = bitem->next)
|
||||||
|
{
|
||||||
|
String file = PushString(arena, bitem->token_file);
|
||||||
|
String s = PushString(arena, bitem->s);
|
||||||
|
L_PushTopoItem(arena, &result.errors, file, bitem->token_pos, s);
|
||||||
|
}
|
||||||
/* C includes */
|
/* C includes */
|
||||||
for (L_BlobItem *bitem = blob->c_includes.first; bitem; bitem = bitem->next)
|
for (L_BlobItem *bitem = blob->c_includes.first; bitem; bitem = bitem->next)
|
||||||
{
|
{
|
||||||
@ -625,12 +672,12 @@ L_Topo L_TopoFromLayerName(Arena *arena, StringList starting_layer_names, String
|
|||||||
String s = PushString(arena, bitem->s);
|
String s = PushString(arena, bitem->s);
|
||||||
L_PushTopoItem(arena, &result.c_includes, file, bitem->token_pos, s);
|
L_PushTopoItem(arena, &result.c_includes, file, bitem->token_pos, s);
|
||||||
}
|
}
|
||||||
/* Errors */
|
/* Startup funcs */
|
||||||
for (L_BlobItem *bitem = blob->errors.first; bitem; bitem = bitem->next)
|
for (L_BlobItem *bitem = blob->startup_functions.first; bitem; bitem = bitem->next)
|
||||||
{
|
{
|
||||||
String file = PushString(arena, bitem->token_file);
|
String file = PushString(arena, bitem->token_file);
|
||||||
String s = PushString(arena, bitem->s);
|
String s = PushString(arena, bitem->s);
|
||||||
L_PushTopoItem(arena, &result.errors, file, bitem->token_pos, s);
|
L_PushTopoItem(arena, &result.startup_functions, file, bitem->token_pos, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,7 +794,7 @@ i32 main(i32 argc, u8 **argv)
|
|||||||
L_Topo topo = L_TopoFromLayerName(arena, starting_layer_names, src_dirs);
|
L_Topo topo = L_TopoFromLayerName(arena, starting_layer_names, src_dirs);
|
||||||
|
|
||||||
//- Process topo errors
|
//- Process topo errors
|
||||||
if (errors.count <= 0 && topo.errors.count > 0)
|
if (topo.errors.count > 0)
|
||||||
{
|
{
|
||||||
StringList topo_errors = ZI;
|
StringList topo_errors = ZI;
|
||||||
u64 max_topo_errors = 50;
|
u64 max_topo_errors = 50;
|
||||||
@ -761,28 +808,48 @@ i32 main(i32 argc, u8 **argv)
|
|||||||
if (errors.count <= 0)
|
if (errors.count <= 0)
|
||||||
{
|
{
|
||||||
StringList c_out_lines = ZI;
|
StringList c_out_lines = ZI;
|
||||||
PushStringToList(arena, &c_out_lines, Lit("// Auto generated file"));
|
/* Includes */
|
||||||
for (L_TopoItem *item = topo.c_includes.first; item; item = item->next)
|
|
||||||
{
|
{
|
||||||
String parent = F_GetParentDir(item->token_file);
|
PushStringToList(arena, &c_out_lines, Lit("// Auto generated file"));
|
||||||
String file = StringF(arena, "%F%F", FmtString(parent), FmtString(item->s));
|
PushStringToList(arena, &c_out_lines, Lit(""));
|
||||||
if (F_IsFile(file))
|
PushStringToList(arena, &c_out_lines, Lit("//- Includes"));
|
||||||
|
for (L_TopoItem *item = topo.c_includes.first; item; item = item->next)
|
||||||
{
|
{
|
||||||
String full = F_GetFull(arena, file);
|
String parent = F_GetParentDir(item->token_file);
|
||||||
String line = StringF(arena, "#include \"%F\"", FmtString(full));
|
String file = StringF(arena, "%F%F", FmtString(parent), FmtString(item->s));
|
||||||
PushStringToList(arena, &c_out_lines, line);
|
if (F_IsFile(file))
|
||||||
}
|
{
|
||||||
else
|
String full = F_GetFull(arena, file);
|
||||||
{
|
String line = StringF(arena, "#include \"%F\"", FmtString(full));
|
||||||
String e = StringF(arena, "File '%F' not found", FmtString(file));
|
PushStringToList(arena, &c_out_lines, line);
|
||||||
PushError(arena, &errors, item->token_file, item->token_pos, e);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String e = StringF(arena, "File '%F' not found", FmtString(file));
|
||||||
|
PushError(arena, &errors, item->token_file, item->token_pos, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String c_out = StringFromStringList(arena, c_out_lines, Lit("\n"));
|
/* StartupLayers definition */
|
||||||
|
{
|
||||||
|
PushStringToList(arena, &c_out_lines, Lit(""));
|
||||||
|
PushStringToList(arena, &c_out_lines, Lit("//- Startup"));
|
||||||
|
PushStringToList(arena, &c_out_lines, Lit("void StartupLayers(void)"));
|
||||||
|
PushStringToList(arena, &c_out_lines, Lit("{"));
|
||||||
|
for (L_TopoItem *item = topo.startup_functions.first; item; item = item->next)
|
||||||
|
{
|
||||||
|
String line = StringF(arena, " %F();", FmtString(item->s));
|
||||||
|
PushStringToList(arena, &c_out_lines, line);
|
||||||
|
}
|
||||||
|
PushStringToList(arena, &c_out_lines, Lit("}"));
|
||||||
|
PushStringToList(arena, &c_out_lines, Lit(""));
|
||||||
|
}
|
||||||
|
/* Write to file */
|
||||||
|
String c_out = StringFromList(arena, c_out_lines, Lit("\n"));
|
||||||
F_ClearWrite(Lit("gen.c"), c_out);
|
F_ClearWrite(Lit("gen.c"), c_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Print errors
|
//- Echo meta errors
|
||||||
for (Error *e = errors.first; e; e = e->next)
|
for (Error *e = errors.first; e; e = e->next)
|
||||||
{
|
{
|
||||||
String s = e->s;
|
String s = e->s;
|
||||||
@ -801,26 +868,56 @@ i32 main(i32 argc, u8 **argv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
error = StringF(arena,
|
error = StringF(arena, "error: %F", FmtString(s));
|
||||||
"error: %F",
|
|
||||||
FmtString(s));
|
|
||||||
}
|
}
|
||||||
Echo(error);
|
Echo(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Compile
|
//- Generate compiler flags
|
||||||
if (ret == 0) {
|
StringList shared_compiler_flags = ZI;
|
||||||
String cmd = Lit("\"cl\" /Zi /DEBUG gen.c /Fo:gen.obj /Fe:pp.exe /nologo");
|
StringList msvc_compiler_flags = ZI;
|
||||||
|
{
|
||||||
|
/* Definitions */
|
||||||
|
PushStringToList(arena, &shared_compiler_flags, Lit("DRtcIsEnabled=1"));
|
||||||
|
PushStringToList(arena, &shared_compiler_flags, Lit("DAsanIsEnabled=0"));
|
||||||
|
PushStringToList(arena, &shared_compiler_flags, Lit("DCrtlibIsEnabled=1"));
|
||||||
|
PushStringToList(arena, &shared_compiler_flags, Lit("DDebinfoEnabled=1"));
|
||||||
|
PushStringToList(arena, &shared_compiler_flags, Lit("DDeveloperIsEnabled=1"));
|
||||||
|
PushStringToList(arena, &shared_compiler_flags, Lit("DProfilingIsEnabled=0"));
|
||||||
|
PushStringToList(arena, &shared_compiler_flags, Lit("DUnoptimizedIsEnabled=1"));
|
||||||
|
PushStringToList(arena, &shared_compiler_flags, Lit("DTestsAreEnabled=0"));
|
||||||
|
PushStringToList(arena, &shared_compiler_flags, Lit("DIncbinRawDir=\"bla\""));
|
||||||
|
|
||||||
OS_CommandResult result = OS_RunCommand(arena, cmd);
|
/* Msvc flags */
|
||||||
if (result.code == 0)
|
PushStringToList(arena, &msvc_compiler_flags, Lit("Zi"));
|
||||||
{
|
PushStringToList(arena, &msvc_compiler_flags, Lit("DEBUG"));
|
||||||
}
|
PushStringToList(arena, &msvc_compiler_flags, Lit("Fo:gen.obj"));
|
||||||
else
|
PushStringToList(arena, &msvc_compiler_flags, Lit("Fe:pp.exe"));
|
||||||
{
|
PushStringToList(arena, &msvc_compiler_flags, Lit("nologo"));
|
||||||
ret = result.code;
|
}
|
||||||
}
|
|
||||||
Echo(result.output);
|
//- Generate compiler cmds
|
||||||
|
String msvc_cmd_str = ZI;
|
||||||
|
{
|
||||||
|
String flags_str = StringF(arena,
|
||||||
|
"/%F /%F",
|
||||||
|
FmtString(StringFromList(arena, shared_compiler_flags, Lit(" /"))),
|
||||||
|
FmtString(StringFromList(arena, msvc_compiler_flags, Lit(" /")))
|
||||||
|
);
|
||||||
|
msvc_cmd_str = StringF(arena, "\"cl\" gen.c %F", FmtString(flags_str));
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Compile C
|
||||||
|
if (ret == 0)
|
||||||
|
{
|
||||||
|
String cmd_str = msvc_cmd_str;
|
||||||
|
OS_CommandResult result = OS_RunCommand(arena, cmd_str);
|
||||||
|
ret = result.code;
|
||||||
|
String output = result.output;
|
||||||
|
output = Trim(output, Lit("\n"));
|
||||||
|
output = Trim(output, Lit("\r"));
|
||||||
|
output = Trim(output, Lit("\n"));
|
||||||
|
Echo(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret != 0 ? ret : errors.count > 0;
|
return ret != 0 ? ret : errors.count > 0;
|
||||||
|
|||||||
@ -528,7 +528,7 @@ StaticAssert(sizeof(Atomic32Padded) == 64 && alignof(Atomic32Padded) == 64);
|
|||||||
StaticAssert(sizeof(Atomic64Padded) == 64 && alignof(Atomic64Padded) == 64);
|
StaticAssert(sizeof(Atomic64Padded) == 64 && alignof(Atomic64Padded) == 64);
|
||||||
|
|
||||||
#if PlatformIsWindows
|
#if PlatformIsWindows
|
||||||
//- 8 bit atomics operations
|
//- 8 bit atomic operations
|
||||||
ForceInline i8 Atomic8Fetch(Atomic8 *x) { return (i8)_InterlockedCompareExchange8((char *)&x->_v, 0, 0); }
|
ForceInline i8 Atomic8Fetch(Atomic8 *x) { return (i8)_InterlockedCompareExchange8((char *)&x->_v, 0, 0); }
|
||||||
ForceInline i8 Atomic8FetchSet(Atomic8 *x, i8 e) { return (i8)_InterlockedExchange8((char *)&x->_v, e); }
|
ForceInline i8 Atomic8FetchSet(Atomic8 *x, i8 e) { return (i8)_InterlockedExchange8((char *)&x->_v, e); }
|
||||||
ForceInline i8 Atomic8FetchTestSet(Atomic8 *x, i8 c, i8 e) { return (i8)_InterlockedCompareExchange8((char *)&x->_v, e, c); }
|
ForceInline i8 Atomic8FetchTestSet(Atomic8 *x, i8 c, i8 e) { return (i8)_InterlockedCompareExchange8((char *)&x->_v, e, c); }
|
||||||
|
|||||||
@ -453,7 +453,7 @@ StringListNode *PushStringToList(Arena *arena, StringList *l, String s)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
String StringFromStringList(Arena *arena, StringList l, String separator)
|
String StringFromList(Arena *arena, StringList l, String separator)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = ZI;
|
||||||
result.text = PushDry(arena, u8);
|
result.text = PushDry(arena, u8);
|
||||||
@ -471,6 +471,34 @@ String StringFromStringList(Arena *arena, StringList l, String separator)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ Trimming helpers
|
||||||
|
|
||||||
|
String TrimLeft(String s, String pattern)
|
||||||
|
{
|
||||||
|
String result = s;
|
||||||
|
while (StringStartsWith(result, pattern))
|
||||||
|
{
|
||||||
|
result.text += pattern.len;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String TrimRight(String s, String pattern)
|
||||||
|
{
|
||||||
|
String result = s;
|
||||||
|
while (StringEndsWith(result, pattern))
|
||||||
|
{
|
||||||
|
result.len -= pattern.len;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String Trim(String s, String pattern)
|
||||||
|
{
|
||||||
|
return TrimLeft(TrimRight(s, pattern), pattern);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Formatting
|
//~ Formatting
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,14 @@ b32 StringEndsWith(String str, String substring);
|
|||||||
//~ String list helpers
|
//~ String list helpers
|
||||||
|
|
||||||
StringListNode *PushStringToList(Arena *arena, StringList *l, String s);
|
StringListNode *PushStringToList(Arena *arena, StringList *l, String s);
|
||||||
String StringFromStringList(Arena *arena, StringList l, String separator);
|
String StringFromList(Arena *arena, StringList l, String separator);
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ Trimming helpers
|
||||||
|
|
||||||
|
String TrimLeft(String s, String pattern);
|
||||||
|
String TrimRight(String s, String pattern);
|
||||||
|
String Trim(String s, String pattern);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Formatting
|
//~ Formatting
|
||||||
|
|||||||
@ -6,9 +6,11 @@ P_SharedLogState P_shared_log_state = ZI;
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void P_StartupLog(String logfile_path)
|
void P_StartupLog(void)
|
||||||
{
|
{
|
||||||
__prof;
|
__prof;
|
||||||
|
/* FIXME: Remove hardcode */
|
||||||
|
String logfile_path = Lit("log.log");
|
||||||
P_SharedLogState *ctx = &P_shared_log_state;
|
P_SharedLogState *ctx = &P_shared_log_state;
|
||||||
ctx->callbacks_arena = AcquireArena(Mebi(8));
|
ctx->callbacks_arena = AcquireArena(Mebi(8));
|
||||||
if (logfile_path.len > 0)
|
if (logfile_path.len > 0)
|
||||||
|
|||||||
@ -116,7 +116,7 @@ Global Readonly P_LogLevelSettings P_log_settings[P_LogLevel_Count] = {
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void P_StartupLog(String logfile_path);
|
void P_StartupLog(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Logging macros
|
//~ Logging macros
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user