tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

gcc-stl-wrapper.template.h (2883B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: sw=2 ts=8 et :
      3 */
      4 /* This Source Code Form is subject to the terms of the Mozilla Public
      5 * License, v. 2.0. If a copy of the MPL was not distributed with this
      6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      7 
      8 #ifndef mozilla_${HEADER}_h
      9 #define mozilla_${HEADER}_h
     10 
     11 #if defined(__cpp_exceptions) && __cpp_exceptions
     12 #  error "STL code can only be used with -fno-exceptions"
     13 #endif
     14 
     15 // Silence "warning: #include_next is a GCC extension"
     16 #pragma GCC system_header
     17 
     18 #if defined(DEBUG) && !defined(_GLIBCXX_DEBUG)
     19 // Enable checked iterators and other goodies
     20 //
     21 // FIXME/bug 551254: gcc's debug STL implementation requires -frtti.
     22 // Figure out how to resolve this with -fno-rtti.  Maybe build with
     23 // -frtti in DEBUG builds?
     24 //
     25 //  # define _GLIBCXX_DEBUG 1
     26 #endif
     27 
     28 // Don't include mozalloc.h for cstdlib, cmath, type_traits, limits and iosfwd.
     29 // See bug 1245076 (cstdlib), bug 1720641 (cmath), bug 1594027 (type_traits,
     30 // limits) and bug 1694575 (iosfwd).
     31 // Please be careful when adding more exceptions, especially regarding
     32 // the header not directly or indirectly including <new>.
     33 #ifndef moz_dont_include_mozalloc_for_cstdlib
     34 #  define moz_dont_include_mozalloc_for_cstdlib
     35 #endif
     36 
     37 #ifndef moz_dont_include_mozalloc_for_cmath
     38 #  define moz_dont_include_mozalloc_for_cmath
     39 #endif
     40 
     41 #ifndef moz_dont_include_mozalloc_for_type_traits
     42 #  define moz_dont_include_mozalloc_for_type_traits
     43 #endif
     44 
     45 #ifndef moz_dont_include_mozalloc_for_limits
     46 #  define moz_dont_include_mozalloc_for_limits
     47 #endif
     48 
     49 #ifndef moz_dont_include_mozalloc_for_iosfwd
     50 #  define moz_dont_include_mozalloc_for_iosfwd
     51 #endif
     52 
     53 // Include mozalloc after the STL header and all other headers it includes
     54 // have been preprocessed.
     55 #if !defined(MOZ_INCLUDE_MOZALLOC_H) && \
     56    !defined(moz_dont_include_mozalloc_for_${HEADER})
     57 #  define MOZ_INCLUDE_MOZALLOC_H
     58 #  define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
     59 #endif
     60 
     61 #pragma GCC visibility push(default)
     62 #include_next <${HEADER}>
     63 #pragma GCC visibility pop
     64 
     65 #ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
     66 // See if we're in code that can use mozalloc.
     67 #  if !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
     68 #    include "mozilla/mozalloc.h"
     69 #  else
     70 #    error "STL code can only be used with infallible ::operator new()"
     71 #  endif
     72 #endif
     73 
     74 // gcc calls a __throw_*() function from bits/functexcept.h when it
     75 // wants to "throw an exception".  functexcept exists nominally to
     76 // support -fno-exceptions, but since we'll always use the system
     77 // libstdc++, and it's compiled with exceptions, then in practice
     78 // these __throw_*() functions will always throw exceptions (shades of
     79 // -fshort-wchar).  We don't want that and so define our own inlined
     80 // __throw_*().
     81 #ifndef mozilla_throw_gcc_h
     82 #  include "mozilla/throw_gcc.h"
     83 #endif
     84 
     85 #endif  // if mozilla_${HEADER}_h