Tue, 23 Nov 2010 13:22:55 -0800
6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "oops/oop.inline.hpp" |
stefank@2314 | 27 | #include "runtime/hpi.hpp" |
stefank@2314 | 28 | #include "runtime/os.hpp" |
duke@435 | 29 | |
duke@435 | 30 | # include <sys/param.h> |
duke@435 | 31 | # include <dlfcn.h> |
duke@435 | 32 | |
duke@435 | 33 | typedef jint (JNICALL *init_t)(GetInterfaceFunc *, void *); |
duke@435 | 34 | |
duke@435 | 35 | void hpi::initialize_get_interface(vm_calls_t *callbacks) |
duke@435 | 36 | { |
duke@435 | 37 | char buf[JVM_MAXPATHLEN]; |
duke@435 | 38 | void *hpi_handle; |
duke@435 | 39 | GetInterfaceFunc& getintf = _get_interface; |
duke@435 | 40 | jint (JNICALL * DLL_Initialize)(GetInterfaceFunc *, void *); |
duke@435 | 41 | |
duke@435 | 42 | if (HPILibPath && HPILibPath[0]) { |
duke@435 | 43 | strncpy(buf, HPILibPath, JVM_MAXPATHLEN - 1); |
duke@435 | 44 | buf[JVM_MAXPATHLEN - 1] = '\0'; |
duke@435 | 45 | } else { |
duke@435 | 46 | const char *thread_type = "native_threads"; |
duke@435 | 47 | |
duke@435 | 48 | os::jvm_path(buf, JVM_MAXPATHLEN); |
duke@435 | 49 | |
duke@435 | 50 | #ifdef PRODUCT |
duke@435 | 51 | const char * hpi_lib = "/libhpi.so"; |
duke@435 | 52 | #else |
duke@435 | 53 | char * ptr = strrchr(buf, '/'); |
duke@435 | 54 | assert(strstr(ptr, "/libjvm") == ptr, "invalid library name"); |
duke@435 | 55 | const char * hpi_lib = strstr(ptr, "_g") ? "/libhpi_g.so" : "/libhpi.so"; |
duke@435 | 56 | #endif |
duke@435 | 57 | |
duke@435 | 58 | *(strrchr(buf, '/')) = '\0'; /* get rid of /libjvm.so */ |
duke@435 | 59 | char* p = strrchr(buf, '/'); |
duke@435 | 60 | if (p != NULL) p[1] = '\0'; /* get rid of hotspot */ |
duke@435 | 61 | strcat(buf, thread_type); |
duke@435 | 62 | strcat(buf, hpi_lib); |
duke@435 | 63 | } |
duke@435 | 64 | /* we use RTLD_NOW because of bug 4032715 */ |
duke@435 | 65 | if (TraceHPI) tty->print_cr("Loading HPI %s ", buf); |
duke@435 | 66 | hpi_handle = dlopen(buf, RTLD_NOW); |
duke@435 | 67 | if (hpi_handle == NULL) { |
duke@435 | 68 | if (TraceHPI) tty->print_cr("HPI dlopen failed: %s", dlerror()); |
duke@435 | 69 | return; |
duke@435 | 70 | } |
duke@435 | 71 | DLL_Initialize = CAST_TO_FN_PTR(jint (JNICALL *)(GetInterfaceFunc *, void *), |
duke@435 | 72 | dlsym(hpi_handle, "DLL_Initialize")); |
duke@435 | 73 | if (TraceHPI && DLL_Initialize == NULL) tty->print_cr("HPI dlsym of DLL_Initialize failed: %s", dlerror()); |
duke@435 | 74 | if (DLL_Initialize == NULL || |
duke@435 | 75 | (*DLL_Initialize)(&getintf, callbacks) < 0) { |
duke@435 | 76 | if (TraceHPI) tty->print_cr("HPI DLL_Initialize failed"); |
duke@435 | 77 | return; |
duke@435 | 78 | } |
duke@435 | 79 | if (TraceHPI) tty->print_cr("HPI loaded successfully"); |
duke@435 | 80 | } |