src/solaris/demo/jvmti/hprof/hprof_md.c

Print this page
rev 8822 : 8024854: PPC64: Basic changes and files to build the class library on AIX
Reviewed-by: alanb, prr, sla, chegar, michaelm, mullan, art
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *

@@ -40,11 +40,11 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#if !defined(LINUX) && !defined(_ALLBSD_SOURCE)
+#if !defined(LINUX) && !defined(_ALLBSD_SOURCE) && !defined(AIX)
 #include <procfs.h>
 #endif
 
 #include <stdio.h>
 #include <stdlib.h>

@@ -63,10 +63,14 @@
 
 #include "jni.h"
 #include "jvm_md.h"
 #include "hprof.h"
 
+#ifdef AIX
+#include "porting_aix.h" /* For the 'dladdr' function. */
+#endif
+
 int
 md_getpid(void)
 {
     static int pid = -1;
 

@@ -84,11 +88,11 @@
 }
 
 void
 md_init(void)
 {
-#if defined(LINUX) || defined(_ALLBSD_SOURCE)
+#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX)
     /* No Hi-Res timer option? */
 #else
     if ( gdata->micro_state_accounting ) {
         char proc_ctl_fn[48];
         int  procfd;

@@ -251,11 +255,11 @@
 
 /* Hi-res timer in micro-seconds */
 jlong
 md_get_microsecs(void)
 {
-#if defined(LINUX) || defined(_ALLBSD_SOURCE)
+#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX)
     return (jlong)(md_timeofday() * (jlong)1000); /* Milli to micro */
 #else
     return (jlong)(gethrtime()/(hrtime_t)1000); /* Nano seconds to micro seconds */
 #endif
 }

@@ -269,11 +273,11 @@
 
 /* Current CPU hi-res CPU time used */
 jlong
 md_get_thread_cpu_timemillis(void)
 {
-#if defined(LINUX) || defined(_ALLBSD_SOURCE)
+#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX)
     return md_timeofday();
 #else
     return (jlong)(gethrvtime()/1000); /* Nano seconds to milli seconds */
 #endif
 }

@@ -284,11 +288,11 @@
     void *addr;
     char libdir[FILENAME_MAX+1];
     Dl_info dlinfo;
 
     libdir[0] = 0;
-#if defined(LINUX) || defined(_ALLBSD_SOURCE)
+#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX)
     addr = (void*)&Agent_OnLoad;
 #else
     /* Just using &Agent_OnLoad will get the first external symbol with
      *   this name in the first .so, which may not be libhprof.so.
      *   On Solaris we can actually ask for the address of our Agent_OnLoad.

@@ -455,5 +459,7 @@
     void * sym;
 
     sym =  dlsym(handle, name);
     return sym;
 }
+
+