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