memory/mozalloc/msvc_raise_wrappers.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: sw=4 ts=4 et :
michael@0 3 */
michael@0 4 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 7
michael@0 8 #include <stdio.h>
michael@0 9
michael@0 10 #if defined(XP_WIN)
michael@0 11 # define MOZALLOC_EXPORT __declspec(dllexport)
michael@0 12 #endif
michael@0 13
michael@0 14 #include "mozalloc_abort.h"
michael@0 15
michael@0 16 #define MOZALLOC_DONT_WRAP_RAISE_FUNCTIONS
michael@0 17 #include "mozilla/throw_msvc.h"
michael@0 18
michael@0 19 __declspec(noreturn) static void abort_from_exception(const char* const which,
michael@0 20 const char* const what);
michael@0 21 static void
michael@0 22 abort_from_exception(const char* const which, const char* const what)
michael@0 23 {
michael@0 24 fprintf(stderr, "fatal: STL threw %s: ", which);
michael@0 25 mozalloc_abort(what);
michael@0 26 }
michael@0 27
michael@0 28 namespace std {
michael@0 29
michael@0 30 // NB: user code is not supposed to touch the std:: namespace. We're
michael@0 31 // doing this after careful review because we want to define our own
michael@0 32 // exception throwing semantics. Don't try this at home!
michael@0 33
michael@0 34 void
michael@0 35 moz_Xinvalid_argument(const char* what)
michael@0 36 {
michael@0 37 abort_from_exception("invalid_argument", what);
michael@0 38 }
michael@0 39
michael@0 40 void
michael@0 41 moz_Xlength_error(const char* what)
michael@0 42 {
michael@0 43 abort_from_exception("length_error", what);
michael@0 44 }
michael@0 45
michael@0 46 void
michael@0 47 moz_Xout_of_range(const char* what)
michael@0 48 {
michael@0 49 abort_from_exception("out_of_range", what);
michael@0 50 }
michael@0 51
michael@0 52 void
michael@0 53 moz_Xoverflow_error(const char* what)
michael@0 54 {
michael@0 55 abort_from_exception("overflow_error", what);
michael@0 56 }
michael@0 57
michael@0 58 void
michael@0 59 moz_Xruntime_error(const char* what)
michael@0 60 {
michael@0 61 abort_from_exception("runtime_error", what);
michael@0 62 }
michael@0 63
michael@0 64 } // namespace std

mercurial