1// Predefined symbols and macros -*- C++ -*- 2 3// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 4// 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 5// 6// This file is part of the GNU ISO C++ Library. This library is free 7// software; you can redistribute it and/or modify it under the 8// terms of the GNU General Public License as published by the 9// Free Software Foundation; either version 3, or (at your option) 10// any later version. 11 12// This library is distributed in the hope that it will be useful, 13// but WITHOUT ANY WARRANTY; without even the implied warranty of 14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15// GNU General Public License for more details. 16 17// Under Section 7 of GPL version 3, you are granted additional 18// permissions described in the GCC Runtime Library Exception, version 19// 3.1, as published by the Free Software Foundation. 20 21// You should have received a copy of the GNU General Public License and 22// a copy of the GCC Runtime Library Exception along with this program; 23// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24// <http://www.gnu.org/licenses/>. 25 26/** @file bits/c++config.h 27 * This is an internal header file, included by other library headers. 28 * Do not attempt to use it directly. @headername{iosfwd} 29 */ 30 31#ifndef _GLIBCXX_CXX_CONFIG_H 32#define _GLIBCXX_CXX_CONFIG_H 1 33 34// The current version of the C++ library in compressed ISO date format. 35#define __GLIBCXX__ 36 37// Macros for various attributes. 38// _GLIBCXX_PURE 39// _GLIBCXX_CONST 40// _GLIBCXX_NORETURN 41// _GLIBCXX_NOTHROW 42// _GLIBCXX_VISIBILITY 43#ifndef _GLIBCXX_PURE 44# define _GLIBCXX_PURE __attribute__ ((__pure__)) 45#endif 46 47#ifndef _GLIBCXX_CONST 48# define _GLIBCXX_CONST __attribute__ ((__const__)) 49#endif 50 51#ifndef _GLIBCXX_NORETURN 52# define _GLIBCXX_NORETURN __attribute__ ((__noreturn__)) 53#endif 54 55// See below for C++ 56#ifndef _GLIBCXX_NOTHROW 57# ifndef __cplusplus 58# define _GLIBCXX_NOTHROW __attribute__((__nothrow__)) 59# endif 60#endif 61 62// Macros for visibility attributes. 63// _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 64// _GLIBCXX_VISIBILITY 65#define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 66 67#if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 68# define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) 69#else 70// If this is not supplied by the OS-specific or CPU-specific 71// headers included below, it will be defined to an empty default. 72# define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V) 73#endif 74 75// Macros for deprecated attributes. 76// _GLIBCXX_USE_DEPRECATED 77// _GLIBCXX_DEPRECATED 78#ifndef _GLIBCXX_USE_DEPRECATED 79# define _GLIBCXX_USE_DEPRECATED 1 80#endif 81 82#if defined(__DEPRECATED) && defined(__GXX_EXPERIMENTAL_CXX0X__) 83# define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__)) 84#else 85# define _GLIBCXX_DEPRECATED 86#endif 87 88#if __cplusplus 89 90// Macro for constexpr, to support in mixed 03/0x mode. 91#ifndef _GLIBCXX_CONSTEXPR 92# ifdef __GXX_EXPERIMENTAL_CXX0X__ 93# define _GLIBCXX_CONSTEXPR constexpr 94# define _GLIBCXX_USE_CONSTEXPR constexpr 95# else 96# define _GLIBCXX_CONSTEXPR 97# define _GLIBCXX_USE_CONSTEXPR const 98# endif 99#endif 100 101// Macro for noexcept, to support in mixed 03/0x mode. 102#ifndef _GLIBCXX_NOEXCEPT 103# ifdef __GXX_EXPERIMENTAL_CXX0X__ 104# define _GLIBCXX_NOEXCEPT noexcept 105# define _GLIBCXX_USE_NOEXCEPT noexcept 106# define _GLIBCXX_THROW(_EXC) 107# else 108# define _GLIBCXX_NOEXCEPT 109# define _GLIBCXX_USE_NOEXCEPT throw() 110# define _GLIBCXX_THROW(_EXC) throw(_EXC) 111# endif 112#endif 113 114#ifndef _GLIBCXX_NOTHROW 115# define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT 116#endif 117 118// Macro for extern template, ie controling template linkage via use 119// of extern keyword on template declaration. As documented in the g++ 120// manual, it inhibits all implicit instantiations and is used 121// throughout the library to avoid multiple weak definitions for 122// required types that are already explicitly instantiated in the 123// library binary. This substantially reduces the binary size of 124// resulting executables. 125// Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern 126// templates only in basic_string, thus activating its debug-mode 127// checks even at -O0. 128#define _GLIBCXX_EXTERN_TEMPLATE 129 130/* 131 Outline of libstdc++ namespaces. 132 133 namespace std 134 { 135 namespace __debug { } 136 namespace __parallel { } 137 namespace __profile { } 138 namespace __cxx1998 { } 139 140 namespace __detail { } 141 142 namespace rel_ops { } 143 144 namespace tr1 145 { 146 namespace placeholders { } 147 namespace regex_constants { } 148 namespace __detail { } 149 } 150 151 namespace tr2 { } 152 153 namespace decimal { } 154 155 namespace chrono { } 156 namespace placeholders { } 157 namespace regex_constants { } 158 namespace this_thread { } 159 } 160 161 namespace abi { } 162 163 namespace __gnu_cxx 164 { 165 namespace __detail { } 166 } 167 168 For full details see: 169 http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html 170*/ 171namespace std 172{ 173 typedef __SIZE_TYPE__ size_t; 174 typedef __PTRDIFF_TYPE__ ptrdiff_t; 175 176#ifdef __GXX_EXPERIMENTAL_CXX0X__ 177 typedef decltype(nullptr) nullptr_t; 178#endif 179} 180 181 182// Defined if inline namespaces are used for versioning. 183#define _GLIBCXX_INLINE_VERSION 184 185// Inline namespace for symbol versioning. 186#if _GLIBCXX_INLINE_VERSION 187 188namespace std 189{ 190 inline namespace __7 { } 191 192 namespace rel_ops { inline namespace __7 { } } 193 194 namespace tr1 195 { 196 inline namespace __7 { } 197 namespace placeholders { inline namespace __7 { } } 198 namespace regex_constants { inline namespace __7 { } } 199 namespace __detail { inline namespace __7 { } } 200 } 201 202 namespace tr2 203 { inline namespace __7 { } } 204 205 namespace decimal { inline namespace __7 { } } 206 207 namespace chrono { inline namespace __7 { } } 208 namespace placeholders { inline namespace __7 { } } 209 namespace regex_constants { inline namespace __7 { } } 210 namespace this_thread { inline namespace __7 { } } 211 212 namespace __detail { inline namespace __7 { } } 213 namespace __regex { inline namespace __7 { } } 214} 215 216namespace __gnu_cxx 217{ 218 inline namespace __7 { } 219 namespace __detail { inline namespace __7 { } } 220} 221# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __7 { 222# define _GLIBCXX_END_NAMESPACE_VERSION } 223#else 224# define _GLIBCXX_BEGIN_NAMESPACE_VERSION 225# define _GLIBCXX_END_NAMESPACE_VERSION 226#endif 227 228 229// Inline namespaces for special modes: debug, parallel, profile. 230#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) \ 231 || defined(_GLIBCXX_PROFILE) 232namespace std 233{ 234 // Non-inline namespace for components replaced by alternates in active mode. 235 namespace __cxx1998 236 { 237#if _GLIBCXX_INLINE_VERSION 238 inline namespace __7 { } 239#endif 240 } 241 242 // Inline namespace for debug mode. 243# ifdef _GLIBCXX_DEBUG 244 inline namespace __debug { } 245# endif 246 247 // Inline namespaces for parallel mode. 248# ifdef _GLIBCXX_PARALLEL 249 inline namespace __parallel { } 250# endif 251 252 // Inline namespaces for profile mode 253# ifdef _GLIBCXX_PROFILE 254 inline namespace __profile { } 255# endif 256} 257 258// Check for invalid usage and unsupported mixed-mode use. 259# if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL) 260# error illegal use of multiple inlined namespaces 261# endif 262# if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_DEBUG) 263# error illegal use of multiple inlined namespaces 264# endif 265# if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_PARALLEL) 266# error illegal use of multiple inlined namespaces 267# endif 268 269// Check for invalid use due to lack for weak symbols. 270# if __NO_INLINE__ && !__GXX_WEAK__ 271# warning currently using inlined namespace mode which may fail \ 272 without inlining due to lack of weak symbols 273# endif 274#endif 275 276// Macros for namespace scope. Either namespace std:: or the name 277// of some nested namespace within it corresponding to the active mode. 278// _GLIBCXX_STD_A 279// _GLIBCXX_STD_C 280// 281// Macros for opening/closing conditional namespaces. 282// _GLIBCXX_BEGIN_NAMESPACE_ALGO 283// _GLIBCXX_END_NAMESPACE_ALGO 284// _GLIBCXX_BEGIN_NAMESPACE_CONTAINER 285// _GLIBCXX_END_NAMESPACE_CONTAINER 286#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) 287# define _GLIBCXX_STD_C __cxx1998 288# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \ 289 namespace _GLIBCXX_STD_C { _GLIBCXX_BEGIN_NAMESPACE_VERSION 290# define _GLIBCXX_END_NAMESPACE_CONTAINER \ 291 } _GLIBCXX_END_NAMESPACE_VERSION 292# undef _GLIBCXX_EXTERN_TEMPLATE 293# define _GLIBCXX_EXTERN_TEMPLATE -1 294#endif 295 296#ifdef _GLIBCXX_PARALLEL 297# define _GLIBCXX_STD_A __cxx1998 298# define _GLIBCXX_BEGIN_NAMESPACE_ALGO \ 299 namespace _GLIBCXX_STD_A { _GLIBCXX_BEGIN_NAMESPACE_VERSION 300# define _GLIBCXX_END_NAMESPACE_ALGO \ 301 } _GLIBCXX_END_NAMESPACE_VERSION 302#endif 303 304#ifndef _GLIBCXX_STD_A 305# define _GLIBCXX_STD_A std 306#endif 307 308#ifndef _GLIBCXX_STD_C 309# define _GLIBCXX_STD_C std 310#endif 311 312#ifndef _GLIBCXX_BEGIN_NAMESPACE_ALGO 313# define _GLIBCXX_BEGIN_NAMESPACE_ALGO 314#endif 315 316#ifndef _GLIBCXX_END_NAMESPACE_ALGO 317# define _GLIBCXX_END_NAMESPACE_ALGO 318#endif 319 320#ifndef _GLIBCXX_BEGIN_NAMESPACE_CONTAINER 321# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER 322#endif 323 324#ifndef _GLIBCXX_END_NAMESPACE_CONTAINER 325# define _GLIBCXX_END_NAMESPACE_CONTAINER 326#endif 327 328// GLIBCXX_ABI Deprecated 329// Define if compatibility should be provided for -mlong-double-64. 330#undef _GLIBCXX_LONG_DOUBLE_COMPAT 331 332// Inline namespace for long double 128 mode. 333#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ 334namespace std 335{ 336 inline namespace __gnu_cxx_ldbl128 { } 337} 338# define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128:: 339# define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 { 340# define _GLIBCXX_END_NAMESPACE_LDBL } 341#else 342# define _GLIBCXX_NAMESPACE_LDBL 343# define _GLIBCXX_BEGIN_NAMESPACE_LDBL 344# define _GLIBCXX_END_NAMESPACE_LDBL 345#endif 346 347// Assert. 348#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PARALLEL) 349# define __glibcxx_assert(_Condition) 350#else 351namespace std 352{ 353 // Avoid the use of assert, because we're trying to keep the <cassert> 354 // include out of the mix. 355 inline void 356 __replacement_assert(const char* __file, int __line, 357 const char* __function, const char* __condition) 358 { 359 __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line, 360 __function, __condition); 361 __builtin_abort(); 362 } 363} 364#define __glibcxx_assert(_Condition) \ 365 do \ 366 { \ 367 if (! (_Condition)) \ 368 std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ 369 #_Condition); \ 370 } while (false) 371#endif 372 373// Macros for race detectors. 374// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and 375// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain 376// atomic (lock-free) synchronization to race detectors: 377// the race detector will infer a happens-before arc from the former to the 378// latter when they share the same argument pointer. 379// 380// The most frequent use case for these macros (and the only case in the 381// current implementation of the library) is atomic reference counting: 382// void _M_remove_reference() 383// { 384// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); 385// if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0) 386// { 387// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); 388// _M_destroy(__a); 389// } 390// } 391// The annotations in this example tell the race detector that all memory 392// accesses occurred when the refcount was positive do not race with 393// memory accesses which occurred after the refcount became zero. 394#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE 395# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) 396#endif 397#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER 398# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) 399#endif 400 401// Macros for C linkage: define extern "C" linkage only when using C++. 402# define _GLIBCXX_BEGIN_EXTERN_C extern "C" { 403# define _GLIBCXX_END_EXTERN_C } 404 405#else // !__cplusplus 406# define _GLIBCXX_BEGIN_EXTERN_C 407# define _GLIBCXX_END_EXTERN_C 408#endif 409 410 411// First includes. 412 413// Pick up any OS-specific definitions. 414#include <bits/os_defines.h> 415 416// Pick up any CPU-specific definitions. 417#include <bits/cpu_defines.h> 418 419// If platform uses neither visibility nor psuedo-visibility, 420// specify empty default for namespace annotation macros. 421#ifndef _GLIBCXX_PSEUDO_VISIBILITY 422# define _GLIBCXX_PSEUDO_VISIBILITY(V) 423#endif 424 425// Certain function definitions that are meant to be overridable from 426// user code are decorated with this macro. For some targets, this 427// macro causes these definitions to be weak. 428#ifndef _GLIBCXX_WEAK_DEFINITION 429# define _GLIBCXX_WEAK_DEFINITION 430#endif 431 432 433// The remainder of the prewritten config is automatic; all the 434// user hooks are listed above. 435 436// Create a boolean flag to be used to determine if --fast-math is set. 437#ifdef __FAST_MATH__ 438# define _GLIBCXX_FAST_MATH 1 439#else 440# define _GLIBCXX_FAST_MATH 0 441#endif 442 443// This marks string literals in header files to be extracted for eventual 444// translation. It is primarily used for messages in thrown exceptions; see 445// src/functexcept.cc. We use __N because the more traditional _N is used 446// for something else under certain OSes (see BADNAMES). 447#define __N(msgid) (msgid) 448 449// For example, <windows.h> is known to #define min and max as macros... 450#undef min 451#undef max 452 453// End of prewritten config; the settings discovered at configure time follow. 454