|
| 1 | +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 | + * vim: sw=2 ts=8 et : |
| 3 | + */ |
| 4 | +/* ***** BEGIN LICENSE BLOCK ***** |
| 5 | + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 6 | + * |
| 7 | + * The contents of this file are subject to the Mozilla Public License Version |
| 8 | + * 1.1 (the "License"); you may not use this file except in compliance with |
| 9 | + * the License. You may obtain a copy of the License at: |
| 10 | + * http://www.mozilla.org/MPL/ |
| 11 | + * |
| 12 | + * Software distributed under the License is distributed on an "AS IS" basis, |
| 13 | + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 14 | + * for the specific language governing rights and limitations under the |
| 15 | + * License. |
| 16 | + * |
| 17 | + * The Original Code is Mozilla Code. |
| 18 | + * |
| 19 | + * The Initial Developer of the Original Code is |
| 20 | + * The Mozilla Foundation |
| 21 | + * Portions created by the Initial Developer are Copyright (C) 2010 |
| 22 | + * the Initial Developer. All Rights Reserved. |
| 23 | + * |
| 24 | + * Contributor(s): |
| 25 | + * Chris Jones <jones.chris.g@gmail.com> |
| 26 | + * |
| 27 | + * Alternatively, the contents of this file may be used under the terms of |
| 28 | + * either the GNU General Public License Version 2 or later (the "GPL"), or |
| 29 | + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
| 30 | + * in which case the provisions of the GPL or the LGPL are applicable instead |
| 31 | + * of those above. If you wish to allow use of your version of this file only |
| 32 | + * under the terms of either the GPL or the LGPL, and not to allow others to |
| 33 | + * use your version of this file under the terms of the MPL, indicate your |
| 34 | + * decision by deleting the provisions above and replace them with the notice |
| 35 | + * and other provisions required by the GPL or the LGPL. If you do not delete |
| 36 | + * the provisions above, a recipient may use your version of this file under |
| 37 | + * the terms of any one of the MPL, the GPL or the LGPL. |
| 38 | + * |
| 39 | + * ***** END LICENSE BLOCK ***** */ |
| 40 | + |
| 41 | +#ifndef mozilla_${HEADER}_h |
| 42 | +#define mozilla_${HEADER}_h |
| 43 | + |
| 44 | +#if _HAS_EXCEPTIONS |
| 45 | +# error "STL code can only be used with -fno-exceptions" |
| 46 | +#endif |
| 47 | + |
| 48 | +// See if we're in code that can use mozalloc. NB: this duplicates |
| 49 | +// code in nscore.h because nscore.h pulls in prtypes.h, and chromium |
| 50 | +// can't build with that being included before base/basictypes.h. |
| 51 | +#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC) |
| 52 | +# include <new> // to give mozalloc std::bad_alloc |
| 53 | +# include <stdlib.h> // to give mozalloc malloc/free decls |
| 54 | +# include <string.h> |
| 55 | +# include "mozilla/mozalloc.h" |
| 56 | +#else |
| 57 | +# error "STL code can only be used with infallible ::operator new()" |
| 58 | +#endif |
| 59 | + |
| 60 | +#ifdef DEBUG |
| 61 | +// From |
| 62 | +// http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx |
| 63 | +// and |
| 64 | +// http://msdn.microsoft.com/en-us/library/aa985965%28VS.80%29.aspx |
| 65 | +// there appear to be two types of STL container checking. The |
| 66 | +// former is enabled by -D_DEBUG (which is implied by -DDEBUG), and |
| 67 | +// looks to be full generation/mutation checked iterators as done by |
| 68 | +// _GLIBCXX_DEBUG. The latter appears to just be bounds checking, and |
| 69 | +// is enabled by the following macros. It appears that the _DEBUG |
| 70 | +// iterators subsume _SECURE_SCL, and the following settings are |
| 71 | +// default anyway, so we'll just leave this commented out. |
| 72 | +//# define _SECURE_SCL 1 |
| 73 | +//# define _SECURE_SCL_THROWS 0 |
| 74 | +#else |
| 75 | +// Note: _SECURE_SCL iterators are on by default in opt builds. We |
| 76 | +// could leave them on, but since gcc doesn't, we might as well |
| 77 | +// preserve that behavior for perf reasons. nsTArray is in the same |
| 78 | +// camp as gcc. Can revisit later. |
| 79 | +// |
| 80 | +// FIXME/bug 551254: because we're not wrapping all the STL headers we |
| 81 | +// use, undefining this here can cause some headers to be built with |
| 82 | +// iterator checking and others not. Turning this off until we have a |
| 83 | +// better plan. |
| 84 | +//# undef _SECURE_SCL |
| 85 | +#endif |
| 86 | + |
| 87 | +// We know that code won't be able to catch exceptions, but that's OK |
| 88 | +// because we're not throwing them. |
| 89 | +#pragma warning( push ) |
| 90 | +#pragma warning( disable : 4530 ) |
| 91 | + |
| 92 | +#include <${HEADER_PATH}> |
| 93 | + |
| 94 | +#pragma warning( pop ) |
| 95 | + |
| 96 | +#endif // if mozilla_${HEADER}_h |
0 commit comments