Back to index

enigmail  1.4.3
stdc++compat.cpp
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is a hack to avoid dependencies on recent libstdc++.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Mozilla Foundation.
00018  * Portions created by the Initial Developer are Copyright (C) 2011
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Mike Hommey <mh@glandium.org>
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include <ostream>
00039 #include <istream>
00040 #include <string>
00041 
00042 /* GLIBCXX_3.4.8  is from gcc 4.1.1 (111691)
00043    GLIBCXX_3.4.9  is from gcc 4.2.0 (111690)
00044    GLIBCXX_3.4.10 is from gcc 4.3.0 (126287)
00045    GLIBCXX_3.4.11 is from gcc 4.4.0 (133006)
00046    GLIBCXX_3.4.12 is from gcc 4.4.1 (147138)
00047    GLIBCXX_3.4.13 is from gcc 4.4.2 (151127)
00048    GLIBCXX_3.4.14 is from gcc 4.5.0 (151126)
00049    GLIBCXX_3.4.15 is from gcc 4.6.0 (160071)
00050    GLIBCXX_3.4.16 is form gcc 4.6.1 (172240) */
00051 
00052 #define GLIBCXX_VERSION(a, b, c) (((a) << 16) | ((b) << 8) | (c))
00053 
00054 namespace std {
00055 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 9)
00056     /* Instantiate these templates to avoid GLIBCXX_3.4.9 symbol versions */
00057     template ostream& ostream::_M_insert(double);
00058     template ostream& ostream::_M_insert(long);
00059     template ostream& ostream::_M_insert(unsigned long);
00060     template ostream& ostream::_M_insert(long long);
00061     template ostream& ostream::_M_insert(unsigned long long);
00062 #ifdef DEBUG
00063     template ostream& ostream::_M_insert(const void*);
00064 #endif
00065     template ostream& __ostream_insert(ostream&, const char*, streamsize);
00066     template istream& istream::_M_extract(double&);
00067 #endif
00068 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 14)
00069     /* Instantiate these templates to avoid GLIBCXX_3.4.14 symbol versions
00070      * depending on optimization level */
00071     template char *string::_S_construct_aux_2(size_type, char, allocator<char> const&);
00072 #ifdef _GLIBCXX_USE_WCHAR_T
00073     template wchar_t *wstring::_S_construct_aux_2(size_type, wchar_t, allocator<wchar_t> const&);
00074 #endif /* _GLIBCXX_USE_WCHAR_T */
00075 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00076     template string::basic_string(string&&);
00077     template string& string::operator=(string&&);
00078     template wstring::basic_string(wstring&&);
00079     template wstring& wstring::operator=(wstring&&);
00080     template wstring& wstring::assign(wstring&&);
00081 #endif /* __GXX_EXPERIMENTAL_CXX0X__ */
00082 #endif /* (__GNUC__ == 4) && (__GNUC_MINOR__ >= 5) */
00083 }
00084 
00085 namespace std __attribute__((visibility("default"))) {
00086 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 14)
00087     /* Hack to avoid GLIBCXX_3.4.14 symbol versions */
00088     struct _List_node_base
00089     {
00090         void hook(_List_node_base * const __position) throw ();
00091 
00092         void unhook() throw ();
00093 
00094         void transfer(_List_node_base * const __first,
00095                       _List_node_base * const __last) throw();
00096 
00097 /* Hack to avoid GLIBCXX_3.4.15 symbol versions */
00098 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 15)
00099         static void swap(_List_node_base& __x, _List_node_base& __y) throw ();
00100     };
00101 
00102     namespace __detail {
00103 
00104     struct _List_node_base
00105     {
00106 #endif
00107         void _M_hook(_List_node_base * const __position) throw ();
00108 
00109         void _M_unhook() throw ();
00110 
00111         void _M_transfer(_List_node_base * const __first,
00112                          _List_node_base * const __last) throw();
00113 
00114 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 15)
00115         static void swap(_List_node_base& __x, _List_node_base& __y) throw ();
00116 #endif
00117     };
00118 
00119     /* The functions actually have the same implementation */
00120     void
00121     _List_node_base::_M_hook(_List_node_base * const __position) throw ()
00122     {
00123         ((std::_List_node_base *)this)->hook((std::_List_node_base * const) __position);
00124     }
00125 
00126     void
00127     _List_node_base::_M_unhook() throw ()
00128     {
00129         ((std::_List_node_base *)this)->unhook();
00130     }
00131 
00132     void
00133     _List_node_base::_M_transfer(_List_node_base * const __first,
00134                                  _List_node_base * const __last) throw ()
00135     {
00136         ((std::_List_node_base *)this)->transfer((std::_List_node_base * const)__first,
00137                                                  (std::_List_node_base * const)__last);
00138     }
00139 
00140 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 15)
00141     void
00142     _List_node_base::swap(_List_node_base& __x, _List_node_base& __y) throw ()
00143     {
00144         std::_List_node_base::swap(*((std::_List_node_base *) &__x),
00145                                    *((std::_List_node_base *) &__y));
00146     }
00147 }
00148 #endif
00149 
00150 #endif /*MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 14)*/
00151 
00152 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 11)
00153     /* Hack to avoid GLIBCXX_3.4.11 symbol versions
00154        An inline definition of ctype<char>::_M_widen_init() used to be in
00155        locale_facets.h before GCC 4.4, but moved out of headers in more
00156        recent versions.
00157        It is actually safe to make it do nothing. */
00158     void ctype<char>::_M_widen_init() const {}
00159 #endif
00160 
00161 }