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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ To retrieve logpp external dependencies, make sure to install and configure [con
3. Install dependencies
```sh
cd build
# If you're on Linux/Windows
conan install ..
# If you're on MacOS
conan install .. --build=fmt
```
4. Build the library
```sh
Expand Down
6 changes: 3 additions & 3 deletions include/logpp/utils/date.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace logpp

inline void gmtime(std::time_t* time, std::tm* out)
{
#if defined(LOGPP_PLATFORM_LINUX)
#if defined(LOGPP_PLATFORM_LINUX) || defined(LOGPP_PLATFORM_DARWIN)
::gmtime_r(time, out);
#elif defined(LOGPP_PLATFORM_WINDOWS)
gmtime_s(out, time);
Expand All @@ -64,7 +64,7 @@ namespace logpp

inline void localtime(std::time_t* time, std::tm* out)
{
#if defined(LOGPP_PLATFORM_LINUX)
#if defined(LOGPP_PLATFORM_LINUX) || defined(LOGPP_PLATFORM_DARWIN)
::localtime_r(time, out);
#elif defined(LOGPP_PLATFORM_WINDOWS)
localtime_s(out, time);
Expand All @@ -75,7 +75,7 @@ namespace logpp

inline time_t timegm(std::tm* tm)
{
#if defined(LOGPP_PLATFORM_LINUX)
#if defined(LOGPP_PLATFORM_LINUX) || defined(LOGPP_PLATFORM_DARWIN)
return ::timegm(tm);
#elif defined(LOGPP_PLATFORM_WINDOWS)
return _mkgmtime(tm);
Expand Down
17 changes: 16 additions & 1 deletion include/logpp/utils/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

#include "logpp/core/config.h"

#if defined(LOGPP_PLATFORM_LINUX)
#if defined(LOGPP_PLATFORM_LINUX) || defined(LOGPP_PLATFORM_DARWIN)
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <pthread.h>
#elif defined(LOGPP_PLATFORM_WINDOWS)
#include <windows.h>
#include <processthreadsapi.h>
Expand All @@ -21,6 +22,20 @@ namespace logpp::thread_utils
return syscall(SYS_gettid);
}

inline long toInteger(id id)
{
return static_cast<long>(id);
}
#elif defined(LOGPP_PLATFORM_DARWIN)
using id = uint64_t;

inline id getCurrentId()
{
uint64_t tid;
pthread_threadid_np(nullptr, &tid);
return tid;
}

inline long toInteger(id id)
{
return static_cast<long>(id);
Expand Down
5 changes: 4 additions & 1 deletion src/SpinWait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#if defined(LOGPP_PLATFORM_WINDOWS)
#define NOMINMAX
#include <Windows.h>
#elif defined(LOGPP_PLATFORM_LINUX) || defined(LOGPP_PLATFORM_DARWIN)
#include <sys/time.h>
#include <time.h>
#endif

namespace logpp
Expand Down Expand Up @@ -105,7 +108,7 @@ namespace logpp
{
#if defined(LOGPP_PLATFORM_WINDOWS)
return static_cast<uint32_t>(GetTickCount());
#elif defined(LOGPP_PLATFORM_LINUX)
#elif defined(LOGPP_PLATFORM_LINUX) || defined(LOGPP_PLATFORM_DARWIN)
#if CLOCK_MONOTONIC
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
Expand Down