BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdldfp_intelimpwrapper.h
Go to the documentation of this file.
1/// @file bdldfp_intelimpwrapper.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdldfp_intelimpwrapper.h -*-C++-*-
8#ifndef INCLUDED_BDLDFP_INTELIMPWRAPPER
9#define INCLUDED_BDLDFP_INTELIMPWRAPPER
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id$")
13
14/// @defgroup bdldfp_intelimpwrapper bdldfp_intelimpwrapper
15/// @brief Provide a central mechanism to configure the Intel DFP library.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdldfp
19/// @{
20/// @addtogroup bdldfp_intelimpwrapper
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdldfp_intelimpwrapper-purpose"> Purpose</a>
25/// * <a href="#bdldfp_intelimpwrapper-classes"> Classes </a>
26/// * <a href="#bdldfp_intelimpwrapper-description"> Description </a>
27/// * <a href="#bdldfp_intelimpwrapper-usage"> Usage </a>
28///
29/// # Purpose {#bdldfp_intelimpwrapper-purpose}
30/// Provide a central mechanism to configure the Intel DFP library.
31///
32/// # Classes {#bdldfp_intelimpwrapper-classes}
33///
34///
35/// @see bdldfp_decimalimputil_inteldfp, bdldfp_decimalplatform
36///
37/// # Description {#bdldfp_intelimpwrapper-description}
38/// This component provides a centralized mechanism to include the
39/// requisite Intel DFP headers, by issuing the appropriate `#define`
40/// configuration macros before including the Intel headers. This component is
41/// for internal use only by the `bdldfp_decimal*` components. Direct use of
42/// any names declared in this component by any other code invokes undefined
43/// behavior. In other words: this code may change, disappear, break, move
44/// without notice, and no support whatsoever will ever be provided for it.
45///
46/// ## Usage {#bdldfp_intelimpwrapper-usage}
47///
48///
49/// This section shows the intended use of this component.
50/// @}
51/** @} */
52/** @} */
53
54/** @addtogroup bdl
55 * @{
56 */
57/** @addtogroup bdldfp
58 * @{
59 */
60/** @addtogroup bdldfp_intelimpwrapper
61 * @{
62 */
63
64#include <bdlscm_version.h>
65
67
68#include <bsls_platform.h>
69
70#include <bsl_cstddef.h>
71
72#if defined(BDLDFP_DECIMALPLATFORM_INTELDFP)
73
74# if !defined(INCLUDED_BID_FUNCTIONS) \
75 && !defined(INCLUDED_BID_CONF) \
76 && !defined(INCLUDED_BID_INTERNAL)
77
78// Controlling macros for the Intel library configuration
79
80# define DECIMAL_CALL_BY_REFERENCE 0
81# define DECIMAL_GLOBAL_ROUNDING 1
82# define DECIMAL_GLOBAL_EXCEPTION_FLAGS 0
83# ifndef LINUX
84# define LINUX
85# define BDLDFP_INTELIMPWRAPPER_FAKE_DEFINE_LINUX
86# endif
87
88# ifdef BSLS_PLATFORM_IS_BIG_ENDIAN
89# define BID_BIG_ENDIAN 1
90# else
91# define BID_BIG_ENDIAN 0
92# endif
93
94// The IBM compiler has trouble with the embedded '__thread' token, under some
95// build modes. We'll turn it off, for now. We'll do so for Sun also, since
96// it is disabled in the wrapper-package for that compiler as well. Also, to
97// prevent redefinition of the 'fexcept_t' type, we signal that we behave like
98// '__QNX__' so that the Intel library includes '<fenv.h>'. As a result, if
99// we're not using GCC or Clang on Linux, we pretend to be "QNX", since the
100// Intel library has the right options chosen for that.
101//
102// 20201110 - hrosen4 - We should revisit this BID_THREAD logic eventually.
103// Our production Sun compiler now supports '__thread', and IBM claims to
104// support it when thread-local storage is enabled by option (which our build
105// systems do not). The Intel DFP library uses thread-local storage, when
106// available, for global variables related to rounding mode and such, and the
107// 'bdldfp' library does not modify or provide access to those, so this is not
108// urgent.
109
110# if !(defined(BSLS_PLATFORM_OS_LINUX) && defined(BSLS_PLATFORM_CMP_GNU)) \
111 && !(defined(BSLS_PLATFORM_OS_LINUX) && defined(BSLS_PLATFORM_CMP_CLANG))\
112 && !defined(BSLS_PLATFORM_OS_WINDOWS)
113// Prevent the intel dfp library from using thread-local storage
114# undef BID_THREAD
115# define BID_THREAD
116# define __QNX__
117# define BDLDFP_INTELIMPWRAPPER_FAKE_DEFINE_QNX
118# endif
119
120// In C++, there's always a 'wchar_t' type, so we need to tell Intel's library
121// about this.
122
123# ifndef _WCHAR_T_DEFINED
124# define _WCHAR_T_DEFINED
125# endif
126
127# ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
128# pragma GCC diagnostic push
129# pragma GCC diagnostic ignored "-Wconversion"
130# pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
131# endif
132
133#ifndef BDE_OMIT_INTERNAL_DEPRECATED
134// calcrt2.h exports a SWAP macro which we want to preserve.
135
136#ifdef SWAP
137 #if SWAP == 99
138 #define BDLDFP_INTELIMPWRAPPER_SWAP_WAS_99 1
139 #endif
140#endif
141
142#endif // BDE_OMIT_INTERNAL_DEPRECATED
143
144// bid_internal.h exports a SWAP macro.
145#undef SWAP
146
147extern "C" {
148 #include <inteldfp/bid_conf.h>
149 #include <inteldfp/bid_functions.h>
150 #include <inteldfp/bid_internal.h>
151}
152
153#undef SWAP
154
155#ifndef BDE_OMIT_INTERNAL_DEPRECATED
156// Restore SWAP macro from calcrt2.h.
157
158#if BDLDFP_INTELIMPWRAPPER_SWAP_WAS_99
159 #define SWAP 99
160 #undef BDLDFP_INTELIMPWRAPPER_SWAP_WAS_99
161#endif
162
163#endif // BDE_OMIT_INTERNAL_DEPRECATED
164
165# ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
166# pragma GCC diagnostic pop
167# endif
168
169// Intel #define's several symbols we don't want to leak out.
170
171# undef P7
172# undef P16
173# undef P34
174
175# undef DECIMAL_CALL_BY_REFERENCE
176# undef DECIMAL_GLOBAL_ROUNDING
177# undef DECIMAL_GLOBAL_EXCEPTION_FLAGS
178
179# ifdef BDLDFP_INTELIMPWRAPPER_FAKE_DEFINE_LINUX
180# undef LINUX
181# undef BDLDFP_INTELIMPWRAPPER_FAKE_DEFINE_LINUX
182# endif
183
184# ifdef BDLDFP_INTELIMPWRAPPER_FAKE_DEFINE_QNX
185# undef __thread
186# undef __QNX__
187# undef BDLDFP_INTELIMPWRAPPER_FAKE_DEFINE_QNX
188# endif
189
190# define INCLUDED_BID_CONF
191# define INCLUDED_BID_FUNCTIONS
192# define INCLUDED_BID_INTERNAL
193# endif
194
195#endif // if defined(BDLDFP_DECIMALPLATFORM_INTELDFP)
196
197#endif
198
199// ----------------------------------------------------------------------------
200// Copyright 2014 Bloomberg Finance L.P.
201//
202// Licensed under the Apache License, Version 2.0 (the "License");
203// you may not use this file except in compliance with the License.
204// You may obtain a copy of the License at
205//
206// http://www.apache.org/licenses/LICENSE-2.0
207//
208// Unless required by applicable law or agreed to in writing, software
209// distributed under the License is distributed on an "AS IS" BASIS,
210// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
211// See the License for the specific language governing permissions and
212// limitations under the License.
213// ----------------------------- END-OF-FILE ----------------------------------
214
215/** @} */
216/** @} */
217/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195