gcc-stl-wrapper.template.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef mozilla_${HEADER}_h
  8. #define mozilla_${HEADER}_h
  9. #if defined(__EXCEPTIONS) && __EXCEPTIONS
  10. # error "STL code can only be used with -fno-exceptions"
  11. #endif
  12. // Silence "warning: #include_next is a GCC extension"
  13. #pragma GCC system_header
  14. #if defined(DEBUG) && !defined(_GLIBCXX_DEBUG)
  15. // Enable checked iterators and other goodies
  16. //
  17. // FIXME/bug 551254: gcc's debug STL implementation requires -frtti.
  18. // Figure out how to resolve this with -fno-rtti. Maybe build with
  19. // -frtti in DEBUG builds?
  20. //
  21. // # define _GLIBCXX_DEBUG 1
  22. #endif
  23. // Don't include mozalloc for cstdlib. See bug 1245076.
  24. #ifndef moz_dont_include_mozalloc_for_cstdlib
  25. # define moz_dont_include_mozalloc_for_cstdlib
  26. #endif
  27. #ifndef moz_dont_include_mozalloc_for_type_traits
  28. # define moz_dont_include_mozalloc_for_type_traits
  29. #endif
  30. #ifndef moz_dont_include_mozalloc_for_limits
  31. # define moz_dont_include_mozalloc_for_limits
  32. #endif
  33. // Include mozalloc after the STL header and all other headers it includes
  34. // have been preprocessed.
  35. #if !defined(MOZ_INCLUDE_MOZALLOC_H) && \
  36. !defined(moz_dont_include_mozalloc_for_${HEADER})
  37. # define MOZ_INCLUDE_MOZALLOC_H
  38. # define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
  39. #endif
  40. #pragma GCC visibility push(default)
  41. #include_next <${HEADER}>
  42. #pragma GCC visibility pop
  43. #ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
  44. // See if we're in code that can use mozalloc. NB: this duplicates
  45. // code in nscore.h because nscore.h pulls in prtypes.h, and chromium
  46. // can't build with that being included before base/basictypes.h.
  47. # if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
  48. # include "mozilla/mozalloc.h"
  49. # else
  50. # error "STL code can only be used with infallible ::operator new()"
  51. # endif
  52. #endif
  53. // gcc calls a __throw_*() function from bits/functexcept.h when it
  54. // wants to "throw an exception". functexcept exists nominally to
  55. // support -fno-exceptions, but since we'll always use the system
  56. // libstdc++, and it's compiled with exceptions, then in practice
  57. // these __throw_*() functions will always throw exceptions (shades of
  58. // -fshort-wchar). We don't want that and so define our own inlined
  59. // __throw_*().
  60. #ifndef mozilla_throw_gcc_h
  61. # include "mozilla/throw_gcc.h"
  62. #endif
  63. #endif // if mozilla_${HEADER}_h