1 /*
   2  * Copyright (c) 1997, 2016, 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_VM_UTILITIES_MACROS_HPP
  26 #define SHARE_VM_UTILITIES_MACROS_HPP
  27 
  28 // Use this to mark code that needs to be cleaned up (for development only)
  29 #define NEEDS_CLEANUP
  30 
  31 // Makes a string of the argument (which is not macro-expanded)
  32 #define STR(a)  #a
  33 
  34 // Makes a string of the macro expansion of a
  35 #define XSTR(a) STR(a)
  36 
  37 // Allow commas in macro arguments.
  38 #define COMMA ,
  39 
  40 // Apply pre-processor token pasting to the expansions of x and y.
  41 // The token pasting operator (##) prevents its arguments from being
  42 // expanded.  This macro allows expansion of its arguments before the
  43 // concatenation is performed.  Note: One auxilliary level ought to be
  44 // sufficient, but two are used because of bugs in some preprocesors.
  45 #define PASTE_TOKENS(x, y) PASTE_TOKENS_AUX(x, y)
  46 #define PASTE_TOKENS_AUX(x, y) PASTE_TOKENS_AUX2(x, y)
  47 #define PASTE_TOKENS_AUX2(x, y) x ## y
  48 
  49 // -DINCLUDE_<something>=0 | 1 can be specified on the command line to include
  50 // or exclude functionality.
  51 
  52 #ifndef INCLUDE_JVMTI
  53 #define INCLUDE_JVMTI 1
  54 #endif  // INCLUDE_JVMTI
  55 
  56 #if INCLUDE_JVMTI
  57 #define JVMTI_ONLY(x) x
  58 #define NOT_JVMTI(x)
  59 #define NOT_JVMTI_RETURN
  60 #define NOT_JVMTI_RETURN_(code) /* next token must be ; */
  61 #else
  62 #define JVMTI_ONLY(x)
  63 #define NOT_JVMTI(x) x
  64 #define NOT_JVMTI_RETURN { return; }
  65 #define NOT_JVMTI_RETURN_(code) { return code; }
  66 #endif // INCLUDE_JVMTI
  67 
  68 #ifndef INCLUDE_FPROF
  69 #define INCLUDE_FPROF 1
  70 #endif
  71 
  72 #if INCLUDE_FPROF
  73 #define NOT_FPROF_RETURN        /* next token must be ; */
  74 #define NOT_FPROF_RETURN_(code) /* next token must be ; */
  75 #else
  76 #define NOT_FPROF_RETURN                {}
  77 #define NOT_FPROF_RETURN_(code) { return code; }
  78 #endif // INCLUDE_FPROF
  79 
  80 #ifndef INCLUDE_VM_STRUCTS
  81 #define INCLUDE_VM_STRUCTS 1
  82 #endif
  83 
  84 #if INCLUDE_VM_STRUCTS
  85 #define NOT_VM_STRUCTS_RETURN        /* next token must be ; */
  86 #define NOT_VM_STRUCTS_RETURN_(code) /* next token must be ; */
  87 #else
  88 #define NOT_VM_STRUCTS_RETURN           {}
  89 #define NOT_VM_STRUCTS_RETURN_(code) { return code; }
  90 #endif // INCLUDE_VM_STRUCTS
  91 
  92 #ifndef INCLUDE_JNI_CHECK
  93 #define INCLUDE_JNI_CHECK 1
  94 #endif
  95 
  96 #if INCLUDE_JNI_CHECK
  97 #define NOT_JNI_CHECK_RETURN        /* next token must be ; */
  98 #define NOT_JNI_CHECK_RETURN_(code) /* next token must be ; */
  99 #else
 100 #define NOT_JNI_CHECK_RETURN            {}
 101 #define NOT_JNI_CHECK_RETURN_(code) { return code; }
 102 #endif // INCLUDE_JNI_CHECK
 103 
 104 #ifndef INCLUDE_SERVICES
 105 #define INCLUDE_SERVICES 1
 106 #endif
 107 
 108 #if INCLUDE_SERVICES
 109 #define NOT_SERVICES_RETURN        /* next token must be ; */
 110 #define NOT_SERVICES_RETURN_(code) /* next token must be ; */
 111 #else
 112 #define NOT_SERVICES_RETURN             {}
 113 #define NOT_SERVICES_RETURN_(code) { return code; }
 114 #endif // INCLUDE_SERVICES
 115 
 116 #ifndef INCLUDE_CDS
 117 #define INCLUDE_CDS 1
 118 #endif
 119 
 120 #if INCLUDE_CDS
 121 #define CDS_ONLY(x) x
 122 #define NOT_CDS(x)
 123 #define NOT_CDS_RETURN        /* next token must be ; */
 124 #define NOT_CDS_RETURN_(code) /* next token must be ; */
 125 #else
 126 #define CDS_ONLY(x)
 127 #define NOT_CDS(x) x
 128 #define NOT_CDS_RETURN          {}
 129 #define NOT_CDS_RETURN_(code) { return code; }
 130 #endif // INCLUDE_CDS
 131 
 132 #ifndef INCLUDE_MANAGEMENT
 133 #define INCLUDE_MANAGEMENT 1
 134 #endif // INCLUDE_MANAGEMENT
 135 
 136 #if INCLUDE_MANAGEMENT
 137 #define NOT_MANAGEMENT_RETURN        /* next token must be ; */
 138 #define NOT_MANAGEMENT_RETURN_(code) /* next token must be ; */
 139 #else
 140 #define NOT_MANAGEMENT_RETURN        {}
 141 #define NOT_MANAGEMENT_RETURN_(code) { return code; }
 142 #endif // INCLUDE_MANAGEMENT
 143 
 144 /*
 145  * When INCLUDE_ALL_GCS is false the only garbage collectors
 146  * included in the JVM are defaultNewGeneration and markCompact.
 147  *
 148  * When INCLUDE_ALL_GCS is true all garbage collectors are
 149  * included in the JVM.
 150  */
 151 #ifndef INCLUDE_ALL_GCS
 152 #define INCLUDE_ALL_GCS 1
 153 #endif // INCLUDE_ALL_GCS
 154 
 155 #if INCLUDE_ALL_GCS
 156 #define NOT_ALL_GCS_RETURN        /* next token must be ; */
 157 #define NOT_ALL_GCS_RETURN_(code) /* next token must be ; */
 158 #else
 159 #define NOT_ALL_GCS_RETURN        {}
 160 #define NOT_ALL_GCS_RETURN_(code) { return code; }
 161 #endif // INCLUDE_ALL_GCS
 162 
 163 #ifndef INCLUDE_NMT
 164 #define INCLUDE_NMT 1
 165 #endif // INCLUDE_NMT
 166 
 167 #if INCLUDE_NMT
 168 #define NOT_NMT_RETURN        /* next token must be ; */
 169 #define NOT_NMT_RETURN_(code) /* next token must be ; */
 170 #else
 171 #define NOT_NMT_RETURN        {}
 172 #define NOT_NMT_RETURN_(code) { return code; }
 173 #endif // INCLUDE_NMT
 174 
 175 #ifndef INCLUDE_TRACE
 176 #define INCLUDE_TRACE 1
 177 #endif // INCLUDE_TRACE
 178 
 179 #ifndef INCLUDE_JVMCI
 180 #define INCLUDE_JVMCI 1
 181 #endif
 182 
 183 #if INCLUDE_JVMCI
 184 #define JVMCI_ONLY(code) code
 185 #define NOT_JVMCI(code)
 186 #define NOT_JVMCI_RETURN /* next token must be ; */
 187 #else
 188 #define JVMCI_ONLY(code)
 189 #define NOT_JVMCI(code) code
 190 #define NOT_JVMCI_RETURN {}
 191 #endif // INCLUDE_JVMCI
 192 
 193 // COMPILER1 variant
 194 #ifdef COMPILER1
 195 #ifdef COMPILER2
 196   #define TIERED
 197 #endif
 198 #define COMPILER1_PRESENT(code) code
 199 #else // COMPILER1
 200 #define COMPILER1_PRESENT(code)
 201 #endif // COMPILER1
 202 
 203 // COMPILER2 variant
 204 #ifdef COMPILER2
 205 #define COMPILER2_PRESENT(code) code
 206 #define NOT_COMPILER2(code)
 207 #else // COMPILER2
 208 #define COMPILER2_PRESENT(code)
 209 #define NOT_COMPILER2(code) code
 210 #endif // COMPILER2
 211 
 212 // COMPILER2 or JVMCI
 213 #if defined(COMPILER2) || INCLUDE_JVMCI
 214 #define COMPILER2_OR_JVMCI 1
 215 #define COMPILER2_OR_JVMCI_PRESENT(code) code
 216 #define NOT_COMPILER2_OR_JVMCI(code)
 217 #else
 218 #define COMPILER2_OR_JVMCI 0
 219 #define COMPILER2_OR_JVMCI_PRESENT(code)
 220 #define NOT_COMPILER2_OR_JVMCI(code) code
 221 #endif
 222 
 223 #ifdef TIERED
 224 #define TIERED_ONLY(code) code
 225 #define NOT_TIERED(code)
 226 #else // TIERED
 227 #define TIERED_ONLY(code)
 228 #define NOT_TIERED(code) code
 229 #endif // TIERED
 230 
 231 
 232 // PRODUCT variant
 233 #ifdef PRODUCT
 234 #define PRODUCT_ONLY(code) code
 235 #define NOT_PRODUCT(code)
 236 #define NOT_PRODUCT_ARG(arg)
 237 #define PRODUCT_RETURN  {}
 238 #define PRODUCT_RETURN0 { return 0; }
 239 #define PRODUCT_RETURN_(code) { code }
 240 #else // PRODUCT
 241 #define PRODUCT_ONLY(code)
 242 #define NOT_PRODUCT(code) code
 243 #define NOT_PRODUCT_ARG(arg) arg,
 244 #define PRODUCT_RETURN  /*next token must be ;*/
 245 #define PRODUCT_RETURN0 /*next token must be ;*/
 246 #define PRODUCT_RETURN_(code)  /*next token must be ;*/
 247 #endif // PRODUCT
 248 
 249 #ifdef CHECK_UNHANDLED_OOPS
 250 #define CHECK_UNHANDLED_OOPS_ONLY(code) code
 251 #define NOT_CHECK_UNHANDLED_OOPS(code)
 252 #else
 253 #define CHECK_UNHANDLED_OOPS_ONLY(code)
 254 #define NOT_CHECK_UNHANDLED_OOPS(code)  code
 255 #endif // CHECK_UNHANDLED_OOPS
 256 
 257 #ifdef CC_INTERP
 258 #define CC_INTERP_ONLY(code) code
 259 #define NOT_CC_INTERP(code)
 260 #else
 261 #define CC_INTERP_ONLY(code)
 262 #define NOT_CC_INTERP(code) code
 263 #endif // CC_INTERP
 264 
 265 #ifdef ASSERT
 266 #define DEBUG_ONLY(code) code
 267 #define NOT_DEBUG(code)
 268 #define NOT_DEBUG_RETURN  /*next token must be ;*/
 269 // Historical.
 270 #define debug_only(code) code
 271 #else // ASSERT
 272 #define DEBUG_ONLY(code)
 273 #define NOT_DEBUG(code) code
 274 #define NOT_DEBUG_RETURN {}
 275 #define debug_only(code)
 276 #endif // ASSERT
 277 
 278 #ifdef  _LP64
 279 #define LP64_ONLY(code) code
 280 #define NOT_LP64(code)
 281 #else  // !_LP64
 282 #define LP64_ONLY(code)
 283 #define NOT_LP64(code) code
 284 #endif // _LP64
 285 
 286 #ifdef LINUX
 287 #define LINUX_ONLY(code) code
 288 #define NOT_LINUX(code)
 289 #else
 290 #define LINUX_ONLY(code)
 291 #define NOT_LINUX(code) code
 292 #endif
 293 
 294 #ifdef AIX
 295 #define AIX_ONLY(code) code
 296 #define NOT_AIX(code)
 297 #else
 298 #define AIX_ONLY(code)
 299 #define NOT_AIX(code) code
 300 #endif
 301 
 302 #ifdef SOLARIS
 303 #define SOLARIS_ONLY(code) code
 304 #define NOT_SOLARIS(code)
 305 #else
 306 #define SOLARIS_ONLY(code)
 307 #define NOT_SOLARIS(code) code
 308 #endif
 309 
 310 #ifdef _WINDOWS
 311 #define WINDOWS_ONLY(code) code
 312 #define NOT_WINDOWS(code)
 313 #else
 314 #define WINDOWS_ONLY(code)
 315 #define NOT_WINDOWS(code) code
 316 #endif
 317 
 318 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
 319 #define BSD_ONLY(code) code
 320 #define NOT_BSD(code)
 321 #else
 322 #define BSD_ONLY(code)
 323 #define NOT_BSD(code) code
 324 #endif
 325 
 326 #ifdef _WIN64
 327 #define WIN64_ONLY(code) code
 328 #define NOT_WIN64(code)
 329 #else
 330 #define WIN64_ONLY(code)
 331 #define NOT_WIN64(code) code
 332 #endif
 333 
 334 #if defined(ZERO)
 335 #define ZERO_ONLY(code) code
 336 #define NOT_ZERO(code)
 337 #else
 338 #define ZERO_ONLY(code)
 339 #define NOT_ZERO(code) code
 340 #endif
 341 
 342 #if defined(SHARK)
 343 #define SHARK_ONLY(code) code
 344 #define NOT_SHARK(code)
 345 #else
 346 #define SHARK_ONLY(code)
 347 #define NOT_SHARK(code) code
 348 #endif
 349 
 350 #if defined(IA32) || defined(AMD64)
 351 #define X86
 352 #define X86_ONLY(code) code
 353 #define NOT_X86(code)
 354 #else
 355 #undef X86
 356 #define X86_ONLY(code)
 357 #define NOT_X86(code) code
 358 #endif
 359 
 360 #ifdef IA32
 361 #define IA32_ONLY(code) code
 362 #define NOT_IA32(code)
 363 #else
 364 #define IA32_ONLY(code)
 365 #define NOT_IA32(code) code
 366 #endif
 367 
 368 // This is a REALLY BIG HACK, but on AIX <sys/systemcfg.h> unconditionally defines IA64.
 369 // At least on AIX 7.1 this is a real problem because 'systemcfg.h' is indirectly included
 370 // by 'pthread.h' and other common system headers.
 371 
 372 #if defined(IA64) && !defined(AIX)
 373 #define IA64_ONLY(code) code
 374 #define NOT_IA64(code)
 375 #else
 376 #define IA64_ONLY(code)
 377 #define NOT_IA64(code) code
 378 #endif
 379 
 380 #ifdef AMD64
 381 #define AMD64_ONLY(code) code
 382 #define NOT_AMD64(code)
 383 #else
 384 #define AMD64_ONLY(code)
 385 #define NOT_AMD64(code) code
 386 #endif
 387 
 388 #ifdef SPARC
 389 #define SPARC_ONLY(code) code
 390 #define NOT_SPARC(code)
 391 #else
 392 #define SPARC_ONLY(code)
 393 #define NOT_SPARC(code) code
 394 #endif
 395 
 396 #if defined(PPC32) || defined(PPC64)
 397 #ifndef PPC
 398 #define PPC
 399 #endif
 400 #define PPC_ONLY(code) code
 401 #define NOT_PPC(code)
 402 #else
 403 #undef PPC
 404 #define PPC_ONLY(code)
 405 #define NOT_PPC(code) code
 406 #endif
 407 
 408 #ifdef PPC32
 409 #define PPC32_ONLY(code) code
 410 #define NOT_PPC32(code)
 411 #else
 412 #define PPC32_ONLY(code)
 413 #define NOT_PPC32(code) code
 414 #endif
 415 
 416 #ifdef PPC64
 417 #define PPC64_ONLY(code) code
 418 #define NOT_PPC64(code)
 419 #else
 420 #define PPC64_ONLY(code)
 421 #define NOT_PPC64(code) code
 422 #endif
 423 
 424 #ifdef E500V2
 425 #define E500V2_ONLY(code) code
 426 #define NOT_E500V2(code)
 427 #else
 428 #define E500V2_ONLY(code)
 429 #define NOT_E500V2(code) code
 430 #endif
 431 
 432 #ifdef ARM
 433 #define ARM_ONLY(code) code
 434 #define NOT_ARM(code)
 435 #else
 436 #define ARM_ONLY(code)
 437 #define NOT_ARM(code) code
 438 #endif
 439 
 440 #ifdef ARM32
 441 #define ARM32_ONLY(code) code
 442 #define NOT_ARM32(code)
 443 #else
 444 #define ARM32_ONLY(code)
 445 #define NOT_ARM32(code) code
 446 #endif
 447 
 448 #ifdef AARCH64
 449 #define AARCH64_ONLY(code) code
 450 #define NOT_AARCH64(code)
 451 #else
 452 #define AARCH64_ONLY(code)
 453 #define NOT_AARCH64(code) code
 454 #endif
 455 
 456 #ifdef JAVASE_EMBEDDED
 457 #define EMBEDDED_ONLY(code) code
 458 #define NOT_EMBEDDED(code)
 459 #else
 460 #define EMBEDDED_ONLY(code)
 461 #define NOT_EMBEDDED(code) code
 462 #endif
 463 
 464 #define define_pd_global(type, name, value) const type pd_##name = value;
 465 
 466 #endif // SHARE_VM_UTILITIES_MACROS_HPP