Improve platform defines, update sprintf

This commit is contained in:
Doyle T 2018-07-05 00:47:11 +10:00
parent a4c7934587
commit a23e2687fe
2 changed files with 1662 additions and 1441 deletions

View File

@ -3,13 +3,7 @@
#include <ws2tcpip.h> #include <ws2tcpip.h>
#include <Windows.h> #include <Windows.h>
#if (defined(_WIN32) || defined(_WIN64))
#define DQN_WIN32_IMPLEMENTATION
#include "Windows.h"
#endif
#if defined(__linux__) #if defined(__linux__)
#define DQN_UNIX_IMPLEMENTATION
#define HANDMADE_MATH_NO_SSE #define HANDMADE_MATH_NO_SSE
#endif #endif
@ -19,6 +13,7 @@
#endif #endif
#define DQN_PLATFORM_HEADER #define DQN_PLATFORM_HEADER
#define DQN_PLATFORM_IMPLEMENTATION
#define DQN_IMPLEMENTATION #define DQN_IMPLEMENTATION
#include "dqn.h" #include "dqn.h"
@ -1829,9 +1824,9 @@ void DqnFile_Test()
if (1) if (1)
{ {
i32 numFiles; i32 numFiles;
#if defined(DQN_UNIX_IMPLEMENTATION) #if defined(DQN___IS_UNIX)
char **filelist = DqnFile::ListDir(".", &numFiles); char **filelist = DqnFile::ListDir(".", &numFiles);
#elif defined(DQN_WIN32_IMPLEMENTATION) #else
char **filelist = DqnFile::ListDir("*", &numFiles); char **filelist = DqnFile::ListDir("*", &numFiles);
#endif #endif
@ -1855,19 +1850,18 @@ void DqnTimer_Test()
{ {
f64 startInMs = DqnTimer_NowInMs(); f64 startInMs = DqnTimer_NowInMs();
#if defined(DQN_UNIX_PLATFORM) #if defined(DQN__IS_UNIX)
u32 sleepTimeInMs = 1; u32 sleepTimeInMs = 1;
sleep(sleepTimeInMs); sleep(sleepTimeInMs);
Log("start: %f, end: %f", startInMs, endInMs); Log("start: %f, end: %f", startInMs, endInMs);
DQN_ASSERT((startInMs + sleepTimeInMs) <= endInMs);
#elif defined(DQN_WIN32_PLATFORM) #else
u32 sleepTimeInMs = 1000; u32 sleepTimeInMs = 1000;
Sleep(sleepTimeInMs); Sleep(sleepTimeInMs);
DQN_ASSERT((startInMs + sleepTimeInMs) <= endInMs);
#endif #endif
f64 endInMs = DqnTimer_NowInMs(); f64 endInMs = DqnTimer_NowInMs();
DQN_ASSERT((startInMs + sleepTimeInMs) <= endInMs);
Log(Status::Ok, "Timer advanced in time over 1 second"); Log(Status::Ok, "Timer advanced in time over 1 second");
globalIndent++; globalIndent++;
Log("Start: %f, End: %f", startInMs, endInMs); Log("Start: %f, End: %f", startInMs, endInMs);
@ -1888,9 +1882,9 @@ FILE_SCOPE void JobQueueDebugCallbackIncrementCounter(DqnJobQueue *const queue,
globalDebugCounter++; globalDebugCounter++;
// u32 number = globalDebugCounter; // u32 number = globalDebugCounter;
#if defined(DQN_WIN32_IMPLEMENTATION) #if defined(DQN__IS_WIN32)
// Log("JobQueueDebugCallbackIncrementCounter(): Thread %d: Incrementing Number: %d", GetCurrentThreadId(), number); // Log("JobQueueDebugCallbackIncrementCounter(): Thread %d: Incrementing Number: %d", GetCurrentThreadId(), number);
#elif defined(DQN_UNIX_IMPLEMENTATION) #else
// Log("JobQueueDebugCallbackIncrementCounter(): Thread unix: Incrementing Number: %d", number); // Log("JobQueueDebugCallbackIncrementCounter(): Thread unix: Incrementing Number: %d", number);
#endif #endif
} }

2127
dqn.h

File diff suppressed because it is too large Load Diff