From: Andrew Gallagher Date: Wed, 11 Jul 2012 21:03:19 +0000 (-0700) Subject: folly/Malloc.h: use libstdc++-safe exception wrappers X-Git-Tag: v0.22.0~1245 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=25189ad927271b3df46ea9b684566d78d5ff129f folly/Malloc.h: use libstdc++-safe exception wrappers 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 --- diff --git a/folly/Malloc.h b/folly/Malloc.h index 7aadfc8f..e43c2afe 100644 --- a/folly/Malloc.h +++ b/folly/Malloc.h @@ -62,6 +62,8 @@ namespace folly { #include +#include + /** * Declare rallocm() and malloc_usable_size() as weak symbols. It * will be provided by jemalloc if we are using jemalloc, or it will @@ -144,19 +146,19 @@ static const size_t jemallocMinInPlaceExpandable = 4096; */ 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); - 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); - if (!p) throw std::bad_alloc(); + if (!p) std::__throw_bad_alloc(); return p; }