You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2007/10/24 20:39:46 UTC

svn commit: r587958 - /harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c

Author: hindessm
Date: Wed Oct 24 11:39:45 2007
New Revision: 587958

URL: http://svn.apache.org/viewvc?rev=587958&view=rev
Log:
Hack to fix portlib tests on FreeBSD.  Something like this might actually
be useful and it might work on more platforms.

Modified:
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c?rev=587958&r1=587957&r2=587958&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c (original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c Wed Oct 24 11:39:45 2007
@@ -41,6 +41,7 @@
 #if defined(FREEBSD) || defined(MACOSX)
 #include <sys/types.h>
 #include <sys/sysctl.h>
+#include <dlfcn.h>
 #endif
 
 #include <unistd.h>
@@ -305,6 +306,23 @@
 #if defined(LINUX)
   return readSymbolicLink (portLibrary, "/proc/self/exe", result);
 #else
+#if defined(FREEBSD)
+  extern int main (int argc, char **argv, char **envp);
+  Dl_info info;
+  if (dladdr( (const void*)&main, &info) == 0) {
+    return -1;
+  }
+  *result =
+    (portLibrary->mem_allocate_memory) (portLibrary,
+                                        strlen (info.dli_fname) + 1);
+
+  if (!*result) {
+    return -1;
+  }
+  strcpy (*result, info.dli_fname);
+  return 0;
+  
+#else
   IDATA retval = -1;
   IDATA length;
   char *p;
@@ -431,6 +449,7 @@
       currentName = NULL;
     }
   return retval;
+#endif
 #endif
 
 }