jdk/src/solaris/demo/jvmti/hprof/hprof_md.c
changeset 12047 320a714614e9
parent 10292 ed7db6a12c2a
child 13014 e2fe1611bb04
--- a/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c	Tue Mar 06 10:25:45 2012 +0800
+++ b/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c	Tue Mar 06 20:34:38 2012 +0000
@@ -42,7 +42,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#ifndef LINUX
+#if !defined(LINUX) && !defined(_ALLBSD_SOURCE)
 #include <procfs.h>
 #endif
 
@@ -62,6 +62,7 @@
 #include <time.h>
 
 #include "jni.h"
+#include "jvm_md.h"
 #include "hprof.h"
 
 int
@@ -85,7 +86,7 @@
 void
 md_init(void)
 {
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
     /* No Hi-Res timer option? */
 #else
     if ( gdata->micro_state_accounting ) {
@@ -247,7 +248,7 @@
 jlong
 md_get_microsecs(void)
 {
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
     return (jlong)(md_timeofday() * (jlong)1000); /* Milli to micro */
 #else
     return (jlong)(gethrtime()/(hrtime_t)1000); /* Nano seconds to micro seconds */
@@ -265,7 +266,7 @@
 jlong
 md_get_thread_cpu_timemillis(void)
 {
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
     return md_timeofday();
 #else
     return (jlong)(gethrvtime()/1000); /* Nano seconds to milli seconds */
@@ -280,7 +281,7 @@
     Dl_info dlinfo;
 
     libdir[0] = 0;
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
     addr = (void*)&Agent_OnLoad;
 #else
     /* Just using &Agent_OnLoad will get the first external symbol with
@@ -308,10 +309,13 @@
         if ( lastSlash != NULL ) {
             *lastSlash = '\0';
         }
+#ifndef __APPLE__
+        // not sure why other platforms have to go up two levels, but on macos we only need up one
         lastSlash = strrchr(libdir, '/');
         if ( lastSlash != NULL ) {
             *lastSlash = '\0';
         }
+#endif /* __APPLE__ */
     }
     (void)snprintf(path, path_len, "%s/%s", libdir, filename);
 }
@@ -388,9 +392,9 @@
 
     /* Construct path to library */
     if (pnamelen == 0) {
-        (void)snprintf(holder, holderlen, "lib%s.so", fname);
+        (void)snprintf(holder, holderlen, "lib%s" JNI_LIB_SUFFIX, fname);
     } else {
-        (void)snprintf(holder, holderlen, "%s/lib%s.so", pname, fname);
+        (void)snprintf(holder, holderlen, "%s/lib%s" JNI_LIB_SUFFIX, pname, fname);
     }
 }