|
| 1 | +/* |
| 2 | + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. |
| 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 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + * |
| 23 | + */ |
| 24 | + |
| 25 | +#include "precompiled.hpp" |
| 26 | + |
| 27 | +#include "cds.h" |
| 28 | +#include "cds/cdsConstants.hpp" |
| 29 | +#include "cds/dynamicArchive.hpp" |
| 30 | +#include "cds/filemap.hpp" |
| 31 | +#include "utilities/globalDefinitions.hpp" |
| 32 | + |
| 33 | +CDSConst CDSConstants::offsets[] = { |
| 34 | + { "CDSFileMapHeaderBase::_magic", offset_of(CDSFileMapHeaderBase, _magic) }, |
| 35 | + { "CDSFileMapHeaderBase::_crc", offset_of(CDSFileMapHeaderBase, _crc) }, |
| 36 | + { "CDSFileMapHeaderBase::_version", offset_of(CDSFileMapHeaderBase, _version) }, |
| 37 | + { "CDSFileMapHeaderBase::_space[0]", offset_of(CDSFileMapHeaderBase, _space) }, |
| 38 | + { "FileMapHeader::_jvm_ident", offset_of(FileMapHeader, _jvm_ident) }, |
| 39 | + { "FileMapHeader::_base_archive_name_size", offset_of(FileMapHeader, _base_archive_name_size) }, |
| 40 | + { "CDSFileMapRegion::_crc", offset_of(CDSFileMapRegion, _crc) }, |
| 41 | + { "CDSFileMapRegion::_used", offset_of(CDSFileMapRegion, _used) }, |
| 42 | + { "DynamicArchiveHeader::_base_region_crc", offset_of(DynamicArchiveHeader, _base_region_crc) } |
| 43 | +}; |
| 44 | + |
| 45 | +CDSConst CDSConstants::constants[] = { |
| 46 | + { "static_magic", (size_t)CDS_ARCHIVE_MAGIC }, |
| 47 | + { "dynamic_magic", (size_t)CDS_DYNAMIC_ARCHIVE_MAGIC }, |
| 48 | + { "int_size", sizeof(int) }, |
| 49 | + { "CDSFileMapRegion_size", sizeof(CDSFileMapRegion) }, |
| 50 | + { "static_file_header_size", sizeof(FileMapHeader) }, |
| 51 | + { "dynamic_archive_header_size", sizeof(DynamicArchiveHeader) }, |
| 52 | + { "size_t_size", sizeof(size_t) } |
| 53 | +}; |
| 54 | + |
| 55 | +size_t CDSConstants::get_cds_offset(const char* name) { |
| 56 | + for (int i = 0; i < (int)ARRAY_SIZE(offsets); i++) { |
| 57 | + if (strcmp(name, offsets[i]._name) == 0) { |
| 58 | + return offsets[i]._value; |
| 59 | + } |
| 60 | + } |
| 61 | + return -1; |
| 62 | +} |
| 63 | + |
| 64 | +size_t CDSConstants::get_cds_constant(const char* name) { |
| 65 | + for (int i = 0; i < (int)ARRAY_SIZE(constants); i++) { |
| 66 | + if (strcmp(name, constants[i]._name) == 0) { |
| 67 | + return constants[i]._value; |
| 68 | + } |
| 69 | + } |
| 70 | + return -1; |
| 71 | +} |
1 commit comments
openjdk-notifier[bot] commentedon Sep 16, 2021
Review
Issues