build/unix/stdc++compat/stdc++compat.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include <ostream>
     6 #include <istream>
     7 #include <string>
     9 /* GLIBCXX_3.4.8  is from gcc 4.1.1 (111691)
    10    GLIBCXX_3.4.9  is from gcc 4.2.0 (111690)
    11    GLIBCXX_3.4.10 is from gcc 4.3.0 (126287)
    12    GLIBCXX_3.4.11 is from gcc 4.4.0 (133006)
    13    GLIBCXX_3.4.12 is from gcc 4.4.1 (147138)
    14    GLIBCXX_3.4.13 is from gcc 4.4.2 (151127)
    15    GLIBCXX_3.4.14 is from gcc 4.5.0 (151126)
    16    GLIBCXX_3.4.15 is from gcc 4.6.0 (160071)
    17    GLIBCXX_3.4.16 is form gcc 4.6.1 (172240) */
    19 #define GLIBCXX_VERSION(a, b, c) (((a) << 16) | ((b) << 8) | (c))
    21 namespace std {
    22 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 9)
    23     /* Instantiate these templates to avoid GLIBCXX_3.4.9 symbol versions */
    24     template ostream& ostream::_M_insert(double);
    25     template ostream& ostream::_M_insert(long);
    26     template ostream& ostream::_M_insert(unsigned long);
    27     template ostream& ostream::_M_insert(long long);
    28     template ostream& ostream::_M_insert(unsigned long long);
    29     template ostream& ostream::_M_insert(bool);
    30     template ostream& ostream::_M_insert(const void*);
    31     template ostream& __ostream_insert(ostream&, const char*, streamsize);
    32     template istream& istream::_M_extract(double&);
    33     template istream& istream::_M_extract(float&);
    34     template istream& istream::_M_extract(unsigned int&);
    35     template istream& istream::_M_extract(unsigned long&);
    36     template istream& istream::_M_extract(unsigned short&);
    37     template istream& istream::_M_extract(unsigned long long&);
    38 #endif
    39 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 14)
    40     /* Instantiate these templates to avoid GLIBCXX_3.4.14 symbol versions
    41      * depending on optimization level */
    42     template char *string::_S_construct_aux_2(size_type, char, allocator<char> const&);
    43 #ifdef _GLIBCXX_USE_WCHAR_T
    44     template wchar_t *wstring::_S_construct_aux_2(size_type, wchar_t, allocator<wchar_t> const&);
    45 #endif /* _GLIBCXX_USE_WCHAR_T */
    46 #ifdef __GXX_EXPERIMENTAL_CXX0X__
    47     template string::basic_string(string&&);
    48     template string& string::operator=(string&&);
    49     template wstring::basic_string(wstring&&);
    50     template wstring& wstring::operator=(wstring&&);
    51     template string& string::assign(string&&);
    52     template wstring& wstring::assign(wstring&&);
    53 #endif /* __GXX_EXPERIMENTAL_CXX0X__ */
    54 #endif /* (__GNUC__ == 4) && (__GNUC_MINOR__ >= 5) */
    55 }
    57 namespace std __attribute__((visibility("default"))) {
    58 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 14)
    59     /* Hack to avoid GLIBCXX_3.4.14 symbol versions */
    60     struct _List_node_base
    61     {
    62         void hook(_List_node_base * const __position) throw ();
    64         void unhook() throw ();
    66         void transfer(_List_node_base * const __first,
    67                       _List_node_base * const __last) throw();
    69         void reverse() throw();
    71 /* Hack to avoid GLIBCXX_3.4.15 symbol versions */
    72 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 15)
    73         static void swap(_List_node_base& __x, _List_node_base& __y) throw ();
    74     };
    76     namespace __detail {
    78     struct _List_node_base
    79     {
    80 #endif
    81         void _M_hook(_List_node_base * const __position) throw ();
    83         void _M_unhook() throw ();
    85         void _M_transfer(_List_node_base * const __first,
    86                          _List_node_base * const __last) throw();
    88         void _M_reverse() throw();
    90 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 15)
    91         static void swap(_List_node_base& __x, _List_node_base& __y) throw ();
    92 #endif
    93     };
    95     /* The functions actually have the same implementation */
    96     void
    97     _List_node_base::_M_hook(_List_node_base * const __position) throw ()
    98     {
    99         ((std::_List_node_base *)this)->hook((std::_List_node_base * const) __position);
   100     }
   102     void
   103     _List_node_base::_M_unhook() throw ()
   104     {
   105         ((std::_List_node_base *)this)->unhook();
   106     }
   108     void
   109     _List_node_base::_M_transfer(_List_node_base * const __first,
   110                                  _List_node_base * const __last) throw ()
   111     {
   112         ((std::_List_node_base *)this)->transfer((std::_List_node_base * const)__first,
   113                                                  (std::_List_node_base * const)__last);
   114     }
   116     void
   117     _List_node_base::_M_reverse() throw ()
   118     {
   119         ((std::_List_node_base *)this)->reverse();
   120     }
   122 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 15)
   123     void
   124     _List_node_base::swap(_List_node_base& __x, _List_node_base& __y) throw ()
   125     {
   126         std::_List_node_base::swap(*((std::_List_node_base *) &__x),
   127                                    *((std::_List_node_base *) &__y));
   128     }
   129 }
   130 #endif
   132 #endif /*MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 14)*/
   134 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 11)
   135     /* Hack to avoid GLIBCXX_3.4.11 symbol versions
   136        An inline definition of ctype<char>::_M_widen_init() used to be in
   137        locale_facets.h before GCC 4.4, but moved out of headers in more
   138        recent versions.
   139        It is actually safe to make it do nothing. */
   140     void ctype<char>::_M_widen_init() const {}
   141 #endif
   143 }

mercurial