1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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/. */
8 #ifndef mozilla_${HEADER}_h
9 #define mozilla_${HEADER}_h
11 // For some reason, Apple's GCC refuses to honor -fno-exceptions when
13 #if defined(__EXCEPTIONS) && __EXCEPTIONS && !(__OBJC__ && __GNUC__ && XP_IOS)
14 # error "STL code can only be used with -fno-exceptions"
17 // Silence "warning: #include_next is a GCC extension"
18 #pragma GCC system_header
20 #if defined(DEBUG) && !defined(_GLIBCXX_DEBUG)
21 // Enable checked iterators and other goodies
23 // FIXME/bug 551254: gcc's debug STL implementation requires -frtti.
24 // Figure out how to resolve this with -fno-rtti. Maybe build with
25 // -frtti in DEBUG builds?
27 // # define _GLIBCXX_DEBUG 1
30 // Don't include mozalloc for cstdlib. See bug 1245076.
31 #ifndef moz_dont_include_mozalloc_for_cstdlib
32 # define moz_dont_include_mozalloc_for_cstdlib
35 #ifndef moz_dont_include_mozalloc_for_type_traits
36 # define moz_dont_include_mozalloc_for_type_traits
39 #ifndef moz_dont_include_mozalloc_for_limits
40 # define moz_dont_include_mozalloc_for_limits
43 // Include mozalloc after the STL header and all other headers it includes
44 // have been preprocessed.
45 #if !defined(MOZ_INCLUDE_MOZALLOC_H) && \
46 !defined(moz_dont_include_mozalloc_for_${HEADER})
47 # define MOZ_INCLUDE_MOZALLOC_H
48 # define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
51 #pragma GCC visibility push(default)
52 #include_next <${HEADER}>
53 #pragma GCC visibility pop
55 #ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
56 // See if we're in code that can use mozalloc.
57 # if !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
58 # include "mozilla/mozalloc.h"
60 # error "STL code can only be used with infallible ::operator new()"
64 // gcc calls a __throw_*() function from bits/functexcept.h when it
65 // wants to "throw an exception". functexcept exists nominally to
66 // support -fno-exceptions, but since we'll always use the system
67 // libstdc++, and it's compiled with exceptions, then in practice
68 // these __throw_*() functions will always throw exceptions (shades of
69 // -fshort-wchar). We don't want that and so define our own inlined
71 #ifndef mozilla_throw_gcc_h
72 # include "mozilla/throw_gcc.h"
75 #endif // if mozilla_${HEADER}_h