This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
fix for single threaded configurations
- From: Andreas Tobler <toa at pop dot agri dot ch>
- To: Java Patches <java-patches at gcc dot gnu dot org>
- Cc: John David Anglin <dave at hiauly1 dot hia dot nrc dot ca>
- Date: Tue, 01 Aug 2006 22:46:02 +0200
- Subject: fix for single threaded configurations
Hello all,
this patch fixes compilation for configuration where
--enable-threads=single.
We do not want to use the reentrant functions like getpwuid_r or others
when we do not have a threaded environment.
The mentioned function(s) is(are) only available on systems which
supports the POSIX threads.
So an additional check on _POSIX_PTHREAD_SEMANTICS should be enough to
make it work.
The actual use case is a single threaded config on hpux-pa, the _r
functions are available in the headers check but not in the lib we link.
I've tested this patch on darwin-ppc, linux-ppc and hpux-pa. On all
archs is see the right reference, on darwin and linux-ppc I have my
getpwuid_r in the .o and on hpux-pa single threaded I have the getpwuid.
I also see the getpwuid_r on hpux-pa if compiled for posix threads.
Is this patch ok for trunk?
Thanks,
Andreas
2006-08-01 Andreas Tobler <a.tobler@schweiz.ch>
* gnu/classpath/natSystemProperties.cc: Add additional check for
getpwuid_r on _POSIX_PTHREAD_SEMANTICS.
(SystemProperties::insertSystemProperties): Likewise.
* java/io/natFilePosix.cc (File::performList): Add
additional check for readdir_r on _POSIX_PTHREAD_SEMANTICS.
* java/util/natVMTimeZone.cc (VMTimeZone::getSystemTimeZoneId): Add
additional check for localtime_r on _POSIX_PTHREAD_SEMANTICS.
Index: gnu/classpath/natSystemProperties.cc
===================================================================
--- gnu/classpath/natSystemProperties.cc (revision 115850)
+++ gnu/classpath/natSystemProperties.cc (working copy)
@@ -82,7 +82,7 @@
static const char *default_file_encoding = DEFAULT_FILE_ENCODING;
-#if HAVE_GETPWUID_R
+#if defined(HAVE_GETPWUID_R) && defined(_POSIX_PTHREAD_SEMANTICS)
/* Use overload resolution to find out the signature of getpwuid_r. */
/* This is Posix getpwuid_r. */
@@ -223,7 +223,7 @@
uid_t user_id = getuid ();
struct passwd *pwd_entry;
-#ifdef HAVE_GETPWUID_R
+#if defined(HAVE_GETPWUID_R) && defined(_POSIX_PTHREAD_SEMANTICS)
struct passwd pwd_r;
size_t len_r = 200;
char *buf_r = (char *) _Jv_AllocBytes (len_r);
Index: java/io/natFilePosix.cc
===================================================================
--- java/io/natFilePosix.cc (revision 115850)
+++ java/io/natFilePosix.cc (working copy)
@@ -1,6 +1,7 @@
// natFile.cc - Native part of File class for POSIX.
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2006
+ Free Software Foundation
This file is part of libgcj.
@@ -288,7 +289,7 @@
java::util::ArrayList *list = new java::util::ArrayList ();
struct dirent *d;
-#ifdef HAVE_READDIR_R
+#if defined(HAVE_READDIR_R) && defined(_POSIX_PTHREAD_SEMANTICS)
int name_max = pathconf (buf, _PC_NAME_MAX);
char dbuf[sizeof (struct dirent) + name_max + 1];
while (readdir_r (dir, (struct dirent *) dbuf, &d) == 0 && d != NULL)
Index: java/util/natVMTimeZone.cc
===================================================================
--- java/util/natVMTimeZone.cc (revision 115850)
+++ java/util/natVMTimeZone.cc (working copy)
@@ -1,6 +1,6 @@
// natVMTimeZone.cc -- Native side of VMTimeZone class.
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
Free Software Foundation
This file is part of libgcj.
@@ -54,7 +54,7 @@
java::util::VMTimeZone::getSystemTimeZoneId()
{
struct tm tim;
-#ifndef HAVE_LOCALTIME_R
+#if !defined(HAVE_LOCALTIME_R) || !defined(_POSIX_PTHREAD_SEMANTICS)
struct tm *lt_tim;
#endif
#ifdef HAVE_TM_ZONE
@@ -66,7 +66,7 @@
char *tzid;
time(¤t_time);
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R) && defined(_POSIX_PTHREAD_SEMANTICS)
localtime_r(¤t_time, &tim);
#else
/* Fall back on non-thread safe localtime. */