10Sstevel@tonic-gate# lock.m4 serial 14 20Sstevel@tonic-gatednl Copyright (C) 2005-2022 Free Software Foundation, Inc. 30Sstevel@tonic-gatednl This file is free software; the Free Software Foundation 40Sstevel@tonic-gatednl gives unlimited permission to copy and/or distribute it, 53066Sjgdnl with or without modifications, as long as this notice is preserved. 63066Sjg 70Sstevel@tonic-gatednl From Bruno Haible. 80Sstevel@tonic-gate 90Sstevel@tonic-gateAC_DEFUN([gl_LOCK], 100Sstevel@tonic-gate[ 110Sstevel@tonic-gate AC_REQUIRE([gl_THREADLIB]) 120Sstevel@tonic-gate if test "$gl_threads_api" = posix; then 130Sstevel@tonic-gate # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the 140Sstevel@tonic-gate # pthread_rwlock_* functions. 150Sstevel@tonic-gate has_rwlock=false 160Sstevel@tonic-gate AC_CHECK_TYPE([pthread_rwlock_t], 170Sstevel@tonic-gate [has_rwlock=true 180Sstevel@tonic-gate AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], 190Sstevel@tonic-gate [Define if the POSIX multithreading library has read/write locks.])], 200Sstevel@tonic-gate [], 210Sstevel@tonic-gate [#include <pthread.h>]) 220Sstevel@tonic-gate if $has_rwlock; then 230Sstevel@tonic-gate gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER 243066Sjg fi 250Sstevel@tonic-gate # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. 260Sstevel@tonic-gate AC_COMPILE_IFELSE([ 273066Sjg AC_LANG_PROGRAM( 280Sstevel@tonic-gate [[#include <pthread.h>]], 290Sstevel@tonic-gate [[ 300Sstevel@tonic-gate#if __FreeBSD__ == 4 310Sstevel@tonic-gateerror "No, in FreeBSD 4.0 recursive mutexes actually don't work." 320Sstevel@tonic-gate#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \ 330Sstevel@tonic-gate && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) 340Sstevel@tonic-gateerror "No, in Mac OS X < 10.7 recursive mutexes actually don't work." 350Sstevel@tonic-gate#else 360Sstevel@tonic-gateint x = (int)PTHREAD_MUTEX_RECURSIVE; 370Sstevel@tonic-gatereturn !x; 380Sstevel@tonic-gate#endif 390Sstevel@tonic-gate ]])], 400Sstevel@tonic-gate [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1], 410Sstevel@tonic-gate [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])]) 420Sstevel@tonic-gate fi 430Sstevel@tonic-gate gl_PREREQ_LOCK 440Sstevel@tonic-gate]) 450Sstevel@tonic-gate 460Sstevel@tonic-gate# Prerequisites of lib/glthread/lock.c. 470Sstevel@tonic-gateAC_DEFUN([gl_PREREQ_LOCK], [:]) 480Sstevel@tonic-gate