Skip to content

Commit

Permalink
LibThreading: Fix building the library on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarbeutner committed Jul 5, 2021
1 parent 565796a commit 01db520
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Meta/Lagom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ include_directories(../../Userland/)
include_directories(../../Userland/Libraries/)
include_directories(${CMAKE_BINARY_DIR})
add_library(LagomCore ${LAGOM_CORE_SOURCES})
find_package(Threads REQUIRED)
target_link_libraries(LagomCore PRIVATE Threads::Threads)

if (BUILD_LAGOM)
add_library(Lagom $<TARGET_OBJECTS:LagomCore> ${LAGOM_MORE_SOURCES})
Expand Down
13 changes: 12 additions & 1 deletion Userland/Libraries/LibThreading/Lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,25 @@ namespace Threading {

class Lock {
public:
Lock() { }
Lock() {
#ifndef __serenity__
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&m_mutex, &attr);
#endif
}
~Lock() { }

void lock();
void unlock();

private:
#ifdef __serenity__
pthread_mutex_t m_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#else
pthread_mutex_t m_mutex;
#endif
};

class Locker {
Expand Down

0 comments on commit 01db520

Please sign in to comment.