Config.h
1 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
29 /*
30 //
31 //%/////////////////////////////////////////////////////////////////////////////
32 */
33 
34 #ifndef Pegasus_Config_h
35 #define Pegasus_Config_h
36 
37 #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
38 # include <Pegasus/Common/Platform_WIN32_IX86_MSVC.h>
39 #elif defined(PEGASUS_PLATFORM_WIN64_IA64_MSVC)
40 # include <Pegasus/Common/Platform_WIN64_IA64_MSVC.h>
41 #elif defined(PEGASUS_PLATFORM_WIN64_X86_64_MSVC)
42 # include <Pegasus/Common/Platform_WIN64_X86_64_MSVC.h>
43 #elif defined (PEGASUS_PLATFORM_LINUX_IX86_GNU)
44 # include <Pegasus/Common/Platform_LINUX_IX86_GNU.h>
45 #elif defined (PEGASUS_PLATFORM_LINUX_XSCALE_GNU)
46 # include <Pegasus/Common/Platform_LINUX_XSCALE_GNU.h>
47 #elif defined (PEGASUS_PLATFORM_PASE_ISERIES_IBMCXX)
48 #include <Pegasus/Common/Platform_PASE_ISERIES_IBMCXX.h>
49 #elif defined (PEGASUS_PLATFORM_AIX_RS_IBMCXX)
50 # include <Pegasus/Common/Platform_AIX_RS_IBMCXX.h>
51 #elif defined (PEGASUS_PLATFORM_HPUX_PARISC_ACC)
52 # include <Pegasus/Common/Platform_HPUX_PARISC_ACC.h>
53 #elif defined (PEGASUS_PLATFORM_HPUX_PARISC_GNU)
54 # include <Pegasus/Common/Platform_HPUX_PARISC_GNU.h>
55 #elif defined (PEGASUS_PLATFORM_HPUX_IA64_ACC)
56 # include <Pegasus/Common/Platform_HPUX_IA64_ACC.h>
57 #elif defined (PEGASUS_PLATFORM_HPUX_IA64_GNU)
58 # include <Pegasus/Common/Platform_HPUX_IA64_GNU.h>
59 #elif defined (PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX)
60 # include <Pegasus/Common/Platform_TRU64_ALPHA_DECCXX.h>
61 #elif defined (PEGASUS_PLATFORM_SOLARIS_SPARC_GNU)
62 # include <Pegasus/Common/Platform_SOLARIS_SPARC_GNU.h>
63 #elif defined (PEGASUS_PLATFORM_SOLARIS_SPARC_CC)
64 # include <Pegasus/Common/Platform_SOLARIS_SPARC_CC.h>
65 #elif defined (PEGASUS_PLATFORM_SOLARIS_SPARC_64_CC)
66 # include <Pegasus/Common/Platform_SOLARIS_SPARC_CC_64.h>
67 #elif defined (PEGASUS_PLATFORM_SOLARIS_IX86_CC)
68 # include <Pegasus/Common/Platform_SOLARIS_IX86_CC.h>
69 #elif defined (PEGASUS_PLATFORM_SOLARIS_X86_64_CC)
70 # include <Pegasus/Common/Platform_SOLARIS_X86_64_CC.h>
71 #elif defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
72 # include <Pegasus/Common/Platform_ZOS_ZSERIES_IBM.h>
73 #elif defined (PEGASUS_PLATFORM_ZOS_ZSERIES64_IBM)
74 # include <Pegasus/Common/Platform_ZOS_ZSERIES64_IBM.h>
75 #elif defined (PEGASUS_PLATFORM_LINUX_IA64_GNU)
76 # include <Pegasus/Common/Platform_LINUX_IA64_GNU.h>
77 #elif defined (PEGASUS_PLATFORM_LINUX_X86_64_GNU)
78 # include <Pegasus/Common/Platform_LINUX_X86_64_GNU.h>
79 #elif defined (PEGASUS_PLATFORM_LINUX_PPC_GNU)
80 # include <Pegasus/Common/Platform_LINUX_PPC_GNU.h>
81 #elif defined (PEGASUS_PLATFORM_LINUX_PPC64_GNU)
82 # include <Pegasus/Common/Platform_LINUX_PPC64_GNU.h>
83 #elif defined (PEGASUS_PLATFORM_LINUX_PPC_E500_GNU)
84 # include <Pegasus/Common/Platform_LINUX_PPC_E500_GNU.h>
85 #elif defined (PEGASUS_PLATFORM_LINUX_SPARCV9_GNU)
86 # include <Pegasus/Common/Platform_LINUX_SPARCV9_GNU.h>
87 #elif defined (PEGASUS_PLATFORM_LINUX_SPARC64_GNU)
88 # include <Pegasus/Common/Platform_LINUX_SPARC64_GNU.h>
89 #elif defined (PEGASUS_PLATFORM_LINUX_ZSERIES_GNU)
90 # include <Pegasus/Common/Platform_LINUX_ZSERIES_GNU.h>
91 #elif defined (PEGASUS_PLATFORM_LINUX_ZSERIES64_GNU)
92 # include <Pegasus/Common/Platform_LINUX_ZSERIES64_GNU.h>
93 #elif defined (PEGASUS_PLATFORM_DARWIN_PPC_GNU)
94 # include <Pegasus/Common/Platform_DARWIN_PPC_GNU.h>
95 #elif defined (PEGASUS_PLATFORM_DARWIN_IX86_GNU)
96 # include <Pegasus/Common/Platform_DARWIN_IX86_GNU.h>
97 #elif defined (PEGASUS_PLATFORM_VMS_ALPHA_DECCXX)
98 # include <Pegasus/Common/Platform_VMS_ALPHA_DECCXX.h>
99 #elif defined (PEGASUS_PLATFORM_VMS_IA64_DECCXX)
100 # include <Pegasus/Common/Platform_VMS_IA64_DECCXX.h>
101 #elif defined (PEGASUS_PLATFORM_LINUX_XSCALE_GNU)
102 # include <Pegasus/Common/Platform_LINUX_XSCALE_GNU.h>
103 #elif defined (PEGASUS_PLATFORM_LINUX_AARCH64_GNU)
104 # include <Pegasus/Common/Platform_LINUX_AARCH64_GNU.h>
105 #elif defined (PEGASUS_PLATFORM_LINUX_LOONGARCH64_GNU)
106 # include <Pegasus/Common/Platform_LINUX_LOONGARCH64_GNU.h>
107 #elif defined (PEGASUS_PLATFORM_LINUX_X86_64_CLANG)
108 # include <Pegasus/Common/Platform_LINUX_X86_64_CLANG.h>
109 #elif defined (PEGASUS_PLATFORM_LINUX_IX86_CLANG)
110 # include <Pegasus/Common/Platform_LINUX_IX86_CLANG.h>
111 #elif defined (PEGASUS_PLATFORM_LINUX_SH4_GNU)
112 # include <Pegasus/Common/Platform_LINUX_SH4_GNU.h>
113 #else
114 # error "<Pegasus/Common/Config.h>: Unsupported Platform"
115 #endif
116 
117 /*
118 //
119 // COMPILER Checks
120 //
121 // This is to allow a check for GCC > 3.2
122 // It needs to be the first thing we check because the next lines load
123 // further source files
124 */
125 
126 #if defined(__GNUC__)
127 #define GCC_VERSION (__GNUC__ * 10000 \
128  + __GNUC_MINOR__ * 100 \
129  + __GNUC_PATCHLEVEL__)
130 
131 /*
132 // To test for GCC > 3.2.0:
133 // #if GCC_VERSION > 30200
134 */
135 
136 #endif
137 
138 
139 #ifdef __cplusplus
140 #include <cstdlib>
141 #endif
142 
143 #ifndef PEGASUS_IMPORT
144 # define PEGASUS_IMPORT /* empty */
145 #endif
146 
147 #ifndef PEGASUS_EXPORT
148 # define PEGASUS_EXPORT /* empty */
149 #endif
150 
151 /*
152 **==============================================================================
153 **
154 ** PEGASUS_HIDDEN_LINKAGE
155 **
156 ** This macro suppresses the export of a symbol in contexts in which the
157 ** default linkage would have otherwise exported the symbol. Consider the
158 ** following example:
159 **
160 ** class PEGASUS_COMMON_LINKAGE MyClass
161 ** {
162 ** public:
163 **
164 ** // Is exported (due to PEGASUS_COMMON_LINKAGE macro).
165 ** void f();
166 **
167 ** // Is not exported (despite the PEGASUS_COMMON_LINKAGE macro).
168 ** PEGASUS_HIDDEN_LINKAGE void g(); // not-exported.
169 ** };
170 **
171 ** Notes: this macro has an empty expansion on many platforms since this
172 ** feature is compiler specific.
173 **
174 **==============================================================================
175 */
176 #ifndef PEGASUS_HIDDEN_LINKAGE
177 # define PEGASUS_HIDDEN_LINKAGE /* empty */
178 #endif
179 
180 #ifdef PEGASUS_HAVE_NAMESPACES
181 #ifdef __cplusplus
182 # define PEGASUS_NAMESPACE_BEGIN namespace Pegasus {
183 # define PEGASUS_NAMESPACE_END }
184 # define PEGASUS_NAMESPACE(X) Pegasus::X
185 
186 #ifndef PEGASUS_HAVE_NO_STD
187 # define PEGASUS_STD(X) std::X
188 # define PEGASUS_USING_STD using namespace std
189 #else
190 # define PEGASUS_STD(X) X
191 # define PEGASUS_USING_STD
192 #endif
193 # define PEGASUS_USING_PEGASUS using namespace Pegasus
194 #else
195 # define PEGASUS_NAMESPACE_BEGIN /* empty */
196 # define PEGASUS_NAMESPACE_END /* empty */
197 # define PEGASUS_NAMESPACE(X) X
198 # define PEGASUS_STD(X) X
199 # define PEGASUS_USING_STD
200 # define PEGASUS_USING_PEGASUS
201 #endif
202 #else
203 # define PEGASUS_NAMESPACE_BEGIN /* empty */
204 # define PEGASUS_NAMESPACE_END /* empty */
205 # define PEGASUS_NAMESPACE(X) X
206 # define PEGASUS_STD(X) X
207 # define PEGASUS_USING_STD
208 # define PEGASUS_USING_PEGASUS
209 #endif
210 
211 #ifdef PEGASUS_HAVE_EXPLICIT
212 #ifdef __cplusplus
213 # define PEGASUS_EXPLICIT explicit
214 #else
215 # define PEGASUS_EXPLICIT /* empty */
216 #endif
217 #else
218 # define PEGASUS_EXPLICIT /* empty */
219 #endif
220 
221 #ifndef PEGASUS_HAVE_FOR_SCOPE
222 # define for if (0) ; else for
223 #endif
224 
225 #ifdef PEGASUS_HAVE_TEMPLATE_SPECIALIZATION
226 #ifdef __cplusplus
227 # define PEGASUS_TEMPLATE_SPECIALIZATION template <>
228 #else
229 # define PEGASUS_TEMPLATE_SPECIALIZATION
230 #endif
231 #else
232 # define PEGASUS_TEMPLATE_SPECIALIZATION
233 #endif
234 
235 #ifdef PEGASUS_HAVE_IOS_BINARY
236 #ifdef __cplusplus
237 #define PEGASUS_IOS_BINARY ,std::ios::binary
238 #define PEGASUS_OR_IOS_BINARY | std::ios::binary
239 #else
240 #define PEGASUS_IOS_BINARY /* empty */
241 #define PEGASUS_OR_IOS_BINARY /* empty */
242 #endif
243 #else
244 #define PEGASUS_IOS_BINARY /* empty */
245 #define PEGASUS_OR_IOS_BINARY /* empty */
246 #endif
247 
248 #ifndef PEGASUS_SINT64_LITERAL
249 #define PEGASUS_SINT64_LITERAL(X) (Sint64 (X##LL))
250 #endif
251 #ifndef PEGASUS_UINT64_LITERAL
252 #define PEGASUS_UINT64_LITERAL(X) (Uint64 (X##ULL))
253 #endif
254 
255 /* Used in printf and scanf conversion strings for Uint64 and Sint64 args */
256 #ifndef PEGASUS_64BIT_CONVERSION_WIDTH
257 #define PEGASUS_64BIT_CONVERSION_WIDTH "ll"
258 #endif
259 
260 #ifndef PEGASUS_MAXHOSTNAMELEN
261 # ifdef _POSIX_HOST_NAME_MAX
262 # define PEGASUS_MAXHOSTNAMELEN _POSIX_HOST_NAME_MAX
263 # else
264 # define PEGASUS_MAXHOSTNAMELEN MAXHOSTNAMELEN
265 # endif
266 #endif
267 
268 #ifdef __cplusplus
269 PEGASUS_NAMESPACE_BEGIN
270 
271 typedef bool Boolean;
272 typedef unsigned char Uint8;
273 typedef signed char Sint8;
274 typedef unsigned short Uint16;
275 typedef signed short Sint16;
276 typedef unsigned int Uint32;
277 typedef signed int Sint32;
278 typedef float Real32;
279 typedef double Real64;
280 typedef PEGASUS_UINT64 Uint64;
281 typedef PEGASUS_SINT64 Sint64;
282 
283 #define PEG_NOT_FOUND Uint32(-1)
284 
285 PEGASUS_NAMESPACE_END
286 #endif
287 
288 
289 /*
290  *PEGASUS_UNREACHABLE implies unreachable code in pegasus.
291  *Should be used in places where the control should not reached.
292  *Please use in this way
293  * PEGASUS_UNREACHABLE( expression;)
294  *not in this way
295  * PEGASUS_UNREACHABLE(expression);
296  *
297  *Though both are same, Former will prevent ;;(double semicolon)
298  *
299  */
300 
301 #ifdef PEGASUS_SUPPRESS_UNREACHABLE_STATEMENTS
302 # define PEGASUS_UNREACHABLE(CODE)
303 #else
304 # if defined(__clang__ )
305 # define PEGASUS_UNREACHABLE(CODE) __builtin_unreachable();
306 # elif defined(GCC_VERSION)
307 # if GCC_VERSION >= 40500 //Unreachable supported only for gcc 4.5 and above
308 # define PEGASUS_UNREACHABLE(CODE) __builtin_unreachable();
309 # else
310 # define PEGASUS_UNREACHABLE(CODE) CODE
311 # endif
312 # elif defined(_MSC_VER) //PEGASUS_OS_TYPE_WINDOWS
313 # define PEGASUS_UNREACHABLE(CODE) __assume(0);
314 # else
315 # define PEGASUS_UNREACHABLE(CODE) CODE
316 # endif
317 #endif
318 
319 /*
320 **==============================================================================
321 **
322 ** PEGASUS_FORMAT
323 **
324 ** This macro allows the compiler to check the arguments to format
325 ** specifiers in the printf family of functions. For example, the following
326 ** enables format checking for the foo function.
327 **
328 ** PEGASUS_FORMAT(1, 2)
329 ** void foo(const char* format, ...);
330 **
331 ** On GCC, the following error is detected below (when using this macro).
332 **
333 ** foo("%s %d", 99, "hello"); // mismatch specifiers!
334 **
335 **==============================================================================
336 */
337 
338 #if defined(__GNUC__) && (__GNUC__ >= 4)
339 # define PEGASUS_FORMAT(A1, A2) __attribute__((format (printf, A1, A2)))
340 #else
341 # define PEGASUS_FORMAT(A1, A2) /* not implemented */
342 #endif
343 
344 /*
345 ** PEGASUS_INITIAL_THREADSTACK_SIZE
346 **
347 ** This macro is used to restrict the maximal stack size used per thread.
348 ** Since OpenPegasus makes heavy use of multi-threading reducing the system
349 ** default is espescially important on embedded systems.
350 **
351 ** This value can be overridden platform specific by defining the macro in
352 ** the corresponding PEGASUS_PLATFORM_*.h file.
353 */
354 #ifndef PEGASUS_INITIAL_THREADSTACK_SIZE
355 # define PEGASUS_INITIAL_THREADSTACK_SIZE 256*1024
356 #endif
357 
358 /*
359 ** PEGASUS_PG_OBJECTMANAGER_ELEMENTNAME
360 **
361 ** This macro is used to set ElementName property on the PG_ObjectManager
362 ** instance. This value is also used in SLP announcment for service-hi-name.
363 **
364 ** This value can be overridden platform specific by defining the macro in
365 ** the corresponding PEGASUS_PLATFORM_*.h file.
366 */
367 #ifndef PEGASUS_PG_OBJECTMANAGER_ELEMENTNAME
368 # ifdef PEGASUS_FLAVOR
369 # define PEGASUS_PG_OBJECTMANAGER_ELEMENTNAME PEGASUS_FLAVOR"-pegasus"
370 # else
371 # define PEGASUS_PG_OBJECTMANAGER_ELEMENTNAME "Pegasus"
372 # endif
373 #endif
374 
375 /*
376 ** PEGASUS_INSTANCEID_GLOBAL_PREFIX
377 ** This macro is used to create the Name property on the PG_ObjectManager
378 ** instance. This value is also used in SLP announcement for service-id.
379 **
380 ** This value can be overridden platform specific by defining the macro in
381 ** the corresponding PEGASUS_PLATFORM_*.h file.
382 */
383 #ifndef PEGASUS_INSTANCEID_GLOBAL_PREFIX
384 # ifdef PEGASUS_FLAVOR
385 # define PEGASUS_INSTANCEID_GLOBAL_PREFIX "PG-"PEGASUS_FLAVOR
386 # else
387 # define PEGASUS_INSTANCEID_GLOBAL_PREFIX "PG"
388 # endif
389 #endif
390 
391 #endif /* Pegasus_Config_h */