Bug 1283439 - Include OpusDecoder.h only for Rust MP4 parsing r=kinetik
[gecko.git] / memory / mozalloc / throw_gcc.h
blob18027e04a4a3c3f0b1daa65045f63dfafad2944c
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/. */
8 #ifndef mozilla_throw_gcc_h
9 #define mozilla_throw_gcc_h
11 #include "mozilla/Attributes.h"
13 #include <stdio.h> // snprintf
14 #include <string.h> // strerror
16 // For gcc, we define these inline to abort so that we're absolutely
17 // certain that (i) no exceptions are thrown from Gecko; (ii) these
18 // errors are always terminal and caught by breakpad.
20 #include "mozilla/mozalloc_abort.h"
22 namespace std {
24 // NB: user code is not supposed to touch the std:: namespace. We're
25 // doing this after careful review because we want to define our own
26 // exception throwing semantics. Don't try this at home!
28 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
29 __throw_bad_exception(void)
31 mozalloc_abort("fatal: STL threw bad_exception");
34 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
35 __throw_bad_alloc(void)
37 mozalloc_abort("fatal: STL threw bad_alloc");
40 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
41 __throw_bad_cast(void)
43 mozalloc_abort("fatal: STL threw bad_cast");
46 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
47 __throw_bad_typeid(void)
49 mozalloc_abort("fatal: STL threw bad_typeid");
52 // used by <functional>
53 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
54 __throw_bad_function_call(void)
56 mozalloc_abort("fatal: STL threw bad_function_call");
59 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
60 __throw_logic_error(const char* msg)
62 mozalloc_abort(msg);
65 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
66 __throw_domain_error(const char* msg)
68 mozalloc_abort(msg);
71 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
72 __throw_invalid_argument(const char* msg)
74 mozalloc_abort(msg);
77 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
78 __throw_length_error(const char* msg)
80 mozalloc_abort(msg);
83 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
84 __throw_out_of_range(const char* msg)
86 mozalloc_abort(msg);
89 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
90 __throw_runtime_error(const char* msg)
92 mozalloc_abort(msg);
95 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
96 __throw_range_error(const char* msg)
98 mozalloc_abort(msg);
101 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
102 __throw_overflow_error(const char* msg)
104 mozalloc_abort(msg);
107 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
108 __throw_underflow_error(const char* msg)
110 mozalloc_abort(msg);
113 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
114 __throw_ios_failure(const char* msg)
116 mozalloc_abort(msg);
119 MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
120 __throw_system_error(int err)
122 char error[128];
123 snprintf(error, sizeof(error)-1,
124 "fatal: STL threw system_error: %s (%d)", strerror(err), err);
125 mozalloc_abort(error);
128 } // namespace std
130 #endif // mozilla_throw_gcc_h