summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2015-03-23 17:03:41 +0000
committerChris Liddell <chris.liddell@artifex.com>2015-03-24 14:04:25 +0000
commitb96200d7fc5f3b7464744589f6657e9b4c4cb3ec (patch)
tree90294e1b18030f5c478d988348a3cba9175539fa
parent9358edca362b60f8ace388768548e6e94f5ebec8 (diff)
downloadghostpdl-b96200d7fc5f3b7464744589f6657e9b4c4cb3ec.tar.gz
Bug 695882: ensure function protypes are available
There are some special defines on Linux to include prototypes for pread, pwrite and pthread_mutexattr_settype: add these to our "unistd_.h" header. Also, tweak the the configure script to check for prototypes as well as just successful linking before including the code that uses those functions No cluster differences
-rw-r--r--configure.ac39
-rw-r--r--gs/base/gp_psync.c1
-rw-r--r--gs/base/unistd_.h1
-rw-r--r--gs/configure.ac37
4 files changed, 73 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 2a9a2c9e3..ffb8b5128 100644
--- a/configure.ac
+++ b/configure.ac
@@ -465,6 +465,16 @@ dnl --------------------------------------------------
AC_CHECK_FUNCS([pread pwrite], [HAVE_PREAD_PWRITE="-DHAVE_PREAD_PWRITE=1"], [HAVE_PREAD_PWRITE=])
+if test "x$HAVE_PREAD_PWRITE" != "x"; then
+ save_cflags=$CFLAGS
+ CFLAGS="$CFLAGS -D__USE_UNIX98=1 -D_XOPEN_SOURCE=500"
+ AC_CHECK_DECLS([pwrite,pread], [], [HAVE_PREAD_PWRITE=])
+ CFLAGS=$save_cflags
+ if test "x$HAVE_PREAD_PWRITE" != "x"; then
+ GCFLAGS="$GCFLAGS -D__USE_UNIX98=1"
+ fi
+fi
+
AC_SUBST(HAVE_PREAD_PWRITE)
SYNC="nosync"
@@ -477,7 +487,7 @@ AC_ARG_ENABLE([threading], AC_HELP_STRING([--disable-threading],
# if you haven't got pread/pwrite, we can't use multithreading
if test "x$HAVE_PREAD_PWRITE" != "x"; then
- if test "$enable_fontconfig" != "no"; then
+ if test "$enable_threading" != "no"; then
case `uname` in
MINGW*)
AC_MSG_WARN([disabling support for pthreads......])
@@ -487,11 +497,34 @@ if test "x$HAVE_PREAD_PWRITE" != "x"; then
SYNC=posync;
PTHREAD_LIBS="-lpthread"
])
+ AC_MSG_CHECKING([recursive mutexes.......])
AC_TRY_COMPILE([#include <pthread.h>],
- [static int k = PTHREAD_MUTEX_RECURSIVE;],
+ [
+ static int k = PTHREAD_MUTEX_RECURSIVE;
+ #ifndef pthread_mutexattr_settype
+ #ifdef __cplusplus
+ (void) pthread_mutexattr_settype;
+ #else
+ (void) pthread_mutexattr_settype;
+ #endif
+ #endif
+ ;
+ return 0;
+ ],
[RECURSIVE_MUTEXATTR="-DGS_RECURSIVE_MUTEXATTR=PTHREAD_MUTEX_RECURSIVE"],
[AC_TRY_COMPILE([#include <pthread.h>],
- [static int k = PTHREAD_MUTEX_RECURSIVE_NP;],
+ [
+ static int k = PTHREAD_MUTEX_RECURSIVE_NP;
+ #ifndef pthread_mutexattr_settype
+ #ifdef __cplusplus
+ (void) pthread_mutexattr_settype;
+ #else
+ (void) pthread_mutexattr_settype;
+ #endif
+ #endif
+ ;
+ return 0;
+ ],
[RECURSIVE_MUTEXATTR="-DGS_RECURSIVE_MUTEXATTR=PTHREAD_MUTEX_RECURSIVE_NP"])])
;;
esac
diff --git a/gs/base/gp_psync.c b/gs/base/gp_psync.c
index 16804f3c1..07b31cc99 100644
--- a/gs/base/gp_psync.c
+++ b/gs/base/gp_psync.c
@@ -17,6 +17,7 @@
/* POSIX pthreads threads / semaphore / monitor implementation */
#include "std.h"
#include "malloc_.h"
+#include "unistd_.h" /* for __USE_UNIX98 */
#include <pthread.h>
#include "gserrors.h"
#include "gpsync.h"
diff --git a/gs/base/unistd_.h b/gs/base/unistd_.h
index d26d1bc21..daf22a94f 100644
--- a/gs/base/unistd_.h
+++ b/gs/base/unistd_.h
@@ -53,6 +53,7 @@
/* _XOPEN_SOURCE 500 define is needed to get
* access to pread and pwrite */
# define _XOPEN_SOURCE 500
+# define __USE_UNIX98
# include <unistd.h>
#endif
diff --git a/gs/configure.ac b/gs/configure.ac
index 0c818b2dc..de67c87da 100644
--- a/gs/configure.ac
+++ b/gs/configure.ac
@@ -494,6 +494,16 @@ AC_CHECK_LIB(m, cos)
AC_CHECK_FUNCS([pread pwrite], [HAVE_PREAD_PWRITE="-DHAVE_PREAD_PWRITE=1"], [HAVE_PREAD_PWRITE=])
+if test "x$HAVE_PREAD_PWRITE" != "x"; then
+ save_cflags=$CFLAGS
+ CFLAGS="$CFLAGS -D__USE_UNIX98=1 -D_XOPEN_SOURCE=500"
+ AC_CHECK_DECLS([pwrite,pread], [], [HAVE_PREAD_PWRITE=])
+ CFLAGS=$save_cflags
+ if test "x$HAVE_PREAD_PWRITE" != "x"; then
+ GCFLAGS="$GCFLAGS -D__USE_UNIX98=1"
+ fi
+fi
+
AC_SUBST(HAVE_PREAD_PWRITE)
SYNC="nosync"
@@ -515,11 +525,34 @@ if test "x$HAVE_PREAD_PWRITE" != "x"; then
SYNC=posync;
PTHREAD_LIBS="-lpthread"
])
+ AC_MSG_CHECKING([recursive mutexes.......])
AC_TRY_COMPILE([#include <pthread.h>],
- [static int k = PTHREAD_MUTEX_RECURSIVE;],
+ [
+ static int k = PTHREAD_MUTEX_RECURSIVE;
+ #ifndef pthread_mutexattr_settype
+ #ifdef __cplusplus
+ (void) pthread_mutexattr_settype;
+ #else
+ (void) pthread_mutexattr_settype;
+ #endif
+ #endif
+ ;
+ return 0;
+ ],
[RECURSIVE_MUTEXATTR="-DGS_RECURSIVE_MUTEXATTR=PTHREAD_MUTEX_RECURSIVE"],
[AC_TRY_COMPILE([#include <pthread.h>],
- [static int k = PTHREAD_MUTEX_RECURSIVE_NP;],
+ [
+ static int k = PTHREAD_MUTEX_RECURSIVE_NP;
+ #ifndef pthread_mutexattr_settype
+ #ifdef __cplusplus
+ (void) pthread_mutexattr_settype;
+ #else
+ (void) pthread_mutexattr_settype;
+ #endif
+ #endif
+ ;
+ return 0;
+ ],
[RECURSIVE_MUTEXATTR="-DGS_RECURSIVE_MUTEXATTR=PTHREAD_MUTEX_RECURSIVE_NP"])])
;;
esac