Mercurial > hg > graal-compiler
annotate src/os/windows/vm/hpi_windows.cpp @ 1643:1e7ec26380bd
Merge
author | apangin |
---|---|
date | Wed, 14 Jul 2010 17:52:18 -0400 |
parents | c18cbe5936b8 |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_hpi_windows.cpp.incl" | |
27 | |
28 typedef jint (JNICALL *init_t)(GetInterfaceFunc *, void *); | |
29 | |
30 void hpi::initialize_get_interface(vm_calls_t *callbacks) | |
31 { | |
32 // Build name of HPI. | |
33 char lib_name[JVM_MAXPATHLEN]; | |
34 | |
35 if (HPILibPath && HPILibPath[0]) { | |
36 strncpy(lib_name, HPILibPath, JVM_MAXPATHLEN - 1); | |
37 lib_name[JVM_MAXPATHLEN - 1] = '\0'; | |
38 } else { | |
39 os::jvm_path(lib_name, sizeof lib_name); | |
40 | |
41 #ifdef PRODUCT | |
42 const char *hpi_lib = "\\hpi.dll"; | |
43 #else | |
44 char *ptr = strrchr(lib_name, '\\'); | |
45 // On Win98 GetModuleFileName() returns the path in the upper case. | |
46 assert(_strnicmp(ptr, "\\jvm",4) == 0, "invalid library name"); | |
47 const char *hpi_lib = (_strnicmp(ptr, "\\jvm_g",6) == 0) ? "\\hpi_g.dll" : "\\hpi.dll"; | |
48 #endif | |
49 | |
50 *(::strrchr(lib_name, '\\')) = '\0'; /* get rid of "\\jvm.dll" */ | |
51 char *p = ::strrchr(lib_name, '\\'); | |
52 if (p != NULL) *p = '\0'; /* get rid of "\\hotspot" */ | |
53 strcat(lib_name, hpi_lib); | |
54 } | |
55 | |
56 // Load it. | |
57 if (TraceHPI) tty->print_cr("Loading HPI %s ", lib_name); | |
58 HINSTANCE lib_handle = LoadLibrary(lib_name); | |
59 if (lib_handle == NULL) { | |
60 if (TraceHPI) tty->print_cr("LoadLibrary failed, code = %d", GetLastError()); | |
61 return; | |
62 } | |
63 | |
64 // Find hpi initializer. | |
65 init_t initer = (init_t)GetProcAddress(lib_handle, "DLL_Initialize"); | |
66 if (initer == NULL) { | |
67 if (TraceHPI) tty->print_cr("GetProcAddress failed, errcode = %d", GetLastError()); | |
68 return; | |
69 } | |
70 | |
71 // Call initializer. | |
72 jint init_result = (*initer)(&_get_interface, callbacks); | |
73 if (init_result < 0) { | |
74 if (TraceHPI) tty->print_cr("DLL_Initialize failed, returned %ld", init_result); | |
75 return; | |
76 } | |
77 | |
78 if (TraceHPI) tty->print_cr("success"); | |
79 return; | |
80 } |