harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r587958 - /harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c
Date Wed, 24 Oct 2007 18:39:46 GMT
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
 
 }



Mime
View raw message