1From ef90544f8df369781a6ef094330c9cfa9f0ee1e4 Mon Sep 17 00:00:00 2001 2From: Khem Raj <raj.khem@gmail.com> 3Date: Thu, 29 Aug 2019 14:09:11 -0700 4Subject: [PATCH 2/4] boost: Backport clang support 5 6backport headers from boost 1.59 7 8Signed-off-by: Khem Raj <raj.khem@gmail.com> 9--- 10 lib/boost/config/compiler/clang.hpp | 272 +++++++++ 11 lib/boost/config/stdlib/libcpp.hpp | 80 +++ 12 lib/boost/cstdint.hpp | 542 ++++++++++++++++++ 13 .../detail/sp_counted_base_clang.hpp | 140 +++++ 14 4 files changed, 1034 insertions(+) 15 create mode 100644 lib/boost/config/compiler/clang.hpp 16 create mode 100644 lib/boost/config/stdlib/libcpp.hpp 17 create mode 100644 lib/boost/cstdint.hpp 18 create mode 100644 lib/boost/smart_ptr/detail/sp_counted_base_clang.hpp 19 20--- /dev/null 21+++ b/lib/boost/config/compiler/clang.hpp 22@@ -0,0 +1,272 @@ 23+ 24+// (C) Copyright Douglas Gregor 2010 25+// 26+// Use, modification and distribution are subject to the 27+// Boost Software License, Version 1.0. (See accompanying file 28+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 29+ 30+// See http://www.boost.org for most recent version. 31+ 32+// Clang compiler setup. 33+ 34+#define BOOST_HAS_PRAGMA_ONCE 35+ 36+// Detecting `-fms-extension` compiler flag assuming that _MSC_VER defined when that flag is used. 37+#if defined (_MSC_VER) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4)) 38+# define BOOST_HAS_PRAGMA_DETECT_MISMATCH 39+#endif 40+ 41+// When compiling with clang before __has_extension was defined, 42+// even if one writes 'defined(__has_extension) && __has_extension(xxx)', 43+// clang reports a compiler error. So the only workaround found is: 44+ 45+#ifndef __has_extension 46+#define __has_extension __has_feature 47+#endif 48+ 49+#if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS) 50+# define BOOST_NO_EXCEPTIONS 51+#endif 52+ 53+#if !__has_feature(cxx_rtti) && !defined(BOOST_NO_RTTI) 54+# define BOOST_NO_RTTI 55+#endif 56+ 57+#if !__has_feature(cxx_rtti) && !defined(BOOST_NO_TYPEID) 58+# define BOOST_NO_TYPEID 59+#endif 60+ 61+#if defined(__int64) && !defined(__GNUC__) 62+# define BOOST_HAS_MS_INT64 63+#endif 64+ 65+#define BOOST_HAS_NRVO 66+ 67+// Branch prediction hints 68+#if defined(__has_builtin) 69+#if __has_builtin(__builtin_expect) 70+#define BOOST_LIKELY(x) __builtin_expect(x, 1) 71+#define BOOST_UNLIKELY(x) __builtin_expect(x, 0) 72+#endif 73+#endif 74+ 75+// Clang supports "long long" in all compilation modes. 76+#define BOOST_HAS_LONG_LONG 77+ 78+// 79+// We disable this if the compiler is really nvcc as it 80+// doesn't actually support __int128 as of CUDA_VERSION=5000 81+// even though it defines __SIZEOF_INT128__. 82+// See https://svn.boost.org/trac/boost/ticket/10418 83+// Only re-enable this for nvcc if you're absolutely sure 84+// of the circumstances under which it's supported: 85+// 86+#if defined(__SIZEOF_INT128__) && !defined(__CUDACC__) 87+# define BOOST_HAS_INT128 88+#endif 89+ 90+ 91+// 92+// Dynamic shared object (DSO) and dynamic-link library (DLL) support 93+// 94+#if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32) 95+# define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default"))) 96+# define BOOST_SYMBOL_IMPORT 97+# define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default"))) 98+#endif 99+ 100+// 101+// The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through 102+// between switch labels. 103+// 104+#if __cplusplus >= 201103L && defined(__has_warning) 105+# if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") 106+# define BOOST_FALLTHROUGH [[clang::fallthrough]] 107+# endif 108+#endif 109+ 110+#if !__has_feature(cxx_auto_type) 111+# define BOOST_NO_CXX11_AUTO_DECLARATIONS 112+# define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS 113+#endif 114+ 115+// 116+// Currently clang on Windows using VC++ RTL does not support C++11's char16_t or char32_t 117+// 118+#if defined(_MSC_VER) || !(defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) 119+# define BOOST_NO_CXX11_CHAR16_T 120+# define BOOST_NO_CXX11_CHAR32_T 121+#endif 122+ 123+#if !__has_feature(cxx_constexpr) 124+# define BOOST_NO_CXX11_CONSTEXPR 125+#endif 126+ 127+#if !__has_feature(cxx_decltype) 128+# define BOOST_NO_CXX11_DECLTYPE 129+#endif 130+ 131+#if !__has_feature(cxx_decltype_incomplete_return_types) 132+# define BOOST_NO_CXX11_DECLTYPE_N3276 133+#endif 134+ 135+#if !__has_feature(cxx_defaulted_functions) 136+# define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS 137+#endif 138+ 139+#if !__has_feature(cxx_deleted_functions) 140+# define BOOST_NO_CXX11_DELETED_FUNCTIONS 141+#endif 142+ 143+#if !__has_feature(cxx_explicit_conversions) 144+# define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS 145+#endif 146+ 147+#if !__has_feature(cxx_default_function_template_args) 148+# define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS 149+#endif 150+ 151+#if !__has_feature(cxx_generalized_initializers) 152+# define BOOST_NO_CXX11_HDR_INITIALIZER_LIST 153+#endif 154+ 155+#if !__has_feature(cxx_lambdas) 156+# define BOOST_NO_CXX11_LAMBDAS 157+#endif 158+ 159+#if !__has_feature(cxx_local_type_template_args) 160+# define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS 161+#endif 162+ 163+#if !__has_feature(cxx_noexcept) 164+# define BOOST_NO_CXX11_NOEXCEPT 165+#endif 166+ 167+#if !__has_feature(cxx_nullptr) 168+# define BOOST_NO_CXX11_NULLPTR 169+#endif 170+ 171+#if !__has_feature(cxx_range_for) 172+# define BOOST_NO_CXX11_RANGE_BASED_FOR 173+#endif 174+ 175+#if !__has_feature(cxx_raw_string_literals) 176+# define BOOST_NO_CXX11_RAW_LITERALS 177+#endif 178+ 179+#if !__has_feature(cxx_reference_qualified_functions) 180+# define BOOST_NO_CXX11_REF_QUALIFIERS 181+#endif 182+ 183+#if !__has_feature(cxx_generalized_initializers) 184+# define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX 185+#endif 186+ 187+#if !__has_feature(cxx_rvalue_references) 188+# define BOOST_NO_CXX11_RVALUE_REFERENCES 189+#endif 190+ 191+#if !__has_feature(cxx_strong_enums) 192+# define BOOST_NO_CXX11_SCOPED_ENUMS 193+#endif 194+ 195+#if !__has_feature(cxx_static_assert) 196+# define BOOST_NO_CXX11_STATIC_ASSERT 197+#endif 198+ 199+#if !__has_feature(cxx_alias_templates) 200+# define BOOST_NO_CXX11_TEMPLATE_ALIASES 201+#endif 202+ 203+#if !__has_feature(cxx_unicode_literals) 204+# define BOOST_NO_CXX11_UNICODE_LITERALS 205+#endif 206+ 207+#if !__has_feature(cxx_variadic_templates) 208+# define BOOST_NO_CXX11_VARIADIC_TEMPLATES 209+#endif 210+ 211+#if !__has_feature(cxx_user_literals) 212+# define BOOST_NO_CXX11_USER_DEFINED_LITERALS 213+#endif 214+ 215+#if !__has_feature(cxx_alignas) 216+# define BOOST_NO_CXX11_ALIGNAS 217+#endif 218+ 219+#if !__has_feature(cxx_trailing_return) 220+# define BOOST_NO_CXX11_TRAILING_RESULT_TYPES 221+#endif 222+ 223+#if !__has_feature(cxx_inline_namespaces) 224+# define BOOST_NO_CXX11_INLINE_NAMESPACES 225+#endif 226+ 227+#if !__has_feature(cxx_override_control) 228+# define BOOST_NO_CXX11_FINAL 229+#endif 230+ 231+#if !(__has_feature(__cxx_binary_literals__) || __has_extension(__cxx_binary_literals__)) 232+# define BOOST_NO_CXX14_BINARY_LITERALS 233+#endif 234+ 235+#if !__has_feature(__cxx_decltype_auto__) 236+# define BOOST_NO_CXX14_DECLTYPE_AUTO 237+#endif 238+ 239+#if !__has_feature(__cxx_aggregate_nsdmi__) 240+# define BOOST_NO_CXX14_AGGREGATE_NSDMI 241+#endif 242+ 243+#if !__has_feature(__cxx_init_captures__) 244+# define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES 245+#endif 246+ 247+#if !__has_feature(__cxx_generic_lambdas__) 248+# define BOOST_NO_CXX14_GENERIC_LAMBDAS 249+#endif 250+ 251+// clang < 3.5 has a defect with dependent type, like following. 252+// 253+// template <class T> 254+// constexpr typename enable_if<pred<T> >::type foo(T &) 255+// { } // error: no return statement in constexpr function 256+// 257+// This issue also affects C++11 mode, but C++11 constexpr requires return stmt. 258+// Therefore we don't care such case. 259+// 260+// Note that we can't check Clang version directly as the numbering system changes depending who's 261+// creating the Clang release (see https://github.com/boostorg/config/pull/39#issuecomment-59927873) 262+// so instead verify that we have a feature that was introduced at the same time as working C++14 263+// constexpr (generic lambda's in this case): 264+// 265+#if !__has_feature(__cxx_generic_lambdas__) || !__has_feature(__cxx_relaxed_constexpr__) 266+# define BOOST_NO_CXX14_CONSTEXPR 267+#endif 268+ 269+#if !__has_feature(__cxx_return_type_deduction__) 270+# define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION 271+#endif 272+ 273+#if !__has_feature(__cxx_variable_templates__) 274+# define BOOST_NO_CXX14_VARIABLE_TEMPLATES 275+#endif 276+ 277+#if __cplusplus < 201400 278+// All versions with __cplusplus above this value seem to support this: 279+# define BOOST_NO_CXX14_DIGIT_SEPARATORS 280+#endif 281+ 282+ 283+// Unused attribute: 284+#if defined(__GNUC__) && (__GNUC__ >= 4) 285+# define BOOST_ATTRIBUTE_UNUSED __attribute__((unused)) 286+#endif 287+ 288+#ifndef BOOST_COMPILER 289+# define BOOST_COMPILER "Clang version " __clang_version__ 290+#endif 291+ 292+// Macro used to identify the Clang compiler. 293+#define BOOST_CLANG 1 294+ 295--- /dev/null 296+++ b/lib/boost/config/stdlib/libcpp.hpp 297@@ -0,0 +1,80 @@ 298+// (C) Copyright Christopher Jefferson 2011. 299+// Use, modification and distribution are subject to the 300+// Boost Software License, Version 1.0. (See accompanying file 301+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 302+ 303+// See http://www.boost.org for most recent version. 304+ 305+// config for libc++ 306+// Might need more in here later. 307+ 308+#if !defined(_LIBCPP_VERSION) 309+# include <ciso646> 310+# if !defined(_LIBCPP_VERSION) 311+# error "This is not libc++!" 312+# endif 313+#endif 314+ 315+#define BOOST_STDLIB "libc++ version " BOOST_STRINGIZE(_LIBCPP_VERSION) 316+ 317+#define BOOST_HAS_THREADS 318+ 319+#ifdef _LIBCPP_HAS_NO_VARIADICS 320+# define BOOST_NO_CXX11_HDR_TUPLE 321+#endif 322+ 323+// BOOST_NO_CXX11_ALLOCATOR should imply no support for the C++11 324+// allocator model. The C++11 allocator model requires a conforming 325+// std::allocator_traits which is only possible with C++11 template 326+// aliases since members rebind_alloc and rebind_traits require it. 327+#if defined(_LIBCPP_HAS_NO_TEMPLATE_ALIASES) 328+# define BOOST_NO_CXX11_ALLOCATOR 329+#endif 330+ 331+#if __cplusplus < 201103 332+# define BOOST_NO_CXX11_HDR_ARRAY 333+# define BOOST_NO_CXX11_HDR_CODECVT 334+# define BOOST_NO_CXX11_HDR_CONDITION_VARIABLE 335+# define BOOST_NO_CXX11_HDR_FORWARD_LIST 336+# define BOOST_NO_CXX11_HDR_INITIALIZER_LIST 337+# define BOOST_NO_CXX11_HDR_MUTEX 338+# define BOOST_NO_CXX11_HDR_RANDOM 339+# define BOOST_NO_CXX11_HDR_RATIO 340+# define BOOST_NO_CXX11_HDR_REGEX 341+# define BOOST_NO_CXX11_HDR_SYSTEM_ERROR 342+# define BOOST_NO_CXX11_HDR_THREAD 343+# define BOOST_NO_CXX11_HDR_TUPLE 344+# define BOOST_NO_CXX11_HDR_TYPEINDEX 345+# define BOOST_NO_CXX11_HDR_UNORDERED_MAP 346+# define BOOST_NO_CXX11_HDR_UNORDERED_SET 347+# define BOOST_NO_CXX11_NUMERIC_LIMITS 348+# define BOOST_NO_CXX11_ALLOCATOR 349+# define BOOST_NO_CXX11_SMART_PTR 350+# define BOOST_NO_CXX11_HDR_FUNCTIONAL 351+# define BOOST_NO_CXX11_STD_ALIGN 352+# define BOOST_NO_CXX11_ADDRESSOF 353+#endif 354+ 355+// 356+// These appear to be unusable/incomplete so far: 357+// 358+# define BOOST_NO_CXX11_HDR_CHRONO 359+# define BOOST_NO_CXX11_HDR_FUTURE 360+# define BOOST_NO_CXX11_HDR_TYPE_TRAITS 361+# define BOOST_NO_CXX11_ATOMIC_SMART_PTR 362+# define BOOST_NO_CXX11_HDR_ATOMIC 363+ 364+// libc++ uses a non-standard messages_base 365+#define BOOST_NO_STD_MESSAGES 366+ 367+#if defined(__has_include) 368+#if !__has_include(<shared_mutex>) 369+# define BOOST_NO_CXX14_HDR_SHARED_MUTEX 370+#elif __cplusplus <= 201103 371+# define BOOST_NO_CXX14_HDR_SHARED_MUTEX 372+#endif 373+#elif __cplusplus < 201402 374+# define BOOST_NO_CXX14_HDR_SHARED_MUTEX 375+#endif 376+ 377+// --- end --- 378--- /dev/null 379+++ b/lib/boost/cstdint.hpp 380@@ -0,0 +1,542 @@ 381+// boost cstdint.hpp header file ------------------------------------------// 382+ 383+// (C) Copyright Beman Dawes 1999. 384+// (C) Copyright Jens Mauer 2001 385+// (C) Copyright John Maddock 2001 386+// Distributed under the Boost 387+// Software License, Version 1.0. (See accompanying file 388+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 389+ 390+// See http://www.boost.org/libs/integer for documentation. 391+ 392+// Revision History 393+// 31 Oct 01 use BOOST_HAS_LONG_LONG to check for "long long" (Jens M.) 394+// 16 Apr 01 check LONGLONG_MAX when looking for "long long" (Jens Maurer) 395+// 23 Jan 01 prefer "long" over "int" for int32_t and intmax_t (Jens Maurer) 396+// 12 Nov 00 Merged <boost/stdint.h> (Jens Maurer) 397+// 23 Sep 00 Added INTXX_C macro support (John Maddock). 398+// 22 Sep 00 Better 64-bit support (John Maddock) 399+// 29 Jun 00 Reimplement to avoid including stdint.h within namespace boost 400+// 8 Aug 99 Initial version (Beman Dawes) 401+ 402+ 403+#ifndef BOOST_CSTDINT_HPP 404+#define BOOST_CSTDINT_HPP 405+ 406+// 407+// Since we always define the INT#_C macros as per C++0x, 408+// define __STDC_CONSTANT_MACROS so that <stdint.h> does the right 409+// thing if possible, and so that the user knows that the macros 410+// are actually defined as per C99. 411+// 412+#ifndef __STDC_CONSTANT_MACROS 413+# define __STDC_CONSTANT_MACROS 414+#endif 415+ 416+#include <boost/config.hpp> 417+ 418+// 419+// Note that GLIBC is a bit inconsistent about whether int64_t is defined or not 420+// depending upon what headers happen to have been included first... 421+// so we disable use of stdint.h when GLIBC does not define __GLIBC_HAVE_LONG_LONG. 422+// See https://svn.boost.org/trac/boost/ticket/3548 and http://sources.redhat.com/bugzilla/show_bug.cgi?id=10990 423+// 424+#if defined(BOOST_HAS_STDINT_H) \ 425+ && (!defined(__GLIBC__) \ 426+ || defined(__GLIBC_HAVE_LONG_LONG) \ 427+ || (defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 17))))) 428+ 429+// The following #include is an implementation artifact; not part of interface. 430+# ifdef __hpux 431+// HP-UX has a vaguely nice <stdint.h> in a non-standard location 432+# include <inttypes.h> 433+# ifdef __STDC_32_MODE__ 434+ // this is triggered with GCC, because it defines __cplusplus < 199707L 435+# define BOOST_NO_INT64_T 436+# endif 437+# elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX) 438+# include <inttypes.h> 439+# else 440+# include <stdint.h> 441+ 442+// There is a bug in Cygwin two _C macros 443+# if defined(__STDC_CONSTANT_MACROS) && defined(__CYGWIN__) 444+# undef INTMAX_C 445+# undef UINTMAX_C 446+# define INTMAX_C(c) c##LL 447+# define UINTMAX_C(c) c##ULL 448+# endif 449+ 450+# endif 451+ 452+#ifdef __QNX__ 453+ 454+// QNX (Dinkumware stdlib) defines these as non-standard names. 455+// Reflect to the standard names. 456+ 457+typedef ::intleast8_t int_least8_t; 458+typedef ::intfast8_t int_fast8_t; 459+typedef ::uintleast8_t uint_least8_t; 460+typedef ::uintfast8_t uint_fast8_t; 461+ 462+typedef ::intleast16_t int_least16_t; 463+typedef ::intfast16_t int_fast16_t; 464+typedef ::uintleast16_t uint_least16_t; 465+typedef ::uintfast16_t uint_fast16_t; 466+ 467+typedef ::intleast32_t int_least32_t; 468+typedef ::intfast32_t int_fast32_t; 469+typedef ::uintleast32_t uint_least32_t; 470+typedef ::uintfast32_t uint_fast32_t; 471+ 472+# ifndef BOOST_NO_INT64_T 473+ 474+typedef ::intleast64_t int_least64_t; 475+typedef ::intfast64_t int_fast64_t; 476+typedef ::uintleast64_t uint_least64_t; 477+typedef ::uintfast64_t uint_fast64_t; 478+ 479+# endif 480+ 481+#endif 482+ 483+namespace boost 484+{ 485+ 486+ using ::int8_t; 487+ using ::int_least8_t; 488+ using ::int_fast8_t; 489+ using ::uint8_t; 490+ using ::uint_least8_t; 491+ using ::uint_fast8_t; 492+ 493+ using ::int16_t; 494+ using ::int_least16_t; 495+ using ::int_fast16_t; 496+ using ::uint16_t; 497+ using ::uint_least16_t; 498+ using ::uint_fast16_t; 499+ 500+ using ::int32_t; 501+ using ::int_least32_t; 502+ using ::int_fast32_t; 503+ using ::uint32_t; 504+ using ::uint_least32_t; 505+ using ::uint_fast32_t; 506+ 507+# ifndef BOOST_NO_INT64_T 508+ 509+ using ::int64_t; 510+ using ::int_least64_t; 511+ using ::int_fast64_t; 512+ using ::uint64_t; 513+ using ::uint_least64_t; 514+ using ::uint_fast64_t; 515+ 516+# endif 517+ 518+ using ::intmax_t; 519+ using ::uintmax_t; 520+ 521+} // namespace boost 522+ 523+#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4) || defined(__osf__) || defined(__VMS) || defined(__SOLARIS9__) || defined(__NetBSD__) 524+// FreeBSD and Tru64 have an <inttypes.h> that contains much of what we need. 525+# include <inttypes.h> 526+ 527+namespace boost { 528+ 529+ using ::int8_t; 530+ typedef int8_t int_least8_t; 531+ typedef int8_t int_fast8_t; 532+ using ::uint8_t; 533+ typedef uint8_t uint_least8_t; 534+ typedef uint8_t uint_fast8_t; 535+ 536+ using ::int16_t; 537+ typedef int16_t int_least16_t; 538+ typedef int16_t int_fast16_t; 539+ using ::uint16_t; 540+ typedef uint16_t uint_least16_t; 541+ typedef uint16_t uint_fast16_t; 542+ 543+ using ::int32_t; 544+ typedef int32_t int_least32_t; 545+ typedef int32_t int_fast32_t; 546+ using ::uint32_t; 547+ typedef uint32_t uint_least32_t; 548+ typedef uint32_t uint_fast32_t; 549+ 550+# ifndef BOOST_NO_INT64_T 551+ 552+ using ::int64_t; 553+ typedef int64_t int_least64_t; 554+ typedef int64_t int_fast64_t; 555+ using ::uint64_t; 556+ typedef uint64_t uint_least64_t; 557+ typedef uint64_t uint_fast64_t; 558+ 559+ typedef int64_t intmax_t; 560+ typedef uint64_t uintmax_t; 561+ 562+# else 563+ 564+ typedef int32_t intmax_t; 565+ typedef uint32_t uintmax_t; 566+ 567+# endif 568+ 569+} // namespace boost 570+ 571+#else // BOOST_HAS_STDINT_H 572+ 573+# include <boost/limits.hpp> // implementation artifact; not part of interface 574+# include <limits.h> // needed for limits macros 575+ 576+ 577+namespace boost 578+{ 579+ 580+// These are fairly safe guesses for some 16-bit, and most 32-bit and 64-bit 581+// platforms. For other systems, they will have to be hand tailored. 582+// 583+// Because the fast types are assumed to be the same as the undecorated types, 584+// it may be possible to hand tailor a more efficient implementation. Such 585+// an optimization may be illusionary; on the Intel x86-family 386 on, for 586+// example, byte arithmetic and load/stores are as fast as "int" sized ones. 587+ 588+// 8-bit types ------------------------------------------------------------// 589+ 590+# if UCHAR_MAX == 0xff 591+ typedef signed char int8_t; 592+ typedef signed char int_least8_t; 593+ typedef signed char int_fast8_t; 594+ typedef unsigned char uint8_t; 595+ typedef unsigned char uint_least8_t; 596+ typedef unsigned char uint_fast8_t; 597+# else 598+# error defaults not correct; you must hand modify boost/cstdint.hpp 599+# endif 600+ 601+// 16-bit types -----------------------------------------------------------// 602+ 603+# if USHRT_MAX == 0xffff 604+# if defined(__crayx1) 605+ // The Cray X1 has a 16-bit short, however it is not recommend 606+ // for use in performance critical code. 607+ typedef short int16_t; 608+ typedef short int_least16_t; 609+ typedef int int_fast16_t; 610+ typedef unsigned short uint16_t; 611+ typedef unsigned short uint_least16_t; 612+ typedef unsigned int uint_fast16_t; 613+# else 614+ typedef short int16_t; 615+ typedef short int_least16_t; 616+ typedef short int_fast16_t; 617+ typedef unsigned short uint16_t; 618+ typedef unsigned short uint_least16_t; 619+ typedef unsigned short uint_fast16_t; 620+# endif 621+# elif (USHRT_MAX == 0xffffffff) && defined(__MTA__) 622+ // On MTA / XMT short is 32 bits unless the -short16 compiler flag is specified 623+ // MTA / XMT does support the following non-standard integer types 624+ typedef __short16 int16_t; 625+ typedef __short16 int_least16_t; 626+ typedef __short16 int_fast16_t; 627+ typedef unsigned __short16 uint16_t; 628+ typedef unsigned __short16 uint_least16_t; 629+ typedef unsigned __short16 uint_fast16_t; 630+# elif (USHRT_MAX == 0xffffffff) && defined(CRAY) 631+ // no 16-bit types on Cray: 632+ typedef short int_least16_t; 633+ typedef short int_fast16_t; 634+ typedef unsigned short uint_least16_t; 635+ typedef unsigned short uint_fast16_t; 636+# else 637+# error defaults not correct; you must hand modify boost/cstdint.hpp 638+# endif 639+ 640+// 32-bit types -----------------------------------------------------------// 641+ 642+# if UINT_MAX == 0xffffffff 643+ typedef int int32_t; 644+ typedef int int_least32_t; 645+ typedef int int_fast32_t; 646+ typedef unsigned int uint32_t; 647+ typedef unsigned int uint_least32_t; 648+ typedef unsigned int uint_fast32_t; 649+# elif (USHRT_MAX == 0xffffffff) 650+ typedef short int32_t; 651+ typedef short int_least32_t; 652+ typedef short int_fast32_t; 653+ typedef unsigned short uint32_t; 654+ typedef unsigned short uint_least32_t; 655+ typedef unsigned short uint_fast32_t; 656+# elif ULONG_MAX == 0xffffffff 657+ typedef long int32_t; 658+ typedef long int_least32_t; 659+ typedef long int_fast32_t; 660+ typedef unsigned long uint32_t; 661+ typedef unsigned long uint_least32_t; 662+ typedef unsigned long uint_fast32_t; 663+# elif (UINT_MAX == 0xffffffffffffffff) && defined(__MTA__) 664+ // Integers are 64 bits on the MTA / XMT 665+ typedef __int32 int32_t; 666+ typedef __int32 int_least32_t; 667+ typedef __int32 int_fast32_t; 668+ typedef unsigned __int32 uint32_t; 669+ typedef unsigned __int32 uint_least32_t; 670+ typedef unsigned __int32 uint_fast32_t; 671+# else 672+# error defaults not correct; you must hand modify boost/cstdint.hpp 673+# endif 674+ 675+// 64-bit types + intmax_t and uintmax_t ----------------------------------// 676+ 677+# if defined(BOOST_HAS_LONG_LONG) && \ 678+ !defined(BOOST_MSVC) && !defined(__BORLANDC__) && \ 679+ (!defined(__GLIBCPP__) || defined(_GLIBCPP_USE_LONG_LONG)) && \ 680+ (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX)) 681+# if defined(__hpux) 682+ // HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions 683+# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615ULL) || (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615ULL) || (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615ULL) 684+ // 2**64 - 1 685+# else 686+# error defaults not correct; you must hand modify boost/cstdint.hpp 687+# endif 688+ 689+ typedef ::boost::long_long_type intmax_t; 690+ typedef ::boost::ulong_long_type uintmax_t; 691+ typedef ::boost::long_long_type int64_t; 692+ typedef ::boost::long_long_type int_least64_t; 693+ typedef ::boost::long_long_type int_fast64_t; 694+ typedef ::boost::ulong_long_type uint64_t; 695+ typedef ::boost::ulong_long_type uint_least64_t; 696+ typedef ::boost::ulong_long_type uint_fast64_t; 697+ 698+# elif ULONG_MAX != 0xffffffff 699+ 700+# if ULONG_MAX == 18446744073709551615 // 2**64 - 1 701+ typedef long intmax_t; 702+ typedef unsigned long uintmax_t; 703+ typedef long int64_t; 704+ typedef long int_least64_t; 705+ typedef long int_fast64_t; 706+ typedef unsigned long uint64_t; 707+ typedef unsigned long uint_least64_t; 708+ typedef unsigned long uint_fast64_t; 709+# else 710+# error defaults not correct; you must hand modify boost/cstdint.hpp 711+# endif 712+# elif defined(__GNUC__) && defined(BOOST_HAS_LONG_LONG) 713+ __extension__ typedef long long intmax_t; 714+ __extension__ typedef unsigned long long uintmax_t; 715+ __extension__ typedef long long int64_t; 716+ __extension__ typedef long long int_least64_t; 717+ __extension__ typedef long long int_fast64_t; 718+ __extension__ typedef unsigned long long uint64_t; 719+ __extension__ typedef unsigned long long uint_least64_t; 720+ __extension__ typedef unsigned long long uint_fast64_t; 721+# elif defined(BOOST_HAS_MS_INT64) 722+ // 723+ // we have Borland/Intel/Microsoft __int64: 724+ // 725+ typedef __int64 intmax_t; 726+ typedef unsigned __int64 uintmax_t; 727+ typedef __int64 int64_t; 728+ typedef __int64 int_least64_t; 729+ typedef __int64 int_fast64_t; 730+ typedef unsigned __int64 uint64_t; 731+ typedef unsigned __int64 uint_least64_t; 732+ typedef unsigned __int64 uint_fast64_t; 733+# else // assume no 64-bit integers 734+# define BOOST_NO_INT64_T 735+ typedef int32_t intmax_t; 736+ typedef uint32_t uintmax_t; 737+# endif 738+ 739+} // namespace boost 740+ 741+ 742+#endif // BOOST_HAS_STDINT_H 743+ 744+// intptr_t/uintptr_t are defined separately because they are optional and not universally available 745+#if defined(BOOST_WINDOWS) && !defined(_WIN32_WCE) && !defined(BOOST_HAS_STDINT_H) 746+// Older MSVC don't have stdint.h and have intptr_t/uintptr_t defined in stddef.h 747+#include <stddef.h> 748+#endif 749+ 750+// PGI seems to not support intptr_t/uintptr_t properly. BOOST_HAS_STDINT_H is not defined for this compiler by Boost.Config. 751+#if !defined(__PGIC__) 752+ 753+#if (defined(BOOST_WINDOWS) && !defined(_WIN32_WCE)) \ 754+ || (defined(_XOPEN_UNIX) && (_XOPEN_UNIX+0 > 0) && !defined(__UCLIBC__)) \ 755+ || defined(__CYGWIN__) \ 756+ || defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) \ 757+ || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(sun) 758+ 759+namespace boost { 760+ using ::intptr_t; 761+ using ::uintptr_t; 762+} 763+#define BOOST_HAS_INTPTR_T 764+ 765+// Clang pretends to be GCC, so it'll match this condition 766+#elif defined(__GNUC__) && defined(__INTPTR_TYPE__) && defined(__UINTPTR_TYPE__) 767+ 768+namespace boost { 769+ typedef __INTPTR_TYPE__ intptr_t; 770+ typedef __UINTPTR_TYPE__ uintptr_t; 771+} 772+#define BOOST_HAS_INTPTR_T 773+ 774+#endif 775+ 776+#endif // !defined(__PGIC__) 777+ 778+#endif // BOOST_CSTDINT_HPP 779+ 780+ 781+/**************************************************** 782+ 783+Macro definition section: 784+ 785+Added 23rd September 2000 (John Maddock). 786+Modified 11th September 2001 to be excluded when 787+BOOST_HAS_STDINT_H is defined (John Maddock). 788+Modified 11th Dec 2009 to always define the 789+INT#_C macros if they're not already defined (John Maddock). 790+ 791+******************************************************/ 792+ 793+#if !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && \ 794+ (!defined(INT8_C) || !defined(INT16_C) || !defined(INT32_C) || !defined(INT64_C)) 795+// 796+// For the following code we get several warnings along the lines of: 797+// 798+// boost/cstdint.hpp:428:35: error: use of C99 long long integer constant 799+// 800+// So we declare this a system header to suppress these warnings. 801+// 802+#if defined(__GNUC__) && (__GNUC__ >= 4) 803+#pragma GCC system_header 804+#endif 805+ 806+#include <limits.h> 807+# define BOOST__STDC_CONSTANT_MACROS_DEFINED 808+# if defined(BOOST_HAS_MS_INT64) 809+// 810+// Borland/Intel/Microsoft compilers have width specific suffixes: 811+// 812+#ifndef INT8_C 813+# define INT8_C(value) value##i8 814+#endif 815+#ifndef INT16_C 816+# define INT16_C(value) value##i16 817+#endif 818+#ifndef INT32_C 819+# define INT32_C(value) value##i32 820+#endif 821+#ifndef INT64_C 822+# define INT64_C(value) value##i64 823+#endif 824+# ifdef __BORLANDC__ 825+ // Borland bug: appending ui8 makes the type a signed char 826+# define UINT8_C(value) static_cast<unsigned char>(value##u) 827+# else 828+# define UINT8_C(value) value##ui8 829+# endif 830+#ifndef UINT16_C 831+# define UINT16_C(value) value##ui16 832+#endif 833+#ifndef UINT32_C 834+# define UINT32_C(value) value##ui32 835+#endif 836+#ifndef UINT64_C 837+# define UINT64_C(value) value##ui64 838+#endif 839+#ifndef INTMAX_C 840+# define INTMAX_C(value) value##i64 841+# define UINTMAX_C(value) value##ui64 842+#endif 843+ 844+# else 845+// do it the old fashioned way: 846+ 847+// 8-bit types ------------------------------------------------------------// 848+ 849+# if (UCHAR_MAX == 0xff) && !defined(INT8_C) 850+# define INT8_C(value) static_cast<boost::int8_t>(value) 851+# define UINT8_C(value) static_cast<boost::uint8_t>(value##u) 852+# endif 853+ 854+// 16-bit types -----------------------------------------------------------// 855+ 856+# if (USHRT_MAX == 0xffff) && !defined(INT16_C) 857+# define INT16_C(value) static_cast<boost::int16_t>(value) 858+# define UINT16_C(value) static_cast<boost::uint16_t>(value##u) 859+# endif 860+ 861+// 32-bit types -----------------------------------------------------------// 862+#ifndef INT32_C 863+# if (UINT_MAX == 0xffffffff) 864+# define INT32_C(value) value 865+# define UINT32_C(value) value##u 866+# elif ULONG_MAX == 0xffffffff 867+# define INT32_C(value) value##L 868+# define UINT32_C(value) value##uL 869+# endif 870+#endif 871+ 872+// 64-bit types + intmax_t and uintmax_t ----------------------------------// 873+#ifndef INT64_C 874+# if defined(BOOST_HAS_LONG_LONG) && \ 875+ (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX) || defined(_ULLONG_MAX) || defined(_LLONG_MAX)) 876+ 877+# if defined(__hpux) 878+ // HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions 879+# define INT64_C(value) value##LL 880+# define UINT64_C(value) value##uLL 881+# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615ULL) || \ 882+ (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615ULL) || \ 883+ (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615ULL) || \ 884+ (defined(_ULLONG_MAX) && _ULLONG_MAX == 18446744073709551615ULL) || \ 885+ (defined(_LLONG_MAX) && _LLONG_MAX == 9223372036854775807LL) 886+ 887+# define INT64_C(value) value##LL 888+# define UINT64_C(value) value##uLL 889+# else 890+# error defaults not correct; you must hand modify boost/cstdint.hpp 891+# endif 892+# elif ULONG_MAX != 0xffffffff 893+ 894+# if ULONG_MAX == 18446744073709551615U // 2**64 - 1 895+# define INT64_C(value) value##L 896+# define UINT64_C(value) value##uL 897+# else 898+# error defaults not correct; you must hand modify boost/cstdint.hpp 899+# endif 900+# elif defined(BOOST_HAS_LONG_LONG) 901+ // Usual macros not defined, work things out for ourselves: 902+# if(~0uLL == 18446744073709551615ULL) 903+# define INT64_C(value) value##LL 904+# define UINT64_C(value) value##uLL 905+# else 906+# error defaults not correct; you must hand modify boost/cstdint.hpp 907+# endif 908+# else 909+# error defaults not correct; you must hand modify boost/cstdint.hpp 910+# endif 911+ 912+# ifdef BOOST_NO_INT64_T 913+# define INTMAX_C(value) INT32_C(value) 914+# define UINTMAX_C(value) UINT32_C(value) 915+# else 916+# define INTMAX_C(value) INT64_C(value) 917+# define UINTMAX_C(value) UINT64_C(value) 918+# endif 919+#endif 920+# endif // Borland/Microsoft specific width suffixes 921+ 922+#endif // INT#_C macros. 923--- /dev/null 924+++ b/lib/boost/smart_ptr/detail/sp_counted_base_clang.hpp 925@@ -0,0 +1,140 @@ 926+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CLANG_HPP_INCLUDED 927+#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CLANG_HPP_INCLUDED 928+ 929+// MS compatible compilers support #pragma once 930+ 931+#if defined(_MSC_VER) && (_MSC_VER >= 1020) 932+# pragma once 933+#endif 934+ 935+// detail/sp_counted_base_clang.hpp - __c11 clang intrinsics 936+// 937+// Copyright (c) 2007, 2013, 2015 Peter Dimov 938+// 939+// Distributed under the Boost Software License, Version 1.0. 940+// See accompanying file LICENSE_1_0.txt or copy at 941+// http://www.boost.org/LICENSE_1_0.txt 942+ 943+#include <boost/detail/sp_typeinfo.hpp> 944+#include <boost/cstdint.hpp> 945+ 946+namespace boost 947+{ 948+ 949+namespace detail 950+{ 951+ 952+typedef _Atomic( boost::int_least32_t ) atomic_int_least32_t; 953+ 954+inline void atomic_increment( atomic_int_least32_t * pw ) 955+{ 956+ __c11_atomic_fetch_add( pw, 1, __ATOMIC_RELAXED ); 957+} 958+ 959+inline boost::int_least32_t atomic_decrement( atomic_int_least32_t * pw ) 960+{ 961+ return __c11_atomic_fetch_sub( pw, 1, __ATOMIC_ACQ_REL ); 962+} 963+ 964+inline boost::int_least32_t atomic_conditional_increment( atomic_int_least32_t * pw ) 965+{ 966+ // long r = *pw; 967+ // if( r != 0 ) ++*pw; 968+ // return r; 969+ 970+ boost::int_least32_t r = __c11_atomic_load( pw, __ATOMIC_RELAXED ); 971+ 972+ for( ;; ) 973+ { 974+ if( r == 0 ) 975+ { 976+ return r; 977+ } 978+ 979+ if( __c11_atomic_compare_exchange_weak( pw, &r, r + 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED ) ) 980+ { 981+ return r; 982+ } 983+ } 984+} 985+ 986+class sp_counted_base 987+{ 988+private: 989+ 990+ sp_counted_base( sp_counted_base const & ); 991+ sp_counted_base & operator= ( sp_counted_base const & ); 992+ 993+ atomic_int_least32_t use_count_; // #shared 994+ atomic_int_least32_t weak_count_; // #weak + (#shared != 0) 995+ 996+public: 997+ 998+ sp_counted_base() 999+ { 1000+ __c11_atomic_init( &use_count_, 1 ); 1001+ __c11_atomic_init( &weak_count_, 1 ); 1002+ } 1003+ 1004+ virtual ~sp_counted_base() // nothrow 1005+ { 1006+ } 1007+ 1008+ // dispose() is called when use_count_ drops to zero, to release 1009+ // the resources managed by *this. 1010+ 1011+ virtual void dispose() = 0; // nothrow 1012+ 1013+ // destroy() is called when weak_count_ drops to zero. 1014+ 1015+ virtual void destroy() // nothrow 1016+ { 1017+ delete this; 1018+ } 1019+ 1020+ virtual void * get_deleter( sp_typeinfo const & ti ) = 0; 1021+ virtual void * get_untyped_deleter() = 0; 1022+ 1023+ void add_ref_copy() 1024+ { 1025+ atomic_increment( &use_count_ ); 1026+ } 1027+ 1028+ bool add_ref_lock() // true on success 1029+ { 1030+ return atomic_conditional_increment( &use_count_ ) != 0; 1031+ } 1032+ 1033+ void release() // nothrow 1034+ { 1035+ if( atomic_decrement( &use_count_ ) == 1 ) 1036+ { 1037+ dispose(); 1038+ weak_release(); 1039+ } 1040+ } 1041+ 1042+ void weak_add_ref() // nothrow 1043+ { 1044+ atomic_increment( &weak_count_ ); 1045+ } 1046+ 1047+ void weak_release() // nothrow 1048+ { 1049+ if( atomic_decrement( &weak_count_ ) == 1 ) 1050+ { 1051+ destroy(); 1052+ } 1053+ } 1054+ 1055+ long use_count() const // nothrow 1056+ { 1057+ return __c11_atomic_load( const_cast< atomic_int_least32_t* >( &use_count_ ), __ATOMIC_ACQUIRE ); 1058+ } 1059+}; 1060+ 1061+} // namespace detail 1062+ 1063+} // namespace boost 1064+ 1065+#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CLANG_HPP_INCLUDED 1066--- /dev/null 1067+++ b/lib/boost/smart_ptr/detail/sp_counted_base_sync.hpp 1068@@ -0,0 +1,156 @@ 1069+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED 1070+#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED 1071+ 1072+// MS compatible compilers support #pragma once 1073+ 1074+#if defined(_MSC_VER) && (_MSC_VER >= 1020) 1075+# pragma once 1076+#endif 1077+ 1078+// detail/sp_counted_base_sync.hpp - g++ 4.1+ __sync intrinsics 1079+// 1080+// Copyright (c) 2007 Peter Dimov 1081+// 1082+// Distributed under the Boost Software License, Version 1.0. 1083+// See accompanying file LICENSE_1_0.txt or copy at 1084+// http://www.boost.org/LICENSE_1_0.txt 1085+ 1086+#include <boost/detail/sp_typeinfo.hpp> 1087+#include <limits.h> 1088+ 1089+#if defined( __ia64__ ) && defined( __INTEL_COMPILER ) 1090+# include <ia64intrin.h> 1091+#endif 1092+ 1093+namespace boost 1094+{ 1095+ 1096+namespace detail 1097+{ 1098+ 1099+#if INT_MAX >= 2147483647 1100+ 1101+typedef int sp_int32_t; 1102+ 1103+#else 1104+ 1105+typedef long sp_int32_t; 1106+ 1107+#endif 1108+ 1109+inline void atomic_increment( sp_int32_t * pw ) 1110+{ 1111+ __sync_fetch_and_add( pw, 1 ); 1112+} 1113+ 1114+inline sp_int32_t atomic_decrement( sp_int32_t * pw ) 1115+{ 1116+ return __sync_fetch_and_add( pw, -1 ); 1117+} 1118+ 1119+inline sp_int32_t atomic_conditional_increment( sp_int32_t * pw ) 1120+{ 1121+ // long r = *pw; 1122+ // if( r != 0 ) ++*pw; 1123+ // return r; 1124+ 1125+ sp_int32_t r = *pw; 1126+ 1127+ for( ;; ) 1128+ { 1129+ if( r == 0 ) 1130+ { 1131+ return r; 1132+ } 1133+ 1134+ sp_int32_t r2 = __sync_val_compare_and_swap( pw, r, r + 1 ); 1135+ 1136+ if( r2 == r ) 1137+ { 1138+ return r; 1139+ } 1140+ else 1141+ { 1142+ r = r2; 1143+ } 1144+ } 1145+} 1146+ 1147+class sp_counted_base 1148+{ 1149+private: 1150+ 1151+ sp_counted_base( sp_counted_base const & ); 1152+ sp_counted_base & operator= ( sp_counted_base const & ); 1153+ 1154+ sp_int32_t use_count_; // #shared 1155+ sp_int32_t weak_count_; // #weak + (#shared != 0) 1156+ 1157+public: 1158+ 1159+ sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) 1160+ { 1161+ } 1162+ 1163+ virtual ~sp_counted_base() // nothrow 1164+ { 1165+ } 1166+ 1167+ // dispose() is called when use_count_ drops to zero, to release 1168+ // the resources managed by *this. 1169+ 1170+ virtual void dispose() = 0; // nothrow 1171+ 1172+ // destroy() is called when weak_count_ drops to zero. 1173+ 1174+ virtual void destroy() // nothrow 1175+ { 1176+ delete this; 1177+ } 1178+ 1179+ virtual void * get_deleter( sp_typeinfo const & ti ) = 0; 1180+ virtual void * get_untyped_deleter() = 0; 1181+ 1182+ void add_ref_copy() 1183+ { 1184+ atomic_increment( &use_count_ ); 1185+ } 1186+ 1187+ bool add_ref_lock() // true on success 1188+ { 1189+ return atomic_conditional_increment( &use_count_ ) != 0; 1190+ } 1191+ 1192+ void release() // nothrow 1193+ { 1194+ if( atomic_decrement( &use_count_ ) == 1 ) 1195+ { 1196+ dispose(); 1197+ weak_release(); 1198+ } 1199+ } 1200+ 1201+ void weak_add_ref() // nothrow 1202+ { 1203+ atomic_increment( &weak_count_ ); 1204+ } 1205+ 1206+ void weak_release() // nothrow 1207+ { 1208+ if( atomic_decrement( &weak_count_ ) == 1 ) 1209+ { 1210+ destroy(); 1211+ } 1212+ } 1213+ 1214+ long use_count() const // nothrow 1215+ { 1216+ return const_cast< sp_int32_t const volatile & >( use_count_ ); 1217+ } 1218+}; 1219+ 1220+} // namespace detail 1221+ 1222+} // namespace boost 1223+ 1224+#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED 1225--- /dev/null 1226+++ b/lib/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp 1227@@ -0,0 +1,182 @@ 1228+#ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED 1229+#define BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED 1230+ 1231+// MS compatible compilers support #pragma once 1232+ 1233+#if defined(_MSC_VER) && (_MSC_VER >= 1020) 1234+# pragma once 1235+#endif 1236+ 1237+// 1238+// detail/sp_counted_base_gcc_mips.hpp - g++ on MIPS 1239+// 1240+// Copyright (c) 2009, Spirent Communications, Inc. 1241+// 1242+// Distributed under the Boost Software License, Version 1.0. (See 1243+// accompanying file LICENSE_1_0.txt or copy at 1244+// http://www.boost.org/LICENSE_1_0.txt) 1245+// 1246+// 1247+// Lock-free algorithm by Alexander Terekhov 1248+// 1249+ 1250+#include <boost/detail/sp_typeinfo.hpp> 1251+ 1252+namespace boost 1253+{ 1254+ 1255+namespace detail 1256+{ 1257+ 1258+inline void atomic_increment( int * pw ) 1259+{ 1260+ // ++*pw; 1261+ 1262+ int tmp; 1263+ 1264+ __asm__ __volatile__ 1265+ ( 1266+ "0:\n\t" 1267+ ".set push\n\t" 1268+ ".set mips2\n\t" 1269+ "ll %0, %1\n\t" 1270+ "addiu %0, 1\n\t" 1271+ "sc %0, %1\n\t" 1272+ ".set pop\n\t" 1273+ "beqz %0, 0b": 1274+ "=&r"( tmp ), "=m"( *pw ): 1275+ "m"( *pw ) 1276+ ); 1277+} 1278+ 1279+inline int atomic_decrement( int * pw ) 1280+{ 1281+ // return --*pw; 1282+ 1283+ int rv, tmp; 1284+ 1285+ __asm__ __volatile__ 1286+ ( 1287+ "0:\n\t" 1288+ ".set push\n\t" 1289+ ".set mips2\n\t" 1290+ "ll %1, %2\n\t" 1291+ "addiu %0, %1, -1\n\t" 1292+ "sc %0, %2\n\t" 1293+ ".set pop\n\t" 1294+ "beqz %0, 0b\n\t" 1295+ "addiu %0, %1, -1": 1296+ "=&r"( rv ), "=&r"( tmp ), "=m"( *pw ): 1297+ "m"( *pw ): 1298+ "memory" 1299+ ); 1300+ 1301+ return rv; 1302+} 1303+ 1304+inline int atomic_conditional_increment( int * pw ) 1305+{ 1306+ // if( *pw != 0 ) ++*pw; 1307+ // return *pw; 1308+ 1309+ int rv, tmp; 1310+ 1311+ __asm__ __volatile__ 1312+ ( 1313+ "0:\n\t" 1314+ ".set push\n\t" 1315+ ".set mips2\n\t" 1316+ "ll %0, %2\n\t" 1317+ "beqz %0, 1f\n\t" 1318+ "addiu %1, %0, 1\n\t" 1319+ "sc %1, %2\n\t" 1320+ ".set pop\n\t" 1321+ "beqz %1, 0b\n\t" 1322+ "addiu %0, %0, 1\n\t" 1323+ "1:": 1324+ "=&r"( rv ), "=&r"( tmp ), "=m"( *pw ): 1325+ "m"( *pw ): 1326+ "memory" 1327+ ); 1328+ 1329+ return rv; 1330+} 1331+ 1332+class sp_counted_base 1333+{ 1334+private: 1335+ 1336+ sp_counted_base( sp_counted_base const & ); 1337+ sp_counted_base & operator= ( sp_counted_base const & ); 1338+ 1339+ int use_count_; // #shared 1340+ int weak_count_; // #weak + (#shared != 0) 1341+ 1342+public: 1343+ 1344+ sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) 1345+ { 1346+ } 1347+ 1348+ virtual ~sp_counted_base() // nothrow 1349+ { 1350+ } 1351+ 1352+ // dispose() is called when use_count_ drops to zero, to release 1353+ // the resources managed by *this. 1354+ 1355+ virtual void dispose() = 0; // nothrow 1356+ 1357+ // destroy() is called when weak_count_ drops to zero. 1358+ 1359+ virtual void destroy() // nothrow 1360+ { 1361+ delete this; 1362+ } 1363+ 1364+ virtual void * get_deleter( sp_typeinfo const & ti ) = 0; 1365+ virtual void * get_untyped_deleter() = 0; 1366+ 1367+ void add_ref_copy() 1368+ { 1369+ atomic_increment( &use_count_ ); 1370+ } 1371+ 1372+ bool add_ref_lock() // true on success 1373+ { 1374+ return atomic_conditional_increment( &use_count_ ) != 0; 1375+ } 1376+ 1377+ void release() // nothrow 1378+ { 1379+ if( atomic_decrement( &use_count_ ) == 0 ) 1380+ { 1381+ dispose(); 1382+ weak_release(); 1383+ } 1384+ } 1385+ 1386+ void weak_add_ref() // nothrow 1387+ { 1388+ atomic_increment( &weak_count_ ); 1389+ } 1390+ 1391+ void weak_release() // nothrow 1392+ { 1393+ if( atomic_decrement( &weak_count_ ) == 0 ) 1394+ { 1395+ destroy(); 1396+ } 1397+ } 1398+ 1399+ long use_count() const // nothrow 1400+ { 1401+ return static_cast<int const volatile &>( use_count_ ); 1402+ } 1403+}; 1404+ 1405+} // namespace detail 1406+ 1407+} // namespace boost 1408+ 1409+#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED 1410