mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
chore(build): make platform and arch defines more specific
This commit is contained in:
parent
5e2001a164
commit
be391c6592
12 changed files with 41 additions and 41 deletions
|
|
@ -20,21 +20,21 @@ set(CMAKE_CXX_STANDARD 11)
|
|||
|
||||
# Arch defines
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(ARCH_64 1)
|
||||
set(WHOA_ARCH_64 1)
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(ARCH_32 1)
|
||||
set(WHOA_ARCH_32 1)
|
||||
endif()
|
||||
|
||||
# OS defines
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(PLATFORM_WIN 1)
|
||||
add_definitions(-DPLATFORM_WIN)
|
||||
set(WHOA_PLATFORM_WIN 1)
|
||||
add_definitions(-DWHOA_PLATFORM_WIN)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(PLATFORM_LINUX 1)
|
||||
add_definitions(-DPLATFORM_LINUX)
|
||||
set(WHOA_PLATFORM_LINUX 1)
|
||||
add_definitions(-DWHOA_PLATFORM_LINUX)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(PLATFORM_MAC 1)
|
||||
add_definitions(-DPLATFORM_MAC)
|
||||
set(WHOA_PLATFORM_MAC 1)
|
||||
add_definitions(-DWHOA_PLATFORM_MAC)
|
||||
endif()
|
||||
|
||||
add_subdirectory(storm)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ file(GLOB STORM_SOURCES
|
|||
"thread/*.cpp"
|
||||
)
|
||||
|
||||
if(PLATFORM_MAC)
|
||||
if(WHOA_PLATFORM_MAC)
|
||||
file(GLOB STORM_MAC_SOURCES
|
||||
"mac/*.cpp"
|
||||
"mac/*.mm"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
#define ERROR_INVALID_PARAMETER 0x57
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#include "storm/thread/CSRWLock.hpp"
|
||||
|
||||
void CSRWLock::Enter(int32_t forwriting) {
|
||||
#ifdef PLATFORM_WIN
|
||||
#ifdef WHOA_PLATFORM_WIN
|
||||
// TODO
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
if (forwriting) {
|
||||
pthread_rwlock_wrlock(&this->m_lock);
|
||||
} else {
|
||||
|
|
@ -15,11 +15,11 @@ void CSRWLock::Enter(int32_t forwriting) {
|
|||
}
|
||||
|
||||
void CSRWLock::Leave(int32_t fromwriting) {
|
||||
#ifdef PLATFORM_WIN
|
||||
#ifdef WHOA_PLATFORM_WIN
|
||||
// TODO
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
pthread_rwlock_unlock(&this->m_lock);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
class CSRWLock {
|
||||
public:
|
||||
// Member variables
|
||||
#ifdef PLATFORM_WIN
|
||||
#ifdef WHOA_PLATFORM_WIN
|
||||
char m_opaqueData[12];
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
pthread_rwlock_t m_lock;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
#include "storm/thread/SCritSect.hpp"
|
||||
|
||||
void SCritSect::Enter() {
|
||||
#if defined(PLATFORM_WIN)
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
EnterCriticalSection(&this->m_opaqueData);
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
pthread_mutex_lock(&this->m_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SCritSect::Leave() {
|
||||
#if defined(PLATFORM_WIN)
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
LeaveCriticalSection(&this->m_opaqueData);
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
pthread_mutex_unlock(&this->m_mutex);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
#ifndef STORM_THREAD_S_CRIT_SECT_HPP
|
||||
#define STORM_THREAD_S_CRIT_SECT_HPP
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
class SCritSect {
|
||||
public:
|
||||
// Member variables
|
||||
#if defined(PLATFORM_WIN)
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
CRITICAL_SECTION m_opaqueData;
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
pthread_mutex_t m_mutex;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
SEvent::SEvent(int32_t manualReset, int32_t initialValue)
|
||||
: SSyncObject() {
|
||||
#if defined(PLATFORM_WIN)
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
this->m_opaqueData = CreateEventA(nullptr, manualReset, initialValue, nullptr);
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
this->m_int0 = 2 - (manualReset >= 1);
|
||||
this->m_value = initialValue;
|
||||
|
||||
|
|
@ -15,11 +15,11 @@ SEvent::SEvent(int32_t manualReset, int32_t initialValue)
|
|||
}
|
||||
|
||||
int32_t SEvent::Reset() {
|
||||
#if defined(PLATFORM_WIN)
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
return ResetEvent(this->m_opaqueData);
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
pthread_mutex_lock(&this->m_mutex);
|
||||
this->m_value = 0;
|
||||
pthread_mutex_unlock(&this->m_mutex);
|
||||
|
|
@ -29,11 +29,11 @@ int32_t SEvent::Reset() {
|
|||
}
|
||||
|
||||
int32_t SEvent::Set() {
|
||||
#if defined(PLATFORM_WIN)
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
return SetEvent(this->m_opaqueData);
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
pthread_mutex_lock(&this->m_mutex);
|
||||
|
||||
this->m_value = 1;
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
#include "storm/thread/SSyncObject.hpp"
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
#include <cerrno>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
SSyncObject::SSyncObject() {
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
pthread_mutex_init(&this->m_mutex, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t SSyncObject::Wait(uint32_t timeoutMs) {
|
||||
#if defined(PLATFORM_WIN)
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
return WaitForSingleObject(this->m_opaqueData, timeoutMs);
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
if (this->m_int0 == 6) {
|
||||
// WAIT_FAILED
|
||||
return 0xFFFFFFFF;
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
class SSyncObject {
|
||||
public:
|
||||
// Member variables
|
||||
#if defined(PLATFORM_WIN)
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
HANDLE m_opaqueData = nullptr;
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
int32_t m_int0 = 6;
|
||||
int32_t m_value;
|
||||
pthread_cond_t m_cond;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
#include "storm/Thread.hpp"
|
||||
|
||||
int32_t SThread::Create(uint32_t (*threadProc)(void*), void* param, SThread& thread, char* threadName, uint32_t a5) {
|
||||
#if defined(PLATFORM_WIN)
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
// TODO implement
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
thread.m_int0 = 5;
|
||||
thread.m_value = 0;
|
||||
pthread_cond_init(&thread.m_cond, nullptr);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
file(GLOB_RECURSE TEST_SOURCES "*.cpp")
|
||||
|
||||
if(PLATFORM_MAC)
|
||||
if(WHOA_PLATFORM_MAC)
|
||||
set_source_files_properties(${TEST_SOURCES}
|
||||
PROPERTIES COMPILE_FLAGS "-x objective-c++"
|
||||
)
|
||||
|
|
@ -16,7 +16,7 @@ if(PLATFORM_MAC)
|
|||
)
|
||||
endif()
|
||||
|
||||
if(PLATFORM_LINUX OR PLATFORM_WIN)
|
||||
if(WHOA_PLATFORM_LINUX OR WHOA_PLATFORM_WIN)
|
||||
add_executable(StormTest ${TEST_SOURCES})
|
||||
|
||||
target_link_libraries(StormTest
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue