1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/memory/mozalloc/msvc_raise_wrappers.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 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 +#include <stdio.h> 1.12 + 1.13 +#if defined(XP_WIN) 1.14 +# define MOZALLOC_EXPORT __declspec(dllexport) 1.15 +#endif 1.16 + 1.17 +#include "mozalloc_abort.h" 1.18 + 1.19 +#define MOZALLOC_DONT_WRAP_RAISE_FUNCTIONS 1.20 +#include "mozilla/throw_msvc.h" 1.21 + 1.22 +__declspec(noreturn) static void abort_from_exception(const char* const which, 1.23 + const char* const what); 1.24 +static void 1.25 +abort_from_exception(const char* const which, const char* const what) 1.26 +{ 1.27 + fprintf(stderr, "fatal: STL threw %s: ", which); 1.28 + mozalloc_abort(what); 1.29 +} 1.30 + 1.31 +namespace std { 1.32 + 1.33 +// NB: user code is not supposed to touch the std:: namespace. We're 1.34 +// doing this after careful review because we want to define our own 1.35 +// exception throwing semantics. Don't try this at home! 1.36 + 1.37 +void 1.38 +moz_Xinvalid_argument(const char* what) 1.39 +{ 1.40 + abort_from_exception("invalid_argument", what); 1.41 +} 1.42 + 1.43 +void 1.44 +moz_Xlength_error(const char* what) 1.45 +{ 1.46 + abort_from_exception("length_error", what); 1.47 +} 1.48 + 1.49 +void 1.50 +moz_Xout_of_range(const char* what) 1.51 +{ 1.52 + abort_from_exception("out_of_range", what); 1.53 +} 1.54 + 1.55 +void 1.56 +moz_Xoverflow_error(const char* what) 1.57 +{ 1.58 + abort_from_exception("overflow_error", what); 1.59 +} 1.60 + 1.61 +void 1.62 +moz_Xruntime_error(const char* what) 1.63 +{ 1.64 + abort_from_exception("runtime_error", what); 1.65 +} 1.66 + 1.67 +} // namespace std