Summary:
gcc errors out when code that throws is compiled with
'-fno-exceptions'. Since we add Malloc.h into our custom libstdc++
use the exception wrappers from functexcept.h so that they can build
with third-party projects that use '-fno-exceptions'.
Test Plan:
Built llvm in the gcc-4.7.1-glibc-2.14.1-fb platform with these
changes.
Reviewed By: tudorb@fb.com
FB internal diff:
D516577
+#include <bits/functexcept.h>
+
/**
* Declare rallocm() and malloc_usable_size() as weak symbols. It
* will be provided by jemalloc if we are using jemalloc, or it will
/**
* Declare rallocm() and malloc_usable_size() as weak symbols. It
* will be provided by jemalloc if we are using jemalloc, or it will
*/
inline void* checkedMalloc(size_t size) {
void* p = malloc(size);
*/
inline void* checkedMalloc(size_t size) {
void* p = malloc(size);
- if (!p) throw std::bad_alloc();
+ if (!p) std::__throw_bad_alloc();
return p;
}
inline void* checkedCalloc(size_t n, size_t size) {
void* p = calloc(n, size);
return p;
}
inline void* checkedCalloc(size_t n, size_t size) {
void* p = calloc(n, size);
- if (!p) throw std::bad_alloc();
+ if (!p) std::__throw_bad_alloc();
return p;
}
inline void* checkedRealloc(void* ptr, size_t size) {
void* p = realloc(ptr, size);
return p;
}
inline void* checkedRealloc(void* ptr, size_t size) {
void* p = realloc(ptr, size);
- if (!p) throw std::bad_alloc();
+ if (!p) std::__throw_bad_alloc();