diff options
| author | Alexandre Oliva <oliva@gcc.gnu.org> | 1999-08-21 11:56:24 +0000 |
|---|---|---|
| committer | Alexandre Oliva <oliva@gcc.gnu.org> | 1999-08-21 11:56:24 +0000 |
| commit | fb82082db3dd75ba956e0c17991c8606bf1d8930 (patch) | |
| tree | 77052244b29b3ddab482afe4823576d4ec70a359 /libjava/java/lang/natSystem.cc | |
| parent | 5b33370d63acf843e6063a952db8d994c73bb0ec (diff) | |
| download | gcc-fb82082db3dd75ba956e0c17991c8606bf1d8930.zip gcc-fb82082db3dd75ba956e0c17991c8606bf1d8930.tar.gz gcc-fb82082db3dd75ba956e0c17991c8606bf1d8930.tar.bz2 | |
natSystem.cc (getpwuid_adaptor): New overloaded function that detects the signature of getpwuid_r.
* 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.
From-SVN: r28790
Diffstat (limited to 'libjava/java/lang/natSystem.cc')
| -rw-r--r-- | libjava/java/lang/natSystem.cc | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/libjava/java/lang/natSystem.cc b/libjava/java/lang/natSystem.cc index b1effaf..71c8579 100644 --- a/libjava/java/lang/natSystem.cc +++ b/libjava/java/lang/natSystem.cc @@ -231,6 +231,34 @@ java::lang::System::identityHashCode (jobject obj) #endif static char *default_file_encoding = DEFAULT_FILE_ENCODING; +#if HAVE_GETPWUID_R +/* Use overload resolution to find out the signature of getpwuid_r. */ + + /* This is Posix getpwuid_r. */ +template <typename T_uid, typename T_passwd, typename T_buf, typename T_len> +static inline int +getpwuid_adaptor(int (*getpwuid_r)(T_uid user_id, T_passwd *pwd_r, + T_buf *buf_r, T_len len_r, + T_passwd **pwd_entry_ptr), + uid_t user_id, struct passwd *pwd_r, + char *buf_r, size_t len_r, struct passwd **pwd_entry) +{ + return getpwuid_r(user_id, pwd_r, buf_r, len_r, pwd_entry); +} + +/* This is used on IRIX 5.2. */ +template <typename T_uid, typename T_passwd, typename T_buf, typename T_len> +static inline int +getpwuid_adaptor(T_passwd * (*getpwuid_r)(T_uid user_id, T_passwd *pwd_r, + T_buf *buf_r, T_len len_r), + uid_t user_id, struct passwd *pwd_r, + char *buf_r, size_t len_r, struct passwd **pwd_entry) +{ + *pwd_entry = getpwuid_r(user_id, pwd_r, buf_r, len_r); + return (*pwd_entry == NULL) ? errno : 0; +} +#endif + void java::lang::System::init_properties (void) { @@ -293,7 +321,8 @@ java::lang::System::init_properties (void) while (buf_r != NULL) { - int r = getpwuid_r (user_id, &pwd_r, buf_r, len_r, &pwd_entry); + int r = getpwuid_adaptor + (getpwuid_r, user_id, &pwd_r, buf_r, len_r, &pwd_entry); if (r == 0) break; else if (r != ERANGE) |
