1 // -*- Mode: C++; -*-
2 //                            Package   : omniORB2
3 // CORBA_sysdep.h             Created on: 30/1/96
4 //                            Author    : Sai Lai Lo (sll)
5 //
6 //    Copyright (C) 2003-2012 Apasphere Ltd
7 //    Copyright (C) 1996-1999 AT&T Laboratories Cambridge
8 //
9 //    This file is part of the omniORB library
10 //
11 //    The omniORB library is free software; you can redistribute it and/or
12 //    modify it under the terms of the GNU Lesser General Public
13 //    License as published by the Free Software Foundation; either
14 //    version 2.1 of the License, or (at your option) any later version.
15 //
16 //    This library is distributed in the hope that it will be useful,
17 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
18 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 //    Lesser General Public License for more details.
20 //
21 //    You should have received a copy of the GNU Lesser General Public
22 //    License along with this library. If not, see http://www.gnu.org/licenses/
23 //
24 //
25 // Description:
26 //	*** PROPRIETARY INTERFACE ***
27 //
28 // 	Define a set of flags in C++ macros. These flags provide information
29 //      about the system and the compiler used.
30 //
31 
32 #ifndef __CORBA_SYSDEP_H__
33 #define __CORBA_SYSDEP_H__
34 
35 #ifndef __cplusplus
36 #error "Cannot use this C++ header file for non C++ programs."
37 #endif
38 
39 
40 #include <omniORB4/local_config.h>
41 
42 
43 //
44 // Most system dependencies either come from autoconf or from
45 // hard-coded values in CORBA_sysdep_trad.h
46 //
47 
48 #ifndef OMNI_CONFIG_EXTERNAL
49 #  include <omniconfig.h>
50 #endif
51 
52 #ifdef OMNI_CONFIG_TRADITIONAL
53 #  include <omniORB4/CORBA_sysdep_trad.h>
54 #else
55 #  include <omniORB4/CORBA_sysdep_auto.h>
56 #endif
57 
58 
59 //
60 // Pointer arithmetic type
61 //
62 
63 #if SIZEOF_PTR == SIZEOF_LONG
64 typedef unsigned long omni_ptr_arith_t;
65 #elif SIZEOF_PTR == SIZEOF_INT
66 typedef unsigned int omni_ptr_arith_t;
67 #elif defined (_WIN64)
68 typedef size_t omni_ptr_arith_t;
69 #else
70 #error "No suitable type to do pointer arithmetic"
71 #endif
72 
73 
74 //
75 // Dependencies that are always hard-coded
76 //
77 
78 #if defined(__WIN32__)
79 #  define NTArchitecture 1
80 #elif defined(__VMS)
81 #else
82 #  define UnixArchitecture 1
83 #endif
84 
85 //
86 // Processor dependencies
87 //
88 
89 // __VFP_FP__ means that the floating point format in use is that of the ARM
90 // VFP unit, which is native-endian IEEE-754.
91 #if defined(__arm__)
92 #  if defined(__armv5teb__) || defined(__VFP_FP__)
93 #    define NO_OMNI_MIXED_ENDIAN_DOUBLE
94 #  else
95 #    define OMNI_MIXED_ENDIAN_DOUBLE
96 #  endif
97 #endif
98 
99 
100 //
101 // Macro to provide const_cast functionality on all platforms.
102 //
103 #ifdef HAS_Cplusplus_const_cast
104 #  define OMNI_CONST_CAST(_t, _v) const_cast< _t >(_v)
105 #  define OMNI_CONST_VOID_CAST(_v) const_cast<void*>(static_cast<const void*>(_v))
106 #else
107 #  define OMNI_CONST_CAST(_t, _v) (_t)(_v)
108 #  define OMNI_CONST_VOID_CAST(_v) (void*)(_t)
109 #endif
110 
111 #ifdef HAS_Cplusplus_reinterpret_cast
112 #  define OMNI_REINTERPRET_CAST(_t, _v) reinterpret_cast< _t const& >(_v)
113 #else
114 #  define OMNI_REINTERPRET_CAST(_t, _v) (*(_t*)(&_v))
115 #endif
116 
117 
118 #if defined(__GNUG__)
119 // GNU G++ compiler
120 #  define NEED_DUMMY_RETURN
121 #endif
122 
123 #if defined(__DECCXX)
124 // DEC C++ compiler
125 #  if __DECCXX_VER < 60000000
126 //    Compaq C++ 5.x
127 //    Work-around for OpenVMS VAX Compaq C++ 5.6 compiler problem with
128 //    %CXX-W-CANTCOMPLETE messages.  Note that this cannot be disabled with a
129 //    compiler switch if the message occurs in a template instantiation (but
130 //    this pragma wasn't implemented until 6.something on Unix).
131 #     ifdef __VMS
132 #       pragma message disable CANTCOMPLETE
133 #     endif
134 #     define NEED_DUMMY_RETURN
135 #     define OMNI_OPERATOR_REFPTR_REQUIRES_TYPEDEF
136 #     define OMNI_PREMATURE_INSTANTIATION
137 //    Extra macros from the Compaq C++ 5.x patch (in <top>/patches/) to be
138 //    added here
139 #     ifndef OMNI_OPERATOR_REFPTR
140 #       error "Patch for Compaq C++ 5.x has not been applied."
141 #     endif
142 #  endif
143 #endif
144 
145 #if defined(__SUNPRO_CC)
146 // SUN C++ compiler
147 #  define NEED_DUMMY_RETURN
148 
149 // XXX
150 // This is a hack to work around a bug in SUN C++ compiler (seen on 4.2).
151 // When instantiating templates, the compiler may generate code in Template.DB.
152 // It stores in the directory the dependency and compiler options to
153 // regenerate the template code if necessary. Unfortunately, it stores the
154 // option -D__OSVERSION__=5 as -D__OSVERSION__='5'. This of course causes
155 // the compilation to fail because the source code assume that the CPP macro
156 // __OSVERSION__ is an interger. The following hack detects this condition
157 // and revert the macro to its expected form.
158 #  ifdef __OSVERSION__
159 #    if __OSVERSION__ != 5
160 #       if __OSVERSION__ == '5'
161 #          undef __OSVERSION__
162 #          define __OSVERSION__ 5
163 #       endif
164 #    endif
165 #  endif
166 #endif
167 
168 #if defined(__HP_aCC) || ( defined(__hpux__) && !defined(__GNUG__) )
169 #  define NEED_DUMMY_RETURN
170 #endif
171 
172 #if defined(__hpux__) && __OSVERSION__ < 11
173 // *** Is this really needed?
174 #  include <stdio.h>
175 #  undef __ptr
176 #endif
177 
178 
179 #if defined(__sgi)
180 #  define OMNI_NEED_STATIC_FUNC_TO_FORCE_LINK
181 #endif
182 
183 
184 #if defined(__aix__) && defined(__xlC__)
185 #  define OMNI_NO_INLINE_FRIENDS
186 #  define NEED_DUMMY_RETURN
187 #endif
188 
189 
190 #if defined(__clang__)
191 #  define OMNI_NO_INLINE_FRIENDS
192 #endif
193 
194 
195 //
196 // Windows DLL hell
197 //
198 
199 #if defined(_MSC_VER)
200 
201 #  define NEED_DUMMY_RETURN
202 
203 // VC.NET 2003 (v. 7.1) has problems recognizing inline friend
204 // operators.
205 
206 #  if (_MSC_VER >= 1310)
207 #    define OMNI_NO_INLINE_FRIENDS
208 #  endif
209 
210 //
211 // _OMNIORB_LIBRARY         is defined when the omniORB library is compiled.
212 // _OMNIORB_DYNAMIC_LIBRARY is defined when the dynamic library is compiled.
213 //  These are defined on the command line when compiling the libraries.
214 //
215 // _WINSTATIC                is defined when an application is compiled to
216 //                           use the static library.
217 //
218 // To package stubs into dlls:
219 //   1. Define the cpp macro _OMNIORB_STUB_DLL when the stub _SK.cc is
220 //      compiled.
221 //   2. A .def file has to be created to export the symbols in the dll.
222 //      The .def file can be generated automatically based on the output
223 //      of dumpbin. For an example, look at how the omniORB2 dll is created.
224 //
225 // To use stubs that has been packaged into dlls:
226 //   1. Make sure that the cpp macro USE_stub_in_nt_dll is defined before
227 //      the stub header (.hh) is included.
228 //
229 // Use _OMNIORB_NTDLL_IMPORT to ensure that MSVC++ use the correct linkage
230 // for constants and variables exported by a DLL.
231 //
232 
233 #  ifdef _WINSTATIC
234 #    define _OMNIORB_NTDLL_IMPORT
235 #  else
236 #    define _OMNIORB_NTDLL_IMPORT  __declspec(dllimport)
237 #  endif
238 
239 #  if defined(_DEBUG)
240 // The type name instantiated from the sequence templates could exceeds the
241 // 255 char limit of the debug symbol names. It is harmless except that one
242 // cannot read their values with the debugger. Disable the warning about
243 // the symbol name truncation.
244 #    pragma warning(disable: 4786)
245 #  endif
246 
247 // Disable warnings about a member function in a derived class overriding
248 // a member function in the base class.
249 #  pragma warning(disable: 4250)
250 
251 #elif defined(__DMC__)
252 #  define NEED_DUMMY_RETURN
253 
254 #  ifdef _WINSTATIC
255 #    define _OMNIORB_NTDLL_IMPORT
256 #  else
257 #    define _OMNIORB_NTDLL_IMPORT  __declspec(dllimport)
258 #  endif
259 
260 #elif defined(__MINGW32__)
261 
262 #  ifdef _WINSTATIC
263 #    define _OMNIORB_NTDLL_IMPORT
264 #  else
265 #    define _OMNIORB_NTDLL_IMPORT  __attribute__((dllimport))
266 #  endif
267 
268 #else
269 
270 // For non-MSVC++ compiler, this macro expands to nothing.
271 #  define _OMNIORB_NTDLL_IMPORT
272 
273 #endif
274 
275 
276 //
277 // Module mapping using namespaces or classes
278 //
279 
280 #ifdef _CORBA_MODULE
281 #  error "Name conflict: _CORBA_MODULE is already defined."
282 #endif
283 
284 #ifdef _CORBA_MODULE_BEG
285 #  error "Name conflict: _CORBA_MODULE_BEG is already defined."
286 #endif
287 
288 #ifdef _CORBA_MODULE_END
289 #  error "Name conflict: _CORBA_MODULE_END is already defined."
290 #endif
291 
292 #ifdef _CORBA_MODULE_OP
293 #  error "Name conflict: _CORBA_MODULE_OP is already defined."
294 #endif
295 
296 #ifdef _CORBA_MODULE_FN
297 #  error "Name conflict: _CORBA_MODULE_FN is already defined."
298 #endif
299 
300 #ifdef _CORBA_MODULE_VAR
301 #  error "Name conflict: _CORBA_MODULE_VAR is already defined."
302 #endif
303 
304 #ifdef _CORBA_MODULE_INLINE
305 #  error "Name conflict: _CORBA_MODULE_INLINE is already defined."
306 #endif
307 
308 #ifdef _CORBA_GLOBAL_VAR
309 #  error "Name conflict: _CORBA_GLOBAL_VAR is already defined."
310 #endif
311 
312 #ifdef _CORBA_MODULE_VARINT
313 #  error "Name conflict: _CORBA_MODULE_VARINT is already defined."
314 #endif
315 
316 #ifdef _CORBA_GLOBAL_VARINT
317 #  error "Name conflict: _CORBA_GLOBAL_VARINT is already defined."
318 #endif
319 
320 #ifdef OMNI_NAMESPACE_BEGIN
321 #  error "Name conflict: OMNI_NAMESPACE_BEGIN is already defined."
322 #endif
323 
324 #ifdef OMNI_NAMESPACE_END
325 #  error "Name conflict: OMNI_NAMESPACE_END is already defined."
326 #endif
327 
328 #ifdef OMNI_USING_NAMESPACE
329 #  error "Name conflict: OMNI_USING_NAMESPACE is already defined."
330 #endif
331 
332 #ifdef _OMNI_NS
333 #  error "Name conflict: _OMNI_NS is already defined."
334 #endif
335 
336 #ifdef _init_in_decl_
337 #  error "Name conflict: _init_in_decl_ is already defined."
338 #endif
339 
340 #ifdef _init_in_def_
341 #  error "Name conflict: _init_in_def_ is already defined."
342 #endif
343 
344 #ifdef _init_in_cldecl_
345 #  error "Name conflict: _init_in_cldecl_ is already defined."
346 #endif
347 
348 #ifdef _init_in_cldef_
349 #  error "Name conflict: _init_in_cldef_ is already defined."
350 #endif
351 
352 
353 #ifdef HAS_Cplusplus_Namespace
354 
355 #  define _CORBA_MODULE        namespace
356 #  define _CORBA_MODULE_BEG    {
357 #  define _CORBA_MODULE_END    }
358 #  define _CORBA_MODULE_OP
359 #  define _CORBA_MODULE_FN
360 #  define _CORBA_MODULE_VAR    extern
361 #  define _CORBA_MODULE_INLINE inline
362 #  define _CORBA_GLOBAL_VAR    extern
363 #  define _CORBA_MODULE_VARINT
364 #  define _CORBA_GLOBAL_VARINT
365 #  define OMNI_NAMESPACE_BEGIN(name) namespace name {
366 #  define OMNI_NAMESPACE_END(name)   }
367 #  define OMNI_USING_NAMESPACE(name) using namespace name;
368 #  define _OMNI_NS(x) omni::x
369 
370 // Integral and enumeration constants are declared in the stub headers as:
371 //    e.g.  class A {
372 //              static const CORBA::Long AA _init_in_cldecl_( = 4 );
373 //          };
374 //          namespace B {
375 //              const CORBA::Long BB _init_in_decl_( = 5 );
376 //          };
377 // And defined in the SK.cc:
378 //    e.g.   const CORBA::Long A::AA _init_in_cldef_( = 4 );
379 //           _init_in_def_( const CORBA::Long B::BB = 5 );
380 //
381 // Final Draft (FD) allows declaration of static const integral or enum type
382 // be specified with a constant-initializer whereas ARM does not.
383 // The _init_in_decl_ and _init_in_def_ macros are defined so that the same
384 // stub will compile on both FD and ARM compilers.
385 // Older MSVC++ are somewhere between FD and ARM.
386 //  _MSC_VER = 1100 for 5.0, 1200 for 6.0.
387 
388 #  define _init_in_decl_(x) x
389 #  define _init_in_def_(x)
390 
391 #  if defined(__INTEL_COMPILER)
392 #    define _init_in_cldecl_(x)
393 #    define _init_in_cldef_(x) x
394 #  elif defined (_MSC_VER) && (_MSC_VER < 1500)
395 #    define _init_in_cldecl_(x)
396 #    define _init_in_cldef_(x) x
397 #  else
398 #    define _init_in_cldecl_(x) x
399 #    define _init_in_cldef_(x)
400 #  endif
401 
402 #else // No namespace support
403 
404 #  define _CORBA_MODULE        class
405 #  define _CORBA_MODULE_BEG    { public:
406 #  define _CORBA_MODULE_END    };
407 #  define _CORBA_MODULE_OP     friend
408 #  define _CORBA_MODULE_FN     static
409 #  define _CORBA_MODULE_VAR    static
410 #  define _CORBA_MODULE_INLINE static inline
411 #  define _CORBA_GLOBAL_VAR    extern
412 #  define _CORBA_MODULE_VARINT static _core_attr
413 #  define _CORBA_GLOBAL_VARINT extern _core_attr
414 #  define OMNI_NAMESPACE_BEGIN(name)
415 #  define OMNI_NAMESPACE_END(name)
416 #  define OMNI_USING_NAMESPACE(name)
417 #  define _OMNI_NS(x) x
418 
419 #  define _init_in_decl_(x)
420 #  define _init_in_def_(x) x
421 #  define _init_in_cldecl_(x)
422 #  define _init_in_cldef_(x) x
423 
424 #endif // HAS_Cplusplus_Namespace
425 
426 
427 #ifdef OMNI_REQUIRES_FQ_BASE_CTOR
428 #  define OMNIORB_BASE_CTOR(a)   a
429 #else
430 #  define OMNIORB_BASE_CTOR(a)
431 #endif
432 
433 #ifndef OMNI_OPERATOR_REFPTR
434 // Only used when the source tree is patched with DEC C++ 5.6 workarounds
435 #  define OMNI_OPERATOR_REFPTR(T) inline operator T*&()
436 #endif
437 
438 #ifndef OMNI_CONSTRTYPE_FIX_VAR_MEMBER
439 // Only used when the source tree is patched with DEC C++ 5.6 workarounds
440 #  define OMNI_CONSTRTYPE_FIX_VAR_MEMBER(T) \
441    typedef _CORBA_ConstrType_Fix_Var<T> _var_type;
442 #endif
443 
444 #ifndef OMNI_CONSTRTYPE_FIX_VAR
445 // Only used when the source tree is patched with DEC C++ 5.6 workarounds
446 #  define OMNI_CONSTRTYPE_FIX_VAR(T) typedef T::_var_type T##_var;
447 #endif
448 
449 
450 //
451 // Suppress throw specifications that are not valid from C++-17. Note
452 // that we keep them for older compilers because removing them may
453 // break ABI compatibility.
454 
455 #if __cplusplus >= 201703L
456 #  define OMNI_THROW_SPEC(...)
457 #else
458 #  define OMNI_THROW_SPEC throw
459 #endif
460 
461 
462 
463 // #define ENABLE_CLIENT_IR_SUPPORT
464 // Define ENABLE_CLIENT_IR_SUPPORT to use as client to an Interface Repository
465 
466 
467 #endif // __CORBA_SYSDEP_H__
468