config/msvc-stl-wrapper.template.h

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.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * vim: sw=2 ts=8 et :
michael@0 3 */
michael@0 4 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 7
michael@0 8 #ifndef mozilla_${HEADER}_h
michael@0 9 #define mozilla_${HEADER}_h
michael@0 10
michael@0 11 #if _HAS_EXCEPTIONS
michael@0 12 # error "STL code can only be used with -fno-exceptions"
michael@0 13 #endif
michael@0 14
michael@0 15 // Suppress windef.h min and max macros - they make std::min/max not compile.
michael@0 16 #define NOMINMAX 1
michael@0 17
michael@0 18 // Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k
michael@0 19 // CRT doesn't export std::_Throw(). So we define it.
michael@0 20 #ifndef mozilla_Throw_h
michael@0 21 # include "mozilla/throw_msvc.h"
michael@0 22 #endif
michael@0 23
michael@0 24 // Code might include <new> before other wrapped headers, but <new>
michael@0 25 // includes <exception> and so we want to wrap it. But mozalloc.h
michael@0 26 // wants <new> also, so we break the cycle by always explicitly
michael@0 27 // including <new> here.
michael@0 28 #include <${NEW_HEADER_PATH}>
michael@0 29
michael@0 30 // See if we're in code that can use mozalloc. NB: this duplicates
michael@0 31 // code in nscore.h because nscore.h pulls in prtypes.h, and chromium
michael@0 32 // can't build with that being included before base/basictypes.h.
michael@0 33 #if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
michael@0 34 # include "mozilla/mozalloc.h"
michael@0 35 #else
michael@0 36 # error "STL code can only be used with infallible ::operator new()"
michael@0 37 #endif
michael@0 38
michael@0 39 #ifdef DEBUG
michael@0 40 // From
michael@0 41 // http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx
michael@0 42 // and
michael@0 43 // http://msdn.microsoft.com/en-us/library/aa985965%28VS.80%29.aspx
michael@0 44 // there appear to be two types of STL container checking. The
michael@0 45 // former is enabled by -D_DEBUG (which is implied by -DDEBUG), and
michael@0 46 // looks to be full generation/mutation checked iterators as done by
michael@0 47 // _GLIBCXX_DEBUG. The latter appears to just be bounds checking, and
michael@0 48 // is enabled by the following macros. It appears that the _DEBUG
michael@0 49 // iterators subsume _SECURE_SCL, and the following settings are
michael@0 50 // default anyway, so we'll just leave this commented out.
michael@0 51 //# define _SECURE_SCL 1
michael@0 52 //# define _SECURE_SCL_THROWS 0
michael@0 53 #else
michael@0 54 // Note: _SECURE_SCL iterators are on by default in opt builds. We
michael@0 55 // could leave them on, but since gcc doesn't, we might as well
michael@0 56 // preserve that behavior for perf reasons. nsTArray is in the same
michael@0 57 // camp as gcc. Can revisit later.
michael@0 58 //
michael@0 59 // FIXME/bug 551254: because we're not wrapping all the STL headers we
michael@0 60 // use, undefining this here can cause some headers to be built with
michael@0 61 // iterator checking and others not. Turning this off until we have a
michael@0 62 // better plan.
michael@0 63 //# undef _SECURE_SCL
michael@0 64 #endif
michael@0 65
michael@0 66 // C4275: When _HAS_EXCEPTIONS is set to 0, system STL header
michael@0 67 // will generate the warning which we can't modify.
michael@0 68 // C4530: We know that code won't be able to catch exceptions,
michael@0 69 // but that's OK because we're not throwing them.
michael@0 70 #pragma warning( push )
michael@0 71 #pragma warning( disable : 4275 4530 )
michael@0 72
michael@0 73 #include <${HEADER_PATH}>
michael@0 74
michael@0 75 #pragma warning( pop )
michael@0 76
michael@0 77 #endif // if mozilla_${HEADER}_h

mercurial