Patchwork [libfortran] PR 47802 Non-POSIX getpwuid_r

login
register
mail settings
Submitter Janne Blomqvist
Date Feb. 24, 2011, 2:56 p.m.
Message ID <AANLkTi=DoQSKOCyo_Ttig0jXkLfJ1n=Y1JBevWajV7XQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/84401/
State New
Headers show

Comments

Janne Blomqvist - Feb. 24, 2011, 2:56 p.m.
On Wed, Feb 23, 2011 at 20:13, Ralf Wildenhues <Ralf.Wildenhues@gmx.de> wrote:
> * Janne Blomqvist wrote on Tue, Feb 22, 2011 at 09:22:14PM CET:
>> 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.
>
>> --- 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
>> +
>> +
>
> Build system parts are OK.  You /could/ indent the AC_CACHE_CHCEK and
> following line, use AC_LINK_IFELSE instead of AC_TRY_LINK, and use the
> three-argument form of AC_DEFINE instead of adding the AH_TEMPLATE, but
> all of that are janitorial issues just as well suitable for stage 1
> cleanup.

Thanks for the review and suggestions (and also to Tobias for
reviewing). What I ultimately committed was the posted patch, but with
the configure.ac parts changed per your suggestions:

 # Check out attribute support.
 LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY
 LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT


I also filed PR 47833 to remind us to eventually clean up the other
usage of AC_TRY_LINK.

Patch

diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 8161659..d25a067 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -513,6 +513,26 @@  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_LINK_IFELSE([AC_LANG_PROGRAM([
+#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], [1], [Define to 1 if we have
POSIX getpwuid_r which takes 5 arguments.])
+fi
+
+