1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/memory/mozalloc/msvc_raise_wrappers.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: sw=4 ts=4 et : 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#ifndef mozilla_msvc_raise_wrappers_h 1.12 +#define mozilla_msvc_raise_wrappers_h 1.13 + 1.14 +#ifdef _XSTDDEF_ 1.15 +# error "Unable to wrap _RAISE(); CRT _RAISE() already defined" 1.16 +#endif 1.17 +#ifdef _XUTILITY_ 1.18 +# error "Unabled to wrap _X[exception]"(); CRT versions already declared" 1.19 +#endif 1.20 + 1.21 +#include "mozilla/mozalloc_abort.h" 1.22 + 1.23 +namespace std { 1.24 + 1.25 +// NB: user code is not supposed to touch the std:: namespace. We're 1.26 +// doing this after careful review because we want to define our own 1.27 +// exception throwing semantics. Don't try this at home! 1.28 + 1.29 +MOZALLOC_EXPORT __declspec(noreturn) void moz_Xinvalid_argument(const char*); 1.30 +MOZALLOC_EXPORT __declspec(noreturn) void moz_Xlength_error(const char*); 1.31 +MOZALLOC_EXPORT __declspec(noreturn) void moz_Xout_of_range(const char*); 1.32 +MOZALLOC_EXPORT __declspec(noreturn) void moz_Xoverflow_error(const char*); 1.33 +MOZALLOC_EXPORT __declspec(noreturn) void moz_Xruntime_error(const char*); 1.34 + 1.35 +} // namespace std 1.36 + 1.37 +#ifndef MOZALLOC_DONT_WRAP_RAISE_FUNCTIONS 1.38 + 1.39 +# define _Xinvalid_argument moz_Xinvalid_argument 1.40 +# define _Xlength_error moz_Xlength_error 1.41 +# define _Xout_of_range moz_Xout_of_range 1.42 +# define _Xoverflow_error moz_Xoverflow_error 1.43 +# define _Xruntime_error moz_Xruntime_error 1.44 + 1.45 +# include <xstddef> 1.46 +# include <xutility> 1.47 + 1.48 +# undef _RAISE 1.49 +# define _RAISE(x) mozalloc_abort((x).what()) 1.50 + 1.51 +#endif // ifndef MOZALLOC_DONT_WRAP_RAISE_FUNCTIONS 1.52 + 1.53 +#endif // ifndef mozilla_msvc_raise_wrappers_h