changeset 1467:6058ce1924ab

. Dynamically look up fdopendir rather than assuming it exists on all platforms. This fixes the build on MacOS X where the linker is stricter than on the other *BSD, where it only caused a compiler warning.
author glewis@misty.eyesbeyond.com
date Thu, 23 Jul 2009 19:23:53 -0700
parents cd10412684b5
children ac301b6fdfad
files src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Sun Jul 19 20:27:02 2009 -0700
+++ b/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Thu Jul 23 19:23:53 2009 -0700
@@ -97,12 +97,14 @@
 typedef int unlinkat_func(int, const char*, int);
 typedef int renameat_func(int, const char*, int, const char*);
 typedef int futimesat_func(int, const char *, const struct timeval *);
+typedef DIR* fdopendir_func(int);
 
 static openat64_func* my_openat64_func = NULL;
 static fstatat64_func* my_fstatat64_func = NULL;
 static unlinkat_func* my_unlinkat_func = NULL;
 static renameat_func* my_renameat_func = NULL;
 static futimesat_func* my_futimesat_func = NULL;
+static fdopendir_func* my_fdopendir_func = NULL;
 
 /**
  * fstatat missing from glibc on Linux. Temporary workaround
@@ -215,6 +217,8 @@
         flags |= sun_nio_fs_UnixNativeDispatcher_HAS_AT_SYSCALLS;
     }
 
+    my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir");
+
     return flags;
 }
 
@@ -570,8 +574,13 @@
 Java_sun_nio_fs_UnixNativeDispatcher_fdopendir(JNIEnv* env, jclass this, int dfd) {
     DIR* dir;
 
+    if (my_fdopendir_func == NULL) {
+        JNU_ThrowInternalError(env, "should not reach here");
+        return -1;
+    }
+
     /* EINTR not listed as a possible error */
-    dir = fdopendir((int)dfd);
+    dir = (*my_fdopendir_func)((int)dfd);
     if (dir == NULL) {
         throwUnixException(env, errno);
     }