]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Handle draft version of getpwuid_r() that accepts only four arguments.
authorBruce Momjian <bruce@momjian.us>
Sat, 20 Mar 2004 15:39:40 +0000 (15:39 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 20 Mar 2004 15:39:40 +0000 (15:39 +0000)
Backpatch to 7.4.X.  Required for Solaris 7 & 8.

config/c-library.m4
configure
configure.in
src/include/pg_config.h.in
src/port/thread.c

index d6acd8c98b69cc0c3dcabe600e129716edf8bbb4..f5f59cba629b8da6401a4f1fa7a1a61b32c43d6a 100644 (file)
@@ -1,5 +1,5 @@
 # Macros that test various C library quirks
-# $Header: /cvsroot/pgsql/config/c-library.m4,v 1.23 2003/07/23 23:30:39 tgl Exp $
+# $Header: /cvsroot/pgsql/config/c-library.m4,v 1.23.4.1 2004/03/20 15:39:40 momjian Exp $
 
 
 # PGAC_VAR_INT_TIMEZONE
@@ -73,6 +73,29 @@ AH_VERBATIM(GETTIMEOFDAY_1ARG_,
 ])# PGAC_FUNC_GETTIMEOFDAY_1ARG
 
 
+# PGAC_FUNC_GETPWUID_R_5ARG
+# ---------------------------
+# Check if getpwuid_r() takes a fifth argument (later POSIX standard, not draft version)
+# If so, define GETPWUID_R_5ARG
+AC_DEFUN([PGAC_FUNC_GETPWUID_R_5ARG],
+[AC_CACHE_CHECK(whether getpwuid_r takes a fifth argument,
+pgac_func_getpwuid_r_5arg,
+[AC_TRY_COMPILE([#include <sys/types.h>
+#include <pwd.h>],
+[uid_t uid;
+struct passwd *space;
+char *buf;
+size_t bufsize;
+struct passwd **result;
+getpwuid_r(uid, space, buf, bufsize, result);],
+[pgac_func_getpwuid_r_5arg=yes],
+[pgac_func_getpwuid_r_5arg=no])])
+if test x"$pgac_func_getpwuid_r_5arg" = xyes ; then
+  AC_DEFINE(GETPWUID_R_5ARG,, [Define to 1 if getpwuid_r() takes a 5th argument.])
+fi
+])# PGAC_FUNC_GETPWUID_R_5ARG
+
+
 # PGAC_UNION_SEMUN
 # ----------------
 # Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
index 0f0a19e3096ad3916bc4769de662e9bd15bb1480..8c3a9641e184f6f3217b8df880055b36f152331c 100755 (executable)
--- a/configure
+++ b/configure
@@ -13484,6 +13484,65 @@ done
 
 CFLAGS="$_CFLAGS"
 LIBS="$_LIBS"
+echo "$as_me:$LINENO: checking whether getpwuid_r takes a fifth argument" >&5
+echo $ECHO_N "checking whether getpwuid_r takes a fifth argument... $ECHO_C" >&6
+if test "${pgac_func_getpwuid_r_5arg+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <pwd.h>
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+uid_t uid;
+struct passwd *space;
+char *buf;
+size_t bufsize;
+struct passwd **result;
+getpwuid_r(uid, space, buf, bufsize, result);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  pgac_func_getpwuid_r_5arg=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+pgac_func_getpwuid_r_5arg=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $pgac_func_getpwuid_r_5arg" >&5
+echo "${ECHO_T}$pgac_func_getpwuid_r_5arg" >&6
+if test x"$pgac_func_getpwuid_r_5arg" = xyes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define GETPWUID_R_5ARG
+_ACEOF
+
+fi
+
 fi
 
 
index 3c16a5ac7056834b3bebbd0d4efd075b5304339e..9716d487464cd3ef2bf5c4bc21f014ccf51ce5f4 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.301.2.6 2004/03/05 19:57:20 momjian Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.301.2.7 2004/03/20 15:39:40 momjian Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -1061,6 +1061,7 @@ LIBS="$LIBS $THREAD_LIBS"
 AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
 CFLAGS="$_CFLAGS"
 LIBS="$_LIBS"
+PGAC_FUNC_GETPWUID_R_5ARG
 fi
 
 
index 4691b81da32d146928c24231123bd9d434630052..2276587885684b8d16515ace1d6f0e1e8821ad77 100644 (file)
@@ -43,6 +43,9 @@
    (--enable-thread-safety) */
 #undef ENABLE_THREAD_SAFETY
 
+/* Define to 1 if getpwuid_r() takes a 5th argument. */
+#undef GETPWUID_R_5ARG
+
 /* Define to 1 if gettimeofday() takes only 1 argument. */
 #undef GETTIMEOFDAY_1ARG
 
index 9c1b3f3167b5c80cc395915cf84e0ccfcaae4fc4..2c8efd95d259127c80eeeaf6f796f969ccd86867 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  *
- * $Id: thread.c,v 1.12.2.3 2004/03/14 14:01:54 momjian Exp $
+ * $Id: thread.c,v 1.12.2.4 2004/03/20 15:39:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -107,14 +107,17 @@ pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer,
                   size_t buflen, struct passwd **result)
 {
 #if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(NEED_REENTRANT_FUNCS) && defined(HAVE_GETPWUID_R)
+
+#ifdef GETPWUID_R_5ARG
+       /* POSIX version */
+       getpwuid_r(uid, resultbuf, buffer, buflen, result);
+#else
        /*
         * Early POSIX draft of getpwuid_r() returns 'struct passwd *'.
         *    getpwuid_r(uid, resultbuf, buffer, buflen)
-        * Do we need to support it?  bjm 2003-08-14
         */
-       /* POSIX version */
-       getpwuid_r(uid, resultbuf, buffer, buflen, result);
-
+       result = getpwuid_r(uid, resultbuf, buffer, buflen);
+#endif
 #else
 
 #if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(NEED_REENTRANT_FUNCS) && !defined(HAVE_GETPWUID_R)