BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls_platform.h
Go to the documentation of this file.
1/// @file bsls_platform.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsls_platform.h -*-C++-*-
8#ifndef INCLUDED_BSLS_PLATFORM
9#define INCLUDED_BSLS_PLATFORM
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bsls_platform bsls_platform
15/// @brief Provide compile-time support for platform/attribute identification.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsls
19/// @{
20/// @addtogroup bsls_platform
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsls_platform-purpose"> Purpose</a>
25/// * <a href="#bsls_platform-classes"> Classes </a>
26/// * <a href="#bsls_platform-macros"> Macros </a>
27/// * <a href="#bsls_platform-description"> Description </a>
28/// * <a href="#bsls_platform-aggressive-inlining"> Aggressive Inlining </a>
29/// * <a href="#bsls_platform-forcing-a-compiler-error"> Forcing a Compiler Error </a>
30/// * <a href="#bsls_platform-windows-subtypes-explained"> Windows Subtypes Explained </a>
31/// * <a href="#bsls_platform-usage"> Usage </a>
32///
33/// # Purpose {#bsls_platform-purpose}
34/// Provide compile-time support for platform/attribute identification.
35///
36/// # Classes {#bsls_platform-classes}
37///
38/// - bsls::Platform: namespace for platform traits
39///
40/// # Macros {#bsls_platform-macros}
41///
42/// - BSLS_PLATFORM_OS_*: operating system type, sub-type, and version
43/// - BSLS_PLATFORM_CPU_*: instruction set, instruction width, and version
44/// - BSLS_PLATFORM_CMP_*: compiler vendor, and version
45/// - BSLS_PLATFORM_COMPILER_ERROR: trigger a compiler error
46/// - BSLS_PLATFORM_AGGRESSIVE_INLINE: inline code for speed over text size
47///
48/// @see bsls_compilerfeatures, bsls_libraryfeatures
49///
50/// # Description {#bsls_platform-description}
51/// This component implements a suite of preprocessor macros and
52/// traits that identify and define platform-specific compile-time attributes.
53/// These attributes consist of the types and versions of (1) the operating
54/// system, (2) the processor(s), and (3) the compiler that together make up the
55/// platform. Many of the macros defined in this component are configured
56/// automatically at compile-time; compile-time switches are used to configure
57/// the rest. Note that compiler capabilities are better determined through the
58/// @ref bsls_compilerfeatures and @ref bsls_libraryfeatures components; this
59/// component focuses on just identifying the tool chain.
60///
61/// Note that, for brevity, the `@` character in the following (alphabetically
62/// organized) tables is used to represent the characters `BSLS_PLATFORM` --
63/// e.g., `@_OS_UNIX` represents `BSLS_PLATFORM_OS_UNIX`:
64/// @code
65/// =============================================================
66/// OPERATING SYSTEM
67/// -------------------------------------------------------------
68/// Type Subtype Version
69/// ----------------- ------------------- -----------------
70/// @_OS_UNIX @_OS_AIX @_OS_VER_MAJOR
71/// @_OS_LINUX @_OS_VER_MINOR
72/// @_OS_FREEBSD
73/// @_OS_SOLARIS
74/// @_OS_SUNOS
75/// @_OS_CYGWIN
76/// @_OS_DARWIN
77///
78/// @_OS_WINDOWS @_OS_WINNT
79/// @_OS_WIN9X
80/// @_OS_WIN2K
81/// @_OS_WINXP
82/// @_OS_WINS03
83/// @_OS_WINS08 -- alias to Vista
84/// @_OS_WINVISTA
85/// @_OS_WIN7
86/// @_OS_WIN8
87/// @_OS_WINBLUE
88/// @_OS_WIN10
89///
90/// Please see also {Windows Subtypes Explained}.
91///
92/// ============================================================
93/// PROCESSOR
94/// ------------------------------------------------------------
95/// Instruction Set Width Version
96/// ----------------- ------------------ ----------------
97/// @_CPU_88000 @_CPU_32_BIT @_CPU_VER_MAJOR
98/// @_CPU_ALPHA @_CPU_64_BIT
99/// @_CPU_HPPA
100/// @_CPU_X86
101/// @_CPU_IA64
102/// @_CPU_X86_64
103/// @_CPU_MIPS
104/// @_CPU_POWERPC
105/// @_CPU_SPARC
106/// @_CPU_ARM
107///
108/// =============================================================
109/// COMPILER
110/// -------------------------------------------------------------
111/// Vendor Version
112/// ----------------- ------------------
113/// @_CMP_CLANG @_CMP_VERSION
114/// @_CMP_EDG @_CMP_VER_MAJOR (deprecated)
115/// @_CMP_GNU
116/// @_CMP_HP
117/// @_CMP_IBM
118/// @_CMP_MSVC
119/// @_CMP_SUN
120///
121/// =============================================================
122///
123/// =============================================================
124/// ENSURE A COMPILER ERROR FOR UNSUPPORTED PLATFORMS
125/// --------------------------------------------------------------
126/// Macro
127/// ---------------
128/// @_COMPILER_ERROR
129///
130/// =============================================================
131///
132/// =============================================================
133/// INLINING
134/// -------------------------------------------------------------
135/// Macro
136/// -----------------
137/// @_AGGRESSIVE_INLINE
138///
139/// =============================================================
140/// @endcode
141/// These macros are configured automatically, where possible. At a minimum,
142/// the generic operating system type (i.e., either `BSLS_PLATFORM_OS_UNIX` or
143/// `BSLS_PLATFORM_OS_WINDOWS`) is defined along with exactly one processor
144/// macro (e.g., `BSLS_PLATFORM_CPU_SPARC`) and exactly one compiler macro
145/// (e.g., `BSLS_PLATFORM_CMP_SUN`). Clients may need to supply additional
146/// macros (controlled via the `-D` option of a compiler) if further
147/// discrimination is required (e.g., based on sub-type or version of a specific
148/// operating system, processor, or compiler). Note that supplying a minor
149/// version number implies that the major version is also defined.
150///
151/// ## Aggressive Inlining {#bsls_platform-aggressive-inlining}
152///
153///
154/// The aggressive inlining macro `BSLS_PLATFORM_AGGRESSIVE_INLINE` is defined
155/// as the `inline` keyword on all compilers except `BSLS_PLATFORM_CMP_IBM` and
156/// `BSLS_PLATFORM_CMP_SUN`, where it is left empty. This is required for some
157/// of our legacy applications where substantially growing the text size is not
158/// possible. Even on those platforms, the symbol will be defined as `inline`
159/// if `BDE_BUILD_TARGET_AGGRESSIVE_INLINE` is passed in via the `-D` option of
160/// the compiler.
161///
162/// ## Forcing a Compiler Error {#bsls_platform-forcing-a-compiler-error}
163///
164///
165/// The compiler-error triggering macro `BSLS_PLATFORM_COMPILER_ERROR` is
166/// defined to a sequence of tokens that guarantees a compilation error on every
167/// supported compiler. This is necessary because not all compilers will
168/// respect the fairly obvious goal of the `#error` preprocessor directive even
169/// though they support it, and just issue a warning (claiming that the C++
170/// standard does not make a difference between a warning and an error, it knows
171/// only about diagnostic messages). Code using @ref bsls_platform macros will
172/// often want to prevent compilation for unsupported platforms, hence this
173/// component provides a macro that can be used to ensure that.
174///
175/// ## Windows Subtypes Explained {#bsls_platform-windows-subtypes-explained}
176///
177///
178/// Windows Subtypes describe what API variation the code is built to target,
179/// not the actual operating system it will run on, with the following mapping
180/// between the macro names and Windows API versions:
181/// @code
182/// MACRO Targeted API Version & Notes Officially supported?
183/// ------------- ---------------------------- ---------------------
184/// @_OS_WINNT NT 4.0 NO
185/// @_OS_WIN9X 95, 98, ME NO
186/// @_OS_WIN2K 2000 NO
187/// @_OS_WINXP XP NO
188/// @_OS_WINS03 Server 2003 NO
189/// @_OS_WINS08 Server 2008, same as Vista yes
190/// @_OS_WINVISTA Vista yes
191/// @_OS_WIN7 7 yes
192/// @_OS_WIN8 8 yes
193/// @_OS_WINBLUE 8.1 yes
194/// @_OS_WIN10 10 yes
195/// @endcode
196/// Note that Vista is the default targeted API.
197///
198/// ## Usage {#bsls_platform-usage}
199///
200///
201/// Writing portable software sometimes involves specializing implementations to
202/// work with platform-specific interfaces. For example, a socket-level
203/// communications framework would need to operate differently on a platform
204/// having a Windows operating system than on one having a Unix one (but it is
205/// probably unnecessary to distinguish between their respective versions):
206/// @code
207/// // my_socket.h
208/// #include <bsls_platform.h>
209///
210/// #ifdef BSLS_PLATFORM_OS_WINDOWS
211/// #ifndef INCLUDED_WINSOCK2
212/// #include <winsock2.h>
213/// #define INCLUDED_WINSOCK2
214/// #endif
215/// #endif
216///
217/// class my_Socket {
218///
219/// #ifdef BSLS_PLATFORM_OS_WINDOWS
220/// SOCKET d_socketObject; // Windows SOCKET handle
221/// #else
222/// int d_socketObject; // Unix socket descriptor
223/// #endif
224///
225/// // ...
226///
227/// };
228/// @endcode
229/// Certain compile-time constants are also provided as preprocessor macros that
230/// encapsulate the capability of determining whether a machine is big-endian or
231/// little-endian across all supported platforms:
232/// @code
233/// BSLS_PLATFORM_IS_BIG_ENDIAN
234/// BSLS_PLATFORM_IS_LITTLE_ENDIAN
235/// @endcode
236/// These macros are useful for writing platform-independent code, such as a
237/// function that converts the bytes in a `short` to network byte order (which
238/// is consistent with big-endian):
239/// @code
240/// short convertToNetworkByteOrder(short input)
241/// // Return the specified 'input' in network byte order.
242/// {
243/// #ifdef BSLS_PLATFORM_IS_BIG_ENDIAN
244/// return input;
245/// #else
246/// return ((input >> 8) & 0xFF) | ((input & 0xFF) << 8);
247/// #endif
248/// }
249/// @endcode
250/// @}
251/** @} */
252/** @} */
253
254/** @addtogroup bsl
255 * @{
256 */
257/** @addtogroup bsls
258 * @{
259 */
260/** @addtogroup bsls_platform
261 * @{
262 */
263
264#ifdef __cplusplus
265
266#endif
267
268 // ===========================
269 // struct bsls_Platform_Assert
270 // ===========================
271
272struct bsls_Platform_Assert;
273 // This 'struct' is declared but not defined. It is used with the 'sizeof'
274 // operator to force a compile-time error on platforms that do not support
275 // '#error'. For example:
276 //..
277 // char die[sizeof(bsls_Platform_Assert)]; // if '#error' unsupported
278 //..
279
280#ifdef __cplusplus
281
282#endif
283
284// Use this macro to trigger a compile-time error if '#error' is not supported.
285#ifdef __cplusplus
286 #define BSLS_PLATFORM_COMPILER_ERROR \
287 char die[sizeof(::BloombergLP::bsls_Platform_Assert)]
288#else
289 #define BSLS_PLATFORM_COMPILER_ERROR char die[sizeof(bsls_Platform_Assert)]
290#endif
291
292 // Automatic Configuration
293
294// IMPLEMENTATION NOTE: The following attempts to configure the system
295// automatically, setting as many of the macros listed in the table above as
296// possible. Since the automatic configuration is based upon the macros set by
297// the compiler, the outer-most level of detection will be driven by whatever
298// compiler is in use. Once the compiler has been determined, the
299// automatic-configuration process will attempt to determine the OS and finally
300// the CPU. At the end of the section for each compiler, the macros that have
301// been defined automatically will be "sanity-checked" (for consistency)
302// against other macros set by the compiler. The order of the statements in
303// the process is the same as that in the table above, which is also
304// alphabetical. Any changes to the list of supported compilers should
305// preserve the alphabetical order of the table, inserting the necessary
306// configuration logic in the preprocessor statements below.
307
308// ----------------------------------------------------------------------------
309#if defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__)
310 #define BSLS_PLATFORM_CMP_IBM 1
311 #define BSLS_PLATFORM_CMP_VERSION __xlC__
312
313#ifndef BDE_OMIT_INTERNAL_DEPRECATED
314 /// @deprecated use 'BSLS_PLATFORM_CMP_IBM' instead.
315 #define BSLS_PLATFORM_CMP_AIX 1
316#endif // BDE_OMIT_INTERNAL_DEPRECATED
317
318 // which OS -- this compiler should only be used on AIX
319 #define BSLS_PLATFORM_OS_UNIX 1
320 #if defined(_AIX) // must be defined
321 #define BSLS_PLATFORM_OS_AIX 1
322 #define BSLS_PLATFORM_OS_VER_MAJOR _AIX
323 #elif defined(__linux__)
324 #define BSLS_PLATFORM_OS_LINUX 1
325 #else
326 #error "AIX compiler appears to be in use on non-AIX OS."
328 #endif
329
330 // which CPU -- should always be POWERPC
331 #if defined(_ARCH_PWR2)
332 #define BSLS_PLATFORM_CPU_VER_MAJOR _ARCH_PWR2
333 #elif defined(_ARCH_PWR)
334 #define BSLS_PLATFORM_CPU_VER_MAJOR _ARCH_PWR
335 #elif defined(_ARCH_POWER)
336 #define BSLS_PLATFORM_CPU_VER_MAJOR _ARCH_POWER
337 #elif defined(_POWER)
338 #define BSLS_PLATFORM_CPU_VER_MAJOR _POWER
339 #elif defined(_ARCH_COM)
340 #define BSLS_PLATFORM_CPU_VER_MAJOR _ARCH_COM
341 #elif defined(_ARCH_601)
342 #define BSLS_PLATFORM_CPU_VER_MAJOR _ARCH_601
343 #elif defined(_ARCH_PPC)
344 #define BSLS_PLATFORM_CPU_VER_MAJOR _ARCH_PPC
345 #elif defined(_ARCH_PPC64)
346 #define BSLS_PLATFORM_CPU_VER_MAJOR _ARCH_PPC64
347 #else
348 #error "Unable to identify the AIX CPU."
350 #endif
351
352 #define BSLS_PLATFORM_CPU_POWERPC 1
353 #if defined (__64BIT__)
354 #define BSLS_PLATFORM_CPU_64_BIT 1
355 #else
356 #define BSLS_PLATFORM_CPU_32_BIT 1
357 #endif
358// ----------------------------------------------------------------------------
359#elif defined(_MSC_VER)
360 #define BSLS_PLATFORM_CMP_MSVC 1
361 #define BSLS_PLATFORM_CMP_VERSION _MSC_VER
362
363 // which OS -- should be some flavor of Windows
364 // there is currently no support for:
365 // - 16-bit versions of Windows (3.x)
366 // - Windows CE
367 #if defined(_WIN64) || defined(_WIN32)
368 #define BSLS_PLATFORM_OS_WINDOWS 1
369 #elif defined(_WIN16)
370 #error "16-bit Windows platform not supported."
372 #else
373 #error "Microsoft OS is running on an unknown platform."
375 #endif
376
377 // which version of Windows, source sampled 2022.Dec.26 18:00EST:
378 // https://learn.microsoft.com/en-us/cpp/porting/ ...
379 // ... modifying-winver-and-win32-winnt
380 #if _WIN32_WINNT >= 0x0A00
381 #define BSLS_PLATFORM_OS_WIN10 1
382 #elif _WIN32_WINNT >= 0x0603
383 #define BSLS_PLATFORM_OS_WINBLUE 1
384 #elif _WIN32_WINNT >= 0x0602
385 #define BSLS_PLATFORM_OS_WIN8 1
386 #elif _WIN32_WINNT >= 0x0601
387 #define BSLS_PLATFORM_OS_WIN7 1
388 #elif _WIN32_WINNT >= 0x0600
389 #define BSLS_PLATFORM_OS_WINVISTA 1
390 #elif _WIN32_WINNT >= 0x0502
391 #define BSLS_PLATFORM_OS_WINS03 1
392 #elif _WIN32_WINNT >= 0x0501
393 #define BSLS_PLATFORM_OS_WINXP 1
394 #elif _WIN32_WINNT >= 0x0500
395 #define BSLS_PLATFORM_OS_WIN2K 1
396 #elif _WIN32_WINNT >= 0x0410
397 #define BSLS_PLATFORM_OS_WIN9X 1
398 #elif _WIN32_WINNT >= 0x0400
399 #define BSLS_PLATFORM_OS_WINNT 1
400 #elif defined(WINVER) && WINVER >= 0x0400 \
401 || defined(_WIN32_WINDOWS) && _WIN32_WINDOWS >= 0x401
402 #define BSLS_PLATFORM_OS_WIN9X 1
403 #else // default when detection fails
404 #define BSLS_PLATFORM_OS_WINVISTA 1
405 #endif
406
407 // set API Version synonyms
408 #if defined(BSLS_PLATFORM_OS_WINVISTA) && !defined(BSLS_PLATFORM_OS_WINS08)
409 #define BSLS_PLATFORM_OS_WINS08 1
410 // Windows Server 2008 is the same API as Windows Vista
411 #endif
412 #if !defined(BSLS_PLATFORM_OS_WINVISTA) && defined(BSLS_PLATFORM_OS_WINS08)
413 #define BSLS_PLATFORM_OS_WINVISTA 1
414 // Windows Server 2008 is the same API as Windows Vista
415 #endif
416
417 // set Version flags
418 #if defined(_WIN32_WINNT)
419 #define BSLS_PLATFORM_OS_VER_MAJOR _WIN32_WINNT / 0x100
420 #define BSLS_PLATFORM_OS_VER_MINOR _WIN32_WINNT % 0x100
421 #elif defined(WINVER)
422 #define BSLS_PLATFORM_OS_VER_MAJOR WINVER / 0x100
423 #define BSLS_PLATFORM_OS_VER_MINOR WINVER % 0x100
424 #elif defined(_WIN32_WINDOWS)
425 #define BSLS_PLATFORM_OS_VER_MAJOR _WIN32_WINDOWS / 0x100
426 #define BSLS_PLATFORM_OS_VER_MINOR _WIN32_WINDOWS % 0x100
427 #else // default
428 #define BSLS_PLATFORM_OS_VER_MAJOR 4
429 #define BSLS_PLATFORM_OS_VER_MINOR 0
430 #endif
431
432 // which CPU
433 // since WinCE is not supported, neither is the HITACHI CPU
434 #if defined(_M_ALPHA)
435 #define BSLS_PLATFORM_CPU_ALPHA 1
436 #elif defined(_M_IX86)
437 #define BSLS_PLATFORM_CPU_X86 1
438 #define BSLS_PLATFORM_CPU_32_BIT 1
439 #define BSLS_PLATFORM_CPU_VER_MAJOR _M_IX86
440 #elif defined(_M_IA64)
441 #if defined(_WIN64) // native mode
442 #define BSLS_PLATFORM_CPU_IA64 1
443 #define BSLS_PLATFORM_CPU_64_BIT 1
444 #else // emulated
445 #define BSLS_PLATFORM_CPU_X86 1
446 #define BSLS_PLATFORM_CPU_32_BIT 1
447 #endif
448 #define BSLS_PLATFORM_CPU_VER_MAJOR _M_IA64
449 #elif defined(_M_AMD64)
450 #if defined(_WIN64) // native mode
451 #define BSLS_PLATFORM_CPU_X86_64 1
452 #define BSLS_PLATFORM_CPU_64_BIT 1
453 #else // emulated
454 #define BSLS_PLATFORM_CPU_X86 1
455 #define BSLS_PLATFORM_CPU_32_BIT 1
456 #endif
457 #define BSLS_PLATFORM_CPU_VER_MAJOR _M_AMD64
458 #elif defined(_M_PPC)
459 #define BSLS_PLATFORM_CPU_POWERPC 1
460 #define BSLS_PLATFORM_CPU_VER_MAJOR _M_PPC
461 #elif defined(_M_MRX000)
462 #define BSLS_PLATFORM_CPU_MIPS 1
463 #define BSLS_PLATFORM_CPU_VER_MAJOR _M_MRX000
464 #elif defined(_M_ARM)
465 #define BSLS_PLATFORM_CPU_ARM 1
466 #define BSLS_PLATFORM_CPU_32_BIT 1
467
468 // MSVC doesn't provide macros for differentiating version, but the
469 // minimum supported one is ARMv7
470 #define BSLS_PLATFORM_CPU_ARM_V7 1
471 #elif defined(_M_ARM64)
472 #define BSLS_PLATFORM_CPU_ARM 1
473 #define BSLS_PLATFORM_CPU_64_BIT 1
474
475 // MSVC doesn't provide macros for differentiating version, but the
476 // minimum supported one is ARMv7
477 #define BSLS_PLATFORM_CPU_ARM_V7 1
478 #else
479 #error "Unable to identify CPU on which the MSVC compiler is running."
481 #endif
482
483// ---------------------------------------------------------------------------
484#elif defined(__clang__) || defined(__GNUC__) || defined(__EDG__)
485
486 #if defined(__clang__)
487 // Clang presents itself as GCC compatible, but sets the pre-defined
488 // GCC version macros ('__GNUC__', '__GNUC_MINOR__', and
489 // '__GNUC_PATCHLEVEL__') to version 4.2.1 no matter the version of
490 // Clang being used. In order to differentiate between Clang and GCC,
491 // the compilers are identified by independent 'BSLS_PLATFORM' macros.
492 // Apple Xcode is based upon LLVM (Clang), but Apple changes the
493 // reported Clang versioning ('__clang_major__', '__clang_minor__',
494 // '__clang_patchlevel__') to report the Xcode version rather than the
495 // actual version of Clang the Xcode release includes. A table of
496 // Xcode/Clang version information is maintained here:
497 // https://trac.macports.org/wiki/XcodeVersionInfo To avoid this extra
498 // dimension, the Clang intrinsics '__has_builtin', '__has_feature',
499 // and '__has_extension' should be used in preference to
500 // 'BSLS_PLATFORM_CMP_VERSION' when checking for compiler features. If
501 // 'BSLS_PLATFORM_CMP_VERSION' must be used, then '__APPLE_CC__' can be
502 // tested to determine if 'BSLS_PLATFORM_CMP_VERSION' represents Clang
503 // LLVM or Apple Xcode version.
504
505 #define BSLS_PLATFORM_CMP_CLANG 1
506 #define BSLS_PLATFORM_CMP_VERSION ( __clang_major__ * 10000 \
507 + __clang_minor__ * 100 \
508 + __clang_patchlevel__ )
509 #elif defined (__GNUC__)
510 #define BSLS_PLATFORM_CMP_GNU 1
511 #if defined(__GNUC_PATCHLEVEL__)
512 #define BSLS_PLATFORM_CMP_VERSION (__GNUC__ * 10000 \
513 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
514 #else
515 #define BSLS_PLATFORM_CMP_VERSION (__GNUC__ * 10000 \
516 + __GNUC_MINOR__ * 100)
517 #endif
518 #else
519 #define BSLS_PLATFORM_CMP_EDG 1
520 #define BSLS_PLATFORM_CMP_VERSION __EDG_VERSION__
521 #endif
522
523 // which OS -- GNU and EDG/Como are implemented almost everywhere
524 #if defined(_AIX)
525 #define BSLS_PLATFORM_OS_AIX 1
526 #elif defined(__CYGWIN__) || defined(cygwin) || defined(__cygwin)
527 #define BSLS_PLATFORM_OS_CYGWIN 1
528 #elif defined(linux) || defined(__linux)
529 #define BSLS_PLATFORM_OS_LINUX 1
530 #elif defined(__FreeBSD__)
531 #define BSLS_PLATFORM_OS_FREEBSD 1
532 #elif defined(sun) || defined(__sun)
533 #if defined(__SVR4) || defined(__svr4__)
534 #define BSLS_PLATFORM_OS_SOLARIS 1
535 #else
536 #define BSLS_PLATFORM_OS_SUNOS 1
537 #endif
538 #elif defined(_WIN32) || defined(__WIN32__) && \
539 !(defined(cygwin) || defined(__cygwin))
540 #define BSLS_PLATFORM_OS_WINDOWS 1
541 #elif defined(__APPLE__)
542 #define BSLS_PLATFORM_OS_DARWIN 1
543 #else
544 #if defined(__GNUC__)
545 #error "Unable to determine on which OS the compiler is running."
546 #else
547 #error "Unable to determine on which OS EDG compiler is running."
548 #endif
550 #endif
551
552 #if !defined(BSLS_PLATFORM_OS_WINDOWS)
553 #define BSLS_PLATFORM_OS_UNIX 1
554 #endif
555
556 // which CPU -- GNU and EDG/Como are implemented almost everywhere
557 #if defined(__alpha__)
558 #define BSLS_PLATFORM_CPU_ALPHA 1
559 #elif defined(__x86_64) || defined(__x86_64__)
560 #define BSLS_PLATFORM_CPU_X86_64 1
561 #define BSLS_PLATFORM_CPU_64_BIT 1
562 #elif defined(__i386) || defined(__i386__) \
563 || defined(__ix86) || defined(__ix86__)
564 #define BSLS_PLATFORM_CPU_X86 1
565 #define BSLS_PLATFORM_CPU_32_BIT 1
566 #elif defined(__ia64) || defined(__ia64__) || defined(_IA64) \
567 || defined(__IA64__)
568 #define BSLS_PLATFORM_CPU_IA64 1
569 #if defined(_LP64) || defined(__LP64__)
570 #define BSLS_PLATFORM_CPU_64_BIT 1
571 #else // defined(_ILP32)
572 #define BSLS_PLATFORM_CPU_32_BIT 1
573 #endif
574 #elif defined(__mips__)
575 #define BSLS_PLATFORM_CPU_MIPS 1
576 #elif defined(__hppa__) || defined(__hppa)
577 #define BSLS_PLATFORM_CPU_HPPA 1
578 #elif defined(__powerpc) || defined(__powerpc__) \
579 || defined(__POWERPC__) || defined(__ppc__) || defined(_POWER)
580 #define BSLS_PLATFORM_CPU_POWERPC 1
581 #if defined(__64BIT__) || defined(_LP64) || defined(__LP64__)
582 #define BSLS_PLATFORM_CPU_64_BIT 1
583 #else // defined(_ILP32)
584 #define BSLS_PLATFORM_CPU_32_BIT 1
585 #endif
586 #elif defined(__sparc__) || defined(__sparc_v9__) || defined(__sparcv9)
587 #define BSLS_PLATFORM_CPU_SPARC 1
588 #if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__)
589 #define BSLS_PLATFORM_CPU_SPARC_V9 1
590 #define BSLS_PLATFORM_CPU_64_BIT 1
591 #else
592 #define BSLS_PLATFORM_CPU_SPARC_32 1
593 #endif
594 #elif defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
595 #define BSLS_PLATFORM_CPU_ARM 1
596 #if defined(__arm64__) || defined(__aarch64__)
597 #define BSLS_PLATFORM_CPU_64_BIT 1
598 #endif
599 #if defined(__ARM_ARCH)
600 #if __ARM_ARCH == 6
601 #define BSLS_PLATFORM_CPU_ARM_V6 1
602 #elif __ARM_ARCH == 7
603 #define BSLS_PLATFORM_CPU_ARM_V7 1
604 #elif __ARM_ARCH == 8
605 #define BSLS_PLATFORM_CPU_ARM_V8 1
606 #endif
607 #elif defined(__ARM_ARCH_5T__) \
608 || defined(__ARM_ARCH_5TE__) \
609 || defined(__ARM_ARCH_5TEJ__)
610 #define BSLS_PLATFORM_CPU_ARM_V5
611 #elif defined(__ARM_ARCH_6__) || defined (__ARM_ARCH_6ZK__)
612 #define BSLS_PLATFORM_CPU_ARM_V6
613 #elif defined(__ARM_ARCH_7__) \
614 || defined(__ARM_ARCH_7A__) \
615 || defined(__ARM_ARCH_7M__) \
616 || defined(__ARM_ARCH_7R__)
617 #define BSLS_PLATFORM_CPU_ARM_V7
618 #elif defined(__ARM64_ARCH_8__) \
619 || defined(__ARM_ARCH_8_3__) \
620 || defined(__ARM_ARCH_8_4__) \
621 || defined(__ARM_ARCH_8_5__)
622 #define BSLS_PLATFORM_CPU_ARM_V8
623 #else
624 #error "Unsupported ARM platform."
625 #endif
626 #else
627 #if defined(__GNUC__)
628 #error "Unable to determine on which CPU the compiler is running."
629 #else
630 #error "Unable to determine on which CPU EDG compiler is running."
631 #endif
633 #endif
634
635 #if !defined(BSLS_PLATFORM_CPU_64_BIT)
636 #define BSLS_PLATFORM_CPU_32_BIT 1
637 #endif
638// ----------------------------------------------------------------------------
639#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C)
640
641 #define BSLS_PLATFORM_CMP_SUN 1
642 #if defined(__cplusplus)
643 #define BSLS_PLATFORM_CMP_VERSION __SUNPRO_CC
644 #else
645 #define BSLS_PLATFORM_CMP_VERSION __SUNPRO_C
646 #endif
647
648 // which OS
649 #define BSLS_PLATFORM_OS_UNIX 1
650 #if defined(sun) || defined(__sun)
651 #define BSLS_PLATFORM_OS_SOLARIS 1
652 #if defined(__SVR4) || defined(__svr4__)
653 #if defined(__SunOS_5_7)
654 #define BSLS_PLATFORM_OS_VER_MAJOR 7
655 #define BSLS_PLATFORM_OS_VER_MINOR 0
656 #elif defined(__SunOS_5_8)
657 #define BSLS_PLATFORM_OS_VER_MAJOR 8
658 #define BSLS_PLATFORM_OS_VER_MINOR 0
659 #elif defined(__SunOS_5_9)
660 #define BSLS_PLATFORM_OS_VER_MAJOR 9
661 #define BSLS_PLATFORM_OS_VER_MINOR 0
662 #elif defined(__SunOS_5_10)
663 #define BSLS_PLATFORM_OS_VER_MAJOR 10
664 #define BSLS_PLATFORM_OS_VER_MINOR 0
665 #elif defined(__SunOS_5_11)
666 #define BSLS_PLATFORM_OS_VER_MAJOR 11
667 #define BSLS_PLATFORM_OS_VER_MINOR 0
668 #else
669 #define BSLS_PLATFORM_OS_VER_MAJOR 1
670 #define BSLS_PLATFORM_OS_VER_MINOR 0
671 #endif
672 #else
673 #error "Unable to determine SUN OS version."
675 #endif
676 #elif defined(__SVR4) || defined(__svr4__)
677 #define BSLS_PLATFORM_OS_SUNOS 1
678 #if defined(__SunOS_5_7)
679 #define BSLS_PLATFORM_OS_VER_MAJOR 7
680 #define BSLS_PLATFORM_OS_VER_MINOR 0
681 #elif defined(__SunOS_5_8)
682 #define BSLS_PLATFORM_OS_VER_MAJOR 8
683 #define BSLS_PLATFORM_OS_VER_MINOR 0
684 #elif defined(__SunOS_5_9)
685 #define BSLS_PLATFORM_OS_VER_MAJOR 9
686 #define BSLS_PLATFORM_OS_VER_MINOR 0
687 #else
688 #define BSLS_PLATFORM_OS_VER_MAJOR 1
689 #endif
690 #else
691 #error "Unable to determine SUN OS version."
693 #endif
694
695 // determine which CPU
696 #if defined(__x86_64) || defined(__x86_64__)
697 #define BSLS_PLATFORM_CPU_X86_64 1
698 #define BSLS_PLATFORM_CPU_64_BIT 1
699 #elif defined(i386) || defined(__i386)
700 #define BSLS_PLATFORM_CPU_X86 1
701 #define BSLS_PLATFORM_CPU_32_BIT 1
702 #elif defined(__sparc64) || defined(__sparcv9)
703 #define BSLS_PLATFORM_CPU_SPARC 1
704 #define BSLS_PLATFORM_CPU_SPARC_V9 1
705 #define BSLS_PLATFORM_CPU_64_BIT 1
706 #elif defined(sparc) || defined(__sparc)
707 #define BSLS_PLATFORM_CPU_SPARC 1
708 #define BSLS_PLATFORM_CPU_SPARC_32 1
709 #define BSLS_PLATFORM_CPU_32_BIT 1
710 #else
711 #error "Cannot determine CPU on which the SUN compiler is running."
713 #endif
714// ---------------------------------------------------------------------------
715#else
716 #error "Could not identify the compiler."
718#endif
719// ----------------------------------------------------------------------------
720
721// Determine endianness.
722
723// GNU libc or Linux or Cygwin
724#if defined(BSLS_PLATFORM_OS_LINUX) || defined(BSLS_PLATFORM_OS_CYGWIN) \
725 || defined(__GLIBC__)
726
727 #include <endian.h>
728 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
729 #define BSLS_PLATFORM_IS_LITTLE_ENDIAN 1
730 #elif (__BYTE_ORDER == __BIG_ENDIAN)
731 #define BSLS_PLATFORM_IS_BIG_ENDIAN 1
732 #endif
733
734// AIX
735#elif defined(BSLS_PLATFORM_OS_AIX)
736 #include <sys/machine.h>
737 #if BYTE_ORDER == LITTLE_ENDIAN
738 #define BSLS_PLATFORM_IS_LITTLE_ENDIAN 1
739 #elif BYTE_ORDER == BIG_ENDIAN
740 #define BSLS_PLATFORM_IS_BIG_ENDIAN 1
741 #endif
742
743// Sun/Solaris
744#elif defined(BSLS_PLATFORM_OS_SUNOS) || defined(BSLS_PLATFORM_OS_SOLARIS)
745 #include <sys/isa_defs.h>
746 #if defined(_LITTLE_ENDIAN)
747 #define BSLS_PLATFORM_IS_LITTLE_ENDIAN 1
748 #elif defined(_BIG_ENDIAN)
749 #define BSLS_PLATFORM_IS_BIG_ENDIAN 1
750 #endif
751
752// Darwin
753#elif defined(BSLS_PLATFORM_OS_DARWIN)
754 #include <machine/endian.h>
755 #if BYTE_ORDER == LITTLE_ENDIAN
756 #define BSLS_PLATFORM_IS_LITTLE_ENDIAN 1
757 #elif BYTE_ORDER == BIG_ENDIAN
758 #define BSLS_PLATFORM_IS_BIG_ENDIAN 1
759 #endif
760
761// MSVC and Windows
762#elif defined(BSLS_PLATFORM_OS_WINDOWS)
763 #define BSLS_PLATFORM_IS_LITTLE_ENDIAN 1
764#endif
765
766// Endianness sanity check is done further in this header.
767
768// ----------------------------------------------------------------------------
769
770 // Detect Supported Platform
771
772#if !defined(BDE_DISABLE_COMPILER_VERSION_CHECK)
773
774#if defined(BSLS_PLATFORM_CMP_CLANG)
775 // No minimum supported compiler version has been identified yet.
776#elif defined(BSLS_PLATFORM_CMP_EDG)
777 // No minimum supported compiler version has been identified yet.
778#elif defined(BSLS_PLATFORM_CMP_HP)
779 #if BSLS_PLATFORM_CMP_VERSION < 62500
780 #error This early compiler is not supported by BDE
781 #endif
782#elif defined(BSLS_PLATFORM_CMP_IBM)
783 // Require at least xlC 12 for AIX.
784 #if BSLS_PLATFORM_CMP_VERSION < 0x0c01
785 #error This early compiler is not supported by BDE
786 #endif
787#elif defined(BSLS_PLATFORM_CMP_SUN)
788 #if BSLS_PLATFORM_CMP_VERSION < 0x5120
789 #error This early compiler is not supported by BDE
790 #endif
791#elif defined(BSLS_PLATFORM_CMP_GNU)
792 // Test GNU late, as so many compilers offer a GNU compatibility mode.
793 #if BSLS_PLATFORM_CMP_VERSION < 40102
794 #error This early compiler is not supported by BDE
795 #endif
796#elif defined(BSLS_PLATFORM_CMP_MSVC)
797 // Test MSVC last, as many compilers targeting Windows offer a Microsoft
798 // compatibility mode.
799 #if BSLS_PLATFORM_CMP_VERSION < 1800
800 #error This early compiler is not supported by BDE
801 #endif
802#else
803 #error This compiler is not recognized by BDE
804#endif
805
806#endif
807
808#ifdef BSLS_PLATFORM_CMP_VERSION
809/// This deprecated macro is defined for backwards compatibility only.
810#define BSLS_PLATFORM_CMP_VER_MAJOR BSLS_PLATFORM_CMP_VERSION
811#endif
812// ----------------------------------------------------------------------------
813
814 // Miscellaneous Platform Macros
815
816#if defined(BSLS_PLATFORM_CMP_GNU) && !defined(__GXX_EXPERIMENTAL_CXX0X__)
817 #define BSLS_PLATFORM_NO_64_BIT_LITERALS 1
818#endif
819
820#if defined(BSLS_PLATFORM_CMP_IBM) && !defined(BSLS_PLATFORM_CPU_64_BIT)
821 #define BSLS_PLATFORM_NO_64_BIT_LITERALS 1
822#endif
823
824#if (defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VER_MAJOR >= 40600) \
825 || defined(BSLS_PLATFORM_CMP_CLANG)
826 #define BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC 1
827 #if defined(BSLS_PLATFORM_CMP_CLANG)
828 #define BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_CLANG 1
829 #else
830 #define BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_GCC 1
831 #endif
832#endif
833
834#if !(defined(BSLS_PLATFORM_CMP_AIX) || defined(BSLS_PLATFORM_CMP_SUN)) \
835 || defined(BDE_BUILD_TARGET_AGGRESSIVE_INLINE)
836 #define BSLS_PLATFORM_AGGRESSIVE_INLINE inline
837#else
838 #define BSLS_PLATFORM_AGGRESSIVE_INLINE
839#endif
840
841#if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 40406 || \
842 defined(BSLS_PLATFORM_CMP_CLANG) || defined(BSLS_PLATFORM_CMP_MSVC)
843 // Support for preserving macro values through the following pragmas:
844 // #pragma push_macro("NAME") // Save macro definition of NAME
845 // #pragma pop_macro("NAME") // Restore macro definition of NAME
846 // Note that if NAME is undefined, the sequence push/define NAME/pop may
847 // leave NAME defined at the end, depending on compiler version.
848 #define BSLS_PLATFORM_HAS_MACRO_PUSH_POP 1
849#endif
850
851///Implementation Note
852///- - - - - - - - - -
853// When compiling with Microsoft Visual Studio, as indicated by the macro
854// '_MSC_VER' being defined, this component assumes that the SSE, SSE2, and
855// SSE3 instruction set extensions are available on x86 platforms. Therefore,
856// x86 processors lacking these extensions are not supported when compiling
857// with Visual Studio. Later extensions, such as SSE4.1, SSE4.2, and AVX, are
858// not assumed. As of the writing of this note, Visual Studio does not provide
859// a reliable way to detect whether x86 instruction set extensions are enabled.
860//
861// Note that it is not necessarily safe to change this component to assume
862// later instruction set extensions are available when compiling with Visual
863// Studio. Doing so may lead to dependent components using instructions that
864// are not available on some x86 platforms.
865//
866// Clang and GCC (as well as compilers with EDG front-ends) provide macros to
867// detect whether most x86 instruction set extensions are enabled.
868
869#if defined(_MSC_VER)
870 #if !defined(BSLS_PLATFORM_CPU_ARM)
871 #define BSLS_PLATFORM_CPU_SSE 1
872 #define BSLS_PLATFORM_CPU_SSE2 1
873 #define BSLS_PLATFORM_CPU_SSE3 1
874 #endif
875#elif defined(__clang__) || defined(__GNUC__) || defined(__EDG__)
876 #if defined(__SSE__)
877 #define BSLS_PLATFORM_CPU_SSE 1
878 #endif
879 #if defined(__SSE2__)
880 #define BSLS_PLATFORM_CPU_SSE2 1
881 #endif
882 #if defined(__SSE3__)
883 #define BSLS_PLATFORM_CPU_SSE3 1
884 #endif
885 #if defined(__SSE4_1__)
886 #define BSLS_PLATFORM_CPU_SSE4_1 1
887 #endif
888 #if defined(__SSE4_2__)
889 #define BSLS_PLATFORM_CPU_SSE4_2 1
890 #endif
891#endif
892
893// ----------------------------------------------------------------------------
894
895 // Self Validation
896
897// Unix flag must be set by the compiler if Unix detected (except for AIX).
898#if defined(BSLS_PLATFORM_OS_UNIX) && !defined(BSLS_PLATFORM_OS_AIX) && \
899 !defined(BSLS_PLATFORM_OS_DARWIN)
900 #if !defined(unix) && !defined(__unix__) && !defined(__unix)
901 #error "Unix platform assumed, but unix flag not set by compiler"
903 #endif
904#endif
905
906// Exactly one 'CMP' type.
907#if BSLS_PLATFORM_CMP_EDG \
908 + BSLS_PLATFORM_CMP_CLANG \
909 + BSLS_PLATFORM_CMP_GNU \
910 + BSLS_PLATFORM_CMP_HP \
911 + BSLS_PLATFORM_CMP_IBM \
912 + BSLS_PLATFORM_CMP_MSVC \
913 + BSLS_PLATFORM_CMP_SUN != 1
914 #error "Exactly one compiler must be set."
916#endif
917
918// Exactly one 'OS' type.
919#if BSLS_PLATFORM_OS_UNIX \
920 + BSLS_PLATFORM_OS_WINDOWS != 1
921 #error "Exactly one operating system must be set."
923#endif
924
925// At most one 'OS' subtype.
926#define BSLS_PLATFORM_OS_SUBTYPE_COUNT \
927 BSLS_PLATFORM_OS_AIX \
928 + BSLS_PLATFORM_OS_DARWIN \
929 + BSLS_PLATFORM_OS_LINUX \
930 + BSLS_PLATFORM_OS_FREEBSD \
931 + BSLS_PLATFORM_OS_SOLARIS \
932 + BSLS_PLATFORM_OS_SUNOS \
933 + BSLS_PLATFORM_OS_CYGWIN \
934 + BSLS_PLATFORM_OS_WIN9X \
935 + BSLS_PLATFORM_OS_WINNT \
936 + BSLS_PLATFORM_OS_WIN2K \
937 + BSLS_PLATFORM_OS_WINXP \
938 + BSLS_PLATFORM_OS_WINS03 \
939 + BSLS_PLATFORM_OS_WINVISTA \
940 + BSLS_PLATFORM_OS_WIN7 \
941 + BSLS_PLATFORM_OS_WIN8 \
942 + BSLS_PLATFORM_OS_WINBLUE \
943 + BSLS_PLATFORM_OS_WIN10
944#if BSLS_PLATFORM_OS_SUBTYPE_COUNT > 1
945 #error "At most one operating system subtype must be set."
947#endif
948
949// Windows Server 2008 API is the same as Vista
950#if defined(BSLS_PLATFORM_OS_WINVISTA) != defined(BSLS_PLATFORM_OS_WINS08)
951 #error "Windows Vista and Server 2008 are the same API."
953#endif
954
955// Exactly one 'CPU' type.
956#if BSLS_PLATFORM_CPU_88000 \
957 + BSLS_PLATFORM_CPU_ALPHA \
958 + BSLS_PLATFORM_CPU_HPPA \
959 + BSLS_PLATFORM_CPU_IA64 \
960 + BSLS_PLATFORM_CPU_X86 \
961 + BSLS_PLATFORM_CPU_X86_64 \
962 + BSLS_PLATFORM_CPU_MIPS \
963 + BSLS_PLATFORM_CPU_POWERPC \
964 + BSLS_PLATFORM_CPU_SPARC \
965 + BSLS_PLATFORM_CPU_ARM != 1
966 #error "Exactly one processor must be set."
968#endif
969
970// Exactly one kind of "endian-ness".
971#if BSLS_PLATFORM_IS_BIG_ENDIAN \
972 + BSLS_PLATFORM_IS_LITTLE_ENDIAN != 1
973 #error "Exactly one kind of endian-ness must be set."
975#endif
976
977#if defined(BSLS_PLATFORM_OS_VER_MAJOR) && BSLS_PLATFORM_OS_SUBTYPE_COUNT != 1
978 // For OS, MAJOR VERSION implies SUBTYPE.
979 #error "Operating system major version but not subtype defined."
981#endif
982
983#undef BSLS_PLATFORM_OS_SUBTYPE_COUNT
984
985#if defined(BSLS_PLATFORM_OS_VER_MINOR) && !defined(BSLS_PLATFORM_OS_VER_MAJOR)
986 #error "Operating System minor but not major version defined."
988#endif
989
990#ifdef __cplusplus
991
992namespace bsls {
993
994// ----------------------------------------------------------------------------
995
996 // ========
997 // Platform
998 // ========
999
1000/// Namespace for platform-trait definitions.
1001struct Platform {
1002
1003 // OS TYPES
1004
1005 struct OsAny {};
1006
1007 struct OsUnix : OsAny {};
1008 struct OsWindows : OsAny {};
1009
1010 struct OsAix : OsUnix {};
1011 struct OsHpux : OsUnix {};
1012 struct OsLinux : OsUnix {};
1013 struct OsFreeBsd : OsUnix {};
1014 struct OsSolaris : OsUnix {};
1015 struct OsCygwin : OsUnix {};
1016 struct OsDarwin : OsUnix {};
1017
1018 struct OsSolaris_V8 : OsSolaris {};
1019 struct OsSolaris_V9 : OsSolaris {};
1020 struct OsSolaris_V10 : OsSolaris {};
1021
1022 struct OsAix_V5 : OsAix {};
1023
1024 struct OsWinNT : OsWindows {};
1025
1026 // PROCESSOR TYPES
1027
1028 struct CpuAny {};
1029
1030 struct Cpu88000 : CpuAny {};
1031 struct CpuAlpha : CpuAny {};
1032 struct CpuHppa : CpuAny {};
1033 struct CpuX86 : CpuAny {};
1034 struct CpuIa64 : CpuAny {};
1035 struct CpuX86_64 : CpuAny {};
1036 struct CpuMips : CpuAny {};
1037
1038 struct CpuPowerpc : CpuAny {};
1039
1040 struct CpuSparc : CpuAny {};
1041 struct CpuSparc_32 : CpuSparc {}; // 32-bit
1042 struct CpuSparc_V9 : CpuSparc {}; // 64-bit
1043
1044 typedef CpuPowerpc CPU_POWERPC;
1045 typedef CpuSparc CPU_SPARC;
1046 typedef CpuSparc_32 CPU_SPARC_32;
1047 typedef CpuSparc_V9 CPU_SPARC_V9;
1048
1049 struct CpuPowerpc_601 : CpuPowerpc {};
1050 struct CpuArch_Pwr : CpuPowerpc {};
1051 struct CpuArch_Pwr2 : CpuPowerpc {};
1052 struct CpuArch_Pwr2s : CpuPowerpc {};
1053
1054 struct CpuArm : CpuAny {};
1055 struct CpuArmv5 : CpuArm {};
1056 struct CpuArmv6 : CpuArm {};
1057 struct CpuArmv7 : CpuArm {};
1058 struct CpuArmv8 : CpuArm {};
1059
1060 // PLATFORM TRAITS
1061
1062 //OS TRAIT
1063 // Will fail to compile if more than one OS type is set.
1064
1065 #if defined(BSLS_PLATFORM_OS_AIX)
1066 #if (BSLS_PLATFORM_OS_VER_MAJOR == _AIX)
1067 typedef OsAix_V5 Os;
1068 #else
1069 typedef OsAix Os;
1070 #endif
1071 #endif
1072 #if defined BSLS_PLATFORM_OS_SOLARIS
1073 #if (BSLS_PLATFORM_OS_VER_MAJOR == 9)
1074 typedef OsSolaris_V9 Os;
1075 #elif (BSLS_PLATFORM_OS_VER_MAJOR == 10)
1076 typedef OsSolaris_V10 Os;
1077 #else
1078 typedef OsSolaris_V8 Os;
1079 #endif
1080 #endif
1081 #if defined(BSLS_PLATFORM_OS_CYGWIN)
1082 typedef OsCygwin Os;
1083 #endif
1084 #if defined(BSLS_PLATFORM_OS_LINUX)
1085 typedef OsLinux Os;
1086 #endif
1087 #if defined(BSLS_PLATFORM_OS_FREEBSD)
1088 typedef OsFreeBsd Os;
1089 #endif
1090 #if defined(BSLS_PLATFORM_OS_WINDOWS)
1091 typedef OsWinNT Os;
1092 #endif
1093 #if defined(BSLS_PLATFORM_OS_DARWIN)
1094 typedef OsDarwin Os;
1095 #endif
1096
1097 //CPU TRAIT
1098 // Will fail to compile if more than one CPU type is set.
1099
1100 #if defined(BSLS_PLATFORM_CPU_X86)
1101 typedef CpuX86 Cpu;
1102 #endif
1103 #if defined(BSLS_PLATFORM_CPU_IA64)
1104 typedef CpuIa64 Cpu;
1105 #endif
1106 #if defined(BSLS_PLATFORM_CPU_X86_64)
1107 typedef CpuX86_64 Cpu;
1108 #endif
1109 #if defined(BSLS_PLATFORM_CPU_POWERPC)
1110 #if defined(BSLS_PLATFORM_CPU_VER_MAJOR) && \
1111 (BSLS_PLATFORM_CPU_VER_MAJOR == _ARCH_601)
1112 typedef CpuPowerpc_601 Cpu;
1113 #else
1114 typedef CpuPowerpc Cpu;
1115 #endif
1116 #endif
1117 #if defined(BSLS_PLATFORM_CPU_SPARC_32)
1118 typedef CpuSparc_32 Cpu;
1119 #endif
1120 #if defined(BSLS_PLATFORM_CPU_SPARC_V9)
1121 typedef CpuSparc_V9 Cpu;
1122 #endif
1123 #if defined(BSLS_PLATFORM_CPU_ARM_V5)
1124 typedef CpuArmv5 Cpu;
1125 #endif
1126 #if defined(BSLS_PLATFORM_CPU_ARM_V6)
1127 typedef CpuArmv6 Cpu;
1128 #endif
1129 #if defined(BSLS_PLATFORM_CPU_ARM_V7)
1130 typedef CpuArmv7 Cpu;
1131 #endif
1132 #if defined(BSLS_PLATFORM_CPU_ARM_V8)
1133 typedef CpuArmv8 Cpu;
1134 #endif
1135};
1136
1137} // close package namespace
1138#endif // __cplusplus
1139
1140#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
1141#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1142
1143 // ======================
1144 // BACKWARD COMPATIBILITY
1145 // ======================
1146
1147#ifdef __cplusplus
1148/// This alias is defined for backward compatibility.
1149typedef bsls::Platform bdes_Platform;
1150#endif // __cplusplus
1151
1152#endif // BDE_OMIT_INTERNAL_DEPRECATED
1153
1154#ifdef __cplusplus
1155/// This alias is defined for backward compatibility.
1156typedef bsls::Platform bsls_Platform;
1157#endif
1158
1159#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
1160
1161#ifdef __cplusplus
1162
1163#endif
1164
1165#if !defined(BSL_DOUBLE_UNDERSCORE_XLAT) || 1 == BSL_DOUBLE_UNDERSCORE_XLAT
1166
1167// 'BDES' aliases
1168
1169#ifdef BSLS_PLATFORM_CMP_AIX
1170# define BDES_PLATFORM__CMP_AIX BSLS_PLATFORM_CMP_AIX
1171#endif
1172#ifdef BSLS_PLATFORM_CMP_GNU
1173# define BDES_PLATFORM__CMP_GNU BSLS_PLATFORM_CMP_GNU
1174#endif
1175#ifdef BSLS_PLATFORM_CMP_HP
1176# define BDES_PLATFORM__CMP_HP BSLS_PLATFORM_CMP_HP
1177#endif
1178#ifdef BSLS_PLATFORM_CMP_MSVC
1179# define BDES_PLATFORM__CMP_MSVC BSLS_PLATFORM_CMP_MSVC
1180#endif
1181#ifdef BSLS_PLATFORM_CMP_SUN
1182# define BDES_PLATFORM__CMP_SUN BSLS_PLATFORM_CMP_SUN
1183#endif
1184#ifdef BSLS_PLATFORM_CMP_VER_MAJOR
1185# define BDES_PLATFORM__CMP_VER_MAJOR BSLS_PLATFORM_CMP_VER_MAJOR
1186#endif
1187#ifdef BSLS_PLATFORM_CPU_64_BIT
1188# define BDES_PLATFORM__CPU_64_BIT BSLS_PLATFORM_CPU_64_BIT
1189#endif
1190#ifdef BSLS_PLATFORM_OS_AIX
1191# define BDES_PLATFORM__OS_AIX BSLS_PLATFORM_OS_AIX
1192#endif
1193#ifdef BSLS_PLATFORM_OS_CYGWIN
1194# define BDES_PLATFORM__OS_CYGWIN BSLS_PLATFORM_OS_CYGWIN
1195#endif
1196#ifdef BSLS_PLATFORM_OS_DARWIN
1197# define BDES_PLATFORM__OS_DARWIN BSLS_PLATFORM_OS_DARWIN
1198#endif
1199#ifdef BSLS_PLATFORM_OS_FREEBSD
1200# define BDES_PLATFORM__OS_FREEBSD BSLS_PLATFORM_OS_FREEBSD
1201#endif
1202#ifdef BSLS_PLATFORM_OS_LINUX
1203# define BDES_PLATFORM__OS_LINUX BSLS_PLATFORM_OS_LINUX
1204#endif
1205#ifdef BSLS_PLATFORM_OS_SOLARIS
1206# define BDES_PLATFORM__OS_SOLARIS BSLS_PLATFORM_OS_SOLARIS
1207#endif
1208#ifdef BSLS_PLATFORM_OS_SUNOS
1209# define BDES_PLATFORM__OS_SUNOS BSLS_PLATFORM_OS_SUNOS
1210#endif
1211#ifdef BSLS_PLATFORM_OS_UNIX
1212# define BDES_PLATFORM__OS_UNIX BSLS_PLATFORM_OS_UNIX
1213#endif
1214#ifdef BSLS_PLATFORM_OS_VER_MAJOR
1215# define BDES_PLATFORM__OS_VER_MAJOR BSLS_PLATFORM_OS_VER_MAJOR
1216#endif
1217#ifdef BSLS_PLATFORM_OS_VER_MINOR
1218# define BDES_PLATFORM__OS_VER_MINOR BSLS_PLATFORM_OS_VER_MINOR
1219#endif
1220#ifdef BSLS_PLATFORM_OS_WIN2K
1221# define BDES_PLATFORM__OS_WIN2K BSLS_PLATFORM_OS_WIN2K
1222#endif
1223#ifdef BSLS_PLATFORM_OS_WIN9X
1224# define BDES_PLATFORM__OS_WIN9X BSLS_PLATFORM_OS_WIN9X
1225#endif
1226#ifdef BSLS_PLATFORM_OS_WINDOWS
1227# define BDES_PLATFORM__OS_WINDOWS BSLS_PLATFORM_OS_WINDOWS
1228#endif
1229#ifdef BSLS_PLATFORM_OS_WINNT
1230# define BDES_PLATFORM__OS_WINNT BSLS_PLATFORM_OS_WINNT
1231#endif
1232#ifdef BSLS_PLATFORM_OS_WINXP
1233# define BDES_PLATFORM__OS_WINXP BSLS_PLATFORM_OS_WINXP
1234#endif
1235
1236// 'BSLS' aliases
1237
1238#ifdef BSLS_PLATFORM_CMP_AIX
1239# define BSLS_PLATFORM__CMP_AIX BSLS_PLATFORM_CMP_AIX
1240#endif
1241#ifdef BSLS_PLATFORM_CMP_CLANG
1242# define BSLS_PLATFORM__CMP_CLANG BSLS_PLATFORM_CMP_CLANG
1243#endif
1244#ifdef BSLS_PLATFORM_CMP_EDG
1245# define BSLS_PLATFORM__CMP_EDG BSLS_PLATFORM_CMP_EDG
1246#endif
1247#ifdef BSLS_PLATFORM_CMP_GNU
1248# define BSLS_PLATFORM__CMP_GNU BSLS_PLATFORM_CMP_GNU
1249#endif
1250#ifdef BSLS_PLATFORM_CMP_HP
1251# define BSLS_PLATFORM__CMP_HP BSLS_PLATFORM_CMP_HP
1252#endif
1253#ifdef BSLS_PLATFORM_CMP_IBM
1254# define BSLS_PLATFORM__CMP_IBM BSLS_PLATFORM_CMP_IBM
1255#endif
1256#ifdef BSLS_PLATFORM_CMP_MSVC
1257# define BSLS_PLATFORM__CMP_MSVC BSLS_PLATFORM_CMP_MSVC
1258#endif
1259#ifdef BSLS_PLATFORM_CMP_SUN
1260# define BSLS_PLATFORM__CMP_SUN BSLS_PLATFORM_CMP_SUN
1261#endif
1262#ifdef BSLS_PLATFORM_CMP_VERSION
1263# define BSLS_PLATFORM__CMP_VERSION BSLS_PLATFORM_CMP_VERSION
1264#endif
1265#ifdef BSLS_PLATFORM_CMP_VER_MAJOR
1266# define BSLS_PLATFORM__CMP_VER_MAJOR BSLS_PLATFORM_CMP_VER_MAJOR
1267#endif
1268#ifdef BSLS_PLATFORM_CPU_32_BIT
1269# define BSLS_PLATFORM__CPU_32_BIT BSLS_PLATFORM_CPU_32_BIT
1270#endif
1271#ifdef BSLS_PLATFORM_CPU_64_BIT
1272# define BSLS_PLATFORM__CPU_64_BIT BSLS_PLATFORM_CPU_64_BIT
1273#endif
1274#ifdef BSLS_PLATFORM_CPU_POWERPC
1275# define BSLS_PLATFORM__CPU_POWERPC BSLS_PLATFORM_CPU_POWERPC
1276#endif
1277#ifdef BSLS_PLATFORM_CPU_X86
1278# define BSLS_PLATFORM__CPU_X86 BSLS_PLATFORM_CPU_X86
1279#endif
1280#ifdef BSLS_PLATFORM_CPU_X86_64
1281# define BSLS_PLATFORM__CPU_X86_64 BSLS_PLATFORM_CPU_X86_64
1282#endif
1283#ifdef BSLS_PLATFORM_IS_BIG_ENDIAN
1284# define BSLS_PLATFORM__IS_BIG_ENDIAN BSLS_PLATFORM_IS_BIG_ENDIAN
1285#endif
1286#ifdef BSLS_PLATFORM_IS_LITTLE_ENDIAN
1287# define BSLS_PLATFORM__IS_LITTLE_ENDIAN BSLS_PLATFORM_IS_LITTLE_ENDIAN
1288#endif
1289#ifdef BSLS_PLATFORM_OS_AIX
1290# define BSLS_PLATFORM__OS_AIX BSLS_PLATFORM_OS_AIX
1291#endif
1292#ifdef BSLS_PLATFORM_OS_CYGWIN
1293# define BSLS_PLATFORM__OS_CYGWIN BSLS_PLATFORM_OS_CYGWIN
1294#endif
1295#ifdef BSLS_PLATFORM_OS_DARWIN
1296# define BSLS_PLATFORM__OS_DARWIN BSLS_PLATFORM_OS_DARWIN
1297#endif
1298#ifdef BSLS_PLATFORM_OS_LINUX
1299# define BSLS_PLATFORM__OS_LINUX BSLS_PLATFORM_OS_LINUX
1300#endif
1301#ifdef BSLS_PLATFORM_OS_SOLARIS
1302# define BSLS_PLATFORM__OS_SOLARIS BSLS_PLATFORM_OS_SOLARIS
1303#endif
1304#ifdef BSLS_PLATFORM_OS_SUNOS
1305# define BSLS_PLATFORM__OS_SUNOS BSLS_PLATFORM_OS_SUNOS
1306#endif
1307#ifdef BSLS_PLATFORM_OS_UNIX
1308# define BSLS_PLATFORM__OS_UNIX BSLS_PLATFORM_OS_UNIX
1309#endif
1310#ifdef BSLS_PLATFORM_OS_WINDOWS
1311# define BSLS_PLATFORM__OS_WINDOWS BSLS_PLATFORM_OS_WINDOWS
1312#endif
1313
1314#endif
1315
1316#endif
1317
1318// ----------------------------------------------------------------------------
1319// Copyright 2019 Bloomberg Finance L.P.
1320//
1321// Licensed under the Apache License, Version 2.0 (the "License");
1322// you may not use this file except in compliance with the License.
1323// You may obtain a copy of the License at
1324//
1325// http://www.apache.org/licenses/LICENSE-2.0
1326//
1327// Unless required by applicable law or agreed to in writing, software
1328// distributed under the License is distributed on an "AS IS" BASIS,
1329// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1330// See the License for the specific language governing permissions and
1331// limitations under the License.
1332// ----------------------------- END-OF-FILE ----------------------------------
1333
1334/** @} */
1335/** @} */
1336/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_PLATFORM_COMPILER_ERROR
Definition bsls_platform.h:289
Definition bdlt_iso8601util.h:691