Skip to content

Commit a05d4da

Browse files
jszakmeisterjasone
authored andcommitted
Implement a more reliable detection scheme for os_unfair_lock.
The core issue here is the weak linking of the symbol, and in certain environments--for instance, using the latest Xcode (8.1) with the latest SDK (10.12)--os_unfair_lock may resolve even though you're compiling on a host that doesn't support it (10.11). We can use the availability macros to circumvent this problem, and detect that we're not compiling for a target that is going to support them and error out at compile time. The other alternative is to do a runtime check, but that presents issues for cross-compiling.
1 parent e98a620 commit a05d4da

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,10 +1708,15 @@ dnl Check for os_unfair_lock operations as provided on Darwin.
17081708

17091709
JE_COMPILABLE([Darwin os_unfair_lock_*()], [
17101710
#include <os/lock.h>
1711+
#include <AvailabilityMacros.h>
17111712
], [
1713+
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
1714+
#error "os_unfair_lock is not supported"
1715+
#else
17121716
os_unfair_lock lock = OS_UNFAIR_LOCK_INIT;
17131717
os_unfair_lock_lock(&lock);
17141718
os_unfair_lock_unlock(&lock);
1719+
#endif
17151720
], [je_cv_os_unfair_lock])
17161721
if test "x${je_cv_os_unfair_lock}" = "xyes" ; then
17171722
AC_DEFINE([JEMALLOC_OS_UNFAIR_LOCK], [ ])

0 commit comments

Comments
 (0)