Fix libjava build error on NetBSD

Krister Walfridsson cato@df.lth.se
Sat Jul 14 21:47:00 GMT 2007


libjava fails to build on older NetBSD if a Linux-compatible /proc
is enabled, because NetBSD 2.x and 3.x do not have strerror_r.

This patch uses strerror if strerror_r is not available.  I also removed the
configure check for strerror, since it was not used anywhere (and other
parts of libjava use strerror without protecting it with HAVE_STRERROR).

Bootstrapped and tested on i386-unknown-netbsdelf2.1.

OK to commit?

    /Krister


2007-07-14  Krister Walfridsson  <cato@df.lth.se>

 	* gnu/gcj/util/natGCInfo.cc: Use HAVE_STRERROR_R.
 	* configure.ac: Remove check for strerror, add check for strerror_r.
 	* configure: Regenerate.
 	* include/config.h.in: Regenerate.
-------------- next part --------------
Index: configure.ac
===================================================================
--- configure.ac	(revision 126610)
+++ configure.ac	(working copy)
@@ -985,7 +985,6 @@ if test "x${with_newlib}" = "xyes"; then
    # we'll have.
    AC_DEFINE(HAVE_MEMMOVE, 1, [Define if you have memmove.])
    AC_DEFINE(HAVE_MEMCPY, 1, [Define if you have memcpy.])
-   AC_DEFINE(HAVE_STRERROR, 1, [Define if you have strerror.])
    AC_DEFINE(HAVE_TIME, 1, [Define if you have time.])
    AC_DEFINE(HAVE_GMTIME_R, 1, [Define if you have the 'gmtime_r' function])
    AC_DEFINE(HAVE_LOCALTIME_R, 1, [Define if you have the 'localtime_r' function.])
@@ -997,7 +996,7 @@ if test "x${with_newlib}" = "xyes"; then
    AC_DEFINE(NO_GETUID, 1, [Define if getuid() and friends are missing.])
    PLATFORMNET=NoNet
 else
-   AC_CHECK_FUNCS([strerror select fstat open fsync sleep opendir \
+   AC_CHECK_FUNCS([strerror_r select fstat open fsync sleep opendir \
                    localtime_r readdir_r getpwuid_r getcwd \
 		   access stat lstat mkdir rename rmdir unlink utime chmod readlink \
 		   nl_langinfo setlocale \
Index: gnu/gcj/util/natGCInfo.cc
===================================================================
--- gnu/gcj/util/natGCInfo.cc	(revision 126610)
+++ gnu/gcj/util/natGCInfo.cc	(working copy)
@@ -245,8 +245,12 @@ GC_enumerator::print_address_map()
   fm = fopen("/proc/self/maps", "r");
   if (fm == NULL)
     {
+#ifdef HAVE_STRERROR_R
       if (0 == strerror_r (errno, buffer, sizeof buffer))
         fputs (buffer, fp);
+#else
+      fputs (strerror (errno), fp);
+#endif
     }
   else
     {


More information about the Java-patches mailing list