macros.hpp revision 6010:abec000618bf
1322249Sbapt/*
2241675Suqs * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3241675Suqs * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4322249Sbapt *
5241675Suqs * This code is free software; you can redistribute it and/or modify it
6241675Suqs * under the terms of the GNU General Public License version 2 only, as
7241675Suqs * published by the Free Software Foundation.
8241675Suqs *
9241675Suqs * This code is distributed in the hope that it will be useful, but WITHOUT
10241675Suqs * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11241675Suqs * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12241675Suqs * version 2 for more details (a copy is included in the LICENSE file that
13241675Suqs * accompanied this code).
14241675Suqs *
15241675Suqs * You should have received a copy of the GNU General Public License version
16241675Suqs * 2 along with this work; if not, write to the Free Software Foundation,
17241675Suqs * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18241675Suqs *
19241675Suqs * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20275432Sbapt * or visit www.oracle.com if you need additional information or have any
21275432Sbapt * questions.
22241675Suqs *
23241675Suqs */
24294113Sbapt
25294113Sbapt#ifndef SHARE_VM_UTILITIES_MACROS_HPP
26241675Suqs#define SHARE_VM_UTILITIES_MACROS_HPP
27241675Suqs
28241675Suqs// Use this to mark code that needs to be cleaned up (for development only)
29241675Suqs#define NEEDS_CLEANUP
30274880Sbapt
31294113Sbapt// Makes a string of the argument (which is not macro-expanded)
32241675Suqs#define STR(a)  #a
33241675Suqs
34241675Suqs// Makes a string of the macro expansion of a
35294113Sbapt#define XSTR(a) STR(a)
36241675Suqs
37241675Suqs// -DINCLUDE_<something>=0 | 1 can be specified on the command line to include
38241675Suqs// or exclude functionality.
39241675Suqs
40294113Sbapt#ifndef INCLUDE_JVMTI
41294113Sbapt#define INCLUDE_JVMTI 1
42294113Sbapt#endif  // INCLUDE_JVMTI
43241675Suqs
44294113Sbapt#if INCLUDE_JVMTI
45241675Suqs#define JVMTI_ONLY(x) x
46294113Sbapt#define NOT_JVMTI(x)
47294113Sbapt#define NOT_JVMTI_RETURN
48294113Sbapt#define NOT_JVMTI_RETURN_(code) /* next token must be ; */
49294113Sbapt#else
50294113Sbapt#define JVMTI_ONLY(x)
51294113Sbapt#define NOT_JVMTI(x) x
52294113Sbapt#define NOT_JVMTI_RETURN { return; }
53294113Sbapt#define NOT_JVMTI_RETURN_(code) { return code; }
54294113Sbapt#endif // INCLUDE_JVMTI
55294113Sbapt
56294113Sbapt#ifndef INCLUDE_FPROF
57294113Sbapt#define INCLUDE_FPROF 1
58294113Sbapt#endif
59241675Suqs
60294113Sbapt#if INCLUDE_FPROF
61294113Sbapt#define NOT_FPROF_RETURN        /* next token must be ; */
62294113Sbapt#define NOT_FPROF_RETURN_(code) /* next token must be ; */
63294113Sbapt#else
64322249Sbapt#define NOT_FPROF_RETURN                {}
65294113Sbapt#define NOT_FPROF_RETURN_(code) { return code; }
66294113Sbapt#endif // INCLUDE_FPROF
67294113Sbapt
68294113Sbapt#ifndef INCLUDE_VM_STRUCTS
69241675Suqs#define INCLUDE_VM_STRUCTS 1
70294113Sbapt#endif
71294113Sbapt
72294113Sbapt#if INCLUDE_VM_STRUCTS
73294113Sbapt#define NOT_VM_STRUCTS_RETURN        /* next token must be ; */
74294113Sbapt#define NOT_VM_STRUCTS_RETURN_(code) /* next token must be ; */
75294113Sbapt#else
76294113Sbapt#define NOT_VM_STRUCTS_RETURN           {}
77294113Sbapt#define NOT_VM_STRUCTS_RETURN_(code) { return code; }
78294113Sbapt#endif // INCLUDE_VM_STRUCTS
79294113Sbapt
80294113Sbapt#ifndef INCLUDE_JNI_CHECK
81294113Sbapt#define INCLUDE_JNI_CHECK 1
82294113Sbapt#endif
83294113Sbapt
84294113Sbapt#if INCLUDE_JNI_CHECK
85322249Sbapt#define NOT_JNI_CHECK_RETURN        /* next token must be ; */
86322249Sbapt#define NOT_JNI_CHECK_RETURN_(code) /* next token must be ; */
87322249Sbapt#else
88322249Sbapt#define NOT_JNI_CHECK_RETURN            {}
89294113Sbapt#define NOT_JNI_CHECK_RETURN_(code) { return code; }
90294113Sbapt#endif // INCLUDE_JNI_CHECK
91294113Sbapt
92294113Sbapt#ifndef INCLUDE_SERVICES
93294113Sbapt#define INCLUDE_SERVICES 1
94294113Sbapt#endif
95294113Sbapt
96294113Sbapt#if INCLUDE_SERVICES
97294113Sbapt#define NOT_SERVICES_RETURN        /* next token must be ; */
98294113Sbapt#define NOT_SERVICES_RETURN_(code) /* next token must be ; */
99294113Sbapt#else
100294113Sbapt#define NOT_SERVICES_RETURN             {}
101294113Sbapt#define NOT_SERVICES_RETURN_(code) { return code; }
102294113Sbapt#endif // INCLUDE_SERVICES
103294113Sbapt
104294113Sbapt#ifndef INCLUDE_CDS
105294113Sbapt#define INCLUDE_CDS 1
106294113Sbapt#endif
107294113Sbapt
108294113Sbapt#if INCLUDE_CDS
109322249Sbapt#define CDS_ONLY(x) x
110322249Sbapt#define NOT_CDS(x)
111294113Sbapt#define NOT_CDS_RETURN        /* next token must be ; */
112294113Sbapt#define NOT_CDS_RETURN_(code) /* next token must be ; */
113294113Sbapt#else
114294113Sbapt#define CDS_ONLY(x)
115294113Sbapt#define NOT_CDS(x) x
116294113Sbapt#define NOT_CDS_RETURN          {}
117294113Sbapt#define NOT_CDS_RETURN_(code) { return code; }
118294113Sbapt#endif // INCLUDE_CDS
119294113Sbapt
120294113Sbapt#ifndef INCLUDE_MANAGEMENT
121294113Sbapt#define INCLUDE_MANAGEMENT 1
122294113Sbapt#endif // INCLUDE_MANAGEMENT
123294113Sbapt
124294113Sbapt#if INCLUDE_MANAGEMENT
125294113Sbapt#define NOT_MANAGEMENT_RETURN        /* next token must be ; */
126294113Sbapt#define NOT_MANAGEMENT_RETURN_(code) /* next token must be ; */
127294113Sbapt#else
128294113Sbapt#define NOT_MANAGEMENT_RETURN        {}
129294113Sbapt#define NOT_MANAGEMENT_RETURN_(code) { return code; }
130294113Sbapt#endif // INCLUDE_MANAGEMENT
131294113Sbapt
132294113Sbapt/*
133294113Sbapt * When INCLUDE_ALL_GCS is false the only garbage collectors
134294113Sbapt * included in the JVM are defaultNewGeneration and markCompact.
135294113Sbapt *
136294113Sbapt * When INCLUDE_ALL_GCS is true all garbage collectors are
137294113Sbapt * included in the JVM.
138294113Sbapt */
139294113Sbapt#ifndef INCLUDE_ALL_GCS
140294113Sbapt#define INCLUDE_ALL_GCS 1
141294113Sbapt#endif // INCLUDE_ALL_GCS
142294113Sbapt
143294113Sbapt#if INCLUDE_ALL_GCS
144294113Sbapt#define NOT_ALL_GCS_RETURN        /* next token must be ; */
145294113Sbapt#define NOT_ALL_GCS_RETURN_(code) /* next token must be ; */
146294113Sbapt#else
147294113Sbapt#define NOT_ALL_GCS_RETURN        {}
148294113Sbapt#define NOT_ALL_GCS_RETURN_(code) { return code; }
149294113Sbapt#endif // INCLUDE_ALL_GCS
150294113Sbapt
151294113Sbapt#ifndef INCLUDE_NMT
152294113Sbapt#define INCLUDE_NMT 1
153294113Sbapt#endif // INCLUDE_NMT
154294113Sbapt
155294113Sbapt#if INCLUDE_NMT
156294113Sbapt#define NOT_NMT_RETURN        /* next token must be ; */
157294113Sbapt#define NOT_NMT_RETURN_(code) /* next token must be ; */
158294113Sbapt#else
159294113Sbapt#define NOT_NMT_RETURN        {}
160294113Sbapt#define NOT_NMT_RETURN_(code) { return code; }
161294113Sbapt#endif // INCLUDE_NMT
162294113Sbapt
163294113Sbapt#ifndef INCLUDE_TRACE
164294113Sbapt#define INCLUDE_TRACE 1
165294113Sbapt#endif // INCLUDE_TRACE
166294113Sbapt
167294113Sbapt// COMPILER1 variant
168294113Sbapt#ifdef COMPILER1
169322249Sbapt#ifdef COMPILER2
170294113Sbapt  #define TIERED
171294113Sbapt#endif
172294113Sbapt#define COMPILER1_PRESENT(code) code
173294113Sbapt#else // COMPILER1
174294113Sbapt#define COMPILER1_PRESENT(code)
175294113Sbapt#endif // COMPILER1
176294113Sbapt
177294113Sbapt// COMPILER2 variant
178294113Sbapt#ifdef COMPILER2
179294113Sbapt#define COMPILER2_PRESENT(code) code
180294113Sbapt#define NOT_COMPILER2(code)
181294113Sbapt#else // COMPILER2
182294113Sbapt#define COMPILER2_PRESENT(code)
183294113Sbapt#define NOT_COMPILER2(code) code
184294113Sbapt#endif // COMPILER2
185294113Sbapt
186294113Sbapt#ifdef TIERED
187294113Sbapt#define TIERED_ONLY(code) code
188294113Sbapt#define NOT_TIERED(code)
189294113Sbapt#else
190294113Sbapt#define TIERED_ONLY(code)
191294113Sbapt#define NOT_TIERED(code) code
192294113Sbapt#endif // TIERED
193294113Sbapt
194294113Sbapt
195294113Sbapt// PRODUCT variant
196294113Sbapt#ifdef PRODUCT
197294113Sbapt#define PRODUCT_ONLY(code) code
198294113Sbapt#define NOT_PRODUCT(code)
199294113Sbapt#define NOT_PRODUCT_ARG(arg)
200294113Sbapt#define PRODUCT_RETURN  {}
201294113Sbapt#define PRODUCT_RETURN0 { return 0; }
202294113Sbapt#define PRODUCT_RETURN_(code) { code }
203294113Sbapt#else // PRODUCT
204294113Sbapt#define PRODUCT_ONLY(code)
205294113Sbapt#define NOT_PRODUCT(code) code
206294113Sbapt#define NOT_PRODUCT_ARG(arg) arg,
207294113Sbapt#define PRODUCT_RETURN  /*next token must be ;*/
208294113Sbapt#define PRODUCT_RETURN0 /*next token must be ;*/
209294113Sbapt#define PRODUCT_RETURN_(code)  /*next token must be ;*/
210294113Sbapt#endif // PRODUCT
211294113Sbapt
212294113Sbapt#ifdef CHECK_UNHANDLED_OOPS
213294113Sbapt#define CHECK_UNHANDLED_OOPS_ONLY(code) code
214294113Sbapt#define NOT_CHECK_UNHANDLED_OOPS(code)
215294113Sbapt#else
216294113Sbapt#define CHECK_UNHANDLED_OOPS_ONLY(code)
217294113Sbapt#define NOT_CHECK_UNHANDLED_OOPS(code)  code
218294113Sbapt#endif // CHECK_UNHANDLED_OOPS
219294113Sbapt
220294113Sbapt#ifdef CC_INTERP
221294113Sbapt#define CC_INTERP_ONLY(code) code
222294113Sbapt#define NOT_CC_INTERP(code)
223294113Sbapt#else
224294113Sbapt#define CC_INTERP_ONLY(code)
225294113Sbapt#define NOT_CC_INTERP(code) code
226294113Sbapt#endif // CC_INTERP
227294113Sbapt
228294113Sbapt#ifdef ASSERT
229294113Sbapt#define DEBUG_ONLY(code) code
230294113Sbapt#define NOT_DEBUG(code)
231294113Sbapt#define NOT_DEBUG_RETURN  /*next token must be ;*/
232294113Sbapt// Historical.
233294113Sbapt#define debug_only(code) code
234294113Sbapt#else // ASSERT
235294113Sbapt#define DEBUG_ONLY(code)
236294113Sbapt#define NOT_DEBUG(code) code
237294113Sbapt#define NOT_DEBUG_RETURN {}
238294113Sbapt#define debug_only(code)
239294113Sbapt#endif // ASSERT
240294113Sbapt
241294113Sbapt#ifdef  _LP64
242294113Sbapt#define LP64_ONLY(code) code
243322249Sbapt#define NOT_LP64(code)
244294113Sbapt#else  // !_LP64
245294113Sbapt#define LP64_ONLY(code)
246322249Sbapt#define NOT_LP64(code) code
247294113Sbapt#endif // _LP64
248294113Sbapt
249294113Sbapt#ifdef LINUX
250322249Sbapt#define LINUX_ONLY(code) code
251322249Sbapt#define NOT_LINUX(code)
252322249Sbapt#else
253322249Sbapt#define LINUX_ONLY(code)
254322249Sbapt#define NOT_LINUX(code) code
255322249Sbapt#endif
256322249Sbapt
257294113Sbapt#ifdef AIX
258294113Sbapt#define AIX_ONLY(code) code
259294113Sbapt#define NOT_AIX(code)
260294113Sbapt#else
261294113Sbapt#define AIX_ONLY(code)
262294113Sbapt#define NOT_AIX(code) code
263294113Sbapt#endif
264294113Sbapt
265294113Sbapt#ifdef SOLARIS
266294113Sbapt#define SOLARIS_ONLY(code) code
267294113Sbapt#define NOT_SOLARIS(code)
268294113Sbapt#else
269294113Sbapt#define SOLARIS_ONLY(code)
270294113Sbapt#define NOT_SOLARIS(code) code
271294113Sbapt#endif
272294113Sbapt
273294113Sbapt#ifdef _WINDOWS
274294113Sbapt#define WINDOWS_ONLY(code) code
275294113Sbapt#define NOT_WINDOWS(code)
276294113Sbapt#else
277294113Sbapt#define WINDOWS_ONLY(code)
278294113Sbapt#define NOT_WINDOWS(code) code
279294113Sbapt#endif
280294113Sbapt
281294113Sbapt#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
282294113Sbapt#define BSD_ONLY(code) code
283294113Sbapt#define NOT_BSD(code)
284294113Sbapt#else
285294113Sbapt#define BSD_ONLY(code)
286294113Sbapt#define NOT_BSD(code) code
287294113Sbapt#endif
288294113Sbapt
289294113Sbapt#ifdef _WIN64
290294113Sbapt#define WIN64_ONLY(code) code
291294113Sbapt#define NOT_WIN64(code)
292294113Sbapt#else
293294113Sbapt#define WIN64_ONLY(code)
294294113Sbapt#define NOT_WIN64(code) code
295294113Sbapt#endif
296294113Sbapt
297294113Sbapt#if defined(ZERO)
298294113Sbapt#define ZERO_ONLY(code) code
299294113Sbapt#define NOT_ZERO(code)
300294113Sbapt#else
301294113Sbapt#define ZERO_ONLY(code)
302294113Sbapt#define NOT_ZERO(code) code
303294113Sbapt#endif
304294113Sbapt
305294113Sbapt#if defined(SHARK)
306294113Sbapt#define SHARK_ONLY(code) code
307294113Sbapt#define NOT_SHARK(code)
308294113Sbapt#else
309294113Sbapt#define SHARK_ONLY(code)
310294113Sbapt#define NOT_SHARK(code) code
311294113Sbapt#endif
312294113Sbapt
313294113Sbapt#if defined(IA32) || defined(AMD64)
314294113Sbapt#define X86
315294113Sbapt#define X86_ONLY(code) code
316294113Sbapt#define NOT_X86(code)
317294113Sbapt#else
318294113Sbapt#undef X86
319294113Sbapt#define X86_ONLY(code)
320294113Sbapt#define NOT_X86(code) code
321294113Sbapt#endif
322294113Sbapt
323294113Sbapt#ifdef IA32
324294113Sbapt#define IA32_ONLY(code) code
325294113Sbapt#define NOT_IA32(code)
326294113Sbapt#else
327294113Sbapt#define IA32_ONLY(code)
328294113Sbapt#define NOT_IA32(code) code
329294113Sbapt#endif
330294113Sbapt
331294113Sbapt// This is a REALLY BIG HACK, but on AIX <sys/systemcfg.h> unconditionally defines IA64.
332294113Sbapt// At least on AIX 7.1 this is a real problem because 'systemcfg.h' is indirectly included
333294113Sbapt// by 'pthread.h' and other common system headers.
334294113Sbapt
335294113Sbapt#if defined(IA64) && !defined(AIX)
336294113Sbapt#define IA64_ONLY(code) code
337294113Sbapt#define NOT_IA64(code)
338294113Sbapt#else
339294113Sbapt#define IA64_ONLY(code)
340294113Sbapt#define NOT_IA64(code) code
341294113Sbapt#endif
342294113Sbapt
343294113Sbapt#ifdef AMD64
344294113Sbapt#define AMD64_ONLY(code) code
345294113Sbapt#define NOT_AMD64(code)
346294113Sbapt#else
347294113Sbapt#define AMD64_ONLY(code)
348294113Sbapt#define NOT_AMD64(code) code
349294113Sbapt#endif
350294113Sbapt
351294113Sbapt#ifdef SPARC
352294113Sbapt#define SPARC_ONLY(code) code
353294113Sbapt#define NOT_SPARC(code)
354294113Sbapt#else
355294113Sbapt#define SPARC_ONLY(code)
356294113Sbapt#define NOT_SPARC(code) code
357294113Sbapt#endif
358294113Sbapt
359294113Sbapt#if defined(PPC32) || defined(PPC64)
360294113Sbapt#ifndef PPC
361294113Sbapt#define PPC
362294113Sbapt#endif
363294113Sbapt#define PPC_ONLY(code) code
364294113Sbapt#define NOT_PPC(code)
365294113Sbapt#else
366294113Sbapt#undef PPC
367294113Sbapt#define PPC_ONLY(code)
368294113Sbapt#define NOT_PPC(code) code
369294113Sbapt#endif
370294113Sbapt
371294113Sbapt#ifdef PPC32
372322249Sbapt#define PPC32_ONLY(code) code
373322249Sbapt#define NOT_PPC32(code)
374294113Sbapt#else
375294113Sbapt#define PPC32_ONLY(code)
376294113Sbapt#define NOT_PPC32(code) code
377294113Sbapt#endif
378294113Sbapt
379294113Sbapt#ifdef PPC64
380294113Sbapt#define PPC64_ONLY(code) code
381294113Sbapt#define NOT_PPC64(code)
382294113Sbapt#else
383294113Sbapt#define PPC64_ONLY(code)
384294113Sbapt#define NOT_PPC64(code) code
385294113Sbapt#endif
386294113Sbapt
387294113Sbapt#ifdef E500V2
388294113Sbapt#define E500V2_ONLY(code) code
389294113Sbapt#define NOT_E500V2(code)
390294113Sbapt#else
391294113Sbapt#define E500V2_ONLY(code)
392294113Sbapt#define NOT_E500V2(code) code
393294113Sbapt#endif
394294113Sbapt
395294113Sbapt
396294113Sbapt#ifdef ARM
397294113Sbapt#define ARM_ONLY(code) code
398294113Sbapt#define NOT_ARM(code)
399294113Sbapt#else
400294113Sbapt#define ARM_ONLY(code)
401294113Sbapt#define NOT_ARM(code) code
402294113Sbapt#endif
403294113Sbapt
404294113Sbapt#ifdef JAVASE_EMBEDDED
405294113Sbapt#define EMBEDDED_ONLY(code) code
406294113Sbapt#define NOT_EMBEDDED(code)
407294113Sbapt#else
408294113Sbapt#define EMBEDDED_ONLY(code)
409294113Sbapt#define NOT_EMBEDDED(code) code
410294113Sbapt#endif
411294113Sbapt
412294113Sbapt#define define_pd_global(type, name, value) const type pd_##name = value;
413294113Sbapt
414294113Sbapt#endif // SHARE_VM_UTILITIES_MACROS_HPP
415294113Sbapt