Replace pragma onces with guards because preproc names are useful
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FIRST_ARRAY_HEADER
|
||||
#define FIRST_ARRAY_HEADER
|
||||
|
||||
#ifndef ARRAY_REALLOCATE
|
||||
#include <stdlib.h>
|
||||
@@ -33,7 +34,7 @@
|
||||
// if (it == 4) ForArrayRemovableDeclare();
|
||||
// }
|
||||
//
|
||||
#ifdef DEFER_HEADER
|
||||
#ifdef FIRST_DEFER_HEADER
|
||||
#define ForArrayRemovable(a) for (int __i = 0; __i < (a).len; __i += 1)
|
||||
#define ForArrayRemovablePrepare(a) \
|
||||
auto &it = (a)[__i]; \
|
||||
@@ -48,7 +49,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef For
|
||||
#define For2(it, array) for(auto &it : (array))
|
||||
#define For2(it, array) for (auto &it : (array))
|
||||
#define For(array) For2(it, array)
|
||||
#endif
|
||||
|
||||
@@ -301,3 +302,5 @@ struct Array {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,6 @@
|
||||
#pragma once
|
||||
#ifndef FIRST_CL_HEADER
|
||||
#define FIRST_CL_HEADER
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
@@ -296,3 +298,5 @@ CL_INLINE bool CL_IsKeywordOrIdent(CL_Kind kind) {
|
||||
bool result = CL_IsKeyword(kind) || kind == CL_IDENTIFIER;
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#define DEFER_HEADER
|
||||
#ifndef FIRST_DEFER_HEADER
|
||||
#define FIRST_DEFER_HEADER
|
||||
|
||||
template <typename T>
|
||||
struct DEFER_ExitScope {
|
||||
@@ -20,4 +20,6 @@ class DEFER_ExitScopeHelp {
|
||||
|
||||
#define DEFER_CONCAT_INTERNAL(x, y) x##y
|
||||
#define DEFER_CONCAT(x, y) DEFER_CONCAT_INTERNAL(x, y)
|
||||
#define defer const auto DEFER_CONCAT(defer__, __LINE__) = DEFER_ExitScopeHelp() + [&]()
|
||||
#define defer const auto DEFER_CONCAT(defer__, __LINE__) = DEFER_ExitScopeHelp() + [&]()
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FIRST_HASH_HEADER
|
||||
#define FIRST_HASH_HEADER
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef HASH_API_FUNCTION
|
||||
@@ -24,3 +25,4 @@ HASH_API_FUNCTION uint64_t HashMix(uint64_t x, uint64_t y);
|
||||
|
||||
#define WRAP_AROUND_POWER_OF_2(x, pow2) (((x) & ((pow2)-1llu)))
|
||||
static inline float GetRandomNormalF(RandomSeed *series) { return (float)GetRandomNormal(series); }
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FIRST_IO_HEADER
|
||||
#define FIRST_IO_HEADER
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef IO_API
|
||||
@@ -86,4 +87,5 @@ const int IO_KindPrintf = 1;
|
||||
const int IO_KindWarningf = 2;
|
||||
|
||||
#define IO_Printf(...) IO__Printf(IO_KindPrintf, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#define IO_Warningf(...) IO__Printf(IO_KindWarningf, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#define IO_Warningf(...) IO__Printf(IO_KindWarningf, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#endif
|
||||
@@ -1,125 +1,127 @@
|
||||
#pragma once
|
||||
#define SLL_QUEUE_ADD_MOD(f, l, n, next) \
|
||||
do { \
|
||||
(n)->next = 0; \
|
||||
if ((f) == 0) { \
|
||||
(f) = (l) = (n); \
|
||||
} \
|
||||
else { \
|
||||
(l) = (l)->next = (n); \
|
||||
} \
|
||||
} while (0)
|
||||
#define SLL_QUEUE_ADD(f, l, n) SLL_QUEUE_ADD_MOD(f, l, n, next)
|
||||
|
||||
#define SLL_QUEUE_POP_FIRST_MOD(f, l, next) \
|
||||
do { \
|
||||
if ((f) == (l)) { \
|
||||
(f) = (l) = 0; \
|
||||
} \
|
||||
else { \
|
||||
(f) = (f)->next; \
|
||||
} \
|
||||
} while (0)
|
||||
#define SLL_QUEUE_POP_FIRST(f, l) SLL_QUEUE_POP_FIRST_MOD(f, l, next)
|
||||
|
||||
#define SLL_STACK_ADD_MOD(stack_base, new_stack_base, next) \
|
||||
do { \
|
||||
(new_stack_base)->next = (stack_base); \
|
||||
(stack_base) = (new_stack_base); \
|
||||
} while (0)
|
||||
#define SLL_STACK_ADD(stack_base, new_stack_base) \
|
||||
SLL_STACK_ADD_MOD(stack_base, new_stack_base, next)
|
||||
|
||||
#define SLL_STACK_POP_AND_STORE(stack_base, out_node) \
|
||||
do { \
|
||||
if (stack_base) { \
|
||||
(out_node) = (stack_base); \
|
||||
(stack_base) = (stack_base)->next; \
|
||||
(out_node)->next = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DLL_QUEUE_ADD_MOD(f, l, node, next, prev) \
|
||||
do { \
|
||||
if ((f) == 0) { \
|
||||
(f) = (l) = (node); \
|
||||
(node)->prev = 0; \
|
||||
(node)->next = 0; \
|
||||
} \
|
||||
else { \
|
||||
(l)->next = (node); \
|
||||
(node)->prev = (l); \
|
||||
(node)->next = 0; \
|
||||
(l) = (node); \
|
||||
} \
|
||||
} while (0)
|
||||
#define DLL_QUEUE_ADD(f, l, node) DLL_QUEUE_ADD_MOD(f, l, node, next, prev)
|
||||
#define DLL_QUEUE_REMOVE_MOD(first, last, node, next, prev) \
|
||||
do { \
|
||||
if ((first) == (last)) { \
|
||||
IO_Assertf((node) == (first), "Not you are trying to remove is not in the list"); \
|
||||
(first) = (last) = 0; \
|
||||
} \
|
||||
else if ((last) == (node)) { \
|
||||
(last) = (last)->prev; \
|
||||
(last)->next = 0; \
|
||||
} \
|
||||
else if ((first) == (node)) { \
|
||||
(first) = (first)->next; \
|
||||
(first)->prev = 0; \
|
||||
} \
|
||||
else { \
|
||||
(node)->prev->next = (node)->next; \
|
||||
(node)->next->prev = (node)->prev; \
|
||||
} \
|
||||
if (node) { \
|
||||
(node)->prev = 0; \
|
||||
(node)->next = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
#define DLL_QUEUE_REMOVE(first, last, node) DLL_QUEUE_REMOVE_MOD(first, last, node, next, prev)
|
||||
|
||||
#define DLL_STACK_ADD_MOD(first, node, next, prev) \
|
||||
do { \
|
||||
(node)->next = (first); \
|
||||
if ((first)) \
|
||||
(first)->prev = (node); \
|
||||
(first) = (node); \
|
||||
(node)->prev = 0; \
|
||||
} while (0)
|
||||
#define DLL_STACK_ADD(first, node) DLL_STACK_ADD_MOD(first, node, next, prev)
|
||||
#define DLL_STACK_REMOVE_MOD(first, node, next, prev) \
|
||||
do { \
|
||||
if ((node) == (first)) { \
|
||||
(first) = (first)->next; \
|
||||
if ((first)) \
|
||||
(first)->prev = 0; \
|
||||
} \
|
||||
else { \
|
||||
(node)->prev->next = (node)->next; \
|
||||
if ((node)->next) \
|
||||
(node)->next->prev = (node)->prev; \
|
||||
} \
|
||||
if (node) { \
|
||||
(node)->prev = 0; \
|
||||
(node)->next = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
#define DLL_STACK_REMOVE(first, node) DLL_STACK_REMOVE_MOD(first, node, next, prev)
|
||||
|
||||
#define DLL_INSERT_NEXT_MOD(base, new, next, prev) \
|
||||
do { \
|
||||
if ((base) == 0) { \
|
||||
(base) = (new); \
|
||||
(new)->next = 0; \
|
||||
(new)->prev = 0; \
|
||||
} \
|
||||
else { \
|
||||
(new)->next = (base)->next; \
|
||||
(base)->next = (new); \
|
||||
(new)->prev = (base); \
|
||||
if ((new)->next) (new)->next->prev = (new); \
|
||||
} \
|
||||
} while (0)
|
||||
#define DLL_INSERT_NEXT(base, new) DLL_INSERT_NEXT_MOD(base, new, next, prev)
|
||||
#define DLL_INSERT_PREV(base, new) DLL_INSERT_NEXT_MOD(base, new, next, prev)
|
||||
#ifndef FIRST_LL_HEADER
|
||||
#define FIRST_LL_HEADER
|
||||
#define SLL_QUEUE_ADD_MOD(f, l, n, next) \
|
||||
do { \
|
||||
(n)->next = 0; \
|
||||
if ((f) == 0) { \
|
||||
(f) = (l) = (n); \
|
||||
} \
|
||||
else { \
|
||||
(l) = (l)->next = (n); \
|
||||
} \
|
||||
} while (0)
|
||||
#define SLL_QUEUE_ADD(f, l, n) SLL_QUEUE_ADD_MOD(f, l, n, next)
|
||||
|
||||
#define SLL_QUEUE_POP_FIRST_MOD(f, l, next) \
|
||||
do { \
|
||||
if ((f) == (l)) { \
|
||||
(f) = (l) = 0; \
|
||||
} \
|
||||
else { \
|
||||
(f) = (f)->next; \
|
||||
} \
|
||||
} while (0)
|
||||
#define SLL_QUEUE_POP_FIRST(f, l) SLL_QUEUE_POP_FIRST_MOD(f, l, next)
|
||||
|
||||
#define SLL_STACK_ADD_MOD(stack_base, new_stack_base, next) \
|
||||
do { \
|
||||
(new_stack_base)->next = (stack_base); \
|
||||
(stack_base) = (new_stack_base); \
|
||||
} while (0)
|
||||
#define SLL_STACK_ADD(stack_base, new_stack_base) \
|
||||
SLL_STACK_ADD_MOD(stack_base, new_stack_base, next)
|
||||
|
||||
#define SLL_STACK_POP_AND_STORE(stack_base, out_node) \
|
||||
do { \
|
||||
if (stack_base) { \
|
||||
(out_node) = (stack_base); \
|
||||
(stack_base) = (stack_base)->next; \
|
||||
(out_node)->next = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DLL_QUEUE_ADD_MOD(f, l, node, next, prev) \
|
||||
do { \
|
||||
if ((f) == 0) { \
|
||||
(f) = (l) = (node); \
|
||||
(node)->prev = 0; \
|
||||
(node)->next = 0; \
|
||||
} \
|
||||
else { \
|
||||
(l)->next = (node); \
|
||||
(node)->prev = (l); \
|
||||
(node)->next = 0; \
|
||||
(l) = (node); \
|
||||
} \
|
||||
} while (0)
|
||||
#define DLL_QUEUE_ADD(f, l, node) DLL_QUEUE_ADD_MOD(f, l, node, next, prev)
|
||||
#define DLL_QUEUE_REMOVE_MOD(first, last, node, next, prev) \
|
||||
do { \
|
||||
if ((first) == (last)) { \
|
||||
IO_Assertf((node) == (first), "Not you are trying to remove is not in the list"); \
|
||||
(first) = (last) = 0; \
|
||||
} \
|
||||
else if ((last) == (node)) { \
|
||||
(last) = (last)->prev; \
|
||||
(last)->next = 0; \
|
||||
} \
|
||||
else if ((first) == (node)) { \
|
||||
(first) = (first)->next; \
|
||||
(first)->prev = 0; \
|
||||
} \
|
||||
else { \
|
||||
(node)->prev->next = (node)->next; \
|
||||
(node)->next->prev = (node)->prev; \
|
||||
} \
|
||||
if (node) { \
|
||||
(node)->prev = 0; \
|
||||
(node)->next = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
#define DLL_QUEUE_REMOVE(first, last, node) DLL_QUEUE_REMOVE_MOD(first, last, node, next, prev)
|
||||
|
||||
#define DLL_STACK_ADD_MOD(first, node, next, prev) \
|
||||
do { \
|
||||
(node)->next = (first); \
|
||||
if ((first)) \
|
||||
(first)->prev = (node); \
|
||||
(first) = (node); \
|
||||
(node)->prev = 0; \
|
||||
} while (0)
|
||||
#define DLL_STACK_ADD(first, node) DLL_STACK_ADD_MOD(first, node, next, prev)
|
||||
#define DLL_STACK_REMOVE_MOD(first, node, next, prev) \
|
||||
do { \
|
||||
if ((node) == (first)) { \
|
||||
(first) = (first)->next; \
|
||||
if ((first)) \
|
||||
(first)->prev = 0; \
|
||||
} \
|
||||
else { \
|
||||
(node)->prev->next = (node)->next; \
|
||||
if ((node)->next) \
|
||||
(node)->next->prev = (node)->prev; \
|
||||
} \
|
||||
if (node) { \
|
||||
(node)->prev = 0; \
|
||||
(node)->next = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
#define DLL_STACK_REMOVE(first, node) DLL_STACK_REMOVE_MOD(first, node, next, prev)
|
||||
|
||||
#define DLL_INSERT_NEXT_MOD(base, new, next, prev) \
|
||||
do { \
|
||||
if ((base) == 0) { \
|
||||
(base) = (new); \
|
||||
(new)->next = 0; \
|
||||
(new)->prev = 0; \
|
||||
} \
|
||||
else { \
|
||||
(new)->next = (base)->next; \
|
||||
(base)->next = (new); \
|
||||
(new)->prev = (base); \
|
||||
if ((new)->next) (new)->next->prev = (new); \
|
||||
} \
|
||||
} while (0)
|
||||
#define DLL_INSERT_NEXT(base, new) DLL_INSERT_NEXT_MOD(base, new, next, prev)
|
||||
#define DLL_INSERT_PREV(base, new) DLL_INSERT_NEXT_MOD(base, new, next, prev)
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FIRST_LIB_HEADER
|
||||
#define FIRST_LIB_HEADER
|
||||
typedef void *LIB_Library;
|
||||
|
||||
LIB_Library LIB_LoadLibrary(char *str);
|
||||
@@ -8,3 +9,4 @@ bool LIB_UnloadLibrary(LIB_Library lib);
|
||||
#ifndef LIB_EXPORT
|
||||
#define LIB_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FIRST_MU_HEADER
|
||||
#define FIRST_MU_HEADER
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
@@ -366,3 +367,4 @@ typedef struct MU_Event {
|
||||
|
||||
|
||||
*/
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FIRST_ENV_HEADER
|
||||
#define FIRST_ENV_HEADER
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
@@ -116,3 +117,4 @@
|
||||
// #pragma clang diagnostic push
|
||||
// #pragma clang diagnostic ignored "-Wmicrosoft-enum-forward-reference"
|
||||
// #endif
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FIRST_REGEX_HEADER
|
||||
#define FIRST_REGEX_HEADER
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -91,3 +92,4 @@ RE_API RE_Match RE3_FindAgain(RE_Regex *regex, char *string, RE_Int len, RE_Matc
|
||||
RE_API RE_Int RE3_MatchFront(RE_Regex *regex, char *string, RE_Int len, char *string_front);
|
||||
RE_API RE_Regex *RE1_Parse(char *buff, RE_Int buffsize, char *string);
|
||||
RE_API RE_Regex *RE2_Parse(char *buff, RE_Int buffsize, char *string, RE_Int len);
|
||||
#endif
|
||||
@@ -530,7 +530,7 @@ S8_API S8_String S8_AddF(S8_Allocator allocator, S8_List *list, const char *str,
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef UTF_HEADER
|
||||
#ifdef FIRST_UTF_HEADER
|
||||
|
||||
S8_API S16_String S8_ToWidecharEx(S8_Allocator allocator, S8_String string) {
|
||||
S8_ASSERT(sizeof(wchar_t) == 2);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#define S8_HEADER
|
||||
#ifndef FIRST_S8_STRING
|
||||
#define FIRST_S8_STRING
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -32,7 +32,7 @@ struct S8_String {
|
||||
S8_String(char *s, int64_t l) : str(s), len(l) {}
|
||||
S8_String(const char *s) : str((char *)s), len(S8_Length((char *)s)) {}
|
||||
S8_String(const char *s, int64_t l) : str((char *)s), len(l) {}
|
||||
#if defined(UTF_HEADER)
|
||||
#if defined(FIRST_UTF_HEADER)
|
||||
struct Iter {
|
||||
UTF8_Iter i;
|
||||
|
||||
@@ -47,7 +47,7 @@ struct S8_String {
|
||||
|
||||
Iter begin() { return {UTF8_IterateEx(str, (int)len)}; }
|
||||
Iter end() { return {}; }
|
||||
#endif // UTF_HEADER
|
||||
#endif // FIRST_UTF_HEADER
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
||||
@@ -192,3 +192,4 @@ inline S8_String operator""_s(const char *str, size_t size) { return {(char *)st
|
||||
inline bool operator==(S8_String a, S8_String b) { return S8_AreEqual(a, b, 0); }
|
||||
inline bool operator!=(S8_String a, S8_String b) { return !S8_AreEqual(a, b, 0); }
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FIRST_TABLE_HEADER
|
||||
#define FIRST_TABLE_HEADER
|
||||
#include <stdint.h>
|
||||
/*
|
||||
Hash table implementation:
|
||||
@@ -20,7 +21,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef TABLE_Allocator
|
||||
#define TABLE_Allocator void *
|
||||
#define TABLE_Allocator void *
|
||||
#endif
|
||||
|
||||
#ifndef TABLE_ALLOCATE
|
||||
@@ -62,7 +63,7 @@ TABLE_PRIVATE_FUNCTION uint64_t TABLE__HashBytes(void *data, unsigned size) {
|
||||
|
||||
TABLE_PRIVATE_FUNCTION int TABLE_CStringLen(char *str) {
|
||||
int i = 0;
|
||||
while(str[i]) i += 1;
|
||||
while (str[i]) i += 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -222,7 +223,7 @@ struct Table {
|
||||
return get(hash, default_value);
|
||||
}
|
||||
|
||||
#ifdef S8_HEADER
|
||||
#ifdef FIRST_S8_HEADER
|
||||
Value *get(S8_String s) {
|
||||
uint64_t hash = TABLE_HASH_BYTES(s.str, (unsigned)s.len);
|
||||
return get(hash);
|
||||
@@ -237,7 +238,7 @@ struct Table {
|
||||
uint64_t hash = TABLE_HASH_BYTES(s.str, (unsigned)s.len);
|
||||
insert(hash, value);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void puts(char *str, const Value &value) {
|
||||
int len = TABLE_CStringLen(str);
|
||||
@@ -259,4 +260,5 @@ struct Table {
|
||||
cap = 0;
|
||||
values = 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FIRST_UTF_HEADER
|
||||
#define FIRST_UTF_HEADER
|
||||
#define UTF_HEADER
|
||||
#include <stdint.h>
|
||||
typedef struct UTF32_Result UTF32_Result;
|
||||
@@ -51,3 +52,4 @@ UTF_API UTF8_Iter UTF8_IterateEx(char *str, int len);
|
||||
UTF_API UTF8_Iter UTF8_Iterate(char *str);
|
||||
|
||||
#define UTF8_For(name, str, len) for (UTF8_Iter name = UTF8_IterateEx(str, (int)len); name.item; UTF8_Advance(&name))
|
||||
#endif
|
||||
Reference in New Issue
Block a user