Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions code/common/clock.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#if defined(_WIN32)
#include <Windows.h>
#elif defined(__linux__)
#include <time.h>
#else
static_assert(false, "clock.cc is not implemented for this operating system");
#include <time.h>
#endif

#include <mutex>
Expand All @@ -27,13 +25,11 @@ namespace common::time
QueryPerformanceCounter(&count);

return count.QuadPart;
#elif defined(__linux__)
#else
timespec ts;
if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts))
debug::panic("Failed to get time!");
return (u64)ts.tv_nsec + (u64)1E9 * (u64)ts.tv_sec;
#else
static_assert(false, "Not implemented");
#endif
}

Expand All @@ -49,10 +45,8 @@ namespace common::time
QueryPerformanceFrequency(&freq);

s_cached_cycles_per_second = freq.QuadPart;
#elif defined(__linux__)
return (u64)1E9;
#else
static_assert(false, "Not implemented");
return (u64)1E9;
#endif
}

Expand Down
12 changes: 3 additions & 9 deletions code/common/dynamic_library.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#if defined(_WIN32)
#include <wil/resource.h>
#elif defined(__linux__)
#include <dlfcn.h>
#else
#error Not Implemented
#include <dlfcn.h>
#endif

#include "common/strings.h"
Expand All @@ -15,10 +13,8 @@ namespace common
{
#if defined(_WIN32)
using handle_type = wil::unique_hmodule;
#elif defined(__linux__)
using handle_type = void*;
#else
#error Not Implemented
using handle_type = void*;
#endif

class dynamic_library::impl
Expand Down Expand Up @@ -68,7 +64,7 @@ namespace common

return reinterpret_cast<void*>(addr);
}
#elif defined(__linux__)
#else
bool dynamic_library::impl::open(std::string_view name)
{
const auto name_string = std::string{ name };
Expand All @@ -90,8 +86,6 @@ namespace common

return dlsym(m_handle, name_string.c_str());
}
#else
#error Not Implemented
#endif

dynamic_library::dynamic_library()
Expand Down
16 changes: 12 additions & 4 deletions code/common/synchro.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#if defined(_WIN32)
#include <Windows.h>
#elif defined(__linux__)
#endif

#if defined(__linux__) || defined(__APPLE__)
#include <pthread.h>
#include <time.h>
#else
static_assert(false, "synchro.cc not defined for this operating system");
#endif

#if defined(__APPLE__)
#include <mach/mach.h>
#endif

#include "common/debug.h"
Expand All @@ -24,6 +28,8 @@ namespace common::synchro
return GetCurrentThreadId();
#elif defined(__linux__)
return static_cast<sint>(pthread_self()); // Return type might need to be OS-dependent
#elif defined(__APPLE__)
return mach_thread_self();
#else
static_assert(false, "Not implemented");
#endif
Expand All @@ -43,6 +49,8 @@ namespace common::synchro
p_set_thread_description(GetCurrentThread(), wname.c_str());
#elif defined(__linux__)
pthread_setname_np(pthread_self(), name.data());
#elif defined(__APPLE__)
pthread_setname_np(name.data());
#else
static_assert(false, "Not implemented");
#endif
Expand All @@ -52,7 +60,7 @@ namespace common::synchro
{
#if defined(_WIN32)
Sleep(ms);
#elif defined(__linux__)
#elif defined(__linux__) || defined(__APPLE__)
timespec ts;
ts.tv_sec = ms / 1000;
ts.tv_nsec = (ms % 1000) * 1000000;
Expand Down