Get the bar fixes
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
// Generated by the DN single header generator 2026-07-21 20:17:37
|
// Generated by the DN single header generator 2026-07-28 00:41:28
|
||||||
|
|
||||||
// DN: Single header generator commented out => #if defined(_CLANGD)
|
// DN: Single header generator commented out => #if defined(_CLANGD)
|
||||||
// #define DN_WITH_TESTS 1
|
// #define DN_WITH_TESTS 1
|
||||||
@@ -3789,7 +3789,7 @@ DN_API DN_Str8 DN_Str8FileDirectoryFromPath(DN_Str8 path)
|
|||||||
{
|
{
|
||||||
DN_Str8 separators[] = {DN_Str8Lit("/"), DN_Str8Lit("\\")};
|
DN_Str8 separators[] = {DN_Str8Lit("/"), DN_Str8Lit("\\")};
|
||||||
DN_Str8BSplitResult split = DN_Str8BSplitLastArray(path, separators, DN_ArrayCountU(separators));
|
DN_Str8BSplitResult split = DN_Str8BSplitLastArray(path, separators, DN_ArrayCountU(separators));
|
||||||
DN_Str8 result = split.lhs;
|
DN_Str8 result = split.rhs.count == 0 ? DN_Str8Lit(".") : split.lhs;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5775,7 +5775,7 @@ static void DN_QSortInsertion_(void *array, DN_USize array_size, DN_USize elem_s
|
|||||||
DN_TcScratchEnd(&scratch);
|
DN_TcScratchEnd(&scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSort(void *array, DN_USize array_size, DN_USize elem_size, void *user_context, DN_QSortCompareFunc *compare)
|
DN_API void DN_QSort_(void *array, DN_USize array_size, DN_USize elem_size, void *user_context, DN_QSortCompareFunc *compare)
|
||||||
{
|
{
|
||||||
if (!array || array_size <= 1 || elem_size == 0 || !compare)
|
if (!array || array_size <= 1 || elem_size == 0 || !compare)
|
||||||
return;
|
return;
|
||||||
@@ -5818,14 +5818,22 @@ DN_API void DN_QSort(void *array, DN_USize array_size, DN_USize elem_size, void
|
|||||||
// Move pivot to right of partition
|
// Move pivot to right of partition
|
||||||
// 4, 5, 2, 3, |6, 8, ^7*
|
// 4, 5, 2, 3, |6, 8, ^7*
|
||||||
DN_QSortSwapElems_(array, elem_size, partition_index, pivot_index);
|
DN_QSortSwapElems_(array, elem_size, partition_index, pivot_index);
|
||||||
DN_QSort(array_u8, partition_index, elem_size, user_context, compare);
|
DN_QSort_(array_u8, partition_index, elem_size, user_context, compare);
|
||||||
|
|
||||||
// Skip the value at partion index since that is guaranteed to be sorted.
|
// Skip the value at partion index since that is guaranteed to be sorted.
|
||||||
// 4, 5, 2, 3, (x), 8, 7
|
// 4, 5, 2, 3, (x), 8, 7
|
||||||
DN_USize one_after_partition_index = partition_index + 1;
|
DN_USize one_after_partition_index = partition_index + 1;
|
||||||
DN_QSort(array_u8 + (one_after_partition_index * elem_size), (array_size - one_after_partition_index), elem_size, user_context, compare);
|
DN_QSort_(array_u8 + (one_after_partition_index * elem_size), (array_size - one_after_partition_index), elem_size, user_context, compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
template <typename T>
|
||||||
|
DN_API void DN_QSort(T *array, DN_USize array_size, void *user_context, DN_QSortCompareFunc *compare)
|
||||||
|
{
|
||||||
|
DN_QSort_(array, array_size, sizeof(T), user_context, compare);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
DN_API bool DN_QSortCompareStr8NaturalAsc(void const* lhs, void const *rhs, void *user_context)
|
DN_API bool DN_QSortCompareStr8NaturalAsc(void const* lhs, void const *rhs, void *user_context)
|
||||||
{
|
{
|
||||||
DN_Str8EqCase eq_case = *DN_Cast(DN_Str8EqCase *) user_context;
|
DN_Str8EqCase eq_case = *DN_Cast(DN_Str8EqCase *) user_context;
|
||||||
@@ -5878,32 +5886,32 @@ DN_API bool DN_QSortCompareBytesGT(void const* lhs, void const *rhs, void *user_
|
|||||||
|
|
||||||
DN_API void DN_QSortBytesLT(void *array, DN_USize array_size, DN_USize elem_size)
|
DN_API void DN_QSortBytesLT(void *array, DN_USize array_size, DN_USize elem_size)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, elem_size, &elem_size, DN_QSortCompareBytesLT);
|
DN_QSort_(array, array_size, elem_size, &elem_size, DN_QSortCompareBytesLT);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSortBytesGT(void *array, DN_USize array_size, DN_USize elem_size)
|
DN_API void DN_QSortBytesGT(void *array, DN_USize array_size, DN_USize elem_size)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, elem_size, &elem_size, DN_QSortCompareBytesGT);
|
DN_QSort_(array, array_size, elem_size, &elem_size, DN_QSortCompareBytesGT);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSortStr8NaturalAsc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
DN_API void DN_QSortStr8NaturalAsc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8NaturalAsc);
|
DN_QSort_(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8NaturalAsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSortStr8NaturalDesc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
DN_API void DN_QSortStr8NaturalDesc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8NaturalDesc);
|
DN_QSort_(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8NaturalDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSortStr8LexicographicAsc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
DN_API void DN_QSortStr8LexicographicAsc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8LexicographicAsc);
|
DN_QSort_(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8LexicographicAsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSortStr8LexicographicDesc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
DN_API void DN_QSortStr8LexicographicDesc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8LexicographicDesc);
|
DN_QSort_(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8LexicographicDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API bool DN_BSearchLessThanBytes(void const *lhs, void const *rhs, void *user_context)
|
DN_API bool DN_BSearchLessThanBytes(void const *lhs, void const *rhs, void *user_context)
|
||||||
@@ -6112,7 +6120,7 @@ DN_FORCE_INLINE DN_U64 DN_Murmur3FMix64_(DN_U64 k)
|
|||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API DN_U32 DN_Murmur3HashU128FromBytesX86(void const *bytes, int len, DN_U32 seed)
|
DN_API DN_U32 DN_Murmur3HashU32FromBytesX86(void const *bytes, int len, DN_U32 seed)
|
||||||
{
|
{
|
||||||
const DN_U8 *data = (const DN_U8 *)bytes;
|
const DN_U8 *data = (const DN_U8 *)bytes;
|
||||||
const int nblocks = len / 4;
|
const int nblocks = len / 4;
|
||||||
@@ -6127,8 +6135,7 @@ DN_API DN_U32 DN_Murmur3HashU128FromBytesX86(void const *bytes, int len, DN_U32
|
|||||||
|
|
||||||
const DN_U32 *blocks = (const DN_U32 *)(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++) {
|
||||||
{
|
|
||||||
DN_U32 k1 = DN_Murmur3GetBlock32_(blocks, i);
|
DN_U32 k1 = DN_Murmur3GetBlock32_(blocks, i);
|
||||||
|
|
||||||
k1 *= c1;
|
k1 *= c1;
|
||||||
@@ -6147,8 +6154,7 @@ DN_API DN_U32 DN_Murmur3HashU128FromBytesX86(void const *bytes, int len, DN_U32
|
|||||||
|
|
||||||
DN_U32 k1 = 0;
|
DN_U32 k1 = 0;
|
||||||
|
|
||||||
switch (len & 3)
|
switch (len & 3) {
|
||||||
{
|
|
||||||
case 3:
|
case 3:
|
||||||
k1 ^= tail[2] << 16;
|
k1 ^= tail[2] << 16;
|
||||||
case 2:
|
case 2:
|
||||||
@@ -6187,8 +6193,7 @@ DN_API DN_Murmur3 DN_Murmur3HashU128FromBytesX64(void const *bytes, int len, DN_
|
|||||||
|
|
||||||
const DN_U64 *blocks = (const DN_U64 *)(data);
|
const DN_U64 *blocks = (const DN_U64 *)(data);
|
||||||
|
|
||||||
for (int i = 0; i < nblocks; i++)
|
for (int i = 0; i < nblocks; i++) {
|
||||||
{
|
|
||||||
DN_U64 k1 = DN_Murmur3GetBlock64_(blocks, i * 2 + 0);
|
DN_U64 k1 = DN_Murmur3GetBlock64_(blocks, i * 2 + 0);
|
||||||
DN_U64 k2 = DN_Murmur3GetBlock64_(blocks, i * 2 + 1);
|
DN_U64 k2 = DN_Murmur3GetBlock64_(blocks, i * 2 + 1);
|
||||||
|
|
||||||
@@ -6219,8 +6224,7 @@ DN_API DN_Murmur3 DN_Murmur3HashU128FromBytesX64(void const *bytes, int len, DN_
|
|||||||
DN_U64 k1 = 0;
|
DN_U64 k1 = 0;
|
||||||
DN_U64 k2 = 0;
|
DN_U64 k2 = 0;
|
||||||
|
|
||||||
switch (len & 15)
|
switch (len & 15) {
|
||||||
{
|
|
||||||
case 15:
|
case 15:
|
||||||
k2 ^= ((DN_U64)tail[14]) << 48;
|
k2 ^= ((DN_U64)tail[14]) << 48;
|
||||||
case 14:
|
case 14:
|
||||||
@@ -7392,7 +7396,7 @@ DN_API DN_V4F32 DN_V4F32Linear01FromSrgb01(DN_V4F32 srgb01)
|
|||||||
|
|
||||||
DN_API DN_V4F32 DN_V4F32Linear01Desaturate(DN_V4F32 linear01, DN_F32 t01)
|
DN_API DN_V4F32 DN_V4F32Linear01Desaturate(DN_V4F32 linear01, DN_F32 t01)
|
||||||
{
|
{
|
||||||
DN_F32 luminance = (linear01.r * DN_V3F32_Rgb_LUMINANCE.r) + (linear01.g * DN_V3F32_Rgb_LUMINANCE.g) + (linear01.b * DN_V3F32_Rgb_LUMINANCE.b);
|
DN_F32 luminance = (linear01.r * DN_V3F32_RGB_LUMINANCE.r) + (linear01.g * DN_V3F32_RGB_LUMINANCE.g) + (linear01.b * DN_V3F32_RGB_LUMINANCE.b);
|
||||||
DN_V4F32 result = linear01;
|
DN_V4F32 result = linear01;
|
||||||
result.rgb = DN_V3F32Lerp(result.rgb, t01, DN_V3F32From1N(luminance));
|
result.rgb = DN_V3F32Lerp(result.rgb, t01, DN_V3F32From1N(luminance));
|
||||||
return result;
|
return result;
|
||||||
@@ -14605,25 +14609,25 @@ DN_API DN_OSPosixProcSelfStatus DN_OS_PosixProcSelfStatus()
|
|||||||
|
|
||||||
for (DN_ForItSize(line_it, DN_Str8, lines.data, lines.count)) {
|
for (DN_ForItSize(line_it, DN_Str8, lines.data, lines.count)) {
|
||||||
DN_Str8 line = DN_Str8TrimWhitespaceAround(*line_it.data);
|
DN_Str8 line = DN_Str8TrimWhitespaceAround(*line_it.data);
|
||||||
if (DN_Str8StartsWith(line, NAME, DN_Str8EqCase_Insensitive)) {
|
if (DN_Str8StartsWithInsensitive(line, NAME)) {
|
||||||
DN_Str8 str8 = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, NAME.count, line.count));
|
DN_Str8 str8 = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, NAME.count, line.count));
|
||||||
result.name_size = DN_Min(str8.count, sizeof(result.name));
|
result.name_size = DN_Min(str8.count, sizeof(result.name));
|
||||||
DN_Memcpy(result.name, str8.data, result.name_size);
|
DN_Memcpy(result.name, str8.data, result.name_size);
|
||||||
} else if (DN_Str8StartsWith(line, PID, DN_Str8EqCase_Insensitive)) {
|
} else if (DN_Str8StartsWithInsensitive(line, PID)) {
|
||||||
DN_Str8 str8 = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, PID.count, line.count));
|
DN_Str8 str8 = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, PID.count, line.count));
|
||||||
DN_U64FromResult to_u64 = DN_U64FromStr8(str8);
|
DN_U64FromResult to_u64 = DN_U64FromStr8(str8);
|
||||||
result.pid = to_u64.value;
|
result.pid = to_u64.value;
|
||||||
DN_Assert(to_u64.success);
|
DN_Assert(to_u64.success);
|
||||||
} else if (DN_Str8StartsWith(line, VM_SIZE, DN_Str8EqCase_Insensitive)) {
|
} else if (DN_Str8StartsWithInsensitive(line, VM_SIZE)) {
|
||||||
DN_Str8 size_with_kb = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, VM_SIZE.count, line.count));
|
DN_Str8 size_with_kb = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, VM_SIZE.count, line.count));
|
||||||
DN_Assert(DN_Str8EndsWith(size_with_kb, DN_Str8Lit("kB")));
|
DN_Assert(DN_Str8EndsWithSensitive(size_with_kb, DN_Str8Lit("kB")));
|
||||||
DN_Str8 vm_size = DN_Str8BSplit(size_with_kb, DN_Str8Lit(" ")).lhs;
|
DN_Str8 vm_size = DN_Str8BSplit(size_with_kb, DN_Str8Lit(" ")).lhs;
|
||||||
DN_U64FromResult to_u64 = DN_U64FromStr8(vm_size);
|
DN_U64FromResult to_u64 = DN_U64FromStr8(vm_size);
|
||||||
result.vm_size = DN_Kilobytes(to_u64.value);
|
result.vm_size = DN_Kilobytes(to_u64.value);
|
||||||
DN_Assert(to_u64.success);
|
DN_Assert(to_u64.success);
|
||||||
} else if (DN_Str8StartsWith(line, VM_PEAK, DN_Str8EqCase_Insensitive)) {
|
} else if (DN_Str8StartsWithInsensitive(line, VM_PEAK)) {
|
||||||
DN_Str8 size_with_kb = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, VM_PEAK.count, line.count));
|
DN_Str8 size_with_kb = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, VM_PEAK.count, line.count));
|
||||||
DN_Assert(DN_Str8EndsWith(size_with_kb, DN_Str8Lit("kB")));
|
DN_Assert(DN_Str8EndsWithSensitive(size_with_kb, DN_Str8Lit("kB")));
|
||||||
DN_Str8 vm_size = DN_Str8BSplit(size_with_kb, DN_Str8Lit(" ")).lhs;
|
DN_Str8 vm_size = DN_Str8BSplit(size_with_kb, DN_Str8Lit(" ")).lhs;
|
||||||
DN_U64FromResult to_u64 = DN_U64FromStr8(vm_size);
|
DN_U64FromResult to_u64 = DN_U64FromStr8(vm_size);
|
||||||
result.vm_peak = DN_Kilobytes(to_u64.value);
|
result.vm_peak = DN_Kilobytes(to_u64.value);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Generated by the DN single header generator 2026-07-21 20:17:37
|
// Generated by the DN single header generator 2026-07-28 00:41:27
|
||||||
|
|
||||||
#if !defined(DN_H)
|
#if !defined(DN_H)
|
||||||
#define DN_H
|
#define DN_H
|
||||||
@@ -302,6 +302,7 @@
|
|||||||
// NOTE: Platform identification
|
// NOTE: Platform identification
|
||||||
#if !defined(DN_PLATFORM_EMSCRIPTEN) && \
|
#if !defined(DN_PLATFORM_EMSCRIPTEN) && \
|
||||||
!defined(DN_PLATFORM_POSIX) && \
|
!defined(DN_PLATFORM_POSIX) && \
|
||||||
|
!defined(DN_PLATFORM_ARM64) && \
|
||||||
!defined(DN_PLATFORM_WIN32)
|
!defined(DN_PLATFORM_WIN32)
|
||||||
#if defined(__aarch64__) || defined(_M_ARM64)
|
#if defined(__aarch64__) || defined(_M_ARM64)
|
||||||
#define DN_PLATFORM_ARM64
|
#define DN_PLATFORM_ARM64
|
||||||
@@ -5249,7 +5250,14 @@ DN_API void DN_ProfilerFmtToStdout
|
|||||||
DN_API DN_F64 DN_ProfilerSecFromTsc (DN_Profiler *profiler, DN_U64 duration_tsc);
|
DN_API DN_F64 DN_ProfilerSecFromTsc (DN_Profiler *profiler, DN_U64 duration_tsc);
|
||||||
DN_API DN_F64 DN_ProfilerMsFromTsc (DN_Profiler *profiler, DN_U64 duration_tsc);
|
DN_API DN_F64 DN_ProfilerMsFromTsc (DN_Profiler *profiler, DN_U64 duration_tsc);
|
||||||
|
|
||||||
DN_API void DN_QSort (void *array, DN_USize array_size, DN_USize elem_size, void *user_context, DN_QSortCompareFunc *compare);
|
DN_API void DN_QSort_ (void *array, DN_USize array_size, DN_USize elem_size, void *user_context, DN_QSortCompareFunc *compare);
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
template <typename T> void DN_QSortT (T *array, DN_USize array_size, void *user_context, DN_QSortCompareFunc *compare);
|
||||||
|
#define DN_QSort(array, array_size, user_context, compare) DN_QSortT(array, array_size, user_context, compare)
|
||||||
|
#else
|
||||||
|
#define DN_QSort(array, array_size, user_context, compare) DN_QSort_(array, array_size, sizeof(*array), user_context, compare)
|
||||||
|
#endif
|
||||||
|
|
||||||
DN_API bool DN_QSortCompareStr8NaturalAsc (void const* lhs, void const *rhs, void *user_context);
|
DN_API bool DN_QSortCompareStr8NaturalAsc (void const* lhs, void const *rhs, void *user_context);
|
||||||
DN_API bool DN_QSortCompareStr8NaturalDesc (void const* lhs, void const *rhs, void *user_context);
|
DN_API bool DN_QSortCompareStr8NaturalDesc (void const* lhs, void const *rhs, void *user_context);
|
||||||
DN_API bool DN_QSortCompareStr8LexicographicAsc (void const* lhs, void const *rhs, void *user_context);
|
DN_API bool DN_QSortCompareStr8LexicographicAsc (void const* lhs, void const *rhs, void *user_context);
|
||||||
@@ -5510,7 +5518,7 @@ DN_API DN_F32 DN_V2F32Area
|
|||||||
|
|
||||||
// NOTE: Grayscale co-efficients from:
|
// NOTE: Grayscale co-efficients from:
|
||||||
// https://github.com/EpicGames/UnrealEngine/blob/260bb2e1c5610b31c63a36206eedd289409c5f11/Engine/Source/Runtime/Core/Private/Math/Color.cpp#L304
|
// https://github.com/EpicGames/UnrealEngine/blob/260bb2e1c5610b31c63a36206eedd289409c5f11/Engine/Source/Runtime/Core/Private/Math/Color.cpp#L304
|
||||||
DN_V3F32 static const DN_V3F32_Rgb_LUMINANCE = DN_V3F32From3N(0.3f, 0.59f, 0.11f);
|
DN_V3F32 static const DN_V3F32_RGB_LUMINANCE = DN_V3F32From3N(0.3f, 0.59f, 0.11f);
|
||||||
|
|
||||||
DN_API bool operator== (DN_V3F32 lhs, DN_V3F32 rhs);
|
DN_API bool operator== (DN_V3F32 lhs, DN_V3F32 rhs);
|
||||||
DN_API bool operator!= (DN_V3F32 lhs, DN_V3F32 rhs);
|
DN_API bool operator!= (DN_V3F32 lhs, DN_V3F32 rhs);
|
||||||
|
|||||||
@@ -1414,25 +1414,25 @@ DN_API DN_OSPosixProcSelfStatus DN_OS_PosixProcSelfStatus()
|
|||||||
|
|
||||||
for (DN_ForItSize(line_it, DN_Str8, lines.data, lines.count)) {
|
for (DN_ForItSize(line_it, DN_Str8, lines.data, lines.count)) {
|
||||||
DN_Str8 line = DN_Str8TrimWhitespaceAround(*line_it.data);
|
DN_Str8 line = DN_Str8TrimWhitespaceAround(*line_it.data);
|
||||||
if (DN_Str8StartsWith(line, NAME, DN_Str8EqCase_Insensitive)) {
|
if (DN_Str8StartsWithInsensitive(line, NAME)) {
|
||||||
DN_Str8 str8 = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, NAME.count, line.count));
|
DN_Str8 str8 = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, NAME.count, line.count));
|
||||||
result.name_size = DN_Min(str8.count, sizeof(result.name));
|
result.name_size = DN_Min(str8.count, sizeof(result.name));
|
||||||
DN_Memcpy(result.name, str8.data, result.name_size);
|
DN_Memcpy(result.name, str8.data, result.name_size);
|
||||||
} else if (DN_Str8StartsWith(line, PID, DN_Str8EqCase_Insensitive)) {
|
} else if (DN_Str8StartsWithInsensitive(line, PID)) {
|
||||||
DN_Str8 str8 = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, PID.count, line.count));
|
DN_Str8 str8 = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, PID.count, line.count));
|
||||||
DN_U64FromResult to_u64 = DN_U64FromStr8(str8);
|
DN_U64FromResult to_u64 = DN_U64FromStr8(str8);
|
||||||
result.pid = to_u64.value;
|
result.pid = to_u64.value;
|
||||||
DN_Assert(to_u64.success);
|
DN_Assert(to_u64.success);
|
||||||
} else if (DN_Str8StartsWith(line, VM_SIZE, DN_Str8EqCase_Insensitive)) {
|
} else if (DN_Str8StartsWithInsensitive(line, VM_SIZE)) {
|
||||||
DN_Str8 size_with_kb = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, VM_SIZE.count, line.count));
|
DN_Str8 size_with_kb = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, VM_SIZE.count, line.count));
|
||||||
DN_Assert(DN_Str8EndsWith(size_with_kb, DN_Str8Lit("kB")));
|
DN_Assert(DN_Str8EndsWithSensitive(size_with_kb, DN_Str8Lit("kB")));
|
||||||
DN_Str8 vm_size = DN_Str8BSplit(size_with_kb, DN_Str8Lit(" ")).lhs;
|
DN_Str8 vm_size = DN_Str8BSplit(size_with_kb, DN_Str8Lit(" ")).lhs;
|
||||||
DN_U64FromResult to_u64 = DN_U64FromStr8(vm_size);
|
DN_U64FromResult to_u64 = DN_U64FromStr8(vm_size);
|
||||||
result.vm_size = DN_Kilobytes(to_u64.value);
|
result.vm_size = DN_Kilobytes(to_u64.value);
|
||||||
DN_Assert(to_u64.success);
|
DN_Assert(to_u64.success);
|
||||||
} else if (DN_Str8StartsWith(line, VM_PEAK, DN_Str8EqCase_Insensitive)) {
|
} else if (DN_Str8StartsWithInsensitive(line, VM_PEAK)) {
|
||||||
DN_Str8 size_with_kb = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, VM_PEAK.count, line.count));
|
DN_Str8 size_with_kb = DN_Str8TrimWhitespaceAround(DN_Str8Subset(line, VM_PEAK.count, line.count));
|
||||||
DN_Assert(DN_Str8EndsWith(size_with_kb, DN_Str8Lit("kB")));
|
DN_Assert(DN_Str8EndsWithSensitive(size_with_kb, DN_Str8Lit("kB")));
|
||||||
DN_Str8 vm_size = DN_Str8BSplit(size_with_kb, DN_Str8Lit(" ")).lhs;
|
DN_Str8 vm_size = DN_Str8BSplit(size_with_kb, DN_Str8Lit(" ")).lhs;
|
||||||
DN_U64FromResult to_u64 = DN_U64FromStr8(vm_size);
|
DN_U64FromResult to_u64 = DN_U64FromStr8(vm_size);
|
||||||
result.vm_peak = DN_Kilobytes(to_u64.value);
|
result.vm_peak = DN_Kilobytes(to_u64.value);
|
||||||
|
|||||||
+24
-20
@@ -3787,7 +3787,7 @@ DN_API DN_Str8 DN_Str8FileDirectoryFromPath(DN_Str8 path)
|
|||||||
{
|
{
|
||||||
DN_Str8 separators[] = {DN_Str8Lit("/"), DN_Str8Lit("\\")};
|
DN_Str8 separators[] = {DN_Str8Lit("/"), DN_Str8Lit("\\")};
|
||||||
DN_Str8BSplitResult split = DN_Str8BSplitLastArray(path, separators, DN_ArrayCountU(separators));
|
DN_Str8BSplitResult split = DN_Str8BSplitLastArray(path, separators, DN_ArrayCountU(separators));
|
||||||
DN_Str8 result = split.lhs;
|
DN_Str8 result = split.rhs.count == 0 ? DN_Str8Lit(".") : split.lhs;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5773,7 +5773,7 @@ static void DN_QSortInsertion_(void *array, DN_USize array_size, DN_USize elem_s
|
|||||||
DN_TcScratchEnd(&scratch);
|
DN_TcScratchEnd(&scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSort(void *array, DN_USize array_size, DN_USize elem_size, void *user_context, DN_QSortCompareFunc *compare)
|
DN_API void DN_QSort_(void *array, DN_USize array_size, DN_USize elem_size, void *user_context, DN_QSortCompareFunc *compare)
|
||||||
{
|
{
|
||||||
if (!array || array_size <= 1 || elem_size == 0 || !compare)
|
if (!array || array_size <= 1 || elem_size == 0 || !compare)
|
||||||
return;
|
return;
|
||||||
@@ -5816,14 +5816,22 @@ DN_API void DN_QSort(void *array, DN_USize array_size, DN_USize elem_size, void
|
|||||||
// Move pivot to right of partition
|
// Move pivot to right of partition
|
||||||
// 4, 5, 2, 3, |6, 8, ^7*
|
// 4, 5, 2, 3, |6, 8, ^7*
|
||||||
DN_QSortSwapElems_(array, elem_size, partition_index, pivot_index);
|
DN_QSortSwapElems_(array, elem_size, partition_index, pivot_index);
|
||||||
DN_QSort(array_u8, partition_index, elem_size, user_context, compare);
|
DN_QSort_(array_u8, partition_index, elem_size, user_context, compare);
|
||||||
|
|
||||||
// Skip the value at partion index since that is guaranteed to be sorted.
|
// Skip the value at partion index since that is guaranteed to be sorted.
|
||||||
// 4, 5, 2, 3, (x), 8, 7
|
// 4, 5, 2, 3, (x), 8, 7
|
||||||
DN_USize one_after_partition_index = partition_index + 1;
|
DN_USize one_after_partition_index = partition_index + 1;
|
||||||
DN_QSort(array_u8 + (one_after_partition_index * elem_size), (array_size - one_after_partition_index), elem_size, user_context, compare);
|
DN_QSort_(array_u8 + (one_after_partition_index * elem_size), (array_size - one_after_partition_index), elem_size, user_context, compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
template <typename T>
|
||||||
|
DN_API void DN_QSort(T *array, DN_USize array_size, void *user_context, DN_QSortCompareFunc *compare)
|
||||||
|
{
|
||||||
|
DN_QSort_(array, array_size, sizeof(T), user_context, compare);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
DN_API bool DN_QSortCompareStr8NaturalAsc(void const* lhs, void const *rhs, void *user_context)
|
DN_API bool DN_QSortCompareStr8NaturalAsc(void const* lhs, void const *rhs, void *user_context)
|
||||||
{
|
{
|
||||||
DN_Str8EqCase eq_case = *DN_Cast(DN_Str8EqCase *) user_context;
|
DN_Str8EqCase eq_case = *DN_Cast(DN_Str8EqCase *) user_context;
|
||||||
@@ -5876,32 +5884,32 @@ DN_API bool DN_QSortCompareBytesGT(void const* lhs, void const *rhs, void *user_
|
|||||||
|
|
||||||
DN_API void DN_QSortBytesLT(void *array, DN_USize array_size, DN_USize elem_size)
|
DN_API void DN_QSortBytesLT(void *array, DN_USize array_size, DN_USize elem_size)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, elem_size, &elem_size, DN_QSortCompareBytesLT);
|
DN_QSort_(array, array_size, elem_size, &elem_size, DN_QSortCompareBytesLT);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSortBytesGT(void *array, DN_USize array_size, DN_USize elem_size)
|
DN_API void DN_QSortBytesGT(void *array, DN_USize array_size, DN_USize elem_size)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, elem_size, &elem_size, DN_QSortCompareBytesGT);
|
DN_QSort_(array, array_size, elem_size, &elem_size, DN_QSortCompareBytesGT);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSortStr8NaturalAsc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
DN_API void DN_QSortStr8NaturalAsc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8NaturalAsc);
|
DN_QSort_(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8NaturalAsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSortStr8NaturalDesc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
DN_API void DN_QSortStr8NaturalDesc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8NaturalDesc);
|
DN_QSort_(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8NaturalDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSortStr8LexicographicAsc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
DN_API void DN_QSortStr8LexicographicAsc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8LexicographicAsc);
|
DN_QSort_(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8LexicographicAsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API void DN_QSortStr8LexicographicDesc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
DN_API void DN_QSortStr8LexicographicDesc(DN_Str8 *array, DN_USize array_size, DN_Str8EqCase eq_case)
|
||||||
{
|
{
|
||||||
DN_QSort(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8LexicographicDesc);
|
DN_QSort_(array, array_size, sizeof(*array), /*user_context=*/ &eq_case, DN_QSortCompareStr8LexicographicDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API bool DN_BSearchLessThanBytes(void const *lhs, void const *rhs, void *user_context)
|
DN_API bool DN_BSearchLessThanBytes(void const *lhs, void const *rhs, void *user_context)
|
||||||
@@ -6110,7 +6118,7 @@ DN_FORCE_INLINE DN_U64 DN_Murmur3FMix64_(DN_U64 k)
|
|||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
DN_API DN_U32 DN_Murmur3HashU128FromBytesX86(void const *bytes, int len, DN_U32 seed)
|
DN_API DN_U32 DN_Murmur3HashU32FromBytesX86(void const *bytes, int len, DN_U32 seed)
|
||||||
{
|
{
|
||||||
const DN_U8 *data = (const DN_U8 *)bytes;
|
const DN_U8 *data = (const DN_U8 *)bytes;
|
||||||
const int nblocks = len / 4;
|
const int nblocks = len / 4;
|
||||||
@@ -6125,8 +6133,7 @@ DN_API DN_U32 DN_Murmur3HashU128FromBytesX86(void const *bytes, int len, DN_U32
|
|||||||
|
|
||||||
const DN_U32 *blocks = (const DN_U32 *)(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++) {
|
||||||
{
|
|
||||||
DN_U32 k1 = DN_Murmur3GetBlock32_(blocks, i);
|
DN_U32 k1 = DN_Murmur3GetBlock32_(blocks, i);
|
||||||
|
|
||||||
k1 *= c1;
|
k1 *= c1;
|
||||||
@@ -6145,8 +6152,7 @@ DN_API DN_U32 DN_Murmur3HashU128FromBytesX86(void const *bytes, int len, DN_U32
|
|||||||
|
|
||||||
DN_U32 k1 = 0;
|
DN_U32 k1 = 0;
|
||||||
|
|
||||||
switch (len & 3)
|
switch (len & 3) {
|
||||||
{
|
|
||||||
case 3:
|
case 3:
|
||||||
k1 ^= tail[2] << 16;
|
k1 ^= tail[2] << 16;
|
||||||
case 2:
|
case 2:
|
||||||
@@ -6185,8 +6191,7 @@ DN_API DN_Murmur3 DN_Murmur3HashU128FromBytesX64(void const *bytes, int len, DN_
|
|||||||
|
|
||||||
const DN_U64 *blocks = (const DN_U64 *)(data);
|
const DN_U64 *blocks = (const DN_U64 *)(data);
|
||||||
|
|
||||||
for (int i = 0; i < nblocks; i++)
|
for (int i = 0; i < nblocks; i++) {
|
||||||
{
|
|
||||||
DN_U64 k1 = DN_Murmur3GetBlock64_(blocks, i * 2 + 0);
|
DN_U64 k1 = DN_Murmur3GetBlock64_(blocks, i * 2 + 0);
|
||||||
DN_U64 k2 = DN_Murmur3GetBlock64_(blocks, i * 2 + 1);
|
DN_U64 k2 = DN_Murmur3GetBlock64_(blocks, i * 2 + 1);
|
||||||
|
|
||||||
@@ -6217,8 +6222,7 @@ DN_API DN_Murmur3 DN_Murmur3HashU128FromBytesX64(void const *bytes, int len, DN_
|
|||||||
DN_U64 k1 = 0;
|
DN_U64 k1 = 0;
|
||||||
DN_U64 k2 = 0;
|
DN_U64 k2 = 0;
|
||||||
|
|
||||||
switch (len & 15)
|
switch (len & 15) {
|
||||||
{
|
|
||||||
case 15:
|
case 15:
|
||||||
k2 ^= ((DN_U64)tail[14]) << 48;
|
k2 ^= ((DN_U64)tail[14]) << 48;
|
||||||
case 14:
|
case 14:
|
||||||
@@ -7390,7 +7394,7 @@ DN_API DN_V4F32 DN_V4F32Linear01FromSrgb01(DN_V4F32 srgb01)
|
|||||||
|
|
||||||
DN_API DN_V4F32 DN_V4F32Linear01Desaturate(DN_V4F32 linear01, DN_F32 t01)
|
DN_API DN_V4F32 DN_V4F32Linear01Desaturate(DN_V4F32 linear01, DN_F32 t01)
|
||||||
{
|
{
|
||||||
DN_F32 luminance = (linear01.r * DN_V3F32_Rgb_LUMINANCE.r) + (linear01.g * DN_V3F32_Rgb_LUMINANCE.g) + (linear01.b * DN_V3F32_Rgb_LUMINANCE.b);
|
DN_F32 luminance = (linear01.r * DN_V3F32_RGB_LUMINANCE.r) + (linear01.g * DN_V3F32_RGB_LUMINANCE.g) + (linear01.b * DN_V3F32_RGB_LUMINANCE.b);
|
||||||
DN_V4F32 result = linear01;
|
DN_V4F32 result = linear01;
|
||||||
result.rgb = DN_V3F32Lerp(result.rgb, t01, DN_V3F32From1N(luminance));
|
result.rgb = DN_V3F32Lerp(result.rgb, t01, DN_V3F32From1N(luminance));
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
+10
-2
@@ -300,6 +300,7 @@
|
|||||||
// NOTE: Platform identification
|
// NOTE: Platform identification
|
||||||
#if !defined(DN_PLATFORM_EMSCRIPTEN) && \
|
#if !defined(DN_PLATFORM_EMSCRIPTEN) && \
|
||||||
!defined(DN_PLATFORM_POSIX) && \
|
!defined(DN_PLATFORM_POSIX) && \
|
||||||
|
!defined(DN_PLATFORM_ARM64) && \
|
||||||
!defined(DN_PLATFORM_WIN32)
|
!defined(DN_PLATFORM_WIN32)
|
||||||
#if defined(__aarch64__) || defined(_M_ARM64)
|
#if defined(__aarch64__) || defined(_M_ARM64)
|
||||||
#define DN_PLATFORM_ARM64
|
#define DN_PLATFORM_ARM64
|
||||||
@@ -3319,7 +3320,14 @@ DN_API void DN_ProfilerFmtToStdout
|
|||||||
DN_API DN_F64 DN_ProfilerSecFromTsc (DN_Profiler *profiler, DN_U64 duration_tsc);
|
DN_API DN_F64 DN_ProfilerSecFromTsc (DN_Profiler *profiler, DN_U64 duration_tsc);
|
||||||
DN_API DN_F64 DN_ProfilerMsFromTsc (DN_Profiler *profiler, DN_U64 duration_tsc);
|
DN_API DN_F64 DN_ProfilerMsFromTsc (DN_Profiler *profiler, DN_U64 duration_tsc);
|
||||||
|
|
||||||
DN_API void DN_QSort (void *array, DN_USize array_size, DN_USize elem_size, void *user_context, DN_QSortCompareFunc *compare);
|
DN_API void DN_QSort_ (void *array, DN_USize array_size, DN_USize elem_size, void *user_context, DN_QSortCompareFunc *compare);
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
template <typename T> void DN_QSortT (T *array, DN_USize array_size, void *user_context, DN_QSortCompareFunc *compare);
|
||||||
|
#define DN_QSort(array, array_size, user_context, compare) DN_QSortT(array, array_size, user_context, compare)
|
||||||
|
#else
|
||||||
|
#define DN_QSort(array, array_size, user_context, compare) DN_QSort_(array, array_size, sizeof(*array), user_context, compare)
|
||||||
|
#endif
|
||||||
|
|
||||||
DN_API bool DN_QSortCompareStr8NaturalAsc (void const* lhs, void const *rhs, void *user_context);
|
DN_API bool DN_QSortCompareStr8NaturalAsc (void const* lhs, void const *rhs, void *user_context);
|
||||||
DN_API bool DN_QSortCompareStr8NaturalDesc (void const* lhs, void const *rhs, void *user_context);
|
DN_API bool DN_QSortCompareStr8NaturalDesc (void const* lhs, void const *rhs, void *user_context);
|
||||||
DN_API bool DN_QSortCompareStr8LexicographicAsc (void const* lhs, void const *rhs, void *user_context);
|
DN_API bool DN_QSortCompareStr8LexicographicAsc (void const* lhs, void const *rhs, void *user_context);
|
||||||
@@ -3580,7 +3588,7 @@ DN_API DN_F32 DN_V2F32Area
|
|||||||
|
|
||||||
// NOTE: Grayscale co-efficients from:
|
// NOTE: Grayscale co-efficients from:
|
||||||
// https://github.com/EpicGames/UnrealEngine/blob/260bb2e1c5610b31c63a36206eedd289409c5f11/Engine/Source/Runtime/Core/Private/Math/Color.cpp#L304
|
// https://github.com/EpicGames/UnrealEngine/blob/260bb2e1c5610b31c63a36206eedd289409c5f11/Engine/Source/Runtime/Core/Private/Math/Color.cpp#L304
|
||||||
DN_V3F32 static const DN_V3F32_Rgb_LUMINANCE = DN_V3F32From3N(0.3f, 0.59f, 0.11f);
|
DN_V3F32 static const DN_V3F32_RGB_LUMINANCE = DN_V3F32From3N(0.3f, 0.59f, 0.11f);
|
||||||
|
|
||||||
DN_API bool operator== (DN_V3F32 lhs, DN_V3F32 rhs);
|
DN_API bool operator== (DN_V3F32 lhs, DN_V3F32 rhs);
|
||||||
DN_API bool operator!= (DN_V3F32 lhs, DN_V3F32 rhs);
|
DN_API bool operator!= (DN_V3F32 lhs, DN_V3F32 rhs);
|
||||||
|
|||||||
Reference in New Issue
Block a user