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