equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * |
3 * |
4 * Redistribution and use in source and binary forms, with or without |
4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions |
5 * modification, are permitted provided that the following conditions |
6 * are met: |
6 * are met: |
7 * |
7 * |
40 |
40 |
41 #include <sys/types.h> |
41 #include <sys/types.h> |
42 #include <sys/stat.h> |
42 #include <sys/stat.h> |
43 #include <fcntl.h> |
43 #include <fcntl.h> |
44 |
44 |
45 #if !defined(LINUX) && !defined(_ALLBSD_SOURCE) |
45 #if !defined(LINUX) && !defined(_ALLBSD_SOURCE) && !defined(AIX) |
46 #include <procfs.h> |
46 #include <procfs.h> |
47 #endif |
47 #endif |
48 |
48 |
49 #include <stdio.h> |
49 #include <stdio.h> |
50 #include <stdlib.h> |
50 #include <stdlib.h> |
63 |
63 |
64 #include "jni.h" |
64 #include "jni.h" |
65 #include "jvm_md.h" |
65 #include "jvm_md.h" |
66 #include "hprof.h" |
66 #include "hprof.h" |
67 |
67 |
|
68 #ifdef AIX |
|
69 #include "porting_aix.h" /* For the 'dladdr' function. */ |
|
70 #endif |
|
71 |
68 int |
72 int |
69 md_getpid(void) |
73 md_getpid(void) |
70 { |
74 { |
71 static int pid = -1; |
75 static int pid = -1; |
72 |
76 |
84 } |
88 } |
85 |
89 |
86 void |
90 void |
87 md_init(void) |
91 md_init(void) |
88 { |
92 { |
89 #if defined(LINUX) || defined(_ALLBSD_SOURCE) |
93 #if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX) |
90 /* No Hi-Res timer option? */ |
94 /* No Hi-Res timer option? */ |
91 #else |
95 #else |
92 if ( gdata->micro_state_accounting ) { |
96 if ( gdata->micro_state_accounting ) { |
93 char proc_ctl_fn[48]; |
97 char proc_ctl_fn[48]; |
94 int procfd; |
98 int procfd; |
251 |
255 |
252 /* Hi-res timer in micro-seconds */ |
256 /* Hi-res timer in micro-seconds */ |
253 jlong |
257 jlong |
254 md_get_microsecs(void) |
258 md_get_microsecs(void) |
255 { |
259 { |
256 #if defined(LINUX) || defined(_ALLBSD_SOURCE) |
260 #if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX) |
257 return (jlong)(md_timeofday() * (jlong)1000); /* Milli to micro */ |
261 return (jlong)(md_timeofday() * (jlong)1000); /* Milli to micro */ |
258 #else |
262 #else |
259 return (jlong)(gethrtime()/(hrtime_t)1000); /* Nano seconds to micro seconds */ |
263 return (jlong)(gethrtime()/(hrtime_t)1000); /* Nano seconds to micro seconds */ |
260 #endif |
264 #endif |
261 } |
265 } |
269 |
273 |
270 /* Current CPU hi-res CPU time used */ |
274 /* Current CPU hi-res CPU time used */ |
271 jlong |
275 jlong |
272 md_get_thread_cpu_timemillis(void) |
276 md_get_thread_cpu_timemillis(void) |
273 { |
277 { |
274 #if defined(LINUX) || defined(_ALLBSD_SOURCE) |
278 #if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX) |
275 return md_timeofday(); |
279 return md_timeofday(); |
276 #else |
280 #else |
277 return (jlong)(gethrvtime()/1000); /* Nano seconds to milli seconds */ |
281 return (jlong)(gethrvtime()/1000); /* Nano seconds to milli seconds */ |
278 #endif |
282 #endif |
279 } |
283 } |
284 void *addr; |
288 void *addr; |
285 char libdir[FILENAME_MAX+1]; |
289 char libdir[FILENAME_MAX+1]; |
286 Dl_info dlinfo; |
290 Dl_info dlinfo; |
287 |
291 |
288 libdir[0] = 0; |
292 libdir[0] = 0; |
289 #if defined(LINUX) || defined(_ALLBSD_SOURCE) |
293 #if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX) |
290 addr = (void*)&Agent_OnLoad; |
294 addr = (void*)&Agent_OnLoad; |
291 #else |
295 #else |
292 /* Just using &Agent_OnLoad will get the first external symbol with |
296 /* Just using &Agent_OnLoad will get the first external symbol with |
293 * this name in the first .so, which may not be libhprof.so. |
297 * this name in the first .so, which may not be libhprof.so. |
294 * On Solaris we can actually ask for the address of our Agent_OnLoad. |
298 * On Solaris we can actually ask for the address of our Agent_OnLoad. |
455 void * sym; |
459 void * sym; |
456 |
460 |
457 sym = dlsym(handle, name); |
461 sym = dlsym(handle, name); |
458 return sym; |
462 return sym; |
459 } |
463 } |
|
464 |
|
465 |