This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, libfortran] PR 47802 Non-POSIX getpwuid_r
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 22 Feb 2011 22:22:14 +0200
- Subject: [Patch, libfortran] PR 47802 Non-POSIX getpwuid_r
Hi,
the attached patch fixes the second part of the bootstrap failure on
HP-UX 10.2. That target provides a non-POSIX getpwuid_r function which
has one argument less than the POSIX version. The patch adds a
configure test for this.
Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
2011-02-22 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/47802
* configure.ac: Add test for POSIX getpwuid_r.
* intrinsics/getlog.c (getlog): CPP test for
HAVE_POSIX_GETPWUID_R.
* config.h.in: Regenerated.
* configure: Regenerated.
--
Janne Blomqvist
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 8161659..b839ae0 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -513,6 +513,28 @@ AC_SUBST(FPU_HOST_HEADER)
IEEE_FLAGS="${ieee_flags}"
AC_SUBST(IEEE_FLAGS)
+
+# Check for POSIX getpwuid_r
+#
+# There are two versions of getpwuid_r, the POSIX one with 5
+# arguments, and another one with 4 arguments used by at least HP-UX
+# 10.2.
+if test "$ac_cv_func_getpwuid_r" = "yes"; then
+AC_CACHE_CHECK([POSIX version of getpwuid_r with 5 arguments], libgfor_cv_posix_getpwuid_r, [
+AC_TRY_LINK([
+#include <stdio.h>
+#include <sys/types.h>
+#include <pwd.h>], [
+ getpwuid_r(0, NULL, NULL, 0, NULL);
+], [libgfor_cv_posix_getpwuid_r="yes"], [libgfor_cv_posix_getpwuid_r="no"])])
+fi
+if test "$libgfor_cv_posix_getpwuid_r" = "yes"; then
+ AC_DEFINE(HAVE_POSIX_GETPWUID_R)
+ AH_TEMPLATE(HAVE_POSIX_GETPWUID_R,
+ [Define to 1 if we have POSIX getpwuid_r which takes 5 arguments.])
+fi
+
+
# Check out attribute support.
LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY
LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT
diff --git a/libgfortran/intrinsics/getlog.c b/libgfortran/intrinsics/getlog.c
index 299ac5a..9e5c8de 100644
--- a/libgfortran/intrinsics/getlog.c
+++ b/libgfortran/intrinsics/getlog.c
@@ -75,7 +75,7 @@ PREFIX(getlog) (char * login, gfc_charlen_type login_len)
memset (login, ' ', login_len); /* Blank the string. */
-#if defined(HAVE_GETPWUID_R) && defined(HAVE_GETEUID)
+#if defined(HAVE_POSIX_GETPWUID_R) && defined(HAVE_GETEUID)
struct passwd pwd;
struct passwd *result;
char *buf;
@@ -113,7 +113,7 @@ PREFIX(getlog) (char * login, gfc_charlen_type login_len)
memcpy (login, p, p_len);
cleanup:
-#ifdef HAVE_GETPWUID_R
+#if defined (HAVE_POSIX_GETPWUID_R) && defined(HAVE_GETEUID)
free (buf);
#else
;