1 /* 2 * Copyright (c) 1997, 2020, 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 #ifndef SHARE_RUNTIME_FLAGS_JVMFLAG_INLINE_HPP 26 #define SHARE_RUNTIME_FLAGS_JVMFLAG_INLINE_HPP 27 28 #include "runtime/flags/jvmFlag.hpp" 29 #include "utilities/ostream.hpp" 30 31 // We are calling printf with a non-literal format string indexed from print_formats[] 32 PRAGMA_DIAG_PUSH 33 PRAGMA_FORMAT_NONLITERAL_IGNORED 34 35 template <typename T> 36 inline void JVMFlag::print_range_helper(outputStream* st, T min, T max) const { 37 assert(print_formats[type()].type == type(), "must be"); 38 const char* fmt = JVMFlag::print_formats[type()].print_range_format; 39 assert(fmt != NULL, "no range check for bool or ccstr"); 40 st->print(fmt, min, max); 41 } 42 43 template <typename T> 44 inline void JVMFlag::print_range_error(T new_value, T min, T max, bool verbose) const { 45 assert(print_formats[type()].type == type(), "must be"); 46 const char* fmt = print_formats[type()].range_error_format; 47 assert(fmt != NULL, "no range check for bool or ccstr"); 48 JVMFlag::printError(verbose, fmt, type_string(), name(), new_value, min, max); 49 } 50 51 PRAGMA_DIAG_POP 52 53 // ---- Macros for defining VM flags in *globals.cpp files ----- 54 55 56 // NOTE: each of the XXX_FLAG macros has a 6th required argument "docs". 57 // However, for __VA_ARGS__ craziness, this arg is not explicitly specified. 58 59 // Meta-information for PRODUCT_FLAG is stored in ProductFlag<T> 60 #define DEFN_PRODUCT_FLAG_COMMON(name) \ 61 ProductFlag<FLAG_TYPE_##name> FLAG_##name(FLAG_TYPE_NAME_##name(), XSTR(name), FLAG_ATTR(FLAG_ATTR_##name()), &name, FLAG_DOCS_##name()) 62 63 #define DEFN_PRODUCT_FLAG(name) \ 64 FLAG_TYPE_##name name = FLAG_DEFVAL_##name(); \ 65 DEFN_PRODUCT_FLAG_COMMON(name) 66 67 #define DEFN_PRODUCT_FLAG_PD(name) \ 68 FLAG_TYPE_##name name = pd_##name; \ 69 DEFN_PRODUCT_FLAG_COMMON(name) 70 71 #ifdef PRODUCT 72 // In product builds, information for DEVELOP_FLAG is stored in 73 // DevelopFlag<T>. 74 75 #define DEFN_DEVELOP_FLAG_COMMON(name) \ 76 DevelopFlag<FLAG_TYPE_##name> FLAG_##name(FLAG_TYPE_NAME_##name(), XSTR(name), FLAG_ATTR(FLAG_ATTR_##name()), &name) 77 78 #define DEFN_DEVELOP_FLAG(name) \ 79 DEFN_DEVELOP_FLAG_COMMON(name) 80 81 #define DEFN_DEVELOP_FLAG_PD(name) \ 82 DEFN_DEVELOP_FLAG_COMMON(name) 83 84 // In product builds, NOTPROD_FLAGs are not visible at all.. 85 // We add a harmless typedef here to allow using the NOTPROD_FLAG macro with 86 // a trailing ";" in xxx_globals.flags.hpp 87 #define DEFN_NOTPROD_FLAG(name) \ 88 typedef int __unused2__##name 89 90 #else 91 // !defined(PRODUCT) 92 93 // In develop builds, NOTPROD_FLAG and DEVELOP_FLAG are equivalent to PRODUCT_FLAG 94 #define DEFN_NOTPROD_FLAG(name) DEFN_PRODUCT_FLAG(name) 95 #define DEFN_DEVELOP_FLAG(name) DEFN_PRODUCT_FLAG(name) 96 #define DEFN_DEVELOP_FLAG_PD(name) DEFN_PRODUCT_FLAG_PD(name) 97 98 #endif // PRODUCT 99 100 // ---- Macros for implementing VM flags constraints in *globals.cpp files ----- 101 102 #define DEFN_PRODUCT_RANGE(name) \ 103 JVMFlagRange<FLAG_TYPE_##name> FLAG_RANGE_##name(&FLAG_##name, FLAG_MIN_##name(), FLAG_MAX_##name()) 104 105 #define DEFN_PRODUCT_CONSTRAINT(name) \ 106 JVMFlagConstraint<FLAG_TYPE_##name> \ 107 FLAG_CONSTRAINT_##name(&FLAG_##name, FLAG_CONSTRAINT_FUNC_##name(), FLAG_CONSTRAINT_PHASE_##name()) 108 109 #define DEFN_PRODUCT_CUSTOM_RANGE(name) \ 110 FLAG_RANGE_TYPE_##name FLAG_RANGE_##name(&FLAG_##name) 111 112 #ifdef PRODUCT 113 #define DEFN_DEVELOP_RANGE(name) typedef int __unused5__##name 114 #define DEFN_DEVELOP_CONSTRAINT(name) typedef int __unused6__##name 115 116 #define DEFN_NOTPROD_RANGE(name) typedef int __unused7__##name 117 #define DEFN_NOTPROD_CONSTRAINT(name) typedef int __unused8__##name 118 119 120 #else 121 // !defined(PRODUCT) 122 123 #define DEFN_DEVELOP_RANGE(name) DEFN_PRODUCT_RANGE(name) 124 #define DEFN_DEVELOP_CONSTRAINT(name) DEFN_PRODUCT_CONSTRAINT(name) 125 126 #define DEFN_NOTPROD_RANGE(name) DEFN_PRODUCT_RANGE(name) 127 #define DEFN_NOTPROD_CONSTRAINT(name) DEFN_PRODUCT_CONSTRAINT(name) 128 129 #endif 130 131 #endif // SHARE_RUNTIME_FLAGS_JVMFLAG_INLINE_HPP