memory/mozalloc/msvc_raise_wrappers.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:60bd2846925c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: sw=4 ts=4 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_msvc_raise_wrappers_h
9 #define mozilla_msvc_raise_wrappers_h
10
11 #ifdef _XSTDDEF_
12 # error "Unable to wrap _RAISE(); CRT _RAISE() already defined"
13 #endif
14 #ifdef _XUTILITY_
15 # error "Unabled to wrap _X[exception]"(); CRT versions already declared"
16 #endif
17
18 #include "mozilla/mozalloc_abort.h"
19
20 namespace std {
21
22 // NB: user code is not supposed to touch the std:: namespace. We're
23 // doing this after careful review because we want to define our own
24 // exception throwing semantics. Don't try this at home!
25
26 MOZALLOC_EXPORT __declspec(noreturn) void moz_Xinvalid_argument(const char*);
27 MOZALLOC_EXPORT __declspec(noreturn) void moz_Xlength_error(const char*);
28 MOZALLOC_EXPORT __declspec(noreturn) void moz_Xout_of_range(const char*);
29 MOZALLOC_EXPORT __declspec(noreturn) void moz_Xoverflow_error(const char*);
30 MOZALLOC_EXPORT __declspec(noreturn) void moz_Xruntime_error(const char*);
31
32 } // namespace std
33
34 #ifndef MOZALLOC_DONT_WRAP_RAISE_FUNCTIONS
35
36 # define _Xinvalid_argument moz_Xinvalid_argument
37 # define _Xlength_error moz_Xlength_error
38 # define _Xout_of_range moz_Xout_of_range
39 # define _Xoverflow_error moz_Xoverflow_error
40 # define _Xruntime_error moz_Xruntime_error
41
42 # include <xstddef>
43 # include <xutility>
44
45 # undef _RAISE
46 # define _RAISE(x) mozalloc_abort((x).what())
47
48 #endif // ifndef MOZALLOC_DONT_WRAP_RAISE_FUNCTIONS
49
50 #endif // ifndef mozilla_msvc_raise_wrappers_h

mercurial