author | serb |
Sun, 24 Jun 2018 16:35:21 -0700 | |
changeset 50834 | 9cf279436b9d |
parent 47216 | 71c04702a3d5 |
child 58202 | a45cce906207 |
permissions | -rw-r--r-- |
35063
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
1 |
/* |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. |
35594 | 3 |
* Copyright (c) 2015, 2015 SAP SE. All rights reserved. |
35063
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
5 |
* |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
9 |
* |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
14 |
* accompanied this code). |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
15 |
* |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
19 |
* |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
22 |
* questions. |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
23 |
* |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
24 |
*/ |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
25 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
26 |
#include "libodm_aix.hpp" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
27 |
#include "misc_aix.hpp" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
28 |
#include <stdlib.h> |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
29 |
#include <dlfcn.h> |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
30 |
#include <string.h> |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
31 |
#include "runtime/arguments.hpp" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
32 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
33 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
34 |
dynamicOdm::dynamicOdm() { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
35 |
const char *libodmname = "/usr/lib/libodm.a(shr_64.o)"; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
36 |
_libhandle = dlopen(libodmname, RTLD_MEMBER | RTLD_NOW); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
37 |
if (!_libhandle) { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
38 |
trcVerbose("Couldn't open %s", libodmname); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
39 |
return; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
40 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
41 |
_odm_initialize = (fun_odm_initialize )dlsym(_libhandle, "odm_initialize" ); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
42 |
_odm_set_path = (fun_odm_set_path )dlsym(_libhandle, "odm_set_path" ); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
43 |
_odm_mount_class = (fun_odm_mount_class)dlsym(_libhandle, "odm_mount_class"); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
44 |
_odm_get_obj = (fun_odm_get_obj )dlsym(_libhandle, "odm_get_obj" ); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
45 |
_odm_terminate = (fun_odm_terminate )dlsym(_libhandle, "odm_terminate" ); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
46 |
if (!_odm_initialize || !_odm_set_path || !_odm_mount_class || !_odm_get_obj || !_odm_terminate) { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
47 |
trcVerbose("Couldn't find all required odm symbols from %s", libodmname); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
48 |
dlclose(_libhandle); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
49 |
_libhandle = NULL; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
50 |
return; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
51 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
52 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
53 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
54 |
dynamicOdm::~dynamicOdm() { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
55 |
if (_libhandle) { dlclose(_libhandle); } |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
56 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
57 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
58 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
59 |
void odmWrapper::clean_data() { if (_data) { free(_data); _data = NULL; } } |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
60 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
61 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
62 |
int odmWrapper::class_offset(char *field, bool is_aix_5) |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
63 |
{ |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
64 |
assert(has_class(), "initialization"); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
65 |
for (int i = 0; i < odm_class()->nelem; i++) { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
66 |
if (strcmp(odm_class()->elem[i].elemname, field) == 0) { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
67 |
int offset = odm_class()->elem[i].offset; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
68 |
if (is_aix_5) { offset += LINK_VAL_OFFSET; } |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
69 |
return offset; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
70 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
71 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
72 |
return -1; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
73 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
74 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
75 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
76 |
void odmWrapper::determine_os_kernel_version(uint32_t* p_ver) { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
77 |
int major_aix_version = ((*p_ver) >> 24) & 0xFF, |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
78 |
minor_aix_version = ((*p_ver) >> 16) & 0xFF; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
79 |
assert(*p_ver, "must be initialized"); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
80 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
81 |
odmWrapper odm("product", "/usr/lib/objrepos"); // could also use "lpp" |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
82 |
if (!odm.has_class()) { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
83 |
trcVerbose("try_determine_os_kernel_version: odm init problem"); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
84 |
return; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
85 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
86 |
int voff, roff, moff, foff; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
87 |
bool is_aix_5 = (major_aix_version == 5); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
88 |
voff = odm.class_offset("ver", is_aix_5); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
89 |
roff = odm.class_offset("rel", is_aix_5); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
90 |
moff = odm.class_offset("mod", is_aix_5); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
91 |
foff = odm.class_offset("fix", is_aix_5); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
92 |
if (voff == -1 || roff == -1 || moff == -1 || foff == -1) { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
93 |
trcVerbose("try_determine_os_kernel_version: could not get offsets"); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
94 |
return; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
95 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
96 |
if (!odm.retrieve_obj("name='bos.mp64'")) { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
97 |
trcVerbose("try_determine_os_kernel_version: odm_get_obj failed"); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
98 |
return; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
99 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
100 |
int version, release, modification, fix_level; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
101 |
do { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
102 |
version = odm.read_short(voff); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
103 |
release = odm.read_short(roff); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
104 |
modification = odm.read_short(moff); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
105 |
fix_level = odm.read_short(foff); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
106 |
trcVerbose("odm found version: %d.%d.%d.%d", version, release, modification, fix_level); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
107 |
if (version >> 8 != 0 || release >> 8 != 0 || modification >> 8 != 0 || fix_level >> 8 != 0) { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
108 |
trcVerbose("8 bit numbers expected"); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
109 |
return; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
110 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
111 |
} while (odm.retrieve_obj()); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
112 |
|
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
113 |
if (version != major_aix_version || release != minor_aix_version) { |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
114 |
trcVerbose("version determined by odm does not match uname"); |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
115 |
return; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
116 |
} |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
117 |
*p_ver = version << 24 | release << 16 | modification << 8 | fix_level; |
cb24277be2e7
8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents:
diff
changeset
|
118 |
} |