From 13cbf9d48f26083e29e07c1b59ad1d67b6efa147 Mon Sep 17 00:00:00 2001 From: Aurelien Reynaud Date: Sat, 19 Jun 2010 20:03:52 +0200 Subject: [PATCH] Fix errno thread-safety under AIX Unlike Linux or Solaris, errno under AIX is not thread-safe by default. This patch sets _THREAD_SAFE_ERRNO when AIX is detected in order to force the thread-safe implementation of errno. Without this, calls like stat() in the rrdtool plugin fail with errno incorrectly set, leading to the inability to create previously absent rrd files. Maybe _THREAD_SAFE should be set instead, to prevent other possible threads-related problems, but this is enough to scratch my current itch... Here is the relevant part of /usr/include/errno.h on AIX: #if defined(_THREAD_SAFE) || defined(_THREAD_SAFE_ERRNO) /* * Per thread errno is provided by the threads provider. Both the extern * int * and the per thread value must be maintained by the threads library. */ extern int *_Errno( void ); #define errno (*_Errno()) #else extern int errno; #endif /* _THREAD_SAFE || _THREAD_SAFE_ERRNO */ Signed-off-by: Aurelien Reynaud Signed-off-by: Florian Forster --- configure.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.in b/configure.in index 3e31cf2a..8f6eadee 100644 --- a/configure.in +++ b/configure.in @@ -88,6 +88,10 @@ if test "x$ac_system" = "xSolaris" then AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.]) fi +if test "x$ac_system" = "xAIX" +then + AC_DEFINE(_THREAD_SAFE_ERRNO, 1, [Define to use the thread-safe version of errno under AIX.]) +fi # Where to install .pc files. pkgconfigdir="${libdir}/pkgconfig" -- 2.30.2