summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2019-03-25 13:08:44 +0000
committerYann Ylavic <ylavic@apache.org>2019-03-25 13:08:44 +0000
commite0114bf183e1550becd8c152c964cecadd4c14c3 (patch)
treed1551768538cfccd0445a3c1a58f228490db5a0d /configure.in
parent97601b05c47214f931613fbb8823812b76568fd4 (diff)
downloadapr-e0114bf183e1550becd8c152c964cecadd4c14c3.tar.gz
Follow up to r1789258: configure to detect whether readdir() is thread-safe.
On platforms where readdir_r() is available but deprecated, readdir() is to be used although it's not in libc_r (e.g. Linux has no libc_r). In this case we can APR_TRY_COMPILE_NO_WARNING readdir_r() and, if it's deprecated, define READDIR_IS_THREAD_SAFE. With this we don't need user-defined APR_USE_READDIR{,64}_R from r1789258. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1856189 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in24
1 files changed, 23 insertions, 1 deletions
diff --git a/configure.in b/configure.in
index a55106977..a7ae4ceaf 100644
--- a/configure.in
+++ b/configure.in
@@ -845,8 +845,30 @@ ac_cv_define_GETSERVBYNAME_IS_THREAD_SAFE=no
if test "$threads" = "1"; then
AC_MSG_NOTICE([APR will use threads])
AC_CHECK_LIB(c_r, readdir,
+ apr_readdir_is_thread_safe=yes)
+ if test "x$apr_readdir_is_thread_safe" = "x"; then
+ AC_CHECK_HEADERS(dirent.h)
+ AC_CHECK_FUNCS(readdir_r)
+ APR_IFALLYES(header:dirent.h func:readdir_r,
+ apr_has_readdir_r="1", apr_has_readdir_r="0")
+ if test "$apr_has_readdir_r" = "1"; then
+ dnl readdir_r() may exist but be deprecated, meaning
+ dnl the readdir() itself is thread-safe
+ APR_TRY_COMPILE_NO_WARNING([
+ #include <dirent.h>
+ ],
+ [
+ DIR *dir = opendir("/tmp");
+ struct dirent entry, *result;
+ return readdir_r(dir, &entry, &result) != 0;
+ ], apr_readdir_is_thread_safe=no, apr_readdir_is_thread_safe=yes)
+ fi
+ fi
+ if test "$apr_readdir_is_thread_safe" = "yes"; then
+ AC_MSG_NOTICE([APR will use thread-safe readdir()])
AC_DEFINE(READDIR_IS_THREAD_SAFE, 1,
- [Define if readdir is thread safe]))
+ [Define if readdir is thread safe])
+ fi
if test "x$apr_gethostbyname_is_thread_safe" = "x"; then
AC_CHECK_LIB(c_r, gethostbyname, apr_gethostbyname_is_thread_safe=yes)
fi