Bug 1025605 - Add stdc++-compat hack for std::__throw_out_of_range_fmt and __cxa_throw_bad_array_new_length. r=nfroyd

This commit is contained in:
Mike Hommey 2014-06-19 09:06:14 +09:00
Родитель 06767fd3c2
Коммит 31ad3d202a
1 изменённых файлов: 36 добавлений и 1 удалений

Просмотреть файл

@ -5,6 +5,9 @@
#include <ostream>
#include <istream>
#include <string>
#include <stdarg.h>
#include <stdio.h>
#include <mozilla/Assertions.h>
/* GLIBCXX_3.4.8 is from gcc 4.1.1 (111691)
GLIBCXX_3.4.9 is from gcc 4.2.0 (111690)
@ -14,7 +17,11 @@
GLIBCXX_3.4.13 is from gcc 4.4.2 (151127)
GLIBCXX_3.4.14 is from gcc 4.5.0 (151126)
GLIBCXX_3.4.15 is from gcc 4.6.0 (160071)
GLIBCXX_3.4.16 is form gcc 4.6.1 (172240) */
GLIBCXX_3.4.16 is from gcc 4.6.1 (172240)
GLIBCXX_3.4.17 is from gcc 4.7.0 (174383)
GLIBCXX_3.4.18 is from gcc 4.8.0 (190787)
GLIBCXX_3.4.19 is from gcc 4.8.1 (199309)
GLIBCXX_3.4.20 is from gcc 4.9.0 (199307) */
#define GLIBCXX_VERSION(a, b, c) (((a) << 16) | ((b) << 8) | (c))
@ -140,4 +147,32 @@ namespace std __attribute__((visibility("default"))) {
void ctype<char>::_M_widen_init() const {}
#endif
#if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 20)
/* We shouldn't be throwing exceptions at all, but it sadly turns out
we call STL (inline) functions that do. */
void __throw_out_of_range_fmt(char const* fmt, ...)
{
va_list ap;
char buf[1024]; // That should be big enough.
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
buf[sizeof(buf) - 1] = 0;
va_end(ap);
__throw_range_error(buf);
}
#endif
}
#if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 20)
/* Technically, this symbol is not in GLIBCXX_3.4.20, but in CXXABI_1.3.8,
but that's equivalent, version-wise. Those calls are added by the compiler
itself on `new Class[n]` calls. */
extern "C" void
__cxa_throw_bad_array_new_length()
{
MOZ_CRASH();
}
#endif