From: Chris Liddell Date: Mon, 23 Mar 2015 17:03:41 +0000 (+0000) Subject: Bug 695882: ensure function protypes are available X-Git-Url: http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff_plain;h=8bb53a7f 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 --- base/gp_psync.c +++ 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 #include "gserrors.h" #include "gpsync.h" --- base/unistd_.h +++ 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 #endif --- configure.ac +++ 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 ], - [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 ], - [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