Pull upstream changes from TELY UI
This commit is contained in:
1 parent
7147ad52a2
commit
d5c98d5288
20 files changed
+17900
-10682
No files matched your search
+5655
-3561
File diff suppressed because it is too large.
Load diff
+3473
-1747
File diff suppressed because it is too large.
Load diff
+26
-26
@@ -16,24 +16,20 @@ DN_Str8 DN_SH_CLIOptionsStr8()
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, char const **arg_ptr, int arg_count)
|
||||
DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, DN_ArgvIterator *it)
|
||||
{
|
||||
DN_SHCLIEatArgResult result = {};
|
||||
result.arg_ptr = arg_ptr;
|
||||
result.arg_count = arg_count;
|
||||
|
||||
DN_Str8 arg = {};
|
||||
if (arg_count)
|
||||
arg = DN_Str8FromCStr8(*result.arg_ptr);
|
||||
DN_Str8 arg = it->arg;
|
||||
|
||||
// NOTE: Try handling the argument if we recognise it
|
||||
{
|
||||
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-exe-path"))) {
|
||||
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
|
||||
result.eaten = true;
|
||||
args->exe_path = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
|
||||
DN_Str8 value = DN_ArgvPeek(it, 1);
|
||||
DN_ArgvEat(it, 1);
|
||||
result.eaten = true;
|
||||
args->exe_path = value;
|
||||
|
||||
if (DN_OS_PathInfo(args->exe_path).type != DN_OSPathInfoType_File) {
|
||||
if (DN_Os_PathInfo(args->exe_path).type != DN_OsPathInfoType_File) {
|
||||
result.error_msg = DN_Str8Lit("Seshc executable path does not point to a file");
|
||||
result.error_arg = args->exe_path;
|
||||
args->exe_path = {};
|
||||
@@ -41,27 +37,31 @@ DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, char const **arg_ptr, i
|
||||
}
|
||||
|
||||
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-account-secret"))) {
|
||||
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
|
||||
result.eaten = true;
|
||||
args->account_secret = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
|
||||
DN_Str8 value = DN_ArgvPeek(it, 1);
|
||||
DN_ArgvEat(it, 1);
|
||||
result.eaten = true;
|
||||
args->account_secret = value;
|
||||
}
|
||||
|
||||
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-seed-node"))) {
|
||||
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
|
||||
result.eaten = true;
|
||||
args->seed_node_url = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
|
||||
DN_Str8 value = DN_ArgvPeek(it, 1);
|
||||
DN_ArgvEat(it, 1);
|
||||
result.eaten = true;
|
||||
args->seed_node_url = value;
|
||||
}
|
||||
|
||||
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-display-name"))) {
|
||||
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
|
||||
result.eaten = true;
|
||||
args->display_name = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
|
||||
DN_Str8 value = DN_ArgvPeek(it, 1);
|
||||
DN_ArgvEat(it, 1);
|
||||
result.eaten = true;
|
||||
args->display_name = value;
|
||||
}
|
||||
|
||||
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-recipient-pkey"))) {
|
||||
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
|
||||
result.eaten = true;
|
||||
args->recipient_pkey = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
|
||||
DN_Str8 value = DN_ArgvPeek(it, 1);
|
||||
DN_ArgvEat(it, 1);
|
||||
result.eaten = true;
|
||||
args->recipient_pkey = value;
|
||||
|
||||
DN_Str8 check = DN_Str8TrimHexPrefix(args->recipient_pkey);
|
||||
if (!DN_Str8StartsWithSensitive(check, DN_Str8Lit("05"))) {
|
||||
@@ -103,9 +103,9 @@ bool DN_SH_CLIArgsSendDMFmt(DN_SHCLIArgs *cli_args, DN_Str8 sesh_pkey_hex, char
|
||||
cmd_line.data = cmds;
|
||||
cmd_line.count = DN_ArrayCountU(cmds);
|
||||
|
||||
DN_OSExecArgs exec_args = {};
|
||||
exec_args.flags |= DN_OSExecFlags_SaveOutput;
|
||||
DN_OSExecResult exec = DN_OS_Exec(cmd_line, &exec_args, &scratch.arena, nullptr);
|
||||
DN_OsExecArgs exec_args = {};
|
||||
exec_args.flags |= DN_OsExecFlags_SaveOutput;
|
||||
DN_OsExecResult exec = DN_Os_Exec(cmd_line, &exec_args, &scratch.arena, nullptr);
|
||||
DN_LogInfoF("OUT (exit code:%zu, os: %zu): %.*s", exec.exit_code, exec.os_error_code, DN_Str8PrintFmt(exec.stdout_text));
|
||||
DN_LogInfoF("ERR: %.*s", DN_Str8PrintFmt(exec.stderr_text));
|
||||
DN_TCScratchEnd(&scratch);
|
||||
|
||||
@@ -21,8 +21,6 @@ struct DN_SHCLIEatArgResult
|
||||
bool eaten;
|
||||
DN_Str8 error_msg; // Parsing error message. String is immutably stored in the data-segment w/ program lifetime.
|
||||
DN_Str8 error_arg; // Argument that caused the parsing error
|
||||
char const **arg_ptr; // Next argument pointer that that the caller should proceed from
|
||||
DN_USize arg_count; // Next argument count that that the caller should assume
|
||||
};
|
||||
|
||||
// NOTE: Seshc
|
||||
@@ -30,7 +28,7 @@ struct DN_SHCLIEatArgResult
|
||||
// Helper library that provides some useful APIs for programatically calling the Seshc CLI
|
||||
// executable to send messages from your C/C++ application.
|
||||
DN_Str8 DN_SH_CLIOptionsStr8 ();
|
||||
DN_SHCLIEatArgResult DN_SH_CLIEatArg (DN_SHCLIArgs *args, char const **arg_ptr, int arg_count);
|
||||
DN_SHCLIEatArgResult DN_SH_CLIEatArg (DN_SHCLIArgs *args, DN_ArgvIterator *it);
|
||||
bool DN_SH_CLIArgsSendDMFmt(DN_SHCLIArgs *cli_args, DN_Str8 sesh_pkey_hex, char const *fmt, ...);
|
||||
|
||||
#endif // #if !defined(DN_SESHC_H)
|
||||
+385
-395
File diff suppressed because it is too large.
Load diff
+15
-15
@@ -1,5 +1,5 @@
|
||||
#if !defined(DN_OS_POSIX_H)
|
||||
#define DN_OS_POSIX_H
|
||||
#if !defined(DN_Os_POSIX_H)
|
||||
#define DN_Os_POSIX_H
|
||||
|
||||
#if defined(_CLANGD)
|
||||
#include "../dn.h"
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
struct DN_OSPosixProcSelfStatus
|
||||
struct DN_OsPosixProcSelfStatus
|
||||
{
|
||||
char name[64];
|
||||
DN_U8 name_size;
|
||||
@@ -35,14 +35,14 @@ struct DN_OSPosixProcSelfStatus
|
||||
// unlocking, or destroying the object is undefined. [...] The effect of
|
||||
// referring to a copy of the object when locking, unlocking, or destroying it
|
||||
// is undefined.
|
||||
enum DN_OSPosixSyncPrimitiveType
|
||||
enum DN_OsPosixSyncPrimitiveType
|
||||
{
|
||||
DN_OSPosixSyncPrimitiveType_Semaphore,
|
||||
DN_OSPosixSyncPrimitiveType_Mutex,
|
||||
DN_OSPosixSyncPrimitiveType_ConditionVariable,
|
||||
DN_OsPosixSyncPrimitiveType_Semaphore,
|
||||
DN_OsPosixSyncPrimitiveType_Mutex,
|
||||
DN_OsPosixSyncPrimitiveType_ConditionVariable,
|
||||
};
|
||||
|
||||
struct DN_OSPosixSyncPrimitive
|
||||
struct DN_OsPosixSyncPrimitive
|
||||
{
|
||||
union
|
||||
{
|
||||
@@ -51,17 +51,17 @@ struct DN_OSPosixSyncPrimitive
|
||||
pthread_cond_t cv;
|
||||
pthread_barrier_t barrier;
|
||||
};
|
||||
DN_OSPosixSyncPrimitive *next;
|
||||
DN_OsPosixSyncPrimitive *next;
|
||||
};
|
||||
|
||||
struct DN_OSPosixCore
|
||||
struct DN_OsPosixCore
|
||||
{
|
||||
DN_OSPosixSyncPrimitive *sync_primitive_free_list;
|
||||
DN_OsPosixSyncPrimitive *sync_primitive_free_list;
|
||||
pthread_mutex_t sync_primitive_free_list_mutex;
|
||||
bool clock_monotonic_raw;
|
||||
};
|
||||
|
||||
DN_API void DN_OS_PosixInit (DN_OSPosixCore *posix);
|
||||
DN_API void DN_OS_PosixThreadSetName (DN_Str8 name);
|
||||
DN_API DN_OSPosixProcSelfStatus DN_OS_PosixProcSelfStatus();
|
||||
#endif // !defined(DN_OS_POSIX_H)
|
||||
DN_API void DN_Os_PosixInit (DN_OsPosixCore *posix);
|
||||
DN_API void DN_Os_PosixThreadSetName (DN_Str8 name);
|
||||
DN_API DN_OsPosixProcSelfStatus DN_Os_PosixProcSelfStatus();
|
||||
#endif // !defined(DN_Os_POSIX_H)
|
||||
+1018
-466
File diff suppressed because it is too large.
Load diff
+84
-67
@@ -1,5 +1,5 @@
|
||||
#if !defined(DN_OS_W32_H)
|
||||
#define DN_OS_W32_H
|
||||
#if !defined(DN_Os_W32_H)
|
||||
#define DN_Os_W32_H
|
||||
|
||||
#if defined(_CLANGD)
|
||||
#define DN_H_WITH_OS 1
|
||||
@@ -7,46 +7,46 @@
|
||||
#include "dn_os_windows.h"
|
||||
#endif
|
||||
|
||||
typedef enum DN_OSW32DllLoadFunctionsResult
|
||||
typedef enum DN_OsW32DllLoadFunctionsResult
|
||||
{
|
||||
DN_OSW32DllLoadFunctionsResult_Ok,
|
||||
DN_OSW32DllLoadFunctionsResult_LoadLibraryFailed,
|
||||
DN_OSW32DllLoadFunctionsResult_FunctionMissing,
|
||||
DN_OsW32DllLoadFunctionsResult_Ok,
|
||||
DN_OsW32DllLoadFunctionsResult_LoadLibraryFailed,
|
||||
DN_OsW32DllLoadFunctionsResult_FunctionMissing,
|
||||
}
|
||||
DN_OSW32DllLoadFunctionsResult;
|
||||
DN_OsW32DllLoadFunctionsResult;
|
||||
|
||||
typedef struct DN_OSW32DllFunction DN_OSW32DllLoadFunction;
|
||||
struct DN_OSW32DllFunction
|
||||
typedef struct DN_OsW32DllFunction DN_OsW32DllFunction;
|
||||
struct DN_OsW32DllFunction
|
||||
{
|
||||
DN_Str8 name;
|
||||
void *func_ptr;
|
||||
};
|
||||
|
||||
typedef struct DN_OSW32DllCore DN_OSW32DllCore;
|
||||
struct DN_OSW32DllCore
|
||||
typedef struct DN_OsW32DllCore DN_OsW32DllCore;
|
||||
struct DN_OsW32DllCore
|
||||
{
|
||||
void* handle;
|
||||
DN_OSW32DllFunction* functions;
|
||||
DN_OsW32DllFunction* functions;
|
||||
DN_USize functions_count;
|
||||
};
|
||||
|
||||
typedef struct DN_OSW32Error DN_OSW32Error;
|
||||
struct DN_OSW32Error
|
||||
typedef struct DN_OsW32Error DN_OsW32Error;
|
||||
struct DN_OsW32Error
|
||||
{
|
||||
unsigned long code;
|
||||
DN_Str8 msg;
|
||||
};
|
||||
|
||||
typedef struct DN_OSW32FolderIteratorW DN_OSW32FolderIteratorW;
|
||||
struct DN_OSW32FolderIteratorW
|
||||
typedef struct DN_OsW32FolderIteratorW DN_OsW32FolderIteratorW;
|
||||
struct DN_OsW32FolderIteratorW
|
||||
{
|
||||
void *handle;
|
||||
DN_Str16 file_name;
|
||||
wchar_t file_name_buf[512];
|
||||
};
|
||||
|
||||
typedef struct DN_OSW32Window DN_OSW32Window;
|
||||
struct DN_OSW32Window
|
||||
typedef struct DN_OsW32Window DN_OsW32Window;
|
||||
struct DN_OsW32Window
|
||||
{
|
||||
HWND hwnd;
|
||||
// NOTE: For windows with custom title bars, this should be the rect in framebuffer units that
|
||||
@@ -55,20 +55,33 @@ struct DN_OSW32Window
|
||||
// those buttons can be handled by your application.
|
||||
DN_Rect custom_title_bar_rect_that_is_draggable;
|
||||
bool custom_title_bar;
|
||||
DN_OSW32Window *next;
|
||||
DN_OsW32Window *next;
|
||||
};
|
||||
|
||||
typedef enum DN_OSW32SyncPrimitiveType
|
||||
typedef struct DN_OsW32TrayIcon DN_OsW32TrayIcon;
|
||||
struct DN_OsW32TrayIcon
|
||||
{
|
||||
DN_OSW32SyncPrimitiveType_Semaphore,
|
||||
DN_OSW32SyncPrimitiveType_Mutex,
|
||||
DN_OSW32SyncPrimitiveType_ConditionVariable,
|
||||
DN_OSW32SyncPrimitiveType_Barrier,
|
||||
}
|
||||
DN_OSW32SyncPrimitiveType;
|
||||
HWND hwnd;
|
||||
UINT id;
|
||||
UINT callback_message_id;
|
||||
UINT taskbar_created_message_id;
|
||||
DN_OsTrayIconCallback *callback;
|
||||
void *user_data;
|
||||
WCHAR tooltip[128];
|
||||
bool init;
|
||||
};
|
||||
|
||||
typedef struct DN_OSW32SyncPrimitive DN_OSW32SyncPrimitive;
|
||||
struct DN_OSW32SyncPrimitive
|
||||
typedef enum DN_OsW32SyncPrimitiveType
|
||||
{
|
||||
DN_OsW32SyncPrimitiveType_Semaphore,
|
||||
DN_OsW32SyncPrimitiveType_Mutex,
|
||||
DN_OsW32SyncPrimitiveType_ConditionVariable,
|
||||
DN_OsW32SyncPrimitiveType_Barrier,
|
||||
}
|
||||
DN_OsW32SyncPrimitiveType;
|
||||
|
||||
typedef struct DN_OsW32SyncPrimitive DN_OsW32SyncPrimitive;
|
||||
struct DN_OsW32SyncPrimitive
|
||||
{
|
||||
union
|
||||
{
|
||||
@@ -78,75 +91,79 @@ struct DN_OSW32SyncPrimitive
|
||||
SYNCHRONIZATION_BARRIER barrier;
|
||||
};
|
||||
|
||||
DN_OSW32SyncPrimitive *next;
|
||||
DN_OsW32SyncPrimitive *next;
|
||||
};
|
||||
|
||||
typedef HRESULT DN_OSW32SetThreadDescriptionFunc (HANDLE hThread, PWSTR const lpThreadDescription);
|
||||
typedef BOOL DN_OSW32SetProcessDpiAwarenessContextFunc(void* value);
|
||||
typedef UINT DN_OSW32GetDpiForWindowFunc (HWND hwnd);
|
||||
typedef HRESULT DN_OSW32GetDpiForMonitorFunc (HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT *dpiX, UINT *dpiY);
|
||||
typedef int DN_OSW32GetSystemMetricsForDpiFunc (int nIndex, UINT dpi);
|
||||
typedef HRESULT DN_OsW32SetThreadDescriptionFunc (HANDLE hThread, PWSTR const lpThreadDescription);
|
||||
typedef BOOL DN_OsW32SetProcessDpiAwarenessContextFunc(void* value);
|
||||
typedef UINT DN_OsW32GetDpiForWindowFunc (HWND hwnd);
|
||||
typedef HRESULT DN_OsW32GetDpiForMonitorFunc (HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT *dpiX, UINT *dpiY);
|
||||
typedef int DN_OsW32GetSystemMetricsForDpiFunc (int nIndex, UINT dpi);
|
||||
|
||||
#define DN_OSW32DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((void*)-4)
|
||||
typedef struct DN_OSW32Core DN_OSW32Core;
|
||||
struct DN_OSW32Core
|
||||
#define DN_OsW32DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((void*)-4)
|
||||
typedef struct DN_OsW32Core DN_OsW32Core;
|
||||
struct DN_OsW32Core
|
||||
{
|
||||
// NOTE: These functions are dynamically loaded because they might not be present on the user's
|
||||
// machine. For example the GetDpiForWindow is Windows 10+ only.
|
||||
DN_OSW32SetThreadDescriptionFunc *set_thread_description;
|
||||
DN_OSW32GetDpiForWindowFunc *get_dpi_for_window;
|
||||
DN_OSW32GetDpiForMonitorFunc *get_dpi_for_monitor;
|
||||
DN_OSW32GetSystemMetricsForDpiFunc *get_system_metrics_for_dpi;
|
||||
DN_OsW32SetThreadDescriptionFunc *set_thread_description;
|
||||
DN_OsW32GetDpiForWindowFunc *get_dpi_for_window;
|
||||
DN_OsW32GetDpiForMonitorFunc *get_dpi_for_monitor;
|
||||
DN_OsW32GetSystemMetricsForDpiFunc *get_system_metrics_for_dpi;
|
||||
|
||||
LARGE_INTEGER qpc_frequency;
|
||||
void* bcrypt_rng_handle;
|
||||
bool bcrypt_init_success;
|
||||
bool sym_initialised;
|
||||
CRITICAL_SECTION sync_primitive_free_list_mutex;
|
||||
DN_OSW32SyncPrimitive* sync_primitive_free_list;
|
||||
DN_OsW32SyncPrimitive* sync_primitive_free_list;
|
||||
|
||||
DN_OSW32Window* windows;
|
||||
DN_OsW32Window* windows;
|
||||
WNDPROC fallback_wnd_proc;
|
||||
DN_OsW32TrayIcon tray_icon;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: DN Win32 book-keeping
|
||||
DN_API void DN_OS_W32Init (DN_OSW32Core *w32);
|
||||
DN_API DN_OSW32Core* DN_OS_W32GetCore ();
|
||||
DN_API DN_OSW32Window* DN_OS_W32WindowFromHwndMaybeAlloc(DN_OSW32Core *w32, HWND hwnd, DN_Arena *arena);
|
||||
DN_API void DN_Os_W32Init (DN_OsW32Core *w32);
|
||||
DN_API DN_OsW32Core* DN_Os_W32GetCore ();
|
||||
DN_API DN_OsW32Window* DN_Os_W32WindowFromHwndMaybeAlloc(DN_OsW32Core *w32, HWND hwnd, DN_Arena *arena);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: Process management
|
||||
DN_API void DN_OS_W32ThreadSetName (DN_Str8 name);
|
||||
DN_API LRESULT __stdcall DN_OS_W32WindowProcCustomTitlebar(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param);
|
||||
DN_API void DN_OS_W32MakeProcessDPIAware ();
|
||||
DN_API void DN_Os_W32ThreadSetName (DN_Str8 name);
|
||||
DN_API LRESULT __stdcall DN_Os_W32WindowProcCustomTitlebarAndTrayIcon(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param);
|
||||
DN_API void DN_Os_W32MakeProcessDPIAware ();
|
||||
DN_API bool DN_Os_W32TrayIconInit (DN_OsWindow *window, DN_U32 icon_id, DN_U32 callback_message, DN_Str8 tooltip, DN_OsTrayIconCallback *callback, void *user_data);
|
||||
DN_API void DN_Os_W32TrayIconDeinit ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: DLL
|
||||
DN_API void DN_OS_W32DllUnload (DN_OSW32DllCore *dll);
|
||||
DN_API DN_OSW32DllLoadFunctionsResult DN_OS_W32DllLoadFunctions (DN_OSW32DllCore *dll, DN_Str8 dll_path);
|
||||
DN_API void DN_Os_W32DllUnload (DN_OsW32DllCore *dll);
|
||||
DN_API DN_OsW32DllLoadFunctionsResult DN_Os_W32DllLoadFunctions (DN_OsW32DllCore *dll, DN_Str8 dll_path);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: Errors
|
||||
DN_API DN_Str16 DN_OS_W32ErrorCodeToMsg16Alloc (DN_U32 error_code);
|
||||
DN_API DN_OSW32Error DN_OS_W32ErrorCodeToMsg (DN_Arena *arena, DN_U32 error_code);
|
||||
DN_API DN_OSW32Error DN_OS_W32ErrorCodeToMsgAlloc (DN_U32 error_code);
|
||||
DN_API DN_OSW32Error DN_OS_W32LastError (DN_Arena *arena);
|
||||
DN_API DN_OSW32Error DN_OS_W32LastErrorAlloc ();
|
||||
DN_API DN_Str16 DN_Os_W32Str16FromErrorCodeToMessageAlloc(DN_U32 error_code);
|
||||
DN_API DN_OsW32Error DN_Os_W32ErrorFromErrorCodeAllocator (DN_Allocator allocator, DN_U32 error_code);
|
||||
DN_API DN_OsW32Error DN_Os_W32ErrorFromLastErrorAllocator (DN_Allocator allocator);
|
||||
DN_API DN_OsW32Error DN_Os_W32ErrorFromLastErrorArena (DN_Arena *arena);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: Windows Str8 <-> Str16
|
||||
DN_API DN_Str16 DN_OS_W32Str8ToStr16 (DN_Arena *arena, DN_Str8 src);
|
||||
DN_API int DN_OS_W32Str8ToStr16Buffer (DN_Str16 src, char *dest, int dest_size);
|
||||
DN_API DN_Str8 DN_OS_W32Str16ToStr8 (DN_Arena *arena, DN_Str16 src);
|
||||
DN_API int DN_OS_W32Str16ToStr8Buffer (DN_Str16 src, char *dest, int dest_size);
|
||||
DN_API DN_Str8 DN_OS_W32Str16ToStr8FromHeap (DN_Str16 src);
|
||||
DN_API int DN_Os_W32Str16FromStr8Buffer (DN_Str8 src, wchar_t *dest, int dest_size);
|
||||
DN_API DN_Str16 DN_Os_W32Str16FromStr8Allocator (DN_Allocator allocator, DN_Str8 src);
|
||||
DN_API DN_Str16 DN_Os_W32Str16FromStr8Arena (DN_Arena *arena, DN_Str8 src);
|
||||
DN_API int DN_Os_W32Str8FromStr16Buffer (DN_Str16 src, char *dest, int dest_size);
|
||||
DN_API DN_Str8 DN_Os_W32Str8FromStr16Heap (DN_Str16 src);
|
||||
DN_API DN_Str8 DN_Os_W32Str8FromStr16Allocator (DN_Allocator allocator, DN_Str16 src);
|
||||
DN_API DN_Str8 DN_Os_W32Str8FromStr16Arena (DN_Arena *arena, DN_Str16 src);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: Path navigation
|
||||
DN_API DN_Str16 DN_OS_W32ExePathW (DN_Arena *arena);
|
||||
DN_API DN_Str16 DN_OS_W32ExeDirW (DN_Arena *arena);
|
||||
DN_API DN_Str8 DN_OS_W32WorkingDir (DN_Arena *arena, DN_Str8 suffix);
|
||||
DN_API DN_Str16 DN_OS_W32WorkingDirW (DN_Arena *arena, DN_Str16 suffix);
|
||||
DN_API bool DN_OS_W32DirWIterate (DN_Str16 path, DN_OSW32FolderIteratorW *it);
|
||||
#endif // !defined(DN_OS_W32_H)
|
||||
DN_API DN_Str16 DN_Os_W32ExePathW (DN_Arena *arena);
|
||||
DN_API DN_Str16 DN_Os_W32ExeDirW (DN_Arena *arena);
|
||||
DN_API DN_Str8 DN_Os_W32WorkingDir (DN_Arena *arena, DN_Str8 suffix);
|
||||
DN_API DN_Str16 DN_Os_W32WorkingDirW (DN_Arena *arena, DN_Str16 suffix);
|
||||
DN_API bool DN_Os_W32DirWIterate (DN_Str16 path, DN_OsW32FolderIteratorW *it);
|
||||
#endif // !defined(DN_Os_W32_H)
|
||||
+565
-21
@@ -14,6 +14,10 @@
|
||||
#pragma comment(lib, "Shell32") // ShellExecuteW
|
||||
#pragma comment(lib, "shlwapi")
|
||||
#pragma comment(lib, "user32")
|
||||
#pragma comment(lib, "pdh") // DN_Os_SysMonitor GPU/thermal counters
|
||||
#pragma comment(lib, "iphlpapi") // DN_Os_SysMonitor network counters
|
||||
#pragma comment(lib, "gdi32") // DN_Os_SysMonitor D3DKMT queries
|
||||
#pragma comment(lib, "powrprof") // DN_Os_SysMonitor CPU clock speed
|
||||
|
||||
// TODO: Technically we only need this library for custom window titlebars to get access to DWM
|
||||
// functions. Otherwise this API surface is not used in the DN OS layer.
|
||||
@@ -24,7 +28,7 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h> // LONG
|
||||
#include <dwmapi.h> // DwmExtendFrameIntoClientArea...
|
||||
#include <bcrypt.h> // DN_OS_SecureRNGBytes -> BCryptOpenAlgorithmProvider ... etc
|
||||
#include <bcrypt.h> // DN_Os_SecureRNGBytes -> BCryptOpenAlgorithmProvider ... etc
|
||||
#include <shellapi.h> // DN_Win_MakeProcessDPIAware -> SetProcessDpiAwareProc
|
||||
#include <ShellScalingApi.h> // MONITOR_DPI_TYPE
|
||||
#include <shlwapi.h> // PathRelativePathTO
|
||||
@@ -34,6 +38,12 @@
|
||||
#include <commdlg.h> // OPENFILENAMEW
|
||||
#include <DbgHelp.h>
|
||||
#include <windowsx.h> // GET_X_PARAM
|
||||
#include <pdh.h> // DN_Os_SysMonitor GPU and thermal counters
|
||||
#include <pdhmsg.h> // PDH status codes
|
||||
#include <iphlpapi.h> // DN_Os_SysMonitor network counters
|
||||
#include <d3dkmthk.h> // DN_Os_SysMonitor GPU temperature
|
||||
#include <winioctl.h> // DN_Os_SysMonitor drive temperatures
|
||||
#include <powrprof.h> // DN_Os_SysMonitor CPU clock speed
|
||||
#else
|
||||
DN_MSVC_WARNING_PUSH
|
||||
DN_MSVC_WARNING_DISABLE(4201) // warning C4201: nonstandard extension used: nameless struct/union
|
||||
@@ -85,6 +95,8 @@
|
||||
// NOTE: shared/winerror.h /////////////////////////////////////////////////////////////////////
|
||||
// NOTE: GetModuleFileNameW
|
||||
#define ERROR_INSUFFICIENT_BUFFER 122L // dderror
|
||||
#define ERROR_SUCCESS 0L
|
||||
#define NO_ERROR 0L
|
||||
|
||||
// NOTE: um/winnls.h ///////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: MultiByteToWideChar
|
||||
@@ -100,11 +112,22 @@
|
||||
typedef long LONG;
|
||||
typedef wchar_t WCHAR; // wc, 16-bit UNICODE character
|
||||
typedef CHAR * NPSTR, *LPSTR, *PSTR;
|
||||
typedef const CHAR * LPCSTR, *PCSTR;
|
||||
typedef WCHAR * NWPSTR, *LPWSTR, *PWSTR;
|
||||
typedef const WCHAR* LPCWSTR, *PCWSTR;
|
||||
typedef long HRESULT;
|
||||
typedef ULONGLONG DWORDLONG;
|
||||
|
||||
#define ANYSIZE_ARRAY 1
|
||||
|
||||
typedef struct _LUID {
|
||||
DWORD LowPart;
|
||||
LONG HighPart;
|
||||
} LUID, *PLUID;
|
||||
|
||||
typedef UINT POWER_INFORMATION_LEVEL;
|
||||
#define ProcessorInformation 11
|
||||
|
||||
// NOTE: VirtualAlloc: Allocation Type
|
||||
#define MEM_RESERVE 0x00002000
|
||||
#define MEM_COMMIT 0x00001000
|
||||
@@ -357,8 +380,10 @@
|
||||
#define SLMFLAG_ALT_INDEX 0x2
|
||||
#define SLMFLAG_NO_SYMBOLS 0x4
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) VOID __stdcall RtlCaptureContext(CONTEXT *ContextRecord);
|
||||
__declspec(dllimport) HANDLE __stdcall GetCurrentProcess(void);
|
||||
__declspec(dllimport) HANDLE __stdcall GetCurrentThread(void);
|
||||
@@ -366,11 +391,15 @@
|
||||
__declspec(dllimport) BOOL __stdcall SymInitialize(HANDLE hProcess, const CHAR* UserSearchPath, BOOL fInvadeProcess);
|
||||
__declspec(dllimport) DWORD64 __stdcall SymLoadModuleEx(HANDLE hProcess, HANDLE hFile, CHAR const *ImageName, CHAR const *ModuleName, DWORD64 BaseOfDll, DWORD DllSize, MODLOAD_DATA *Data, DWORD Flags);
|
||||
__declspec(dllimport) BOOL __stdcall SymUnloadModule64(HANDLE hProcess, DWORD64 BaseOfDll);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/heapapi.h ////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) HANDLE __stdcall HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize);
|
||||
__declspec(dllimport) BOOL __stdcall HeapDestroy(HANDLE hHeap);
|
||||
__declspec(dllimport) VOID * __stdcall HeapAlloc(HANDLE hHeap, DWORD dwFlags,SIZE_T dwBytes);
|
||||
@@ -379,7 +408,9 @@
|
||||
__declspec(dllimport) SIZE_T __stdcall HeapSize(HANDLE hHeap, DWORD dwFlags, VOID const *lpMem);
|
||||
__declspec(dllimport) HANDLE __stdcall GetProcessHeap(VOID);
|
||||
__declspec(dllimport) SIZE_T __stdcall HeapCompact(HANDLE hHeap, DWORD dwFlags);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: shared/windef.h ////////////////////////////////////////////////////////////////////
|
||||
typedef struct tagPOINT
|
||||
@@ -393,23 +424,133 @@
|
||||
};
|
||||
typedef struct HMONITOR__ *HMONITOR;
|
||||
|
||||
// NOTE: shared/guiddef.h //////////////////////////////////////////////////////////////////////
|
||||
typedef struct _GUID {
|
||||
DWORD Data1;
|
||||
WORD Data2;
|
||||
WORD Data3;
|
||||
BYTE Data4[8];
|
||||
} GUID, *LPGUID;
|
||||
|
||||
// NOTE: shared/ifdef.h ////////////////////////////////////////////////////////////////////////
|
||||
#define IF_MAX_STRING_SIZE 256
|
||||
#define IF_MAX_PHYS_ADDRESS_LENGTH 32
|
||||
|
||||
typedef union _NET_LUID_LH {
|
||||
ULONG64 Value;
|
||||
struct {
|
||||
ULONG64 Reserved : 24;
|
||||
ULONG64 NetLuidIndex: 24;
|
||||
ULONG64 IfType : 16;
|
||||
} Info;
|
||||
} NET_LUID_LH, *PNET_LUID_LH;
|
||||
typedef NET_LUID_LH NET_LUID;
|
||||
typedef GUID NET_IF_NETWORK_GUID;
|
||||
typedef ULONG NET_IFINDEX;
|
||||
|
||||
typedef ULONG IF_OPER_STATUS;
|
||||
#define IfOperStatusUp 1
|
||||
|
||||
// NOTE: shared/ipifcons.h /////////////////////////////////////////////////////////////////////
|
||||
typedef ULONG IFTYPE;
|
||||
#define IF_TYPE_SOFTWARE_LOOPBACK 24
|
||||
|
||||
// NOTE: shared/netioapi.h /////////////////////////////////////////////////////////////////////
|
||||
#define ANY_SIZE 1
|
||||
|
||||
typedef struct _MIB_IF_ROW2 {
|
||||
NET_LUID InterfaceLuid;
|
||||
NET_IFINDEX InterfaceIndex;
|
||||
GUID InterfaceGuid;
|
||||
WCHAR Alias[IF_MAX_STRING_SIZE + 1];
|
||||
WCHAR Description[IF_MAX_STRING_SIZE + 1];
|
||||
ULONG PhysicalAddressLength;
|
||||
UCHAR PhysicalAddress[IF_MAX_PHYS_ADDRESS_LENGTH];
|
||||
UCHAR PermanentPhysicalAddress[IF_MAX_PHYS_ADDRESS_LENGTH];
|
||||
ULONG Mtu;
|
||||
IFTYPE Type;
|
||||
ULONG TunnelType;
|
||||
ULONG MediaType;
|
||||
ULONG PhysicalMediumType;
|
||||
ULONG AccessType;
|
||||
ULONG DirectionType;
|
||||
struct {
|
||||
UCHAR HardwareInterface : 1;
|
||||
UCHAR FilterInterface : 1;
|
||||
UCHAR ConnectorPresent : 1;
|
||||
UCHAR NotAuthenticated : 1;
|
||||
UCHAR NotMediaConnected : 1;
|
||||
UCHAR Paused : 1;
|
||||
UCHAR LowPower : 1;
|
||||
UCHAR EndPointInterface : 1;
|
||||
} InterfaceAndOperStatusFlags;
|
||||
IF_OPER_STATUS OperStatus;
|
||||
ULONG AdminStatus;
|
||||
ULONG MediaConnectState;
|
||||
NET_IF_NETWORK_GUID NetworkGuid;
|
||||
ULONG ConnectionType;
|
||||
ULONG64 TransmitLinkSpeed;
|
||||
ULONG64 ReceiveLinkSpeed;
|
||||
ULONG64 InOctets;
|
||||
ULONG64 InUcastPkts;
|
||||
ULONG64 InNUcastPkts;
|
||||
ULONG64 InDiscards;
|
||||
ULONG64 InErrors;
|
||||
ULONG64 InUnknownProtos;
|
||||
ULONG64 InUcastOctets;
|
||||
ULONG64 InMulticastOctets;
|
||||
ULONG64 InBroadcastOctets;
|
||||
ULONG64 OutOctets;
|
||||
ULONG64 OutUcastPkts;
|
||||
ULONG64 OutNUcastPkts;
|
||||
ULONG64 OutDiscards;
|
||||
ULONG64 OutErrors;
|
||||
ULONG64 OutUcastOctets;
|
||||
ULONG64 OutMulticastOctets;
|
||||
ULONG64 OutBroadcastOctets;
|
||||
ULONG64 OutQLen;
|
||||
} MIB_IF_ROW2, *PMIB_IF_ROW2;
|
||||
|
||||
typedef struct _MIB_IF_TABLE2 {
|
||||
ULONG NumEntries;
|
||||
MIB_IF_ROW2 Table[ANY_SIZE];
|
||||
} MIB_IF_TABLE2, *PMIB_IF_TABLE2;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) DWORD __stdcall GetIfTable2 (MIB_IF_TABLE2 **Table);
|
||||
__declspec(dllimport) VOID __stdcall FreeMibTable (VOID *Memory);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: handleapi.h ///////////////////////////////////////////////////////////////////////////
|
||||
#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall CloseHandle(HANDLE hObject);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: consoleapi.h ///////////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall WriteConsoleW(HANDLE hConsoleOutput, const VOID* lpBuffer, DWORD nNumberOfCharsToWrite, DWORD *lpNumberOfCharsWritten, VOID *lpReserved);
|
||||
__declspec(dllimport) BOOL __stdcall AllocConsole(VOID);
|
||||
__declspec(dllimport) BOOL __stdcall FreeConsole(VOID);
|
||||
__declspec(dllimport) BOOL __stdcall AttachConsole(DWORD dwProcessId);
|
||||
__declspec(dllimport) BOOL __stdcall GetConsoleMode(HANDLE hConsoleHandle, DWORD *lpMode);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/minwinbase.h ///////////////////////////////////////////////////////////////////////
|
||||
// NOTE: FindFirstFile
|
||||
@@ -520,21 +661,47 @@
|
||||
// NOTE: CreateProcessW
|
||||
#define STARTF_USESTDHANDLES 0x00000100
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall MoveFileExW (const WCHAR *lpExistingFileName, const WCHAR *lpNewFileName, DWORD dwFlags);
|
||||
__declspec(dllimport) BOOL __stdcall CopyFileW (const WCHAR *lpExistingFileName, const WCHAR *lpNewFileName, BOOL bFailIfExists);
|
||||
__declspec(dllimport) HANDLE __stdcall CreateSemaphoreA(SECURITY_ATTRIBUTES *lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, const CHAR *lpName);
|
||||
__declspec(dllimport) DWORD __stdcall FormatMessageW (DWORD dwFlags, VOID const *lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list *Arguments);
|
||||
__declspec(dllimport) HLOCAL __stdcall LocalFree (HLOCAL hMem);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/stringapiset.h /////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) int __stdcall MultiByteToWideChar(UINT CodePage, DWORD dwFlags, const CHAR *lpMultiByteStr, int cbMultiByte, WCHAR *lpWideCharStr, int cchWideChar);
|
||||
__declspec(dllimport) int __stdcall WideCharToMultiByte(UINT CodePage, DWORD dwFlags, const WCHAR *lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, const CHAR *lpDefaultChar, BOOL *lpUsedDefaultChar);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/winbase.h //////////////////////////////////////////////////////////////////////////
|
||||
#define DRIVE_UNKNOWN 0
|
||||
#define DRIVE_NO_ROOT_DIR 1
|
||||
#define DRIVE_REMOVABLE 2
|
||||
#define DRIVE_FIXED 3
|
||||
#define DRIVE_REMOTE 4
|
||||
#define DRIVE_CDROM 5
|
||||
#define DRIVE_RAMDISK 6
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) int __stdcall lstrlenW(LPCWSTR lpString);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/fileapi.h //////////////////////////////////////////////////////////////////////////
|
||||
#define INVALID_FILE_SIZE ((DWORD)0xFFFFFFFF)
|
||||
@@ -556,8 +723,10 @@
|
||||
DWORD nFileSizeLow;
|
||||
} WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall FlushFileBuffers (HANDLE hFile);
|
||||
__declspec(dllimport) BOOL __stdcall CreateDirectoryW (const WCHAR *lpPathName, SECURITY_ATTRIBUTES *lpSecurityAttributes);
|
||||
__declspec(dllimport) BOOL __stdcall RemoveDirectoryW (const WCHAR *lpPathName);
|
||||
@@ -573,18 +742,27 @@
|
||||
__declspec(dllimport) BOOL __stdcall ReadFile (HANDLE hFile, VOID *lpBuffer, DWORD nNumberOfBytesToRead, DWORD *lpNumberOfBytesRead, OVERLAPPED *lpOverlapped);
|
||||
__declspec(dllimport) BOOL __stdcall WriteFile (HANDLE hFile, const VOID *lpBuffer, DWORD nNumberOfBytesToWrite, DWORD *lpNumberOfBytesWritten, OVERLAPPED *lpOverlapped);
|
||||
__declspec(dllimport) BOOL __stdcall GetDiskFreeSpaceExW (WCHAR const *lpDirectoryName, ULARGE_INTEGER *lpFreeBytesAvailableToCaller, ULARGE_INTEGER *lpTotalNumberOfBytes, ULARGE_INTEGER *lpTotalNumberOfFreeBytes);
|
||||
__declspec(dllimport) UINT __stdcall GetDriveTypeW (LPCWSTR lpRootPathName);
|
||||
__declspec(dllimport) DWORD __stdcall GetLogicalDriveStringsW (DWORD nBufferLength, LPWSTR lpBuffer);
|
||||
__declspec(dllimport) BOOL __stdcall GetVolumeInformationW (LPCWSTR lpRootPathName, LPWSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, DWORD *lpVolumeSerialNumber, DWORD *lpMaximumComponentLength, DWORD *lpFileSystemFlags, LPWSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/processenv.h ///////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) DWORD __stdcall GetCurrentDirectoryW (DWORD nBufferLength, WCHAR *lpBuffer);
|
||||
__declspec(dllimport) HANDLE __stdcall GetStdHandle (DWORD nStdHandle);
|
||||
__declspec(dllimport) WCHAR* __stdcall GetEnvironmentStringsW ();
|
||||
__declspec(dllimport) BOOL __stdcall FreeEnvironmentStringsW(WCHAR *penv);
|
||||
__declspec(dllimport) DWORD __stdcall GetEnvironmentVariableW(WCHAR const *lpName, WCHAR *lpBuffer, DWORD nSize);
|
||||
__declspec(dllimport) BOOL __stdcall SetEnvironmentVariableW(WCHAR const *lpName, WCHAR const *lpValue);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/psapi.h ////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct _PROCESS_MEMORY_COUNTERS {
|
||||
@@ -618,10 +796,14 @@
|
||||
} PROCESS_MEMORY_COUNTERS_EX2;
|
||||
typedef PROCESS_MEMORY_COUNTERS_EX2 *PPROCESS_MEMORY_COUNTERS_EX2;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall GetProcessMemoryInfo(HANDLE Process, PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/sysinfoapi.h ///////////////////////////////////////////////////////////////////////
|
||||
typedef struct _SYSTEM_INFO {
|
||||
@@ -655,14 +837,18 @@
|
||||
DWORDLONG ullAvailExtendedVirtual;
|
||||
} MEMORYSTATUSEX, *LPMEMORYSTATUSEX;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall GlobalMemoryStatusEx (LPMEMORYSTATUSEX lpBuffer);
|
||||
__declspec(dllimport) VOID __stdcall GetSystemInfo (SYSTEM_INFO *lpSystemInfo);
|
||||
__declspec(dllimport) VOID __stdcall GetSystemTime (SYSTEMTIME *lpSystemTime);
|
||||
__declspec(dllimport) VOID __stdcall GetSystemTimeAsFileTime(FILETIME *lpSystemTimeAsFileTime);
|
||||
__declspec(dllimport) VOID __stdcall GetLocalTime (SYSTEMTIME *lpSystemTime);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/timezoneapi.h //////////////////////////////////////////////////////////////////////
|
||||
typedef struct _TIME_ZONE_INFORMATION {
|
||||
@@ -675,12 +861,16 @@
|
||||
LONG DaylightBias;
|
||||
} TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall FileTimeToSystemTime (const FILETIME* lpFileTime, SYSTEMTIME *lpSystemTime);
|
||||
__declspec(dllimport) BOOL __stdcall SystemTimeToFileTime (const SYSTEMTIME* lpSystemTime, FILETIME *lpFileTime);
|
||||
__declspec(dllimport) BOOL __stdcall TzSpecificLocalTimeToSystemTime(const TIME_ZONE_INFORMATION* lpTimeZoneInformation, const SYSTEMTIME* lpLocalTime, const LPSYSTEMTIME lpUniversalTime);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: shared/windef.h ///////////////////////////////////////////////////////////////////////
|
||||
typedef struct tagRECT {
|
||||
@@ -767,6 +957,16 @@
|
||||
#define WS_SIZEBOX WS_THICKFRAME
|
||||
#define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW
|
||||
|
||||
#define WS_EX_LAYERED 0x00080000L
|
||||
#define WS_EX_TOOLWINDOW 0x00000080L
|
||||
#define WS_EX_TRANSPARENT 0x00000020L
|
||||
#define WS_EX_NOACTIVATE 0x08000000L
|
||||
#define WS_EX_APPWINDOW 0x00040000L
|
||||
|
||||
#define HWND_TOPMOST ((HWND)(-1))
|
||||
#define HWND_NOTOPMOST ((HWND)(-2))
|
||||
|
||||
|
||||
#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | \
|
||||
WS_CAPTION | \
|
||||
WS_SYSMENU | \
|
||||
@@ -808,6 +1008,7 @@
|
||||
#define GWLP_WNDPROC (-4)
|
||||
|
||||
#define GWL_STYLE (-16)
|
||||
#define GWL_EXSTYLE (-20)
|
||||
|
||||
#define WS_OVERLAPPED 0x00000000L
|
||||
|
||||
@@ -846,29 +1047,282 @@
|
||||
#define HTHELP 21
|
||||
#endif /* WINVER >= 0x0400 */
|
||||
|
||||
#define WM_NULL 0x0000
|
||||
#define WM_GETICON 0x007F
|
||||
#define WM_LBUTTONDOWN 0x0201
|
||||
#define WM_LBUTTONUP 0x0202
|
||||
#define WM_LBUTTONDBLCLK 0x0203
|
||||
#define WM_RBUTTONDOWN 0x0204
|
||||
#define WM_RBUTTONUP 0x0205
|
||||
#define WM_RBUTTONDBLCLK 0x0206
|
||||
#define WM_APP 0x8000
|
||||
|
||||
#define ICON_SMALL 0
|
||||
#define ICON_BIG 1
|
||||
#define IDI_APPLICATION ((LPCWSTR)(ULONG_PTR)32512)
|
||||
|
||||
#define NIM_ADD 0x00000000
|
||||
#define NIM_MODIFY 0x00000001
|
||||
#define NIM_DELETE 0x00000002
|
||||
|
||||
#define NIF_MESSAGE 0x00000001
|
||||
#define NIF_ICON 0x00000002
|
||||
#define NIF_TIP 0x00000004
|
||||
|
||||
#define MF_STRING 0x00000000
|
||||
#define MF_SEPARATOR 0x00000800
|
||||
|
||||
#define TPM_RIGHTBUTTON 0x0002
|
||||
#define TPM_NONOTIFY 0x0080
|
||||
#define TPM_RETURNCMD 0x0100
|
||||
|
||||
struct HICON__ { int unused; };
|
||||
typedef struct HICON__ *HICON;
|
||||
struct HMENU__ { int unused; };
|
||||
typedef struct HMENU__ *HMENU;
|
||||
|
||||
typedef struct NOTIFYICONDATAW
|
||||
{
|
||||
DWORD cbSize;
|
||||
HWND hWnd;
|
||||
UINT uID;
|
||||
UINT uFlags;
|
||||
UINT uCallbackMessage;
|
||||
HICON hIcon;
|
||||
WCHAR szTip[128];
|
||||
DWORD dwState;
|
||||
DWORD dwStateMask;
|
||||
WCHAR szInfo[256];
|
||||
UINT uVersion;
|
||||
WCHAR szInfoTitle[64];
|
||||
DWORD dwInfoFlags;
|
||||
} NOTIFYICONDATAW, *PNOTIFYICONDATAW;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
__declspec(dllimport) BOOL __stdcall GetWindowRect (HWND hWnd, RECT *lpRect);
|
||||
__declspec(dllimport) BOOL __stdcall SetWindowPos (HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
|
||||
__declspec(dllimport) UINT __stdcall GetWindowModuleFileNameA(HWND hwnd, LPSTR pszFileName, UINT cchFileNameMax);
|
||||
__declspec(dllimport) BOOL __stdcall ShowWindow (HWND hWnd, int nCmdShow);
|
||||
__declspec(dllimport) BOOL __stdcall GetWindowPlacement (HWND hWnd, WINDOWPLACEMENT *lpwndpl);
|
||||
__declspec(dllimport) BOOL __stdcall IsIconic (HWND hWnd);
|
||||
__declspec(dllimport) BOOL __stdcall IsZoomed (HWND hWnd);
|
||||
__declspec(dllimport) BOOL __stdcall BringWindowToTop (HWND hWnd);
|
||||
__declspec(dllimport) BOOL __stdcall SetForegroundWindow (HWND hWnd);
|
||||
__declspec(dllimport) HWND __stdcall SetFocus (HWND hWnd);
|
||||
__declspec(dllimport) HWND __stdcall GetForegroundWindow ();
|
||||
__declspec(dllimport) BOOL __stdcall SetWindowTextW (HWND hWnd, LPCWSTR lpString);
|
||||
__declspec(dllimport) UINT __stdcall GetDoubleClickTime ();
|
||||
__declspec(dllimport) LONG_PTR __stdcall GetWindowLongPtrW (HWND hWnd, int nIndex);
|
||||
__declspec(dllimport) LONG_PTR __stdcall SetWindowLongPtrW (HWND hWnd, int nIndex, LONG_PTR dwNewLong);
|
||||
__declspec(dllimport) LONG __stdcall GetWindowLongW (HWND hWnd, int nIndex);
|
||||
__declspec(dllimport) LRESULT __stdcall CallWindowProcW (WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
__declspec(dllimport) int __stdcall GetSystemMetrics (int nIndex);
|
||||
__declspec(dllimport) BOOL __stdcall ScreenToClient (HWND hWnd, LPPOINT lpPoint);
|
||||
__declspec(dllimport) LRESULT __stdcall DefWindowProcW (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall GetWindowRect (HWND hWnd, RECT *lpRect);
|
||||
__declspec(dllimport) BOOL __stdcall SetWindowPos (HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
|
||||
__declspec(dllimport) UINT __stdcall GetWindowModuleFileNameA (HWND hwnd, LPSTR pszFileName, UINT cchFileNameMax);
|
||||
__declspec(dllimport) BOOL __stdcall ShowWindow (HWND hWnd, int nCmdShow);
|
||||
__declspec(dllimport) BOOL __stdcall GetWindowPlacement (HWND hWnd, WINDOWPLACEMENT *lpwndpl);
|
||||
__declspec(dllimport) BOOL __stdcall IsIconic (HWND hWnd);
|
||||
__declspec(dllimport) BOOL __stdcall IsZoomed (HWND hWnd);
|
||||
__declspec(dllimport) BOOL __stdcall IsWindowVisible (HWND hWnd);
|
||||
__declspec(dllimport) BOOL __stdcall BringWindowToTop (HWND hWnd);
|
||||
__declspec(dllimport) BOOL __stdcall SetForegroundWindow (HWND hWnd);
|
||||
__declspec(dllimport) HWND __stdcall SetFocus (HWND hWnd);
|
||||
__declspec(dllimport) HWND __stdcall GetForegroundWindow ();
|
||||
__declspec(dllimport) BOOL __stdcall SetWindowTextW (HWND hWnd, LPCWSTR lpString);
|
||||
__declspec(dllimport) UINT __stdcall GetDoubleClickTime ();
|
||||
__declspec(dllimport) int __stdcall wsprintfW (LPWSTR lpOut, LPCWSTR lpFmt, ...);
|
||||
__declspec(dllimport) LONG_PTR __stdcall GetWindowLongPtrW (HWND hWnd, int nIndex);
|
||||
__declspec(dllimport) LONG_PTR __stdcall SetWindowLongPtrW (HWND hWnd, int nIndex, LONG_PTR dwNewLong);
|
||||
__declspec(dllimport) LONG __stdcall GetWindowLongW (HWND hWnd, int nIndex);
|
||||
__declspec(dllimport) LRESULT __stdcall CallWindowProcW (WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
__declspec(dllimport) int __stdcall GetSystemMetrics (int nIndex);
|
||||
__declspec(dllimport) BOOL __stdcall GetCursorPos (LPPOINT lpPoint);
|
||||
__declspec(dllimport) BOOL __stdcall ScreenToClient (HWND hWnd, LPPOINT lpPoint);
|
||||
__declspec(dllimport) LRESULT __stdcall DefWindowProcW (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
__declspec(dllimport) LRESULT __stdcall SendMessageW (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
__declspec(dllimport) BOOL __stdcall PostMessageW (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
__declspec(dllimport) HICON __stdcall LoadIconW (HINSTANCE hInstance, LPCWSTR lpIconName);
|
||||
__declspec(dllimport) HMENU __stdcall CreatePopupMenu ();
|
||||
__declspec(dllimport) BOOL __stdcall DestroyMenu (HMENU hMenu);
|
||||
__declspec(dllimport) BOOL __stdcall AppendMenuW (HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem);
|
||||
__declspec(dllimport) BOOL __stdcall TrackPopupMenu (HMENU hMenu, UINT uFlags, int x, int y, int nReserved, HWND hWnd, const RECT *prcRect);
|
||||
__declspec(dllimport) UINT __stdcall RegisterWindowMessageW (LPCWSTR lpString);
|
||||
__declspec(dllimport) BOOL __stdcall Shell_NotifyIconW (DWORD dwMessage, PNOTIFYICONDATAW lpData);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/powerbase.h ////////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) LONG __stdcall CallNtPowerInformation(UINT InformationLevel, VOID *InputBuffer, ULONG InputBufferLength, VOID *OutputBuffer, ULONG OutputBufferLength);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/pdh.h //////////////////////////////////////////////////////////////////////////////
|
||||
typedef LONG PDH_STATUS;
|
||||
typedef HANDLE PDH_HQUERY;
|
||||
typedef HANDLE PDH_HCOUNTER;
|
||||
|
||||
typedef struct _PDH_FMT_COUNTERVALUE {
|
||||
DWORD CStatus;
|
||||
union {
|
||||
LONG longValue;
|
||||
double doubleValue;
|
||||
LONGLONG largeValue;
|
||||
LPCSTR AnsiStringValue;
|
||||
LPCWSTR WideStringValue;
|
||||
};
|
||||
} PDH_FMT_COUNTERVALUE;
|
||||
|
||||
typedef struct _PDH_FMT_COUNTERVALUE_ITEM_W {
|
||||
LPWSTR szName;
|
||||
PDH_FMT_COUNTERVALUE FmtValue;
|
||||
} PDH_FMT_COUNTERVALUE_ITEM_W, *PPDH_FMT_COUNTERVALUE_ITEM_W;
|
||||
|
||||
#define PDH_FMT_DOUBLE 0x00000200
|
||||
|
||||
// NOTE: um/pdhmsg.h ///////////////////////////////////////////////////////////////////////////
|
||||
#define PDH_CSTATUS_VALID_DATA 0x00000000L
|
||||
#define PDH_CSTATUS_NEW_DATA 0x00000001L
|
||||
#define PDH_MORE_DATA 0x800007D2L
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) PDH_STATUS __stdcall PdhOpenQueryW (LPCWSTR szDataSource, DWORD_PTR dwUserData, PDH_HQUERY *phQuery);
|
||||
__declspec(dllimport) PDH_STATUS __stdcall PdhAddEnglishCounterW (PDH_HQUERY hQuery, LPCWSTR szFullCounterPath, DWORD_PTR dwUserData, PDH_HCOUNTER *phCounter);
|
||||
__declspec(dllimport) PDH_STATUS __stdcall PdhCollectQueryData (PDH_HQUERY hQuery);
|
||||
__declspec(dllimport) PDH_STATUS __stdcall PdhGetFormattedCounterArrayW(PDH_HCOUNTER hCounter, DWORD dwFormat, DWORD *lpdwBufferSize, DWORD *lpdwItemCount, PPDH_FMT_COUNTERVALUE_ITEM_W ItemBuffer);
|
||||
__declspec(dllimport) PDH_STATUS __stdcall PdhCloseQuery (PDH_HQUERY hQuery);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/ioapiset.h /////////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, VOID *lpInBuffer, DWORD nInBufferSize, VOID *lpOutBuffer, DWORD nOutBufferSize, DWORD *lpBytesReturned, OVERLAPPED *lpOverlapped);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/winioctl.h /////////////////////////////////////////////////////////////////////////
|
||||
typedef enum _STORAGE_PROPERTY_ID {
|
||||
StorageDeviceTemperatureProperty = 52,
|
||||
} STORAGE_PROPERTY_ID, *PSTORAGE_PROPERTY_ID;
|
||||
|
||||
typedef enum _STORAGE_QUERY_TYPE {
|
||||
PropertyStandardQuery = 0,
|
||||
} STORAGE_QUERY_TYPE, *PSTORAGE_QUERY_TYPE;
|
||||
|
||||
typedef struct _STORAGE_PROPERTY_QUERY {
|
||||
STORAGE_PROPERTY_ID PropertyId;
|
||||
STORAGE_QUERY_TYPE QueryType;
|
||||
BYTE AdditionalParameters[1];
|
||||
} STORAGE_PROPERTY_QUERY, *PSTORAGE_PROPERTY_QUERY;
|
||||
|
||||
typedef struct _STORAGE_TEMPERATURE_INFO {
|
||||
WORD Index;
|
||||
SHORT Temperature;
|
||||
SHORT OverThreshold;
|
||||
SHORT UnderThreshold;
|
||||
UCHAR OverThresholdChangable;
|
||||
UCHAR UnderThresholdChangable;
|
||||
UCHAR EventGenerated;
|
||||
BYTE Reserved0;
|
||||
DWORD Reserved1;
|
||||
} STORAGE_TEMPERATURE_INFO, *PSTORAGE_TEMPERATURE_INFO;
|
||||
|
||||
typedef struct _STORAGE_TEMPERATURE_DATA_DESCRIPTOR {
|
||||
DWORD Version;
|
||||
DWORD Size;
|
||||
SHORT CriticalTemperature;
|
||||
SHORT WarningTemperature;
|
||||
WORD InfoCount;
|
||||
BYTE Reserved0[2];
|
||||
DWORD Reserved1[2];
|
||||
STORAGE_TEMPERATURE_INFO TemperatureInfo[ANYSIZE_ARRAY];
|
||||
} STORAGE_TEMPERATURE_DATA_DESCRIPTOR, *PSTORAGE_TEMPERATURE_DATA_DESCRIPTOR;
|
||||
|
||||
typedef struct _DISK_EXTENT {
|
||||
DWORD DiskNumber;
|
||||
LARGE_INTEGER StartingOffset;
|
||||
LARGE_INTEGER ExtentLength;
|
||||
} DISK_EXTENT, *PDISK_EXTENT;
|
||||
|
||||
typedef struct _VOLUME_DISK_EXTENTS {
|
||||
DWORD NumberOfDiskExtents;
|
||||
DISK_EXTENT Extents[ANYSIZE_ARRAY];
|
||||
} VOLUME_DISK_EXTENTS, *PVOLUME_DISK_EXTENTS;
|
||||
|
||||
#define IOCTL_STORAGE_QUERY_PROPERTY 0x002D1400
|
||||
#define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS 0x00560000
|
||||
|
||||
// NOTE: shared/d3dkmthk.h /////////////////////////////////////////////////////////////////////
|
||||
typedef UINT D3DKMT_HANDLE;
|
||||
|
||||
#define KMTQAITYPE_ADAPTERREGISTRYINFO 8
|
||||
#define KMTQAITYPE_NODEPERFDATA 61
|
||||
#define KMTQAITYPE_ADAPTERPERFDATA 62
|
||||
|
||||
typedef struct _D3DKMT_ADAPTERINFO {
|
||||
D3DKMT_HANDLE hAdapter;
|
||||
LUID AdapterLuid;
|
||||
ULONG NumOfSources;
|
||||
BOOL bPrecisePresentRegionsPreferred;
|
||||
} D3DKMT_ADAPTERINFO, *PD3DKMT_ADAPTERINFO;
|
||||
|
||||
typedef struct _D3DKMT_ENUMADAPTERS2 {
|
||||
ULONG NumAdapters;
|
||||
D3DKMT_ADAPTERINFO *pAdapters;
|
||||
} D3DKMT_ENUMADAPTERS2, *PD3DKMT_ENUMADAPTERS2;
|
||||
|
||||
typedef struct _D3DKMT_QUERYADAPTERINFO {
|
||||
D3DKMT_HANDLE hAdapter;
|
||||
UINT Type;
|
||||
VOID *pPrivateDriverData;
|
||||
UINT PrivateDriverDataSize;
|
||||
} D3DKMT_QUERYADAPTERINFO, *PD3DKMT_QUERYADAPTERINFO;
|
||||
|
||||
typedef struct _D3DKMT_ADAPTER_PERFDATA {
|
||||
UINT PhysicalAdapterIndex;
|
||||
ULONGLONG MemoryFrequency;
|
||||
ULONGLONG MaxMemoryFrequency;
|
||||
ULONGLONG MaxMemoryFrequencyOC;
|
||||
ULONGLONG MemoryBandwidth;
|
||||
ULONGLONG PCIEBandwidth;
|
||||
ULONG FanRPM;
|
||||
ULONG Power;
|
||||
ULONG Temperature;
|
||||
UCHAR PowerStateOverride;
|
||||
} D3DKMT_ADAPTER_PERFDATA, *PD3DKMT_ADAPTER_PERFDATA;
|
||||
|
||||
typedef struct _D3DKMT_ADAPTERREGISTRYINFO {
|
||||
WCHAR AdapterString[MAX_PATH];
|
||||
WCHAR BiosString[MAX_PATH];
|
||||
WCHAR DacType[MAX_PATH];
|
||||
WCHAR ChipType[MAX_PATH];
|
||||
} D3DKMT_ADAPTERREGISTRYINFO, *PD3DKMT_ADAPTERREGISTRYINFO;
|
||||
|
||||
typedef struct _D3DKMT_NODE_PERFDATA {
|
||||
UINT NodeOrdinal;
|
||||
UINT PhysicalAdapterIndex;
|
||||
ULONGLONG Frequency;
|
||||
ULONGLONG MaxFrequency;
|
||||
ULONGLONG MaxFrequencyOC;
|
||||
ULONG Voltage;
|
||||
ULONG VoltageMax;
|
||||
ULONG VoltageMaxOC;
|
||||
ULONGLONG MaxTransitionLatency;
|
||||
} D3DKMT_NODE_PERFDATA, *PD3DKMT_NODE_PERFDATA;
|
||||
|
||||
typedef struct _D3DKMT_CLOSEADAPTER {
|
||||
D3DKMT_HANDLE hAdapter;
|
||||
} D3DKMT_CLOSEADAPTER, *PD3DKMT_CLOSEADAPTER;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) LONG __stdcall D3DKMTEnumAdapters2 (D3DKMT_ENUMADAPTERS2 *unnamedParam1);
|
||||
__declspec(dllimport) LONG __stdcall D3DKMTQueryAdapterInfo (D3DKMT_QUERYADAPTERINFO *unnamedParam1);
|
||||
__declspec(dllimport) LONG __stdcall D3DKMTCloseAdapter (D3DKMT_CLOSEADAPTER const *unnamedParam1);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/dwmapi.h //////////////////////////////////////////////////////////////////////////
|
||||
typedef struct _MARGINS
|
||||
@@ -879,10 +1333,14 @@
|
||||
int cyBottomHeight; // height of bottom border that retains its size
|
||||
} MARGINS, *PMARGINS;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) HRESULT __stdcall DwmExtendFrameIntoClientArea(HWND hWnd, const MARGINS* pMarInset);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/wininet.h //////////////////////////////////////////////////////////////////////////
|
||||
typedef WORD INTERNET_PORT;
|
||||
@@ -1115,8 +1573,10 @@
|
||||
DWORD dwStatusInformationLength
|
||||
);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) HINTERNET __stdcall WinHttpOpen(WCHAR const *pszAgentW, DWORD dwAccessType, WCHAR const *pszProxyW, WCHAR const *pszProxyBypassW, DWORD dwFlags);
|
||||
__declspec(dllimport) BOOL __stdcall WinHttpCloseHandle(HINTERNET hInternet);
|
||||
__declspec(dllimport) HINTERNET __stdcall WinHttpConnect(HINTERNET hSession, WCHAR const *pswzServerName, INTERNET_PORT nServerPort, DWORD dwReserved);
|
||||
@@ -1133,7 +1593,9 @@
|
||||
__declspec(dllimport) BOOL __stdcall WinHttpQueryHeaders(HINTERNET hRequest, DWORD dwInfoLevel, WCHAR const *pwszName, VOID *lpBuffer, DWORD *lpdwBufferLength, DWORD *lpdwIndex);
|
||||
__declspec(dllimport) BOOL __stdcall WinHttpReceiveResponse(HINTERNET hRequest, VOID *lpReserved);
|
||||
__declspec(dllimport) WINHTTP_STATUS_CALLBACK __stdcall WinHttpSetStatusCallback(HINTERNET hInternet, WINHTTP_STATUS_CALLBACK lpfnInternetCallback, DWORD dwNotificationFlags, DWORD_PTR dwReserved);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/DbgHelp.h //////////////////////////////////////////////////////////////////////////
|
||||
#define SYMOPT_CASE_INSENSITIVE 0x00000001
|
||||
@@ -1250,31 +1712,43 @@
|
||||
typedef DWORD64(__stdcall GET_MODULE_BASE_ROUTINE64)(HANDLE hProcess, DWORD64 Address);
|
||||
typedef DWORD64(__stdcall TRANSLATE_ADDRESS_ROUTINE64)(HANDLE hProcess, HANDLE hThread, ADDRESS64 *lpaddr);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall StackWalk64 (DWORD MachineType, HANDLE hProcess, HANDLE hThread, STACKFRAME64 *StackFrame, VOID *ContextRecord, READ_PROCESS_MEMORY_ROUTINE64 *ReadMemoryRoutine, FUNCTION_TABLE_ACCESS_ROUTINE64 *FunctionTableAccessRoutine, GET_MODULE_BASE_ROUTINE64 *GetModuleBaseRoutine, TRANSLATE_ADDRESS_ROUTINE64 *TranslateAddress);
|
||||
__declspec(dllimport) BOOL __stdcall SymFromAddrW (HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, SYMBOL_INFOW *Symbol);
|
||||
__declspec(dllimport) VOID * __stdcall SymFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase);
|
||||
__declspec(dllimport) BOOL __stdcall SymGetLineFromAddrW64 (HANDLE hProcess, DWORD64 dwAddr, DWORD *pdwDisplacement, IMAGEHLP_LINEW64 *Line);
|
||||
__declspec(dllimport) DWORD64 __stdcall SymGetModuleBase64 (HANDLE hProcess, DWORD64 qwAddr);
|
||||
__declspec(dllimport) BOOL __stdcall SymRefreshModuleList (HANDLE hProcess);
|
||||
#if defined(__cplusplus)
|
||||
};
|
||||
#endif
|
||||
|
||||
// NOTE: um/errhandlingapi.h ///////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) DWORD __stdcall GetLastError(VOID);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/libloaderapi.h /////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) HMODULE __stdcall LoadLibraryA (const CHAR *lpLibFileName);
|
||||
__declspec(dllimport) BOOL __stdcall FreeLibrary (HMODULE hLibModule);
|
||||
__declspec(dllimport) void * __stdcall GetProcAddress (HMODULE hModule, const CHAR *lpProcName);
|
||||
__declspec(dllimport) HMODULE __stdcall GetModuleHandleA (const CHAR *lpModuleName);
|
||||
__declspec(dllimport) DWORD __stdcall GetModuleFileNameW(HMODULE hModule, WCHAR *lpFilename, DWORD nSize);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/synchapi.h /////////////////////////////////////////////////////////////////////////
|
||||
typedef RTL_CONDITION_VARIABLE CONDITION_VARIABLE, *PCONDITION_VARIABLE;
|
||||
@@ -1287,8 +1761,10 @@
|
||||
#define SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY 0x02
|
||||
#define SYNCHRONIZATION_BARRIER_FLAGS_NO_DELETE 0x04
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) VOID __stdcall InitializeConditionVariable (CONDITION_VARIABLE *ConditionVariable);
|
||||
__declspec(dllimport) VOID __stdcall WakeConditionVariable (CONDITION_VARIABLE *ConditionVariable);
|
||||
__declspec(dllimport) VOID __stdcall WakeAllConditionVariable (CONDITION_VARIABLE *ConditionVariable);
|
||||
@@ -1310,14 +1786,20 @@
|
||||
__declspec(dllimport) BOOL __stdcall EnterSynchronizationBarrier (SYNCHRONIZATION_BARRIER *lpBarrier, DWORD dwFlags);
|
||||
__declspec(dllimport) BOOL __stdcall InitializeSynchronizationBarrier (SYNCHRONIZATION_BARRIER *lpBarrier, LONG lTotalThreads, LONG lSpinCount);
|
||||
__declspec(dllimport) BOOL __stdcall DeleteSynchronizationBarrier (SYNCHRONIZATION_BARRIER *lpBarrier);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/profileapi.h ///////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall QueryPerformanceCounter (LARGE_INTEGER* lpPerformanceCount);
|
||||
__declspec(dllimport) BOOL __stdcall QueryPerformanceFrequency(LARGE_INTEGER* lpFrequency);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/processthreadsapi.h ////////////////////////////////////////////////////////////////
|
||||
typedef struct _PROCESS_INFORMATION {
|
||||
@@ -1353,57 +1835,86 @@
|
||||
);
|
||||
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall CreateProcessW (WCHAR const *lpApplicationName, WCHAR *lpCommandLine, SECURITY_ATTRIBUTES *lpProcessAttributes, SECURITY_ATTRIBUTES *lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, VOID *lpEnvironment, WCHAR const *lpCurrentDirectory, STARTUPINFOW *lpStartupInfo, PROCESS_INFORMATION *lpProcessInformation);
|
||||
__declspec(dllimport) HANDLE __stdcall CreateThread (SECURITY_ATTRIBUTES *lpThreadAttributes, SIZE_T dwStackSize, PTHREAD_START_ROUTINE lpStartAddress, VOID *lpParameter, DWORD dwCreationFlags, DWORD *lpThreadId);
|
||||
__declspec(dllimport) DWORD __stdcall GetCurrentThreadId(VOID);
|
||||
__declspec(dllimport) BOOL __stdcall GetSystemTimes (LPFILETIME lpIdleTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
|
||||
__declspec(dllimport) BOOL __stdcall GetExitCodeProcess(HANDLE hProcess, DWORD *lpExitCode);
|
||||
__declspec(dllimport) void __stdcall ExitProcess (UINT uExitCode);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/memoryapi.h ////////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) VOID * __stdcall VirtualAlloc (VOID *lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
|
||||
__declspec(dllimport) BOOL __stdcall VirtualProtect(VOID *lpAddress, SIZE_T dwSize, DWORD flNewProtect, DWORD *lpflOldProtect);
|
||||
__declspec(dllimport) BOOL __stdcall VirtualFree (VOID *lpAddress, SIZE_T dwSize, DWORD dwFreeType);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: shared/bcrypt.h ///////////////////////////////////////////////////////////////////////
|
||||
typedef VOID *BCRYPT_ALG_HANDLE;
|
||||
typedef LONG NTSTATUS;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) NTSTATUS __stdcall BCryptOpenAlgorithmProvider(BCRYPT_ALG_HANDLE *phAlgorithm, const WCHAR *pszAlgId, const WCHAR *pszImplementation, ULONG dwFlags);
|
||||
__declspec(dllimport) NTSTATUS __stdcall BCryptGenRandom (BCRYPT_ALG_HANDLE hAlgorithm, UCHAR *pbBuffer, ULONG cbBuffer, ULONG dwFlags);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/shellapi.h /////////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) HINSTANCE __stdcall ShellExecuteW(HWND hwnd, WCHAR const *lpOperation, WCHAR const *lpFile, WCHAR const *lpParameters, WCHAR const *lpDirectory, INT nShowCmd);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/debugapi.h /////////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall IsDebuggerPresent();
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/namedpipeapi.h /////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall CreatePipe (HANDLE *hReadPipe, HANDLE *hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize);
|
||||
__declspec(dllimport) BOOL __stdcall PeekNamedPipe(HANDLE hNamedPipe, VOID *lpBuffer, DWORD nBufferSize, DWORD *lpBytesRead, DWORD *lpTotalBytesAvail, DWORD *lpBytesLeftThisMessage);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/handleapi.h ////////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall SetHandleInformation(HANDLE hObject, DWORD dwMask, DWORD dwFlags);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/commdlg.h //////////////////////////////////////////////////////////////////////////
|
||||
typedef UINT_PTR (__stdcall *LPOFNHOOKPROC)(HWND, UINT, WPARAM, LPARAM);
|
||||
@@ -1478,18 +1989,26 @@
|
||||
#define OFN_EX_NOPLACESBAR 0x00000001
|
||||
#endif // (_WIN32_WINNT >= 0x0500)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall GetSaveFileNameW(LPOPENFILENAMEW);
|
||||
__declspec(dllimport) BOOL __stdcall GetOpenFileNameW(LPOPENFILENAMEW);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/shlwapi.h //////////////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) BOOL __stdcall PathRelativePathToW(WCHAR *pszPath, WCHAR const *pszFrom, DWORD dwAttrFrom, WCHAR const *pszTo, DWORD dwAttrTo);
|
||||
__declspec(dllimport) BOOL __stdcall PathIsRelativeW(WCHAR *pszPath);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: um/pathcch.h //////////////////////////////////////////////////////////////////////////
|
||||
typedef enum PATHCCH_OPTIONS
|
||||
@@ -1535,16 +2054,24 @@
|
||||
PATHCCH_CANONICALIZE_SLASHES = 0x040,
|
||||
} PATHCCH_OPTIONS;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) HRESULT __stdcall PathCchCanonicalizeEx(PWSTR pszPathOut, size_t cchPathOut, WCHAR const *pszPathIn, ULONG dwFlags);
|
||||
#if defined(__cplusplus)
|
||||
};
|
||||
#endif
|
||||
|
||||
// NOTE: um/errhandlingapi.h ///////////////////////////////////////////////////////////////////
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
__declspec(dllimport) VOID __stdcall RaiseException(DWORD dwExceptionCode, DWORD dwExceptionFlags, DWORD nNumberOfArguments, const ULONG_PTR* lpArguments);
|
||||
#if defined(__cplusplus)
|
||||
};
|
||||
#endif
|
||||
|
||||
// NOTE: include/excpt.h ///////////////////////////////////////////////////////////////////
|
||||
#define EXCEPTION_EXECUTE_HANDLER 1
|
||||
@@ -1561,4 +2088,21 @@
|
||||
|
||||
DN_MSVC_WARNING_POP
|
||||
#endif // !defined(_INC_WINDOWS)
|
||||
|
||||
// NOTE: ntpoapi.h ///////////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: PROCESSOR_POWER_INFORMATION was omitted from the Windows SDK's WinNT.h even though it is
|
||||
// documented by Microsoft. It is available in ntpoapi.h, but including that header would pull in
|
||||
// the WDK, so define the documented structure locally instead.
|
||||
#if !defined(_NTPOAPI_H) && !defined(__NTPOAPI_H)
|
||||
typedef struct _PROCESSOR_POWER_INFORMATION
|
||||
{
|
||||
ULONG Number;
|
||||
ULONG MaxMhz;
|
||||
ULONG CurrentMhz;
|
||||
ULONG MhzLimit;
|
||||
ULONG MaxIdleState;
|
||||
ULONG CurrentIdleState;
|
||||
} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
|
||||
#endif
|
||||
|
||||
#endif // !defined(DN_OS_WINDOWS_H)
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "dn_json_builder.h"
|
||||
#include <inttypes.h>
|
||||
|
||||
static void DN_JSB_Indent_(DN_JSBBuilder *builder, char *buf, size_t buf_size, size_t depth)
|
||||
{
|
||||
@@ -221,6 +222,78 @@ DN_JSBResult DN_JSB_ValueNumber(DN_JSBBuilder *builder, char *buf, size_t buf_si
|
||||
return result;
|
||||
}
|
||||
|
||||
static DN_JSBResult DN_JSB_ValueUnsigned_(DN_JSBBuilder *builder, char *buf, size_t buf_size, uint64_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_BeginWriteValue_(builder, buf, buf_size);
|
||||
if (result == DN_JSBResult_Success) {
|
||||
result = DN_JSB_AppendF_(builder, buf, buf_size, "%" PRIu64, value);
|
||||
DN_JSB_FinishWriteValue_(builder, result);
|
||||
}
|
||||
if (builder->error == DN_JSBResult_Success)
|
||||
builder->error = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
static DN_JSBResult DN_JSB_ValueSigned_(DN_JSBBuilder *builder, char *buf, size_t buf_size, int64_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_BeginWriteValue_(builder, buf, buf_size);
|
||||
if (result == DN_JSBResult_Success) {
|
||||
result = DN_JSB_AppendF_(builder, buf, buf_size, "%" PRId64, value);
|
||||
DN_JSB_FinishWriteValue_(builder, result);
|
||||
}
|
||||
if (builder->error == DN_JSBResult_Success)
|
||||
builder->error = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueU8(DN_JSBBuilder *builder, char *buf, size_t buf_size, uint8_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueUnsigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueU16(DN_JSBBuilder *builder, char *buf, size_t buf_size, uint16_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueUnsigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueU32(DN_JSBBuilder *builder, char *buf, size_t buf_size, uint32_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueUnsigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueU64(DN_JSBBuilder *builder, char *buf, size_t buf_size, uint64_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueUnsigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueI8(DN_JSBBuilder *builder, char *buf, size_t buf_size, int8_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueSigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueI16(DN_JSBBuilder *builder, char *buf, size_t buf_size, int16_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueSigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueI32(DN_JSBBuilder *builder, char *buf, size_t buf_size, int32_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueSigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_ValueI64(DN_JSBBuilder *builder, char *buf, size_t buf_size, int64_t value)
|
||||
{
|
||||
DN_JSBResult result = DN_JSB_ValueSigned_(builder, buf, buf_size, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_JSBResult DN_JSB_BeginWriteValue_(DN_JSBBuilder *builder, char *buf, size_t buf_size)
|
||||
{
|
||||
DN_JSBDepth *top = DN_JSB_PeekDepth_(builder, 0);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define DN_JSON_BUILDER_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
#include <stdbool.h>
|
||||
@@ -63,6 +64,14 @@ DN_JSBResult DN_JSB_ValueStringF (DN_JSBBuilder *builder, char *buf, size_t
|
||||
DN_JSBResult DN_JSB_ValueBool (DN_JSBBuilder *builder, char *buf, size_t buf_size, bool flag);
|
||||
DN_JSBResult DN_JSB_ValueNull (DN_JSBBuilder *builder, char *buf, size_t buf_size);
|
||||
DN_JSBResult DN_JSB_ValueNumber (DN_JSBBuilder *builder, char *buf, size_t buf_size, double number);
|
||||
DN_JSBResult DN_JSB_ValueU8 (DN_JSBBuilder *builder, char *buf, size_t buf_size, uint8_t value);
|
||||
DN_JSBResult DN_JSB_ValueU16 (DN_JSBBuilder *builder, char *buf, size_t buf_size, uint16_t value);
|
||||
DN_JSBResult DN_JSB_ValueU32 (DN_JSBBuilder *builder, char *buf, size_t buf_size, uint32_t value);
|
||||
DN_JSBResult DN_JSB_ValueU64 (DN_JSBBuilder *builder, char *buf, size_t buf_size, uint64_t value);
|
||||
DN_JSBResult DN_JSB_ValueI8 (DN_JSBBuilder *builder, char *buf, size_t buf_size, int8_t value);
|
||||
DN_JSBResult DN_JSB_ValueI16 (DN_JSBBuilder *builder, char *buf, size_t buf_size, int16_t value);
|
||||
DN_JSBResult DN_JSB_ValueI32 (DN_JSBBuilder *builder, char *buf, size_t buf_size, int32_t value);
|
||||
DN_JSBResult DN_JSB_ValueI64 (DN_JSBBuilder *builder, char *buf, size_t buf_size, int64_t value);
|
||||
|
||||
DN_JSBDepth * DN_JSB_PeekDepth_ (DN_JSBBuilder *builder, size_t offset);
|
||||
bool DN_JSB_PushDepth_ (DN_JSBBuilder *builder, DN_JSBDepthType type);
|
||||
|
||||
@@ -780,7 +780,7 @@ DN_TestCore DN_SHA3_TestSuite(DN_Arena *arena)
|
||||
|
||||
// NOTE: Test SHA3 against some deterministic inputs generated from a PRNG
|
||||
for (DN_TestScopeF(&result, "[%.*s] Deterministic random inputs", DN_Str8PrintFmt(hash_name))) {
|
||||
DN_Pcg32 rng = DN_Pcg32Init(0xd48e'be21'2af8'733d);
|
||||
DN_Pcg32 rng = DN_Pcg32Init(0xd48ebe212af8733d);
|
||||
for (DN_USize index = 0; index < 128; index++) {
|
||||
// NOTE: Create a 4kb buffer with the deterministic contents
|
||||
char src[4096] = {};
|
||||
@@ -800,7 +800,7 @@ DN_TestCore DN_SHA3_TestSuite(DN_Arena *arena)
|
||||
|
||||
void DN_SHA3_TestSuiteThenOutput(DN_Str8FromTestCoreFlags flags)
|
||||
{
|
||||
DN_Arena arena = DN_ArenaFromHeap(DN_Megabytes(1), DN_Kilobytes(64), DN_MemFlags_Nil, DN_OS_HeapInitDefault(), "DN SHA3 Tests");
|
||||
DN_Arena arena = DN_ArenaFromHeap(DN_Megabytes(1), DN_Kilobytes(64), DN_MemListFlags_Nil, DN_Os_HeapInitDefault(), "DN SHA3 Tests");
|
||||
DN_TestCore test = DN_SHA3_TestSuite(&arena);
|
||||
DN_Str8 output = DN_Str8FromTestCore(&test, &arena, flags);
|
||||
printf("%.*s", DN_Str8PrintFmt(output));
|
||||
|
||||
+4251
-2699
File diff suppressed because it is too large.
Load diff
+1793
-1643
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,19 @@
|
||||
#if !defined(DN_CPP_CPP)
|
||||
#define DN_CPP_CPP
|
||||
|
||||
#include "dn.h"
|
||||
#include "dn_cpp.h"
|
||||
|
||||
#if defined(__cplusplus) && DN_CPP
|
||||
DN_TcScratchCpp::DN_TcScratchCpp(DN_Arena **conflicts, DN_USize count)
|
||||
{
|
||||
this->data = DN_TcScratchBeginArena(conflicts, count);
|
||||
}
|
||||
|
||||
DN_TcScratchCpp::~DN_TcScratchCpp()
|
||||
{
|
||||
DN_TcScratchEnd(&this->data);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DN_CPP_CPP
|
||||
+498
@@ -0,0 +1,498 @@
|
||||
#if !defined(DN_CPP_H)
|
||||
#define DN_CPP_H
|
||||
|
||||
#if defined(_CLANGD)
|
||||
#include "dn.h"
|
||||
#endif
|
||||
|
||||
#if !defined(DN_H)
|
||||
#error "Include dn.h before dn_cpp.h"
|
||||
#endif
|
||||
|
||||
// NOTE: Defaults to 1. The caller may predefine `DN_CPP 0` to keep the C array macros and skip
|
||||
// the C++ wrappers entirely.
|
||||
#if !defined(DN_CPP)
|
||||
#define DN_CPP 1
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && DN_CPP
|
||||
#define DN_DEFER const auto DN_UniqueName(defer_lambda_) = DN_DeferHelper() + [&]()
|
||||
|
||||
// NOTE: `dn.h` defines these macros in terms of `DN_Array*`. Redefine them in terms of the typed
|
||||
// `DN_TArray*` templates below.
|
||||
#undef DN_PArrayAdd
|
||||
#undef DN_PArrayAddArena
|
||||
#undef DN_PArrayAddArray
|
||||
#undef DN_PArrayAddArrayArena
|
||||
#undef DN_PArrayAddArrayHeap
|
||||
#undef DN_PArrayAddArrayPool
|
||||
#undef DN_PArrayAddHeap
|
||||
#undef DN_PArrayAddPool
|
||||
#undef DN_PArrayAppend
|
||||
#undef DN_PArrayAppendArena
|
||||
#undef DN_PArrayAppendArray
|
||||
#undef DN_PArrayAppendAssert
|
||||
#undef DN_PArrayAppendHeap
|
||||
#undef DN_PArrayAppendPool
|
||||
#undef DN_PArrayCopyPtrArena
|
||||
#undef DN_PArrayCopyPtrArenaAssert
|
||||
#undef DN_PArrayCopyPtrHeap
|
||||
#undef DN_PArrayCopyPtrHeapAssert
|
||||
#undef DN_PArrayCopyPtrPool
|
||||
#undef DN_PArrayCopyPtrPoolAssert
|
||||
#undef DN_PArrayErase
|
||||
#undef DN_PArrayEraseRange
|
||||
#undef DN_PArrayFind
|
||||
#undef DN_PArrayFindMemEq
|
||||
#undef DN_PArrayInsert
|
||||
#undef DN_PArrayInsertArray
|
||||
#undef DN_PArrayMake
|
||||
#undef DN_PArrayMakeArena
|
||||
#undef DN_PArrayMakeArenaNoZ
|
||||
#undef DN_PArrayMakeArenaZ
|
||||
#undef DN_PArrayMakeArray
|
||||
#undef DN_PArrayMakeArrayArena
|
||||
#undef DN_PArrayMakeArrayArenaNoZ
|
||||
#undef DN_PArrayMakeArrayArenaZ
|
||||
#undef DN_PArrayMakeArrayAssert
|
||||
#undef DN_PArrayMakeArrayAssertNoZ
|
||||
#undef DN_PArrayMakeArrayAssertZ
|
||||
#undef DN_PArrayMakeArrayHeap
|
||||
#undef DN_PArrayMakeArrayHeapNoZ
|
||||
#undef DN_PArrayMakeArrayHeapZ
|
||||
#undef DN_PArrayMakeArrayNoZ
|
||||
#undef DN_PArrayMakeArrayPool
|
||||
#undef DN_PArrayMakeArrayPoolNoZ
|
||||
#undef DN_PArrayMakeArrayPoolZ
|
||||
#undef DN_PArrayMakeArrayZ
|
||||
#undef DN_PArrayMakeAssert
|
||||
#undef DN_PArrayMakeAssertNoZ
|
||||
#undef DN_PArrayMakeAssertZ
|
||||
#undef DN_PArrayMakeHeap
|
||||
#undef DN_PArrayMakeHeapNoZ
|
||||
#undef DN_PArrayMakeHeapZ
|
||||
#undef DN_PArrayMakeNoZ
|
||||
#undef DN_PArrayMakePool
|
||||
#undef DN_PArrayMakePoolNoZ
|
||||
#undef DN_PArrayMakePoolZ
|
||||
#undef DN_PArrayMakeZ
|
||||
#undef DN_PArrayPopBack
|
||||
#undef DN_PArrayPopFront
|
||||
#undef DN_PArrayPrepareArena
|
||||
#undef DN_PArrayPrepareHeap
|
||||
#undef DN_PArrayPreparePool
|
||||
#undef DN_PArrayPrepend
|
||||
#undef DN_PArrayPrependArena
|
||||
#undef DN_PArrayPrependArray
|
||||
#undef DN_PArrayPrependHeap
|
||||
#undef DN_PArrayPrependPool
|
||||
#undef DN_PArrayReserveArena
|
||||
#undef DN_PArrayReserveHeap
|
||||
#undef DN_PArrayReservePool
|
||||
#undef DN_PArrayResizeArena
|
||||
#undef DN_PArrayResizeHeap
|
||||
#undef DN_PArrayResizePool
|
||||
|
||||
// NOTE: Typed array macros
|
||||
#define DN_PArrayFind(ptr, size, ptr_find, eq_func) DN_TArrayFind(ptr, size, ptr_find, eq_func)
|
||||
#define DN_PArrayFindMemEq(ptr, size, ptr_find) DN_TArrayFindMemEq(ptr, size, ptr_find)
|
||||
#define DN_PArrayResizePool(ptr, ptr_size, ptr_max, pool, new_max) DN_TArrayResizeAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromPool(pool), new_max)
|
||||
#define DN_PArrayResizeArena(ptr, ptr_size, ptr_max, arena, new_max) DN_TArrayResizeAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromArena(arena), new_max)
|
||||
#define DN_PArrayReservePool(ptr, ptr_max, pool, new_max) DN_TArrayReserveAllocator(&(ptr), ptr_max, DN_AllocatorFromPool(pool), new_max)
|
||||
#define DN_PArrayReserveArena(ptr, ptr_max, arena, new_max) DN_TArrayReserveAllocator(&(ptr), ptr_max, DN_AllocatorFromArena(arena), new_max)
|
||||
#define DN_PArrayPreparePool(ptr, size, ptr_max, pool, add_count) DN_TArrayPrepareAllocator(&(ptr), size, ptr_max, DN_AllocatorFromPool(pool), add_count)
|
||||
#define DN_PArrayPrepareArena(ptr, size, ptr_max, arena, add_count) DN_TArrayPrepareAllocator(&(ptr), size, ptr_max, DN_AllocatorFromArena(arena), add_count)
|
||||
#define DN_PArrayCopyPtrPool(dest, src, count_, pool) DN_TArrayCopyPtrAllocator(&(dest), src, count_, DN_AllocatorFromPool(pool))
|
||||
#define DN_PArrayCopyPtrPoolAssert(dest, src, count_, pool) DN_TArrayCopyPtrAllocatorAssert(&(dest), src, count_, DN_AllocatorFromPool(pool), DN_CallSiteNow)
|
||||
#define DN_PArrayCopyPtrArena(dest, src, count_, arena) DN_TArrayCopyPtrAllocator(&(dest), src, count_, DN_AllocatorFromArena(arena))
|
||||
#define DN_PArrayCopyPtrArenaAssert(dest, src, count_, arena) DN_TArrayCopyPtrAllocatorAssert(&(dest), src, count_, DN_AllocatorFromArena(arena), DN_CallSiteNow)
|
||||
|
||||
#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_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_PArrayMakeArrayArena(ptr, ptr_size, ptr_max, arena, count, z_mem) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromArena(arena), count, z_mem)
|
||||
#define DN_PArrayMakeArrayArenaZ(ptr, ptr_size, ptr_max, arena, count) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromArena(arena), count, DN_ZMem_Yes)
|
||||
#define DN_PArrayMakeArrayArenaNoZ(ptr, ptr_size, ptr_max, arena, count) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromArena(arena), count, DN_ZMem_No)
|
||||
#define DN_PArrayMakeArrayPool(ptr, ptr_size, ptr_max, pool, count, z_mem) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromPool(pool), count, z_mem)
|
||||
#define DN_PArrayMakeArrayPoolZ(ptr, ptr_size, ptr_max, pool, count) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromPool(pool), count, DN_ZMem_Yes)
|
||||
#define DN_PArrayMakeArrayPoolNoZ(ptr, ptr_size, ptr_max, pool, count) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromPool(pool), count, DN_ZMem_No)
|
||||
|
||||
#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_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_PArrayMakeArena(ptr, ptr_size, ptr_max, arena, z_mem) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromArena(arena), 1, z_mem)
|
||||
#define DN_PArrayMakeArenaZ(ptr, ptr_size, ptr_max, arena) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromArena(arena), 1, DN_ZMem_Yes)
|
||||
#define DN_PArrayMakeArenaNoZ(ptr, ptr_size, ptr_max, arena) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromArena(arena), 1, DN_ZMem_No)
|
||||
#define DN_PArrayMakePool(ptr, ptr_size, ptr_max, pool, z_mem) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromPool(pool), 1, z_mem)
|
||||
#define DN_PArrayMakePoolZ(ptr, ptr_size, ptr_max, pool) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromPool(pool), 1, DN_ZMem_Yes)
|
||||
#define DN_PArrayMakePoolNoZ(ptr, ptr_size, ptr_max, pool) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromPool(pool), 1, DN_ZMem_No)
|
||||
|
||||
#define DN_PArrayAddArray(ptr, ptr_size, max, items, count, add) DN_TArrayAddArray(ptr, ptr_size, max, items, count, add)
|
||||
#define DN_PArrayAddArrayArena(ptr, ptr_size, ptr_max, arena, items, count, add) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromArena(arena), items, count, add)
|
||||
#define DN_PArrayAddArrayPool(ptr, ptr_size, ptr_max, pool, items, count, add) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromPool(pool), items, count, add)
|
||||
#define DN_PArrayAdd(ptr, ptr_size, max, item, add) DN_TArrayAddArray(ptr, ptr_size, max, &item, 1, add)
|
||||
#define DN_PArrayAddArena(ptr, ptr_size, ptr_max, arena, item, add) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromArena(arena), &item, 1, add)
|
||||
#define DN_PArrayAddPool(ptr, ptr_size, ptr_max, pool, item, add) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromPool(pool), &item, 1, add)
|
||||
#define DN_PArrayAppendArray(ptr, ptr_size, max, items, count) DN_TArrayAddArray(ptr, ptr_size, max, items, count, DN_AddType_Append)
|
||||
#define DN_PArrayAppend(ptr, ptr_size, max, item) DN_TArrayAddArray(ptr, ptr_size, max, &item, 1, DN_AddType_Append)
|
||||
#define DN_PArrayAppendArena(ptr, ptr_size, ptr_max, arena, item) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromArena(arena), &item, 1, DN_AddType_Append)
|
||||
#define DN_PArrayAppendPool(ptr, ptr_size, ptr_max, pool, item) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromPool(pool), &item, 1, DN_AddType_Append)
|
||||
#define DN_PArrayAppendAssert(ptr, ptr_size, max, item) DN_TArrayAddArrayAssert(ptr, ptr_size, max, &item, 1, DN_AddType_Append, DN_CallSiteNow)
|
||||
#define DN_PArrayPrependArray(ptr, ptr_size, max, items, count) DN_TArrayAddArray(ptr, ptr_size, max, items, count, DN_AddType_Prepend)
|
||||
#define DN_PArrayPrepend(ptr, ptr_size, max, item) DN_TArrayAddArray(ptr, ptr_size, max, &item, 1, DN_AddType_Prepend)
|
||||
#define DN_PArrayPrependArena(ptr, ptr_size, ptr_max, arena, item) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromArena(arena), &item, 1, DN_AddType_Prepend)
|
||||
#define DN_PArrayPrependPool(ptr, ptr_size, ptr_max, pool, item) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromPool(pool), &item, 1, DN_AddType_Prepend)
|
||||
|
||||
#define DN_PArrayEraseRange(ptr, ptr_size, begin_index, count, erase) DN_TArrayEraseRange(ptr, ptr_size, begin_index, count, erase)
|
||||
#define DN_PArrayErase(ptr, ptr_size, index, erase) DN_TArrayEraseRange(ptr, ptr_size, index, 1, erase)
|
||||
#define DN_PArrayInsertArray(ptr, ptr_size, max, index, items, count) DN_TArrayInsertArray(ptr, ptr_size, max, index, items, count)
|
||||
#define DN_PArrayInsert(ptr, ptr_size, max, index, item) DN_TArrayInsertArray(ptr, ptr_size, max, index, &item, 1)
|
||||
#define DN_PArrayPopFront(ptr, ptr_size, max, count) DN_TArrayPopFront(ptr, ptr_size, count)
|
||||
#define DN_PArrayPopBack(ptr, ptr_size, max, count) DN_TArrayPopBack(ptr, ptr_size, count)
|
||||
|
||||
#define DN_PArrayResizeHeap(ptr, ptr_size, ptr_max, heap, new_max) DN_TArrayResizeAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromHeap(heap), new_max)
|
||||
#define DN_PArrayReserveHeap(ptr, ptr_max, heap, new_max) DN_TArrayReserveAllocator(&(ptr), ptr_max, DN_AllocatorFromHeap(heap), new_max)
|
||||
#define DN_PArrayPrepareHeap(ptr, size, ptr_max, heap, add_count) DN_TArrayPrepareAllocator(&(ptr), size, ptr_max, DN_AllocatorFromHeap(heap), add_count)
|
||||
#define DN_PArrayCopyPtrHeap(dest, src, count_, heap) DN_TArrayCopyPtrAllocator(&(dest), src, count_, DN_AllocatorFromHeap(heap))
|
||||
#define DN_PArrayCopyPtrHeapAssert(dest, src, count_, heap) DN_TArrayCopyPtrAllocatorAssert(&(dest), src, count_, DN_AllocatorFromHeap(heap), DN_CallSiteNow)
|
||||
#define DN_PArrayMakeArrayHeap(ptr, ptr_size, ptr_max, heap, count, z_mem) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromHeap(heap), count, z_mem)
|
||||
#define DN_PArrayMakeArrayHeapZ(ptr, ptr_size, ptr_max, heap, count) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromHeap(heap), count, DN_ZMem_Yes)
|
||||
#define DN_PArrayMakeArrayHeapNoZ(ptr, ptr_size, ptr_max, heap, count) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromHeap(heap), count, DN_ZMem_No)
|
||||
#define DN_PArrayMakeHeap(ptr, ptr_size, ptr_max, heap, z_mem) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromHeap(heap), 1, z_mem)
|
||||
#define DN_PArrayMakeHeapZ(ptr, ptr_size, ptr_max, heap) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromHeap(heap), 1, DN_ZMem_Yes)
|
||||
#define DN_PArrayMakeHeapNoZ(ptr, ptr_size, ptr_max, heap) DN_TArrayMakeArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromHeap(heap), 1, DN_ZMem_No)
|
||||
#define DN_PArrayAddArrayHeap(ptr, ptr_size, ptr_max, heap, items, count, add) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromHeap(heap), items, count, add)
|
||||
#define DN_PArrayAddHeap(ptr, ptr_size, ptr_max, heap, item, add) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromHeap(heap), &item, 1, add)
|
||||
#define DN_PArrayAppendHeap(ptr, ptr_size, ptr_max, heap, item) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromHeap(heap), &item, 1, DN_AddType_Append)
|
||||
#define DN_PArrayPrependHeap(ptr, ptr_size, ptr_max, heap, item) DN_TArrayAddArrayAllocator(&(ptr), ptr_size, ptr_max, DN_AllocatorFromHeap(heap), &item, 1, DN_AddType_Prepend)
|
||||
|
||||
// NOTE: Vector operators
|
||||
inline bool operator==(DN_V2I32 lhs, DN_V2I32 rhs) { return DN_V2I32Eq(lhs, rhs); }
|
||||
inline bool operator!=(DN_V2I32 lhs, DN_V2I32 rhs) { return DN_V2I32Ne(lhs, rhs); }
|
||||
inline bool operator>=(DN_V2I32 lhs, DN_V2I32 rhs) { return DN_V2I32Ge(lhs, rhs); }
|
||||
inline bool operator<=(DN_V2I32 lhs, DN_V2I32 rhs) { return DN_V2I32Le(lhs, rhs); }
|
||||
inline bool operator<(DN_V2I32 lhs, DN_V2I32 rhs) { return DN_V2I32Lt(lhs, rhs); }
|
||||
inline bool operator>(DN_V2I32 lhs, DN_V2I32 rhs) { return DN_V2I32Gt(lhs, rhs); }
|
||||
inline DN_V2I32 operator-(DN_V2I32 lhs) { return DN_V2I32Neg(lhs); }
|
||||
inline DN_V2I32 operator-(DN_V2I32 lhs, DN_V2I32 rhs) { return DN_V2I32Sub(lhs, rhs); }
|
||||
inline DN_V2I32 operator+(DN_V2I32 lhs, DN_V2I32 rhs) { return DN_V2I32Add(lhs, rhs); }
|
||||
inline DN_V2I32 operator*(DN_V2I32 lhs, DN_V2I32 rhs) { return DN_V2I32Mul(lhs, rhs); }
|
||||
inline DN_V2I32 operator*(DN_V2I32 lhs, DN_F32 rhs) { return DN_V2I32MulF32(lhs, rhs); }
|
||||
inline DN_V2I32 operator*(DN_V2I32 lhs, DN_I32 rhs) { return DN_V2I32MulI32(lhs, rhs); }
|
||||
inline DN_V2I32 operator/(DN_V2I32 lhs, DN_V2I32 rhs) { return DN_V2I32Div(lhs, rhs); }
|
||||
inline DN_V2I32 operator/(DN_V2I32 lhs, DN_F32 rhs) { return DN_V2I32DivF32(lhs, rhs); }
|
||||
inline DN_V2I32 operator/(DN_V2I32 lhs, DN_I32 rhs) { return DN_V2I32DivI32(lhs, rhs); }
|
||||
inline DN_V2I32& operator*=(DN_V2I32& lhs, DN_V2I32 rhs) { return lhs = DN_V2I32Mul(lhs, rhs); }
|
||||
inline DN_V2I32& operator*=(DN_V2I32& lhs, DN_F32 rhs) { return lhs = DN_V2I32MulF32(lhs, rhs); }
|
||||
inline DN_V2I32& operator*=(DN_V2I32& lhs, DN_I32 rhs) { return lhs = DN_V2I32MulI32(lhs, rhs); }
|
||||
inline DN_V2I32& operator/=(DN_V2I32& lhs, DN_V2I32 rhs) { return lhs = DN_V2I32Div(lhs, rhs); }
|
||||
inline DN_V2I32& operator/=(DN_V2I32& lhs, DN_F32 rhs) { return lhs = DN_V2I32DivF32(lhs, rhs); }
|
||||
inline DN_V2I32& operator/=(DN_V2I32& lhs, DN_I32 rhs) { return lhs = DN_V2I32DivI32(lhs, rhs); }
|
||||
inline DN_V2I32& operator-=(DN_V2I32& lhs, DN_V2I32 rhs) { return lhs = DN_V2I32Sub(lhs, rhs); }
|
||||
inline DN_V2I32& operator+=(DN_V2I32& lhs, DN_V2I32 rhs) { return lhs = DN_V2I32Add(lhs, rhs); }
|
||||
|
||||
inline bool operator!=(DN_V2U16 lhs, DN_V2U16 rhs) { return DN_V2U16Ne(lhs, rhs); }
|
||||
inline bool operator==(DN_V2U16 lhs, DN_V2U16 rhs) { return DN_V2U16Eq(lhs, rhs); }
|
||||
inline bool operator>=(DN_V2U16 lhs, DN_V2U16 rhs) { return DN_V2U16Ge(lhs, rhs); }
|
||||
inline bool operator<=(DN_V2U16 lhs, DN_V2U16 rhs) { return DN_V2U16Le(lhs, rhs); }
|
||||
inline bool operator<(DN_V2U16 lhs, DN_V2U16 rhs) { return DN_V2U16Lt(lhs, rhs); }
|
||||
inline bool operator>(DN_V2U16 lhs, DN_V2U16 rhs) { return DN_V2U16Gt(lhs, rhs); }
|
||||
inline DN_V2U16 operator-(DN_V2U16 lhs, DN_V2U16 rhs) { return DN_V2U16Sub(lhs, rhs); }
|
||||
inline DN_V2U16 operator+(DN_V2U16 lhs, DN_V2U16 rhs) { return DN_V2U16Add(lhs, rhs); }
|
||||
inline DN_V2U16 operator*(DN_V2U16 lhs, DN_V2U16 rhs) { return DN_V2U16Mul(lhs, rhs); }
|
||||
inline DN_V2U16 operator*(DN_V2U16 lhs, DN_F32 rhs) { return DN_V2U16MulF32(lhs, rhs); }
|
||||
inline DN_V2U16 operator*(DN_V2U16 lhs, DN_I32 rhs) { return DN_V2U16MulI32(lhs, rhs); }
|
||||
inline DN_V2U16 operator/(DN_V2U16 lhs, DN_V2U16 rhs) { return DN_V2U16Div(lhs, rhs); }
|
||||
inline DN_V2U16 operator/(DN_V2U16 lhs, DN_F32 rhs) { return DN_V2U16DivF32(lhs, rhs); }
|
||||
inline DN_V2U16 operator/(DN_V2U16 lhs, DN_I32 rhs) { return DN_V2U16DivI32(lhs, rhs); }
|
||||
inline DN_V2U16& operator*=(DN_V2U16& lhs, DN_V2U16 rhs) { return lhs = DN_V2U16Mul(lhs, rhs); }
|
||||
inline DN_V2U16& operator*=(DN_V2U16& lhs, DN_F32 rhs) { return lhs = DN_V2U16MulF32(lhs, rhs); }
|
||||
inline DN_V2U16& operator*=(DN_V2U16& lhs, DN_I32 rhs) { return lhs = DN_V2U16MulI32(lhs, rhs); }
|
||||
inline DN_V2U16& operator/=(DN_V2U16& lhs, DN_V2U16 rhs) { return lhs = DN_V2U16Div(lhs, rhs); }
|
||||
inline DN_V2U16& operator/=(DN_V2U16& lhs, DN_F32 rhs) { return lhs = DN_V2U16DivF32(lhs, rhs); }
|
||||
inline DN_V2U16& operator/=(DN_V2U16& lhs, DN_I32 rhs) { return lhs = DN_V2U16DivI32(lhs, rhs); }
|
||||
inline DN_V2U16& operator-=(DN_V2U16& lhs, DN_V2U16 rhs) { return lhs = DN_V2U16Sub(lhs, rhs); }
|
||||
inline DN_V2U16& operator+=(DN_V2U16& lhs, DN_V2U16 rhs) { return lhs = DN_V2U16Add(lhs, rhs); }
|
||||
|
||||
inline bool operator!=(DN_V2F32 lhs, DN_V2F32 rhs) { return DN_V2F32Ne(lhs, rhs); }
|
||||
inline bool operator==(DN_V2F32 lhs, DN_V2F32 rhs) { return DN_V2F32Eq(lhs, rhs); }
|
||||
inline bool operator>=(DN_V2F32 lhs, DN_V2F32 rhs) { return DN_V2F32Ge(lhs, rhs); }
|
||||
inline bool operator<=(DN_V2F32 lhs, DN_V2F32 rhs) { return DN_V2F32Le(lhs, rhs); }
|
||||
inline bool operator<(DN_V2F32 lhs, DN_V2F32 rhs) { return DN_V2F32Lt(lhs, rhs); }
|
||||
inline bool operator>(DN_V2F32 lhs, DN_V2F32 rhs) { return DN_V2F32Gt(lhs, rhs); }
|
||||
inline DN_V2F32 operator-(DN_V2F32 lhs) { return DN_V2F32Neg(lhs); }
|
||||
inline DN_V2F32 operator-(DN_V2F32 lhs, DN_V2F32 rhs) { return DN_V2F32Sub(lhs, rhs); }
|
||||
inline DN_V2F32 operator-(DN_V2F32 lhs, DN_V2I32 rhs) { return DN_V2F32SubV2I32(lhs, rhs); }
|
||||
inline DN_V2F32 operator-(DN_V2F32 lhs, DN_F32 rhs) { return DN_V2F32SubF32(lhs, rhs); }
|
||||
inline DN_V2F32 operator-(DN_V2F32 lhs, DN_I32 rhs) { return DN_V2F32SubI32(lhs, rhs); }
|
||||
inline DN_V2F32 operator+(DN_V2F32 lhs, DN_V2F32 rhs) { return DN_V2F32Add(lhs, rhs); }
|
||||
inline DN_V2F32 operator+(DN_V2F32 lhs, DN_V2I32 rhs) { return DN_V2F32AddV2I32(lhs, rhs); }
|
||||
inline DN_V2F32 operator+(DN_V2F32 lhs, DN_F32 rhs) { return DN_V2F32AddF32(lhs, rhs); }
|
||||
inline DN_V2F32 operator+(DN_V2F32 lhs, DN_I32 rhs) { return DN_V2F32AddI32(lhs, rhs); }
|
||||
inline DN_V2F32 operator*(DN_V2F32 lhs, DN_V2F32 rhs) { return DN_V2F32Mul(lhs, rhs); }
|
||||
inline DN_V2F32 operator*(DN_V2F32 lhs, DN_V2I32 rhs) { return DN_V2F32MulV2I32(lhs, rhs); }
|
||||
inline DN_V2F32 operator*(DN_V2F32 lhs, DN_F32 rhs) { return DN_V2F32MulF32(lhs, rhs); }
|
||||
inline DN_V2F32 operator*(DN_V2F32 lhs, DN_I32 rhs) { return DN_V2F32MulI32(lhs, rhs); }
|
||||
inline DN_V2F32 operator/(DN_V2F32 lhs, DN_V2F32 rhs) { return DN_V2F32Div(lhs, rhs); }
|
||||
inline DN_V2F32 operator/(DN_V2F32 lhs, DN_V2I32 rhs) { return DN_V2F32DivV2I32(lhs, rhs); }
|
||||
inline DN_V2F32 operator/(DN_V2F32 lhs, DN_F32 rhs) { return DN_V2F32DivF32(lhs, rhs); }
|
||||
inline DN_V2F32 operator/(DN_V2F32 lhs, DN_I32 rhs) { return DN_V2F32DivI32(lhs, rhs); }
|
||||
inline DN_V2F32& operator*=(DN_V2F32& lhs, DN_V2F32 rhs) { return lhs = DN_V2F32Mul(lhs, rhs); }
|
||||
inline DN_V2F32& operator*=(DN_V2F32& lhs, DN_V2I32 rhs) { return lhs = DN_V2F32MulV2I32(lhs, rhs); }
|
||||
inline DN_V2F32& operator*=(DN_V2F32& lhs, DN_F32 rhs) { return lhs = DN_V2F32MulF32(lhs, rhs); }
|
||||
inline DN_V2F32& operator*=(DN_V2F32& lhs, DN_I32 rhs) { return lhs = DN_V2F32MulI32(lhs, rhs); }
|
||||
inline DN_V2F32& operator/=(DN_V2F32& lhs, DN_V2F32 rhs) { return lhs = DN_V2F32Div(lhs, rhs); }
|
||||
inline DN_V2F32& operator/=(DN_V2F32& lhs, DN_V2I32 rhs) { return lhs = DN_V2F32DivV2I32(lhs, rhs); }
|
||||
inline DN_V2F32& operator/=(DN_V2F32& lhs, DN_F32 rhs) { return lhs = DN_V2F32DivF32(lhs, rhs); }
|
||||
inline DN_V2F32& operator/=(DN_V2F32& lhs, DN_I32 rhs) { return lhs = DN_V2F32DivI32(lhs, rhs); }
|
||||
inline DN_V2F32& operator-=(DN_V2F32& lhs, DN_V2F32 rhs) { return lhs = DN_V2F32Sub(lhs, rhs); }
|
||||
inline DN_V2F32& operator-=(DN_V2F32& lhs, DN_V2I32 rhs) { return lhs = DN_V2F32SubV2I32(lhs, rhs); }
|
||||
inline DN_V2F32& operator-=(DN_V2F32& lhs, DN_F32 rhs) { return lhs = DN_V2F32SubF32(lhs, rhs); }
|
||||
inline DN_V2F32& operator-=(DN_V2F32& lhs, DN_I32 rhs) { return lhs = DN_V2F32SubI32(lhs, rhs); }
|
||||
inline DN_V2F32& operator+=(DN_V2F32& lhs, DN_V2F32 rhs) { return lhs = DN_V2F32Add(lhs, rhs); }
|
||||
inline DN_V2F32& operator+=(DN_V2F32& lhs, DN_V2I32 rhs) { return lhs = DN_V2F32AddV2I32(lhs, rhs); }
|
||||
inline DN_V2F32& operator+=(DN_V2F32& lhs, DN_F32 rhs) { return lhs = DN_V2F32AddF32(lhs, rhs); }
|
||||
inline DN_V2F32& operator+=(DN_V2F32& lhs, DN_I32 rhs) { return lhs = DN_V2F32AddI32(lhs, rhs); }
|
||||
|
||||
inline bool operator==(DN_V3F32 lhs, DN_V3F32 rhs) { return DN_V3F32Eq(lhs, rhs); }
|
||||
inline bool operator!=(DN_V3F32 lhs, DN_V3F32 rhs) { return DN_V3F32Ne(lhs, rhs); }
|
||||
inline bool operator>=(DN_V3F32 lhs, DN_V3F32 rhs) { return DN_V3F32Ge(lhs, rhs); }
|
||||
inline bool operator<=(DN_V3F32 lhs, DN_V3F32 rhs) { return DN_V3F32Le(lhs, rhs); }
|
||||
inline bool operator<(DN_V3F32 lhs, DN_V3F32 rhs) { return DN_V3F32Lt(lhs, rhs); }
|
||||
inline bool operator>(DN_V3F32 lhs, DN_V3F32 rhs) { return DN_V3F32Gt(lhs, rhs); }
|
||||
inline DN_V3F32 operator-(DN_V3F32 lhs, DN_V3F32 rhs) { return DN_V3F32Sub(lhs, rhs); }
|
||||
inline DN_V3F32 operator-(DN_V3F32 lhs) { return DN_V3F32Neg(lhs); }
|
||||
inline DN_V3F32 operator+(DN_V3F32 lhs, DN_V3F32 rhs) { return DN_V3F32Add(lhs, rhs); }
|
||||
inline DN_V3F32 operator*(DN_V3F32 lhs, DN_V3F32 rhs) { return DN_V3F32Mul(lhs, rhs); }
|
||||
inline DN_V3F32 operator*(DN_V3F32 lhs, DN_F32 rhs) { return DN_V3F32MulF32(lhs, rhs); }
|
||||
inline DN_V3F32 operator*(DN_V3F32 lhs, DN_I32 rhs) { return DN_V3F32MulI32(lhs, rhs); }
|
||||
inline DN_V3F32 operator/(DN_V3F32 lhs, DN_V3F32 rhs) { return DN_V3F32Div(lhs, rhs); }
|
||||
inline DN_V3F32 operator/(DN_V3F32 lhs, DN_F32 rhs) { return DN_V3F32DivF32(lhs, rhs); }
|
||||
inline DN_V3F32 operator/(DN_V3F32 lhs, DN_I32 rhs) { return DN_V3F32DivI32(lhs, rhs); }
|
||||
inline DN_V3F32& operator*=(DN_V3F32& lhs, DN_V3F32 rhs) { return lhs = DN_V3F32Mul(lhs, rhs); }
|
||||
inline DN_V3F32& operator*=(DN_V3F32& lhs, DN_F32 rhs) { return lhs = DN_V3F32MulF32(lhs, rhs); }
|
||||
inline DN_V3F32& operator*=(DN_V3F32& lhs, DN_I32 rhs) { return lhs = DN_V3F32MulI32(lhs, rhs); }
|
||||
inline DN_V3F32& operator/=(DN_V3F32& lhs, DN_V3F32 rhs) { return lhs = DN_V3F32Div(lhs, rhs); }
|
||||
inline DN_V3F32& operator/=(DN_V3F32& lhs, DN_F32 rhs) { return lhs = DN_V3F32DivF32(lhs, rhs); }
|
||||
inline DN_V3F32& operator/=(DN_V3F32& lhs, DN_I32 rhs) { return lhs = DN_V3F32DivI32(lhs, rhs); }
|
||||
inline DN_V3F32& operator-=(DN_V3F32& lhs, DN_V3F32 rhs) { return lhs = DN_V3F32Sub(lhs, rhs); }
|
||||
inline DN_V3F32& operator+=(DN_V3F32& lhs, DN_V3F32 rhs) { return lhs = DN_V3F32Add(lhs, rhs); }
|
||||
|
||||
inline bool operator==(DN_V4F32 lhs, DN_V4F32 rhs) { return DN_V4F32Eq(lhs, rhs); }
|
||||
inline bool operator!=(DN_V4F32 lhs, DN_V4F32 rhs) { return DN_V4F32Ne(lhs, rhs); }
|
||||
inline bool operator>=(DN_V4F32 lhs, DN_V4F32 rhs) { return DN_V4F32Ge(lhs, rhs); }
|
||||
inline bool operator<=(DN_V4F32 lhs, DN_V4F32 rhs) { return DN_V4F32Le(lhs, rhs); }
|
||||
inline bool operator<(DN_V4F32 lhs, DN_V4F32 rhs) { return DN_V4F32Lt(lhs, rhs); }
|
||||
inline bool operator>(DN_V4F32 lhs, DN_V4F32 rhs) { return DN_V4F32Gt(lhs, rhs); }
|
||||
inline DN_V4F32 operator-(DN_V4F32 lhs, DN_V4F32 rhs) { return DN_V4F32Sub(lhs, rhs); }
|
||||
inline DN_V4F32 operator-(DN_V4F32 lhs) { return DN_V4F32Neg(lhs); }
|
||||
inline DN_V4F32 operator+(DN_V4F32 lhs, DN_V4F32 rhs) { return DN_V4F32Add(lhs, rhs); }
|
||||
inline DN_V4F32 operator*(DN_V4F32 lhs, DN_V4F32 rhs) { return DN_V4F32Mul(lhs, rhs); }
|
||||
inline DN_V4F32 operator*(DN_V4F32 lhs, DN_F32 rhs) { return DN_V4F32MulF32(lhs, rhs); }
|
||||
inline DN_V4F32 operator*(DN_V4F32 lhs, DN_I32 rhs) { return DN_V4F32MulI32(lhs, rhs); }
|
||||
inline DN_V4F32 operator/(DN_V4F32 lhs, DN_F32 rhs) { return DN_V4F32DivF32(lhs, rhs); }
|
||||
inline DN_V4F32& operator*=(DN_V4F32& lhs, DN_V4F32 rhs) { return lhs = DN_V4F32Mul(lhs, rhs); }
|
||||
inline DN_V4F32& operator*=(DN_V4F32& lhs, DN_F32 rhs) { return lhs = DN_V4F32MulF32(lhs, rhs); }
|
||||
inline DN_V4F32& operator*=(DN_V4F32& lhs, DN_I32 rhs) { return lhs = DN_V4F32MulI32(lhs, rhs); }
|
||||
inline DN_V4F32& operator-=(DN_V4F32& lhs, DN_V4F32 rhs) { return lhs = DN_V4F32Sub(lhs, rhs); }
|
||||
inline DN_V4F32& operator+=(DN_V4F32& lhs, DN_V4F32 rhs) { return lhs = DN_V4F32Add(lhs, rhs); }
|
||||
|
||||
// NOTE: Scope helpers
|
||||
template <typename Procedure>
|
||||
struct DN_Defer
|
||||
{
|
||||
Procedure proc;
|
||||
DN_Defer(Procedure p) : proc(p) {}
|
||||
~DN_Defer() { proc(); }
|
||||
};
|
||||
|
||||
struct DN_DeferHelper
|
||||
{
|
||||
template <typename Lambda>
|
||||
DN_Defer<Lambda> operator+(Lambda lambda) { return DN_Defer<Lambda>(lambda); };
|
||||
};
|
||||
|
||||
typedef struct DN_TcScratchCpp DN_TcScratchCpp;
|
||||
struct DN_TcScratchCpp
|
||||
{
|
||||
DN_TcScratchCpp(DN_Arena **conflicts, DN_USize count);
|
||||
~DN_TcScratchCpp();
|
||||
DN_TcScratch data;
|
||||
};
|
||||
|
||||
// NOTE: Typed array (template) implementations
|
||||
template <typename T> DN_ArrayFindResult DN_TArrayFind (T *data, DN_USize count, void const *find, DN_ArrayFindEqFunc *eq_func);
|
||||
template <typename T> DN_ArrayFindResult DN_TArrayFindMemEq (T *data, DN_USize count, void const *find, DN_ArrayFindEqFunc *eq_func);
|
||||
template <typename T> T* DN_TArrayInsertArray (T *data, DN_USize *count, DN_USize max, DN_USize index, void const *items, DN_USize pop_count);
|
||||
template <typename T> T* DN_TArrayPopFront (T *data, DN_USize *count, DN_USize pop_count);
|
||||
template <typename T> T* DN_TArrayPopBack (T *data, DN_USize *count, DN_USize pop_count);
|
||||
template <typename T> DN_USize DN_TArrayEraseRange (T *data, DN_USize *count, DN_USize begin_index, DN_ISize erase_count, DN_ArrayErase erase);
|
||||
template <typename T> T* DN_TArrayMakeArray (T *data, DN_USize *count, DN_USize max, DN_USize make_count, DN_ZMem z_mem);
|
||||
template <typename T> T* DN_TArrayMakeArrayAssert (T *data, DN_USize *count, DN_USize max, DN_USize make_count, DN_ZMem z_mem, DN_CallSite call_site);
|
||||
template <typename T> T* DN_TArrayMakeArrayAssertZ (T *data, DN_USize *count, DN_USize max, DN_USize make_count, DN_CallSite call_site);
|
||||
template <typename T> T* DN_TArrayMakeArrayAssertNoZ (T *data, DN_USize *count, DN_USize max, DN_USize make_count, DN_CallSite call_site);
|
||||
template <typename T> T* DN_TArrayAddArray (T *data, DN_USize *count, DN_USize max, T const *elems, DN_USize elems_count, DN_AddType add);
|
||||
template <typename T> T* DN_TArrayAddArrayAssert (T *data, DN_USize *count, DN_USize max, T const *elems, DN_USize elems_count, DN_AddType add, DN_CallSite call_site);
|
||||
template <typename T> T* DN_TArrayMakeArrayAllocator (T **data, DN_USize *count, DN_USize *max, DN_Allocator allocator, DN_USize make_count, DN_ZMem z_mem);
|
||||
template <typename T> T* DN_TArrayMakeArrayAllocatorZ (T **data, DN_USize *count, DN_USize *max, DN_Allocator allocator, DN_USize make_count);
|
||||
template <typename T> T* DN_TArrayMakeArrayAllocatorNoZ (T **data, DN_USize *count, DN_USize *max, DN_Allocator allocator, DN_USize make_count);
|
||||
template <typename T> T* DN_TArrayAddArrayAllocator (T **data, DN_USize *count, DN_USize *max, DN_Allocator allocator, T const *elems, DN_USize elems_count, DN_AddType add);
|
||||
template <typename T> bool DN_TArrayResizeAllocator (T **data, DN_USize *count, DN_USize *max, DN_Allocator allocator, DN_USize new_max);
|
||||
template <typename T> bool DN_TArrayReserveAllocator (T **data, DN_USize *max, DN_Allocator allocator, DN_USize new_max);
|
||||
template <typename T> bool DN_TArrayPrepareAllocator (T **data, DN_USize count, DN_USize *max, DN_Allocator allocator, DN_USize add_count);
|
||||
template <typename T> DN_USize DN_TArrayCopyPtrAllocator (T **data, T const *src, DN_USize count, DN_Allocator allocator);
|
||||
template <typename T> DN_USize DN_TArrayCopyPtrAllocatorAssert(T **data, T const *src, DN_USize count, DN_Allocator allocator, DN_CallSite call_site);
|
||||
|
||||
template <typename T>
|
||||
DN_ArrayFindResult DN_TArrayFind(T *data, DN_USize count, void const *find, DN_ArrayFindEqFunc *eq_func)
|
||||
{
|
||||
DN_ArrayFindResult result = DN_ArrayFind(data, count, sizeof(*data), find, eq_func);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
DN_ArrayFindResult DN_TArrayFindMemEq(T *data, DN_USize count, void const *find)
|
||||
{
|
||||
DN_ArrayFindResult result = DN_ArrayFindMemEq(data, count, sizeof(*data), find);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayInsertArray(T *data, DN_USize *count, DN_USize max, DN_USize index, T const *items, DN_USize items_count)
|
||||
{
|
||||
T *result = DN_Cast(T *)DN_ArrayInsertArray(data, count, max, sizeof(*data), index, items, items_count);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayPopFront(T *data, DN_USize *count, DN_USize pop_count)
|
||||
{
|
||||
T *result = DN_Cast(T *)DN_ArrayPopFront(data, count, sizeof(*data), pop_count);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayPopBack(T *data, DN_USize *count, DN_USize pop_count)
|
||||
{
|
||||
T *result = DN_Cast(T *)DN_ArrayPopBack(data, count, sizeof(*data), pop_count);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
DN_USize DN_TArrayEraseRange(T *data, DN_USize *count, DN_USize begin_index, DN_ISize erase_count, DN_ArrayErase erase)
|
||||
{
|
||||
return DN_ArrayEraseRange(data, count, sizeof(*data), begin_index, erase_count, erase);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayMakeArray(T *data, DN_USize *count, DN_USize max, DN_USize make_count, DN_ZMem z_mem)
|
||||
{
|
||||
T *result = DN_Cast(T *)DN_ArrayMakeArray(data, count, max, sizeof(*data), make_count, z_mem);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayMakeArrayAssert(T *data, DN_USize *count, DN_USize max, DN_USize make_count, DN_ZMem z_mem, DN_CallSite call_site)
|
||||
{
|
||||
T *result = DN_Cast(T *)DN_ArrayMakeArrayAssert(data, count, max, sizeof(*data), make_count, z_mem, call_site);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayMakeArrayAssertZ(T *data, DN_USize *count, DN_USize max, DN_USize make_count, DN_CallSite call_site)
|
||||
{
|
||||
T* result = DN_TArrayMakeArrayAssert(data, count, max, make_count, DN_ZMem_Yes, call_site);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayMakeArrayAssertNoZ(T *data, DN_USize *count, DN_USize max, DN_USize make_count, DN_CallSite call_site)
|
||||
{
|
||||
T* result = DN_TArrayMakeArrayAssert(data, count, max, make_count, DN_ZMem_No, call_site);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayAddArray(T *data, DN_USize *count, DN_USize max, T const *elems, DN_USize elems_count, DN_AddType add)
|
||||
{
|
||||
T* result = DN_Cast(T *)DN_ArrayAddArray(data, count, max, sizeof(*elems), elems, elems_count, add);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayAddArrayAssert(T *data, DN_USize *count, DN_USize max, T const *elems, DN_USize elems_count, DN_AddType add, DN_CallSite call_site)
|
||||
{
|
||||
T* result = DN_Cast(T *)DN_ArrayAddArrayAssert(data, count, max, sizeof(*elems), elems, elems_count, add, call_site);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayMakeArrayAllocator(T **data, DN_USize *count, DN_USize *max, DN_Allocator allocator, DN_USize make_count, DN_ZMem z_mem)
|
||||
{
|
||||
T *result = DN_Cast(T *)DN_ArrayMakeArrayAllocator(DN_Cast(void **)data, count, max, sizeof(**data), allocator, make_count, z_mem);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayMakeArrayAllocatorZ(T **data, DN_USize *count, DN_USize *max, DN_Allocator allocator, DN_USize make_count)
|
||||
{
|
||||
T *result = DN_TArrayMakeArrayAllocator(data, count, max, allocator, make_count, DN_ZMem_Yes);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayMakeArrayAllocatorNoZ(T **data, DN_USize *count, DN_USize *max, DN_Allocator allocator, DN_USize make_count)
|
||||
{
|
||||
T *result = DN_TArrayMakeArrayAllocator(data, count, max, allocator, make_count, DN_ZMem_No);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *DN_TArrayAddArrayAllocator(T **data, DN_USize *count, DN_USize *max, DN_Allocator allocator, T const *elems, DN_USize elems_count, DN_AddType add)
|
||||
{
|
||||
T *result = DN_Cast(T *)DN_ArrayAddArrayAllocator(DN_Cast(void **)data, count, max, sizeof(**data), allocator, elems, elems_count, add);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool DN_TArrayResizeAllocator(T **data, DN_USize *count, DN_USize *max, DN_Allocator allocator, DN_USize new_max)
|
||||
{
|
||||
bool result = DN_ArrayResizeAllocator(DN_Cast(void **)data, count, max, sizeof(**data), allocator, new_max);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool DN_TArrayReserveAllocator(T **data, DN_USize *max, DN_Allocator allocator, DN_USize new_max)
|
||||
{
|
||||
bool result = DN_ArrayReserveAllocator(DN_Cast(void **)data, max, sizeof(**data), allocator, new_max);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool DN_TArrayPrepareAllocator(T **data, DN_USize count, DN_USize *max, DN_Allocator allocator, DN_USize add_count)
|
||||
{
|
||||
bool result = DN_ArrayPrepareAllocator(DN_Cast(void **)data, count, max, sizeof(**data), allocator, add_count);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
DN_USize DN_TArrayCopyPtrAllocator(T **data, T const *src, DN_USize count, DN_Allocator allocator)
|
||||
{
|
||||
DN_USize result = DN_ArrayCopyPtrAllocator(DN_Cast(void **)data, src, count, sizeof(T), allocator);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
DN_USize DN_TArrayCopyPtrAllocatorAssert(T **data, T const *src, DN_USize count, DN_Allocator allocator, DN_CallSite call_site)
|
||||
{
|
||||
DN_USize result = DN_ArrayCopyPtrAllocatorAssert(DN_Cast(void **)data, src, count, sizeof(T), allocator, call_site);
|
||||
return result;
|
||||
}
|
||||
#endif // defined(__cplusplus) && DN_CPP
|
||||
#endif // DN_CPP_H
|
||||
+24
-26
@@ -33,24 +33,20 @@ DN_Str8 DN_SH_CLIOptionsStr8()
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, char const **arg_ptr, int arg_count)
|
||||
DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, DN_ArgvIterator *it)
|
||||
{
|
||||
DN_SHCLIEatArgResult result = {};
|
||||
result.arg_ptr = arg_ptr;
|
||||
result.arg_count = arg_count;
|
||||
|
||||
DN_Str8 arg = {};
|
||||
if (arg_count)
|
||||
arg = DN_Str8FromCStr8(*result.arg_ptr);
|
||||
DN_Str8 arg = it->arg;
|
||||
|
||||
// NOTE: Try handling the argument if we recognise it
|
||||
{
|
||||
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-exe-path"))) {
|
||||
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
|
||||
result.eaten = true;
|
||||
args->exe_path = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
|
||||
DN_Str8 value = DN_ArgvPeek(it, 1);
|
||||
DN_ArgvEat(it, 1);
|
||||
result.eaten = true;
|
||||
args->exe_path = value;
|
||||
|
||||
if (DN_OS_PathInfo(args->exe_path).type != DN_OSPathInfoType_File) {
|
||||
if (DN_Os_PathInfo(args->exe_path).type != DN_OsPathInfoType_File) {
|
||||
result.error_msg = DN_Str8Lit("Seshc executable path does not point to a file");
|
||||
result.error_arg = args->exe_path;
|
||||
args->exe_path = {};
|
||||
@@ -58,11 +54,12 @@ DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, char const **arg_ptr, i
|
||||
}
|
||||
|
||||
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-ini-path"))) {
|
||||
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
|
||||
result.eaten = true;
|
||||
args->ini_path = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
|
||||
DN_Str8 value = DN_ArgvPeek(it, 1);
|
||||
DN_ArgvEat(it, 1);
|
||||
result.eaten = true;
|
||||
args->ini_path = value;
|
||||
|
||||
if (DN_OS_PathInfo(args->ini_path).type != DN_OSPathInfoType_File) {
|
||||
if (DN_Os_PathInfo(args->ini_path).type != DN_OsPathInfoType_File) {
|
||||
result.error_msg = DN_Str8Lit("Seshc ini path does not point to a file");
|
||||
result.error_arg = args->ini_path;
|
||||
args->ini_path = {};
|
||||
@@ -70,9 +67,10 @@ DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, char const **arg_ptr, i
|
||||
}
|
||||
|
||||
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-seed-node"))) {
|
||||
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
|
||||
result.eaten = true;
|
||||
args->seed_node_url = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
|
||||
DN_Str8 value = DN_ArgvPeek(it, 1);
|
||||
DN_ArgvEat(it, 1);
|
||||
result.eaten = true;
|
||||
args->seed_node_url = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +122,7 @@ bool DN_SH_MsgSendBlockingFmt(DN_SHMsgSendData send, DN_SHCLIArgs *cli_args, cha
|
||||
DN_Str8Slice cmd_line = {};
|
||||
cmd_line.data = cmds;
|
||||
cmd_line.count = cmds_count;
|
||||
DN_OSExecResult exec = DN_OS_Exec(cmd_line, DN_OS_ExecArgsDefault(), &scratch.arena, nullptr);
|
||||
DN_OsExecResult exec = DN_Os_Exec(cmd_line, DN_Os_ExecArgsDefault(), &scratch.arena, nullptr);
|
||||
result = exec.os_error_code == 0 && exec.exit_code == 0;
|
||||
if (!result) {
|
||||
DN_LogErrorF("Error sending message to %.*s (exit code: %d, os: %d): %.*s",
|
||||
@@ -139,7 +137,7 @@ bool DN_SH_MsgSendBlockingFmt(DN_SHMsgSendData send, DN_SHCLIArgs *cli_args, cha
|
||||
return result;
|
||||
}
|
||||
|
||||
static int DN_SH_MsgSendDetachedFmtThreadFunc_(DN_OSThread *thread)
|
||||
static int DN_SH_MsgSendDetachedFmtThreadFunc_(DN_OsThread *thread)
|
||||
{
|
||||
DN_SHMsgSendAsyncContext_ *context = DN_Cast(DN_SHMsgSendAsyncContext_ *) thread->user_context;
|
||||
context->send_success = DN_SH_MsgSendBlockingFmt(context->send, &context->args, "%.*s", DN_Str8PrintFmt(context->msg));
|
||||
@@ -163,17 +161,17 @@ static DN_SHMsgSendAsyncHandle DN_SH_MsgSendAsyncFmtVMaybeDetached_(DN_SHMsgSend
|
||||
context->detached = detached;
|
||||
|
||||
// NOTE: Execute and forget
|
||||
DN_OSThreadInitArgs thread_args = DN_OS_ThreadInitArgsDefault();
|
||||
DN_OsThreadInitArgs thread_args = DN_Os_ThreadInitArgsDefault();
|
||||
if (detached)
|
||||
thread_args.flags |= DN_OSThreadFlags_Detached;
|
||||
thread_args.flags |= DN_OsThreadFlags_Detached;
|
||||
|
||||
DN_OS_ThreadInit(&result.thread, DN_SH_MsgSendDetachedFmtThreadFunc_, thread_args, context);
|
||||
DN_Os_ThreadInit(&result.thread, DN_SH_MsgSendDetachedFmtThreadFunc_, thread_args, context);
|
||||
return result;
|
||||
}
|
||||
|
||||
void DN_SH_MsgSendDetachedFmt(DN_SHMsgSendData send, DN_SHCLIArgs *cli_args, char const *fmt, ...)
|
||||
{
|
||||
DN_Arena arena_stack = DN_OS_ArenaFromHeapVirtual(0, 0, DN_MemFlags_Nil);
|
||||
DN_Arena arena_stack = DN_Os_ArenaFromHeapVirtual(0, 0, DN_MemListFlags_Nil);
|
||||
DN_Arena *arena = DN_ArenaNewZ(&arena_stack, DN_Arena);
|
||||
*arena = arena_stack;
|
||||
|
||||
@@ -196,7 +194,7 @@ DN_SHMsgSendAsyncStatus DN_SH_MsgSendAsyncWait(DN_SHMsgSendAsyncHandle *handle,
|
||||
{
|
||||
DN_SHMsgSendAsyncStatus result = DN_SHMsgSendAsyncStatus_Success;
|
||||
if (handle && handle->thread.user_context) {
|
||||
bool joined = DN_OS_ThreadJoin(&handle->thread, timeout_ms, DN_TcDeinitArenas_Yes);
|
||||
bool joined = DN_Os_ThreadJoin(&handle->thread, timeout_ms, DN_TcDeinitArenas_Yes);
|
||||
if (joined) {
|
||||
DN_SHMsgSendAsyncContext_ *context = DN_Cast(DN_SHMsgSendAsyncContext_ *) handle->thread.user_context;
|
||||
result = context->send_success ? DN_SHMsgSendAsyncStatus_Success : DN_SHMsgSendAsyncStatus_Failed;
|
||||
@@ -222,7 +220,7 @@ void DN_SH_LogBroadcastFmtV(DN_SHLogMode mode, DN_LogType type, DN_SHMsgSendData
|
||||
}
|
||||
DN_LogF(type, "%.*s%.*s. %.*s", DN_Str8PrintFmt(prefix), DN_Str8PrintFmt(short_desc), DN_Str8PrintFmt(msg));
|
||||
|
||||
DN_Date date = DN_OS_DateLocalTimeNow();
|
||||
DN_Date date = DN_Os_DateLocalTimeNow();
|
||||
|
||||
// NOTE: 12-hour conversion
|
||||
DN_U8 hour12 = date.hour % 12;
|
||||
|
||||
+2
-4
@@ -19,8 +19,6 @@ struct DN_SHCLIEatArgResult
|
||||
bool eaten;
|
||||
DN_Str8 error_msg; // Parsing error message. String is immutably stored in the data-segment w/ program lifetime.
|
||||
DN_Str8 error_arg; // Argument that caused the parsing error
|
||||
char const **arg_ptr; // Next argument pointer that that the caller should proceed from
|
||||
DN_USize arg_count; // Next argument count that that the caller should assume
|
||||
};
|
||||
|
||||
struct DN_SHMsgSendData
|
||||
@@ -32,7 +30,7 @@ struct DN_SHMsgSendData
|
||||
|
||||
struct DN_SHMsgSendAsyncHandle
|
||||
{
|
||||
DN_OSThread thread;
|
||||
DN_OsThread thread;
|
||||
};
|
||||
|
||||
enum DN_SHLogMode
|
||||
@@ -70,7 +68,7 @@ enum DN_SHMsgSendAsyncStatus
|
||||
|
||||
DN_SHCLIArgs DN_SH_CLIArgsCopy (DN_SHCLIArgs const *src, DN_Arena *arena);
|
||||
DN_Str8 DN_SH_CLIOptionsStr8 ();
|
||||
DN_SHCLIEatArgResult DN_SH_CLIEatArg (DN_SHCLIArgs *args, char const **arg_ptr, int arg_count);
|
||||
DN_SHCLIEatArgResult DN_SH_CLIEatArg (DN_SHCLIArgs *args, DN_ArgvIterator *it);
|
||||
bool DN_SH_MsgSendBlockingFmt (DN_SHMsgSendData send, DN_SHCLIArgs *cli_args, char const *fmt, ...);
|
||||
void DN_SH_MsgSendDetachedFmt (DN_SHMsgSendData send, DN_SHCLIArgs *cli_args, char const *fmt, ...);
|
||||
DN_SHMsgSendAsyncHandle DN_SH_MsgSendAsyncFmt (DN_SHMsgSendData send, DN_SHCLIArgs *cli_args, DN_Arena *arena, char const *fmt, ...);
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ int main(int, char**)
|
||||
DN_TestCore sha3_test = DN_SHA3_TestSuite(arena);
|
||||
DN_Str8 dn_str8 = DN_Str8FromTestCore(&dn_test, arena, DN_Str8FromTestCoreFlags_Colour);
|
||||
DN_Str8 sha3_str8 = DN_Str8FromTestCore(&sha3_test, arena, DN_Str8FromTestCoreFlags_Colour);
|
||||
DN_OS_PrintOutF("%.*s\n%.*s", DN_Str8PrintFmt(dn_str8), DN_Str8PrintFmt(sha3_str8));
|
||||
DN_Os_PrintOutF("%.*s\n%.*s", DN_Str8PrintFmt(dn_str8), DN_Str8PrintFmt(sha3_str8));
|
||||
return 0;
|
||||
}
|
||||
DN_MSVC_WARNING_POP
|
||||
@@ -28,7 +28,7 @@ static void AppendCppFileLineByLine(DN_Str8Builder *dest, DN_Str8 cpp_path)
|
||||
{
|
||||
DN_TcScratch scratch = DN_TcScratchBeginArena(&dest->arena, 1);
|
||||
DN_ErrSink *err = DN_TcErrSinkBeginDefault();
|
||||
DN_Str8 buffer = DN_OS_FileReadAllArena(&scratch.arena, cpp_path, err);
|
||||
DN_Str8 buffer = DN_Os_FileReadAllArena(&scratch.arena, cpp_path, err);
|
||||
DN_ErrSinkEndExitIfErrorF(err, -1, "Failed to load file from '%S' for appending", cpp_path);
|
||||
|
||||
bool inside_clangd_preprocessor_block = false;
|
||||
@@ -93,14 +93,14 @@ int main(int argc, char **argv)
|
||||
DN_Init(&dn, DN_InitFlags_OS, DN_TcInitArgsDefault());
|
||||
|
||||
if (argc != 3) {
|
||||
DN_OS_PrintErrF("USAGE: %s <path/to/dn/Source> <output_dir>", argv[0]);
|
||||
DN_Os_PrintErrF("USAGE: %s <path/to/dn/Source> <output_dir>", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
DN_Str8 dn_root_dir = DN_Str8FromCStr8(argv[1]);
|
||||
DN_Str8 output_dir = DN_Str8FromCStr8(argv[2]);
|
||||
if (!DN_OS_PathMakeDir(output_dir)) {
|
||||
DN_OS_PrintErrF("Failed to make requested output directory: %S", output_dir);
|
||||
if (!DN_Os_PathMakeDir(output_dir)) {
|
||||
DN_Os_PrintErrF("Failed to make requested output directory: %S", output_dir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -117,13 +117,13 @@ int main(int argc, char **argv)
|
||||
AppendCppFileLineByLine(&builder, path);
|
||||
}
|
||||
|
||||
DN_Date date = DN_OS_DateLocalTimeNow();
|
||||
DN_Date date = DN_Os_DateLocalTimeNow();
|
||||
DN_Str8BuilderPrependF(&builder, "// Generated by the DN single header generator %04u-%02u-%02u %02u:%02u:%02u\n\n", date.year, date.month, date.day, date.hour, date.minutes, date.seconds);
|
||||
|
||||
DN_Str8 buffer = DN_Str8TrimWhitespaceAround(DN_Str8FromStr8BuilderArena(&builder, &scratch.arena));
|
||||
DN_Str8 single_header_path = DN_Str8PathFmtOsArena(&scratch.arena, "%S/dn_single_header.%S", output_dir, suffix).value;
|
||||
DN_ErrSink *err = DN_TcErrSinkBeginDefault();
|
||||
DN_OS_FileWriteAllSafe(single_header_path, buffer, err);
|
||||
DN_Os_FileWriteAllSafe(single_header_path, buffer, err);
|
||||
DN_ErrSinkEndExitIfErrorF(err, -1, "Failed to write Single header file '%S'", single_header_path);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user