Get latest changes from Primitive Indexer
This commit is contained in:
+181
-108
@@ -3,6 +3,7 @@
|
||||
|
||||
#if defined(_CLANGD)
|
||||
#define DN_STR8_AVX512F 1
|
||||
#define DN_PARANOIA_LEVEL 1
|
||||
#include "../dn.h"
|
||||
#endif
|
||||
|
||||
@@ -147,99 +148,160 @@
|
||||
#define DN_ZeroInit {0}
|
||||
#endif
|
||||
|
||||
// NOTE: Address sanitizer
|
||||
#if !defined(DN_ASAN_POISON)
|
||||
#define DN_ASAN_POISON 0
|
||||
#endif
|
||||
// NOTE: Macros
|
||||
#define DN_Stringify(x) #x
|
||||
#define DN_TokenCombine2(x, y) x ## y
|
||||
#define DN_TokenCombine(x, y) DN_TokenCombine2(x, y)
|
||||
|
||||
#if !defined(DN_ASAN_VET_POISON)
|
||||
#define DN_ASAN_VET_POISON 0
|
||||
#endif
|
||||
// NOTE: Error Checking/Validating
|
||||
// Asserts are useful to verify invariants in the codebase, but there's sometimes the ambiguous
|
||||
// question of what should be asserted, what happens when we should have triggered an assert
|
||||
// in a release build (where they are canonically turned off), what alternative mechanisms should we
|
||||
// use for error checking that should be visible to non-developers.
|
||||
//
|
||||
// The following is an excerpt from Tom Forsyth's assertion article which he references Chris
|
||||
// Hargrove's guidelines on how asserts show be used. It is quite reasonable and we model our
|
||||
// primitives after based on those concepts:
|
||||
//
|
||||
// Logging, asserts and unit tests (https://tomforsyth1000.github.io/blog.wiki.html
|
||||
//
|
||||
// Assert: Immediately fatal, and not ignorable. Fundamental assumption by an engineer has been
|
||||
// disproven and needs immediate handling. Requires discipline on the part of the engineer to not
|
||||
// add them in situations that are actually non-fatal (rule of thumb being that if a crash would
|
||||
// be almost certain to happen anyway due to the same condition, then you’re no worse off making
|
||||
// an assert).
|
||||
//
|
||||
// Errors: Probably fatal soon, but not necessarily immediately. Basically a marker for “you are
|
||||
// now in a f*cked state, you might limp along a bit, but assume nothing”. Game continues, but an
|
||||
// ugly red number gets displayed onscreen for how many of these have been encountered (so when
|
||||
// people send you screenshots of bugs you can then point to the red error count and blame
|
||||
// accordingly). Savegames are disabled from this point so as not to make the error effectively
|
||||
// permanent; you should also deliberately violate a few other TCRs as soon as an error is
|
||||
// encountered in order to ensure that all parties up and down the publisher/developer chain are
|
||||
// aware of how bad things are. Errors are technically “ignorable” but everyone knows that it
|
||||
// might only buy you a little bit of borrowed time; these are only a small step away from the
|
||||
// immediately-blocking nature of an assert, but sometimes that small step can have a big impact
|
||||
// on productivity.
|
||||
//
|
||||
// Warnings: Used for “you did something bad, but we caught it so it’s fine (the game state is
|
||||
// still okay), however it might not be fine in the future so if you want to save yourself some
|
||||
// headache you should fix this sooner rather than later”. Great for content problems. Also
|
||||
// displayed onscreen as a yellow number (near the red error number). You can keep these around
|
||||
// for a while and triage them when their utility is called into question.
|
||||
//
|
||||
// Crumbs: The meta-category for a large number of “verbose” informational breadcrumb categories
|
||||
// that must be explicitly enabled so you don’t clutter everything up and obscure stuff that
|
||||
// matters. Note that the occurrance of certain Errors should automatically enable relevant
|
||||
// categories of crumbs so that more detailed information about the aforementioned f*cked state
|
||||
// will be provided during the limp-along timeframe.
|
||||
//
|
||||
// In the excerpt, their domain (games programming) prioritises continuity over immediate failure
|
||||
// on warning and error as this allows non-developer clientele to continue using the application
|
||||
// despite error laden states. This is useful in general as not all failures are critical to the
|
||||
// use case that the end user is dealing with.
|
||||
//
|
||||
// We model `Errors` and `Warnings` as `DN_Verify` and `DN_VerifyWarning` respectively. The verify
|
||||
// variants check the expression to test, log and a message and allow the developer to branch on the
|
||||
// result and "recover" where appropriate. Verify checks are never compiled out. We have traditional
|
||||
// `Asserts` as `DN_Assert` which can be compiled out.
|
||||
//
|
||||
// The article also defines what it calls a paranoia level. We `#define DN_PARANOIA_LEVEL <Integer>`
|
||||
// to customise the validation layers of the codebase. See DN_PARANOIA_LEVEL in the customisation
|
||||
// section for more information.
|
||||
//
|
||||
// In summary use each of the primitives in these situation:
|
||||
//
|
||||
// `DN_Assert`: Fatal and immediately needs attention and can be compiled out
|
||||
//
|
||||
// `DN_Verify`: Fatal or eventually fatal but not necessarily immediately, program is or will
|
||||
// degenerate into an incorrect state. Is always compiled in and is visible in non-debug
|
||||
// environments.
|
||||
//
|
||||
// `DN_VerifyWarning`: Something bad happened, but we caught it and recovered from it. Program
|
||||
// state remains consistent. It is always compiled in and is visible in non-debug environments.
|
||||
|
||||
#define DN_ASAN_POISON_ALIGNMENT 8
|
||||
|
||||
#if !defined(DN_ASAN_POISON_GUARD_SIZE)
|
||||
#define DN_ASAN_POISON_GUARD_SIZE 128
|
||||
#if !defined(DN_PARANOIA_LEVEL)
|
||||
#if defined(NDEBUG)
|
||||
#define DN_PARANOIA_LEVEL 0
|
||||
#else
|
||||
#define DN_PARANOIA_LEVEL 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if DN_HAS_FEATURE(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
|
||||
#include <sanitizer/asan_interface.h>
|
||||
#endif
|
||||
|
||||
// NOTE: Memory
|
||||
#define DN_ASAN_POISON_ALIGNMENT 8
|
||||
#if !defined(DN_ASAN_VET_POISON)
|
||||
#define DN_ASAN_VET_POISON 0
|
||||
#endif
|
||||
|
||||
#if !defined(DN_ASAN_POISON)
|
||||
#if DN_PARANOIA_LEVEL >= 1
|
||||
#define DN_ASAN_POISON 1
|
||||
#else
|
||||
#define DN_ASAN_POISON 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(DN_ASAN_POISON_GUARD_SIZE)
|
||||
#define DN_ASAN_POISON_GUARD_SIZE 128
|
||||
#endif
|
||||
|
||||
#if !defined(DN_ARENA_TEMP_MEM_UAF_GUARD)
|
||||
#define DN_ARENA_TEMP_MEM_UAF_GUARD 0
|
||||
#if DN_PARANOIA_LEVEL >= 1
|
||||
#define DN_ARENA_TEMP_MEM_UAF_GUARD 1
|
||||
#else
|
||||
#define DN_ARENA_TEMP_MEM_UAF_GUARD 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(DN_ARENA_TEMP_MEM_UAF_TRACE_ON_BY_DEFAULT)
|
||||
#define DN_ARENA_TEMP_MEM_UAF_TRACE_ON_BY_DEFAULT 0
|
||||
#if DN_PARANOIA_LEVEL >= 2
|
||||
#define DN_ARENA_TEMP_MEM_UAF_TRACE_ON_BY_DEFAULT 1
|
||||
#else
|
||||
#define DN_ARENA_TEMP_MEM_UAF_TRACE_ON_BY_DEFAULT 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(DN_SCRUB_UNINIT_MEM_BYTE)
|
||||
#define DN_SCRUB_UNINIT_MEM_BYTE 0
|
||||
#if DN_PARANOIA_LEVEL >= 1
|
||||
#define DN_SCRUB_UNINIT_MEM_BYTE 0xCD
|
||||
#else
|
||||
#define DN_SCRUB_UNINIT_MEM_BYTE 0x00
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// NOTE: Macros
|
||||
#define DN_Stringify(x) #x
|
||||
#define DN_TokenCombine2(x, y) x ## y
|
||||
#define DN_TokenCombine(x, y) DN_TokenCombine2(x, y)
|
||||
|
||||
// NOTE: Asserts
|
||||
#define DN_HardAssertF(expr, fmt, ...) \
|
||||
do { \
|
||||
if (!(expr)) { \
|
||||
DN_Str8 stack_trace_ = DN_Str8FromStackTraceNowHeap(128 /*limit*/, 3 /*skip*/); \
|
||||
DN_LogErrorF("Hard assertion [" #expr "], stack trace was:\n\n%.*s\n\n" fmt, \
|
||||
DN_Str8PrintFmt(stack_trace_), \
|
||||
##__VA_ARGS__); \
|
||||
DN_DebugBreak; \
|
||||
} \
|
||||
#define DN_AssertRaw(expr) do { if (!(expr)) DN_DebugBreak; } while (0)
|
||||
#define DN_AssertAlwaysCallSiteF(expr, call_site, fmt, ...) \
|
||||
do { \
|
||||
if (!(expr)) { \
|
||||
DN_Str8 trace_ = DN_Str8FromStackTraceNowHeap(128 /*limit*/, 3 /*skip*/); \
|
||||
DN_LogTypeParam log_type_ = DN_LogTypeParamFromType(DN_LogType_Error); \
|
||||
DN_LogPrintF(log_type_, call_site, DN_LogFlags_Nil, "Assertion triggered [" #expr "]. " fmt "\nTrace:\n%.*s", ## __VA_ARGS__, DN_Str8PrintFmt(trace_)); \
|
||||
DN_DebugBreak; \
|
||||
} \
|
||||
} while (0)
|
||||
#define DN_HardAssert(expr) DN_HardAssertF(expr, "")
|
||||
|
||||
// NOTE: Our default assert requires stack traces which has a bit of a chicken-and-egg problem if
|
||||
// we're trying to detect some code related to the DN startup sequence. If we try to assert before
|
||||
// the OS layer is initialised stack-traces will try to use temporary memory which requires TLS to
|
||||
// be setup which belongs to the OS.
|
||||
//
|
||||
// This causes recursion errors as they call into each other. We use RawAsserts for these kind of
|
||||
// checks.
|
||||
#if defined(DN_NO_ASSERT)
|
||||
#define DN_RawAssert(...)
|
||||
#define DN_Assert(...)
|
||||
#define DN_AssertOnce(...)
|
||||
#define DN_AssertArgsF(...)
|
||||
#define DN_AssertF(...)
|
||||
#define DN_AssertFOnce(...)
|
||||
#define DN_AssertAlwaysF(expr, fmt, ...) DN_AssertAlwaysCallSiteF(expr, (DN_CallSiteNow), fmt, ##__VA_ARGS__)
|
||||
#define DN_AssertAlways(expr) DN_AssertAlwaysF(expr, "")
|
||||
#define DN_AssertInvalidCodePathF(fmt, ...) DN_AssertAlwaysF(0, fmt, ##__VA_ARGS__)
|
||||
#define DN_AssertInvalidCodePath DN_AssertInvalidCodePathF("Invalid code path")
|
||||
#if DN_PARANOIA_LEVEL >= 1
|
||||
#define DN_AssertCallSiteF(expr, call_site, fmt, ...) DN_AssertAlwaysCallSiteF(expr, call_site, fmt, ## __VA_ARGS__)
|
||||
#define DN_AssertF(expr, fmt, ...) DN_AssertCallSiteF(expr, (DN_CallSiteNow), fmt, ## __VA_ARGS__)
|
||||
#define DN_Assert(expr) DN_AssertAlways(expr)
|
||||
#else
|
||||
#define DN_RawAssert(expr) do { if (!(expr)) DN_DebugBreak; } while (0)
|
||||
#define DN_AssertArgsF(expr, call_site, fmt, ...) \
|
||||
do { \
|
||||
if (!(expr)) { \
|
||||
DN_Str8 stack_trace_ = DN_Str8FromStackTraceNowHeap(128 /*limit*/, 3 /*skip*/); \
|
||||
DN_LogPrint(DN_LogTypeParamFromType(DN_LogType_Error), \
|
||||
call_site, \
|
||||
DN_LogFlags_Nil, \
|
||||
"Assertion [" #expr "], stack trace was:\n\n%.*s\n\n" fmt, \
|
||||
DN_Str8PrintFmt(stack_trace_), \
|
||||
##__VA_ARGS__); \
|
||||
DN_DebugBreak; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DN_AssertF(expr, fmt, ...) DN_AssertArgsF(expr, DN_CALL_SITE, fmt, ## __VA_ARGS__)
|
||||
#define DN_AssertFOnce(expr, fmt, ...) \
|
||||
do { \
|
||||
for (static bool once_ = true; !(expr) && once_; once_ = false) \
|
||||
DN_AssertF(expr, fmt, ## __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define DN_Assert(expr) DN_AssertF((expr), "")
|
||||
#define DN_AssertOnce(expr) DN_AssertFOnce((expr), "")
|
||||
#define DN_AssertCallSiteF(expr, call_site, fmt, ...) (void)(expr); (void)call_site
|
||||
#define DN_AssertF(expr, fmt, ...) (void)(expr)
|
||||
#define DN_Assert(expr) (void)(expr)
|
||||
#endif
|
||||
#define DN_VerifyF(expr, fmt, ...) DN_VerifyArgsF(DN_VerifyType_Nil, expr, (DN_CallSiteNow), DN_Str8Lit(#expr), fmt, ##__VA_ARGS__)
|
||||
#define DN_VerifyWarningF(expr, fmt, ...) DN_VerifyArgsF(DN_VerifyType_Warning, expr, (DN_CallSiteNow), DN_Str8Lit(#expr), fmt, ##__VA_ARGS__)
|
||||
#define DN_Verify(expr) DN_VerifyF(expr, 0)
|
||||
#define DN_VerifyWarning(expr) DN_VerifyWarningF(expr, 0)
|
||||
|
||||
#define DN_InvalidCodePathF(fmt, ...) DN_HardAssertF(0, fmt, ##__VA_ARGS__)
|
||||
#define DN_InvalidCodePath DN_InvalidCodePathF("Invalid code path triggered")
|
||||
#define DN_StaticAssert(expr) \
|
||||
DN_GCC_WARNING_PUSH \
|
||||
DN_GCC_WARNING_DISABLE(-Wunused-local-typedefs) \
|
||||
@@ -481,6 +543,12 @@ typedef DN_I32 DN_B32;
|
||||
#define DN_CountLeadingZerosUSize(value) DN_CountLeadingZerosU32(value)
|
||||
#endif
|
||||
|
||||
enum DN_VerifyType
|
||||
{
|
||||
DN_VerifyType_Nil,
|
||||
DN_VerifyType_Warning,
|
||||
};
|
||||
|
||||
enum DN_ZMem
|
||||
{
|
||||
DN_ZMem_No, // Memory can be handed out without zero-ing it out
|
||||
@@ -679,7 +747,7 @@ struct DN_CallSite
|
||||
DN_U32 line;
|
||||
};
|
||||
|
||||
#define DN_CALL_SITE DN_CallSite { DN_Str8Lit(__FILE__), DN_Str8Lit(__func__), __LINE__ }
|
||||
#define DN_CallSiteNow DN_Literal(DN_CallSite){DN_Str8Lit(__FILE__), DN_Str8Lit(__func__), __LINE__ }
|
||||
|
||||
#if defined(__cplusplus)
|
||||
template <typename Procedure>
|
||||
@@ -1632,6 +1700,9 @@ DN_GCC_WARNING_DISABLE(-Wunused-function)
|
||||
DN_GCC_WARNING_POP
|
||||
DN_MSVC_WARNING_POP
|
||||
|
||||
DN_API bool DN_VerifyArgsF (DN_VerifyType type, bool expr, DN_CallSite call_site, DN_Str8 expr_str8, char const *fmt, ...);
|
||||
DN_API bool DN_VerifyArgs (DN_VerifyType type, bool expr, DN_CallSite call_site, DN_Str8 expr_str8);
|
||||
|
||||
#define DN_SPrintF(...) STB_SPRINTF_DECORATE(sprintf)(__VA_ARGS__)
|
||||
#define DN_SNPrintF(...) STB_SPRINTF_DECORATE(snprintf)(__VA_ARGS__)
|
||||
#define DN_VSPrintF(...) STB_SPRINTF_DECORATE(vsprintf)(__VA_ARGS__)
|
||||
@@ -1641,8 +1712,8 @@ DN_API bool DN_MemStartsWith
|
||||
DN_API bool DN_MemEq (void const *lhs, DN_USize lhs_size, void const *rhs, DN_USize rhs_size);
|
||||
DN_API bool DN_MemEqUnsafe (void const *lhs, void const *rhs, DN_USize size);
|
||||
#if defined(__cplusplus)
|
||||
template <typename T> T* DN_TMemCopyObj (T *dest, T const *src, DN_USize count);
|
||||
#define DN_MemCopyObj(dest, src, count) DN_TMemCopyObj(dest, src, count)
|
||||
template <typename T> T* DN_MemCopyObjT (T *dest, T const *src, DN_USize count);
|
||||
#define DN_MemCopyObj(dest, src, count) DN_MemCopyObjT(dest, src, count)
|
||||
#else
|
||||
#define DN_MemCopyObj(dest, src, count) DN_Memcpy(dest, src, sizeof(*src) * count)
|
||||
#endif
|
||||
@@ -1703,6 +1774,7 @@ DN_API void DN_BitUnsetInplace
|
||||
DN_API void DN_BitSetInplace (DN_USize *flags, DN_USize bitfield);
|
||||
DN_API bool DN_BitIsSet (DN_USize bits, DN_USize bits_to_set);
|
||||
DN_API bool DN_BitIsNotSet (DN_USize bits, DN_USize bits_to_check);
|
||||
DN_API bool DN_BitIsAny (DN_USize bits, DN_USize bits_to_check);
|
||||
#define DN_BitClearNextLSB(value) (value) & ((value) - 1)
|
||||
|
||||
DN_API DN_I64 DN_SafeAddI64 (DN_I64 a, DN_I64 b);
|
||||
@@ -1875,26 +1947,26 @@ DN_API void * DN_PoolCopy
|
||||
#define DN_PoolNewArrayCopy(pool, T, src, count) (T *)DN_PoolCopy (pool, (src), sizeof(T) * (count), alignof(T))
|
||||
|
||||
DN_API DN_ErrSink* DN_ErrSinkBegin_ (DN_ErrSink *err, DN_ErrSinkMode mode, DN_CallSite call_site);
|
||||
#define DN_ErrSinkBegin(err, mode) DN_ErrSinkBegin_(err, mode, DN_CALL_SITE)
|
||||
#define DN_ErrSinkBegin(err, mode) DN_ErrSinkBegin_(err, mode, DN_CallSiteNow)
|
||||
#define DN_ErrSinkBeginDefault(err) DN_ErrSinkBegin(err, DN_ErrSinkMode_Nil)
|
||||
DN_API bool DN_ErrSinkHasError (DN_ErrSink *err);
|
||||
DN_API DN_ErrSinkMsg* DN_ErrSinkEnd (DN_Arena *arena, DN_ErrSink *err);
|
||||
DN_API DN_Str8 DN_ErrSinkEndStr8 (DN_Arena *arena, DN_ErrSink *err);
|
||||
DN_API void DN_ErrSinkEndIgnore (DN_ErrSink *err);
|
||||
DN_API bool DN_ErrSinkEndLogError_ (DN_ErrSink *err, DN_CallSite call_site, DN_Str8 msg);
|
||||
#define DN_ErrSinkEndLogError(err, err_msg) DN_ErrSinkEndLogError_(err, DN_CALL_SITE, err_msg)
|
||||
#define DN_ErrSinkEndLogError(err, err_msg) DN_ErrSinkEndLogError_(err, DN_CallSiteNow, err_msg)
|
||||
DN_API bool DN_ErrSinkEndLogErrorFV_ (DN_ErrSink *err, DN_CallSite call_site, DN_FMT_ATTRIB char const *fmt, va_list args);
|
||||
#define DN_ErrSinkEndLogErrorFV(err, fmt, args) DN_ErrSinkEndLogErrorFV_(err, DN_CALL_SITE, fmt, args)
|
||||
#define DN_ErrSinkEndLogErrorFV(err, fmt, args) DN_ErrSinkEndLogErrorFV_(err, DN_CallSiteNow, fmt, args)
|
||||
DN_API bool DN_ErrSinkEndLogErrorF_ (DN_ErrSink *err, DN_CallSite call_site, DN_FMT_ATTRIB char const *fmt, ...);
|
||||
#define DN_ErrSinkEndLogErrorF(err, fmt, ...) DN_ErrSinkEndLogErrorF_(err, DN_CALL_SITE, fmt, ##__VA_ARGS__)
|
||||
#define DN_ErrSinkEndLogErrorF(err, fmt, ...) DN_ErrSinkEndLogErrorF_(err, DN_CallSiteNow, fmt, ##__VA_ARGS__)
|
||||
DN_API void DN_ErrSinkEndExitIfErrorF_ (DN_ErrSink *err, DN_CallSite call_site, DN_U32 exit_val, DN_FMT_ATTRIB char const *fmt, ...);
|
||||
#define DN_ErrSinkEndExitIfErrorF(err, exit_val, fmt, ...) DN_ErrSinkEndExitIfErrorF_(err, DN_CALL_SITE, exit_val, fmt, ##__VA_ARGS__)
|
||||
#define DN_ErrSinkEndExitIfErrorF(err, exit_val, fmt, ...) DN_ErrSinkEndExitIfErrorF_(err, DN_CallSiteNow, exit_val, fmt, ##__VA_ARGS__)
|
||||
DN_API void DN_ErrSinkEndExitIfErrorFV_ (DN_ErrSink *err, DN_CallSite call_site, DN_U32 exit_val, DN_FMT_ATTRIB char const *fmt, va_list args);
|
||||
#define DN_ErrSinkEndExitIfErrorFV(err, exit_val, fmt, args) DN_ErrSinkEndExitIfErrorFV_(err, DN_CALL_SITE, exit_val, fmt, args)
|
||||
#define DN_ErrSinkEndExitIfErrorFV(err, exit_val, fmt, args) DN_ErrSinkEndExitIfErrorFV_(err, DN_CallSiteNow, exit_val, fmt, args)
|
||||
DN_API void DN_ErrSinkAppendFV_ (DN_ErrSink *err, DN_U32 error_code, DN_CallSite call_site, DN_FMT_ATTRIB char const *fmt, va_list args);
|
||||
#define DN_ErrSinkAppendFV(error, error_code, fmt, args) DN_ErrSinkAppendFV_(error, error_code, DN_CALL_SITE, fmt, args)
|
||||
#define DN_ErrSinkAppendFV(error, error_code, fmt, args) DN_ErrSinkAppendFV_(error, error_code, DN_CallSiteNow, fmt, args)
|
||||
DN_API void DN_ErrSinkAppendF_ (DN_ErrSink *err, DN_U32 error_code, DN_CallSite call_site, DN_FMT_ATTRIB char const *fmt, ...);
|
||||
#define DN_ErrSinkAppendF(error, error_code, fmt, ...) DN_ErrSinkAppendF_(error, error_code, DN_CALL_SITE, fmt, ##__VA_ARGS__)
|
||||
#define DN_ErrSinkAppendF(error, error_code, fmt, ...) DN_ErrSinkAppendF_(error, error_code, DN_CallSiteNow, fmt, ##__VA_ARGS__)
|
||||
|
||||
DN_API DN_TCInitArgs DN_TCInitArgsDefault ();
|
||||
DN_API void DN_TCInit (DN_TCCore *tc, DN_U64 thread_id, DN_Arena *main_arena, DN_Arena *temp_arenas, DN_USize temp_arenas_count, DN_Arena *err_sink_arena);
|
||||
@@ -2283,20 +2355,21 @@ DN_API DN_Str8 DN_Str8FromFmtANSIColourV3F32RGB255Arena
|
||||
// OS functionality enabled, the log callback is by default set to outputting via standard out.
|
||||
DN_API DN_LogPrefixSize DN_LogMakePrefix (DN_LogStyle style, DN_LogTypeParam type, DN_CallSite call_site, DN_LogDate date, char *dest, DN_USize dest_size);
|
||||
DN_API void DN_LogSetPrintFunc (DN_LogPrintFunc *print_func, void *user_data);
|
||||
DN_API void DN_LogPrint (DN_LogTypeParam type, DN_CallSite call_site, DN_LogFlags flags, DN_FMT_ATTRIB char const *fmt, ...);
|
||||
DN_API void DN_LogPrintF (DN_LogTypeParam type, DN_CallSite call_site, DN_LogFlags flags, DN_FMT_ATTRIB char const *fmt, ...);
|
||||
DN_API void DN_LogPrintFV (DN_LogTypeParam type, DN_CallSite call_site, DN_LogFlags flags, DN_FMT_ATTRIB char const *fmt, va_list args);
|
||||
DN_API DN_LogTypeParam DN_LogTypeParamFromType (DN_LogType type);
|
||||
#define DN_LogF(type, fmt, ...) DN_LogPrint(DN_LogTypeParamFromType(type), DN_CALL_SITE, DN_LogFlags_Nil, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogF(type, fmt, ...) DN_LogPrintF(DN_LogTypeParamFromType(type), DN_CallSiteNow, DN_LogFlags_Nil, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define DN_LogDebugF(fmt, ...) DN_LogPrint(DN_LogTypeParamFromType(DN_LogType_Debug), DN_CALL_SITE, DN_LogFlags_Nil, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogInfoF(fmt, ...) DN_LogPrint(DN_LogTypeParamFromType(DN_LogType_Info), DN_CALL_SITE, DN_LogFlags_Nil, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogWarningF(fmt, ...) DN_LogPrint(DN_LogTypeParamFromType(DN_LogType_Warning), DN_CALL_SITE, DN_LogFlags_Nil, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogErrorF(fmt, ...) DN_LogPrint(DN_LogTypeParamFromType(DN_LogType_Error), DN_CALL_SITE, DN_LogFlags_Nil, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogDebugF(fmt, ...) DN_LogPrintF(DN_LogTypeParamFromType(DN_LogType_Debug), DN_CallSiteNow, DN_LogFlags_Nil, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogInfoF(fmt, ...) DN_LogPrintF(DN_LogTypeParamFromType(DN_LogType_Info), DN_CallSiteNow, DN_LogFlags_Nil, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogWarningF(fmt, ...) DN_LogPrintF(DN_LogTypeParamFromType(DN_LogType_Warning), DN_CallSiteNow, DN_LogFlags_Nil, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogErrorF(fmt, ...) DN_LogPrintF(DN_LogTypeParamFromType(DN_LogType_Error), DN_CallSiteNow, DN_LogFlags_Nil, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define DN_LogFlagF(type, flags, fmt, ...) DN_LogPrint(DN_LogTypeParamFromType(type), DN_CALL_SITE, flags, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogFlagDebugF(flags, fmt, ...) DN_LogPrint(DN_LogTypeParamFromType(DN_LogType_Debug), DN_CALL_SITE, flags, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogFlagInfoF(flags, fmt, ...) DN_LogPrint(DN_LogTypeParamFromType(DN_LogType_Info), DN_CALL_SITE, flags, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogFlagWarningF(flags, fmt, ...) DN_LogPrint(DN_LogTypeParamFromType(DN_LogType_Warning), DN_CALL_SITE, flags, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogFlagErrorF(flags, fmt, ...) DN_LogPrint(DN_LogTypeParamFromType(DN_LogType_Error), DN_CALL_SITE, flags, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogFlagF(type, flags, fmt, ...) DN_LogPrintF(DN_LogTypeParamFromType(type), DN_CallSiteNow, flags, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogFlagDebugF(flags, fmt, ...) DN_LogPrintF(DN_LogTypeParamFromType(DN_LogType_Debug), DN_CallSiteNow, flags, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogFlagInfoF(flags, fmt, ...) DN_LogPrintF(DN_LogTypeParamFromType(DN_LogType_Info), DN_CallSiteNow, flags, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogFlagWarningF(flags, fmt, ...) DN_LogPrintF(DN_LogTypeParamFromType(DN_LogType_Warning), DN_CallSiteNow, flags, fmt, ##__VA_ARGS__)
|
||||
#define DN_LogFlagErrorF(flags, fmt, ...) DN_LogPrintF(DN_LogTypeParamFromType(DN_LogType_Error), DN_CallSiteNow, flags, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
// NOTE: OS primitives that the OS layer can provide for the base layer but is optional.
|
||||
@@ -2850,22 +2923,22 @@ DN_API DN_RaycastV2 DN_RaycastLineIntersectV2
|
||||
#define DN_PArrayMakeArray(ptr, ptr_size, max, count, z_mem) DN_TArrayMakeArray(ptr, ptr_size, max, count, z_mem)
|
||||
#define DN_PArrayMakeArrayZ(ptr, ptr_size, max, count) DN_TArrayMakeArray(ptr, ptr_size, max, count, DN_ZMem_Yes)
|
||||
#define DN_PArrayMakeArrayNoZ(ptr, ptr_size, max, count) DN_TArrayMakeArray(ptr, ptr_size, max, count, DN_ZMem_No)
|
||||
#define DN_PArrayMakeArrayAssert(ptr, ptr_size, max, count, z_mem) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, count, z_mem, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeArrayAssertZ(ptr, ptr_size, max, count) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, count, DN_ZMem_Yes, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeArrayAssertNoZ(ptr, ptr_size, max, count) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, count, DN_ZMem_No, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeArrayAssert(ptr, ptr_size, max, count, z_mem) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, count, z_mem, DN_CallSiteNow)
|
||||
#define DN_PArrayMakeArrayAssertZ(ptr, ptr_size, max, count) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, count, DN_ZMem_Yes, DN_CallSiteNow)
|
||||
#define DN_PArrayMakeArrayAssertNoZ(ptr, ptr_size, max, count) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, count, DN_ZMem_No, DN_CallSiteNow)
|
||||
|
||||
#define DN_PArrayMake(ptr, ptr_size, max, z_mem) DN_TArrayMakeArray(ptr, ptr_size, max, 1, z_mem)
|
||||
#define DN_PArrayMakeZ(ptr, ptr_size, max) DN_TArrayMakeArray(ptr, ptr_size, max, 1, DN_ZMem_Yes)
|
||||
#define DN_PArrayMakeNoZ(ptr, ptr_size, max) DN_TArrayMakeArray(ptr, ptr_size, max, 1, DN_ZMem_No)
|
||||
#define DN_PArrayMakeAssert(ptr, ptr_size, max, z_mem) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, 1, z_mem, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeAssertZ(ptr, ptr_size, max) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, 1, DN_ZMem_Yes, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeAssertNoZ(ptr, ptr_size, max) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, 1, DN_ZMem_No, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeAssert(ptr, ptr_size, max, z_mem) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, 1, z_mem, DN_CallSiteNow)
|
||||
#define DN_PArrayMakeAssertZ(ptr, ptr_size, max) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, 1, DN_ZMem_Yes, DN_CallSiteNow)
|
||||
#define DN_PArrayMakeAssertNoZ(ptr, ptr_size, max) DN_TArrayMakeArrayAssert(ptr, ptr_size, max, 1, DN_ZMem_No, DN_CallSiteNow)
|
||||
|
||||
#define DN_PArrayAddArray(ptr, ptr_size, max, items, count, add) DN_TArrayAddArray(ptr, ptr_size, max, items, count, add)
|
||||
#define DN_PArrayAdd(ptr, ptr_size, max, item, add) DN_TArrayAddArray(ptr, ptr_size, max, &item, 1, add)
|
||||
#define DN_PArrayAppendArray(ptr, ptr_size, max, items, count) DN_TArrayAddArray(ptr, ptr_size, max, items, count, DN_ArrayAdd_Append)
|
||||
#define DN_PArrayAppend(ptr, ptr_size, max, item) DN_TArrayAddArray(ptr, ptr_size, max, &item, 1, DN_ArrayAdd_Append)
|
||||
#define DN_PArrayAppendAssert(ptr, ptr_size, max, item) DN_TArrayAddArrayAssert(ptr, ptr_size, max, &item, 1, DN_ArrayAdd_Append, DN_CALL_SITE)
|
||||
#define DN_PArrayAppendAssert(ptr, ptr_size, max, item) DN_TArrayAddArrayAssert(ptr, ptr_size, max, &item, 1, DN_ArrayAdd_Append, DN_CallSiteNow)
|
||||
#define DN_PArrayPrependArray(ptr, ptr_size, max, items, count) DN_TArrayAddArray(ptr, ptr_size, max, items, count, DN_ArrayAdd_Prepend)
|
||||
#define DN_PArrayPrepend(ptr, ptr_size, max, item) DN_TArrayAddArray(ptr, ptr_size, max, &item, 1, DN_ArrayAdd_Prepend)
|
||||
|
||||
@@ -2888,22 +2961,22 @@ DN_API DN_RaycastV2 DN_RaycastLineIntersectV2
|
||||
#define DN_PArrayMakeArray(ptr, ptr_size, max, count, z_mem) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArray(ptr, ptr_size, max, sizeof((ptr)[0]), count, z_mem)
|
||||
#define DN_PArrayMakeArrayZ(ptr, ptr_size, max, count) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArray(ptr, ptr_size, max, sizeof((ptr)[0]), count, DN_ZMem_Yes)
|
||||
#define DN_PArrayMakeArrayNoZ(ptr, ptr_size, max, count) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArray(ptr, ptr_size, max, sizeof((ptr)[0]), count, DN_ZMem_No)
|
||||
#define DN_PArrayMakeArrayAssert(ptr, ptr_size, max, count, z_mem) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), count, z_mem, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeArrayAssertZ(ptr, ptr_size, max, count) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), count, DN_ZMem_Yes, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeArrayAssertNoZ(ptr, ptr_size, max, count) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), count, DN_ZMem_No, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeArrayAssert(ptr, ptr_size, max, count, z_mem) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), count, z_mem, DN_CallSiteNow)
|
||||
#define DN_PArrayMakeArrayAssertZ(ptr, ptr_size, max, count) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), count, DN_ZMem_Yes, DN_CallSiteNow)
|
||||
#define DN_PArrayMakeArrayAssertNoZ(ptr, ptr_size, max, count) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), count, DN_ZMem_No, DN_CallSiteNow)
|
||||
|
||||
#define DN_PArrayMake(ptr, ptr_size, max, z_mem) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArray(ptr, ptr_size, max, sizeof((ptr)[0]), 1, z_mem)
|
||||
#define DN_PArrayMakeZ(ptr, ptr_size, max) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArray(ptr, ptr_size, max, sizeof((ptr)[0]), 1, DN_ZMem_Yes)
|
||||
#define DN_PArrayMakeNoZ(ptr, ptr_size, max) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArray(ptr, ptr_size, max, sizeof((ptr)[0]), 1, DN_ZMem_No)
|
||||
#define DN_PArrayMakeAssert(ptr, ptr_size, max, z_mem) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), 1, z_mem, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeAssertZ(ptr, ptr_size, max) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), 1, DN_ZMem_Yes, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeAssertNoZ(ptr, ptr_size, max) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), 1, DN_ZMem_No, DN_CALL_SITE)
|
||||
#define DN_PArrayMakeAssert(ptr, ptr_size, max, z_mem) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), 1, z_mem, DN_CallSiteNow)
|
||||
#define DN_PArrayMakeAssertZ(ptr, ptr_size, max) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), 1, DN_ZMem_Yes, DN_CallSiteNow)
|
||||
#define DN_PArrayMakeAssertNoZ(ptr, ptr_size, max) (DN_CppDeclType(&(ptr)[0]))DN_ArrayMakeArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), 1, DN_ZMem_No, DN_CallSiteNow)
|
||||
|
||||
#define DN_PArrayAddArray(ptr, ptr_size, max, items, count, add) (DN_CppDeclType(&(ptr)[0]))DN_ArrayAddArray(ptr, ptr_size, max, sizeof((ptr)[0]), items, count, add)
|
||||
#define DN_PArrayAdd(ptr, ptr_size, max, item, add) (DN_CppDeclType(&(ptr)[0]))DN_ArrayAddArray(ptr, ptr_size, max, sizeof((ptr)[0]), &item, 1, add)
|
||||
#define DN_PArrayAppendArray(ptr, ptr_size, max, items, count) (DN_CppDeclType(&(ptr)[0]))DN_ArrayAddArray(ptr, ptr_size, max, sizeof((ptr)[0]), items, count, DN_ArrayAdd_Append)
|
||||
#define DN_PArrayAppend(ptr, ptr_size, max, item) (DN_CppDeclType(&(ptr)[0]))DN_ArrayAddArray(ptr, ptr_size, max, sizeof((ptr)[0]), &item, 1, DN_ArrayAdd_Append)
|
||||
#define DN_PArrayAppendAssert(ptr, ptr_size, max, item) (DN_CppDeclType(&(ptr)[0]))DN_ArrayAddArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), &item, 1, DN_ArrayAdd_Append, DN_CALL_SITE)
|
||||
#define DN_PArrayAppendAssert(ptr, ptr_size, max, item) (DN_CppDeclType(&(ptr)[0]))DN_ArrayAddArrayAssert(ptr, ptr_size, max, sizeof((ptr)[0]), &item, 1, DN_ArrayAdd_Append, DN_CallSiteNow)
|
||||
#define DN_PArrayPrependArray(ptr, ptr_size, max, items, count) (DN_CppDeclType(&(ptr)[0]))DN_ArrayAddArray(ptr, ptr_size, max, sizeof((ptr)[0]), items, count, DN_ArrayAdd_Prepend)
|
||||
#define DN_PArrayPrepend(ptr, ptr_size, max, item) (DN_CppDeclType(&(ptr)[0]))DN_ArrayAddArray(ptr, ptr_size, max, sizeof((ptr)[0]), &item, 1, DN_ArrayAdd_Prepend)
|
||||
|
||||
@@ -3312,7 +3385,7 @@ DN_API void DN_LeakDump_ (DN_LeakTracker *leak);
|
||||
|
||||
// NOTE: Template implementations
|
||||
#if defined(__cplusplus)
|
||||
template <typename T> T *DN_TMemCopyObj(T *dest, T const *src, DN_USize count)
|
||||
template <typename T> T *DN_MemCopyObjT(T *dest, T const *src, DN_USize count)
|
||||
{
|
||||
T* result = dest;
|
||||
DN_Memcpy(dest, src, sizeof(T) * count);
|
||||
|
||||
Reference in New Issue
Block a user