Commit 1aac76b0 authored by Dan Zimmerman's avatar Dan Zimmerman Committed by Facebook Github Bot

Make memory/Arena.h work with -fno-exceptions

Summary: We may want to disable exceptions, so lets make this work

Reviewed By: yfeldblum

Differential Revision: D9381726

fbshipit-source-id: 6e6d022740728a40a5b710ec32309da99f6d0bd0
parent 1a32e2cf
......@@ -44,6 +44,7 @@
#include <folly/Range.h>
#include <folly/Traits.h>
#include <folly/Unit.h>
#include <folly/lang/Exception.h>
#include <folly/portability/Math.h>
namespace folly {
......@@ -129,7 +130,7 @@ inline ConversionCode enforceWhitespaceErr(StringPiece sp) {
inline void enforceWhitespace(StringPiece sp) {
auto err = enforceWhitespaceErr(sp);
if (err != ConversionCode::SUCCESS) {
throw makeConversionError(err, sp);
throw_exception(makeConversionError(err, sp));
}
}
} // namespace detail
......@@ -1512,10 +1513,14 @@ inline
detail::ReturnUnit<Error>>::type;
auto tmp = detail::parseToWrap(src, result);
return tmp
.thenOrThrow(Check(), [&](Error e) { throw makeConversionError(e, src); })
.thenOrThrow(
Check(),
[&](Error e) { throw_exception(makeConversionError(e, src)); })
.thenOrThrow(
[&](Unit) { return std::move(result); },
[&](Error e) { throw makeConversionError(e, tmp.value()); });
[&](Error e) {
throw_exception(makeConversionError(e, tmp.value()));
});
}
/**
......
......@@ -48,7 +48,7 @@ void* Arena<Alloc>::allocateSlow(size_t size) {
size_t allocSize = std::max(size, minBlockSize()) + sizeof(Block);
if (sizeLimit_ != kNoSizeLimit &&
allocSize > sizeLimit_ - totalAllocatedSize_) {
throw std::bad_alloc();
throw_exception(std::bad_alloc());
}
if (size > minBlockSize()) {
......
......@@ -28,6 +28,7 @@
#include <folly/Likely.h>
#include <folly/Memory.h>
#include <folly/lang/Align.h>
#include <folly/lang/Exception.h>
#include <folly/memory/Malloc.h>
namespace folly {
......@@ -69,8 +70,8 @@ class Arena {
, sizeLimit_(sizeLimit)
, maxAlign_(maxAlign) {
if ((maxAlign_ & (maxAlign_ - 1)) || maxAlign_ > alignof(Block)) {
throw std::invalid_argument(
folly::to<std::string>("Invalid maxAlign: ", maxAlign_));
throw_exception(std::invalid_argument(
folly::to<std::string>("Invalid maxAlign: ", maxAlign_)));
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment