feat(app): add windows app

This commit is contained in:
fallenoak 2023-01-03 00:45:25 -06:00 committed by GitHub
parent 6bebfe5e2f
commit 655d795a9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 176 additions and 66 deletions

View file

@ -10,8 +10,10 @@
#include <atomic>
#endif
bool Blizzard::System_Thread::s_initialized;
Blizzard::System_Debug::AssertCallback Blizzard::System_Debug::s_assertCallback = nullptr;
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
bool Blizzard::System_Thread::s_initialized;
Blizzard::Lock::DoOnceData Blizzard::System_Lock::s_initMutexAttrOnce;
Blizzard::System_Lock::MutexAttr Blizzard::System_Lock::s_mutexattr;
Blizzard::Thread::ThreadRecord* Blizzard::System_Thread::s_mainThread;
@ -22,6 +24,7 @@ Blizzard::Thread::TLSSlot Blizzard::System_Thread::s_threadRecordTLS;
std::map<Blizzard::Thread::ThreadRecord*, Blizzard::Thread::ThreadRecord*>* Blizzard::System_Thread::s_threadRegistry;
Blizzard::Thread::TLSSlot* Blizzard::System_Thread::s_slotList[128];
int32_t Blizzard::System_Thread::s_slotListUsed;
#endif
void Blizzard::Debug::Assert(const char* a1, const char* a2, uint32_t a3) {
if (System_Debug::s_assertCallback) {
@ -103,14 +106,17 @@ void Blizzard::String::MemFill(void* a1, uint32_t a2, unsigned char a3) {
}
void Blizzard::Process::Sleep(uint32_t duration) {
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
struct timespec request;
request.tv_sec = 0;
request.tv_nsec = duration * 1000000;
nanosleep(&request, nullptr);
#endif
}
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
void Blizzard::Lock::DoOnce(DoOnceData& a1, void (*a2)(void*), void* a3) {
if (!a1.done) {
if (Blizzard::Lock::Atomic::Increment(&a1.atomic) == 1) {
@ -325,3 +331,4 @@ Blizzard::Thread::ThreadRecord* Blizzard::System_Thread::NewThread(uint32_t (*a1
bool Blizzard::System_Thread::TLSSlotIsAllocated(const Thread::TLSSlot* slot) {
return slot->allocated;
}
#endif

View file

@ -34,6 +34,21 @@ namespace Blizzard {
void Sleep(uint32_t);
}
namespace System_Debug {
// Types
typedef void (*AssertCallback)(const char*, const char*, const char*, uint32_t);
// Variables
extern AssertCallback s_assertCallback;
}
namespace Debug {
// Functions
void Assert(const char*, const char*, uint32_t);
void SetAssertHandler(Blizzard::System_Debug::AssertCallback);
}
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
namespace Lock {
// Types
typedef pthread_mutex_t Mutex;
@ -54,20 +69,6 @@ namespace Blizzard {
}
}
namespace System_Debug {
// Types
typedef void (*AssertCallback)(const char*, const char*, const char*, uint32_t);
// Variables
extern AssertCallback s_assertCallback;
}
namespace Debug {
// Functions
void Assert(const char*, const char*, uint32_t);
void SetAssertHandler(Blizzard::System_Debug::AssertCallback);
}
namespace System_Lock {
// Types
typedef pthread_mutexattr_t MutexAttr;
@ -127,6 +128,7 @@ namespace Blizzard {
Thread::ThreadRecord* NewThread(uint32_t (*)(void*), void*, const char*);
bool TLSSlotIsAllocated(const Thread::TLSSlot*);
};
#endif
};
#endif

View file

@ -2,6 +2,7 @@
#include <cstring>
#include <limits>
#include <storm/Memory.hpp>
#include <storm/String.hpp>
// TODO Proper implementation
int32_t SFile::Close(SFile* file) {
@ -27,11 +28,11 @@ int32_t SFile::IsStreamingMode() {
// TODO Proper implementation
int32_t SFile::Load(SArchive* archive, const char* filename, void** buffer, size_t* bytes, size_t extraBytes, uint32_t flags, SOVERLAPPED* overlapped) {
size_t pathlen = strlen(filename);
char path[pathlen];
strcpy(path, filename);
auto pathLen = SStrLen(filename);
char path[STORM_MAX_PATH];
SStrCopy(path, filename, sizeof(path));
for (int32_t i = 0; i < pathlen; ++i) {
for (int32_t i = 0; i < pathLen; ++i) {
if (path[i] == '\\') {
path[i] = '/';
}
@ -72,11 +73,11 @@ int32_t SFile::Open(const char* filename, SFile** file) {
// TODO Proper implementation
int32_t SFile::OpenEx(SArchive* archive, const char* filename, uint32_t flags, SFile** file) {
size_t pathlen = strlen(filename);
char path[pathlen];
strcpy(path, filename);
auto pathLen = SStrLen(filename);
char path[STORM_MAX_PATH];
SStrCopy(path, filename, sizeof(path));
for (int32_t i = 0; i < pathlen; ++i) {
for (int32_t i = 0; i < pathLen; ++i) {
if (path[i] == '\\') {
path[i] = '/';
}