michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: sw=4 ts=4 et : michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include michael@0: michael@0: #if defined(XP_WIN) michael@0: # define MOZALLOC_EXPORT __declspec(dllexport) michael@0: #endif michael@0: michael@0: #include "mozalloc_abort.h" michael@0: michael@0: #define MOZALLOC_DONT_WRAP_RAISE_FUNCTIONS michael@0: #include "mozilla/throw_msvc.h" michael@0: michael@0: __declspec(noreturn) static void abort_from_exception(const char* const which, michael@0: const char* const what); michael@0: static void michael@0: abort_from_exception(const char* const which, const char* const what) michael@0: { michael@0: fprintf(stderr, "fatal: STL threw %s: ", which); michael@0: mozalloc_abort(what); michael@0: } michael@0: michael@0: namespace std { michael@0: michael@0: // NB: user code is not supposed to touch the std:: namespace. We're michael@0: // doing this after careful review because we want to define our own michael@0: // exception throwing semantics. Don't try this at home! michael@0: michael@0: void michael@0: moz_Xinvalid_argument(const char* what) michael@0: { michael@0: abort_from_exception("invalid_argument", what); michael@0: } michael@0: michael@0: void michael@0: moz_Xlength_error(const char* what) michael@0: { michael@0: abort_from_exception("length_error", what); michael@0: } michael@0: michael@0: void michael@0: moz_Xout_of_range(const char* what) michael@0: { michael@0: abort_from_exception("out_of_range", what); michael@0: } michael@0: michael@0: void michael@0: moz_Xoverflow_error(const char* what) michael@0: { michael@0: abort_from_exception("overflow_error", what); michael@0: } michael@0: michael@0: void michael@0: moz_Xruntime_error(const char* what) michael@0: { michael@0: abort_from_exception("runtime_error", what); michael@0: } michael@0: michael@0: } // namespace std