diff options
| author | oliva <oliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-08-21 11:56:24 +0000 |
|---|---|---|
| committer | oliva <oliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-08-21 11:56:24 +0000 |
| commit | 1547863b53d08557a706f2f4f56e0d461af51235 (patch) | |
| tree | 77052244b29b3ddab482afe4823576d4ec70a359 /libjava/java/util | |
| parent | 155b2c7dddd8032a9b01194e23c51e9190407fee (diff) | |
| download | ppe42-gcc-1547863b53d08557a706f2f4f56e0d461af51235.tar.gz ppe42-gcc-1547863b53d08557a706f2f4f56e0d461af51235.zip | |
* java/lang/natSystem.cc (getpwuid_adaptor): New overloaded
function that detects the signature of getpwuid_r.
(init_properties): Use it.
* java/util/natDate.cc (ctime_adaptor): Likewise for ctime_r.
(toString): Use it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@28790 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/util')
| -rw-r--r-- | libjava/java/util/natDate.cc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/libjava/java/util/natDate.cc b/libjava/java/util/natDate.cc index 27f91f6fa19..563f8c0cd8e 100644 --- a/libjava/java/util/natDate.cc +++ b/libjava/java/util/natDate.cc @@ -28,13 +28,35 @@ details. */ #include <sys/time.h> #endif +#if HAVE_CTIME_R +/* Use overload resolution to find out the signature of ctime_r. */ + + /* This is Posix ctime_r(). */ +template <typename T_clock, typename T_buf, size_t buflen> +static inline char * +ctime_adaptor (char* (*ctime_r)(T_clock *clock, T_buf *buf), + time_t *clock, char (&buf)[buflen]) +{ + return ctime_r(clock, buf); +} + +/* This is an old-style ctime_r, used on IRIX 5.2. */ +template <typename T_clock, typename T_buf, typename T_buflen, size_t buflen> +static inline char * +ctime_adaptor (char* (*ctime_r)(T_clock *clock, T_buf *buf, T_buflen len), + time_t *clock, char (&buf)[buflen]) +{ + return ctime_r(clock, buf, buflen); +} +#endif + jstring java::util::Date::toString() { #ifdef HAVE_CTIME_R time_t t = millis / 1000; char buf[30]; - return JvNewStringLatin1 (ctime_r (&t, buf)); + return JvNewStringLatin1 (ctime_adaptor (ctime_r, &t, buf)); #elif defined (HAVE_CTIME) // FIXME: this isn't thread-safe. time_t t = millis / 1000; |

