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
6 changes: 5 additions & 1 deletion eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,12 @@ elseif(CLR_CMAKE_HOST_APPLE)
endif()
endif()
elseif(CLR_CMAKE_HOST_HAIKU)
# Workaround until https://gitlab.kitware.com/cmake/cmake/-/merge_requests/11915 gets merged.
# Haiku uses the GNU toolchain so this should work.
set(CMAKE_LINK_GROUP_USING_RESCAN "LINKER:--start-group" "LINKER:--end-group")
set(CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED TRUE)
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
add_linker_flag("-Wl,--no-undefined")
add_linker_flag("-Wl,--build-id=sha1")
endif()

#------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/native/libs/Common/pal_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
#cmakedefine01 HAVE_CLOCK_GETTIME_NSEC_NP
#cmakedefine01 HAVE_PTHREAD_CONDATTR_SETCLOCK
#cmakedefine01 HAVE_PTHREAD_MUTEX_CLOCKLOCK
#cmakedefine01 HAVE_PTHREAD_MUTEX_CONSISTENT
#cmakedefine01 HAVE_PTHREAD_MUTEXATTR_SETROBUST
#cmakedefine01 HAVE_TCP_H_TCPSTATE_ENUM
#cmakedefine01 HAVE_TCP_FSM_H
#cmakedefine01 HAVE_GSSFW_HEADERS
Expand Down
4 changes: 4 additions & 0 deletions src/native/libs/System.Native/pal_crossprocessmutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ int32_t SystemNative_LowLevelCrossProcessMutex_Init(LowLevelCrossProcessMutex* m
error = pthread_mutexattr_settype(&mutexAttributes, PTHREAD_MUTEX_RECURSIVE);
assert(error == 0);

#if HAVE_PTHREAD_MUTEXATTR_SETROBUST
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkoritzinsky Is the cross-process mutex going to work without these APIs? Should Haiku use the fallback path instead?

error = pthread_mutexattr_setrobust(&mutexAttributes, PTHREAD_MUTEX_ROBUST);
assert(error == 0);
#endif

error = pthread_mutexattr_setpshared(&mutexAttributes, PTHREAD_PROCESS_SHARED);
assert(error == 0);
Expand All @@ -114,12 +116,14 @@ int32_t SystemNative_LowLevelCrossProcessMutex_Acquire(LowLevelCrossProcessMutex
{
int32_t result = AcquirePThreadMutexWithTimeout(&mutex->Mutex, timeoutMilliseconds);

#if HAVE_PTHREAD_MUTEX_CONSISTENT
if (result == EOWNERDEAD)
{
// The mutex was abandoned by the previous owner.
// Make it consistent so that it can be used again.
int setConsistentResult = pthread_mutex_consistent(&mutex->Mutex);
}
#endif

return ConvertErrorPlatformToPal(result);
}
Expand Down
2 changes: 2 additions & 0 deletions src/native/libs/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ endif()
if (NOT CLR_CMAKE_TARGET_WASI)
check_library_exists(${PTHREAD_LIBRARY} pthread_condattr_setclock "" HAVE_PTHREAD_CONDATTR_SETCLOCK)
check_library_exists(${PTHREAD_LIBRARY} pthread_mutex_clocklock "" HAVE_PTHREAD_MUTEX_CLOCKLOCK)
check_library_exists(${PTHREAD_LIBRARY} pthread_mutex_consistent "" HAVE_PTHREAD_MUTEX_CONSISTENT)
check_library_exists(${PTHREAD_LIBRARY} pthread_mutexattr_setrobust "" HAVE_PTHREAD_MUTEXATTR_SETROBUST)
endif()

check_symbol_exists(
Expand Down
Loading