#endif
#endif
+#include <atomic>
+#include <limits>
+#include <type_traits>
+
+// libc++ doesn't provide this header
+#ifndef _LIBCPP_VERSION
// This file appears in two locations: inside fbcode and in the
// libstdc++ source code (when embedding fbstring as std::string).
// To aid in this schizophrenic use, two macros are defined in
// _LIBSTDCXX_FBSTRING - Set inside libstdc++. This is useful to
// gate use inside fbcode v. libstdc++
#include <bits/c++config.h>
+#endif
#ifdef _LIBSTDCXX_FBSTRING
#define FBSTRING_LIKELY(x) (__builtin_expect((x), 1))
#define FBSTRING_UNLIKELY(x) (__builtin_expect((x), 0))
-#include <atomic>
-#include <limits>
-#include <type_traits>
-
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
detail/DiscriminatedPtrDetail.h \
detail/FileUtilDetail.h \
detail/FingerprintPolynomial.h \
+ detail/FunctionalExcept.h \
detail/Futex.h \
detail/GroupVarintDetail.h \
detail/Malloc.h \
libfolly_la_SOURCES += detail/Malloc.cpp
endif
+if !HAVE_BITS_FUNCTEXCEPT
+libfolly_la_SOURCES += detail/FunctionalExcept.cpp
+endif
+
FingerprintTables.cpp: generate_fingerprint_tables
./generate_fingerprint_tables
CLEANFILES += FingerprintTables.cpp
extern "C" int allocm(void**, size_t*, size_t, int)
__attribute__((weak));
+#include <bits/functexcept.h>
#define FOLLY_HAVE_MALLOC_H 1
#else
#include "folly/detail/Malloc.h"
#include <new>
-#include <bits/functexcept.h>
-
/**
* Define various ALLOCM_* macros normally provided by jemalloc. We define
* them so that we don't have to include jemalloc.h, in case the program is
#include "folly/detail/Clock.h"
#endif
+// Provide our own std::__throw_* wrappers for platforms that don't have them
+#if FOLLY_HAVE_BITS_FUNCTEXCEPT_H
+#include <bits/functexcept.h>
+#else
+#include "folly/detail/FunctionalExcept.h"
+#endif
+
#if defined(__cplusplus)
// Unfortunately, boost::has_trivial_copy<T> is broken in libc++ due to its
// usage of __has_trivial_copy(), so we can't use it as a
#include <stdexcept>
#include <type_traits>
#include <boost/operators.hpp>
+
+// libc++ doesn't provide this header
+#if !FOLLY_USE_LIBCPP
+// This file appears in two locations: inside fbcode and in the
+// libstdc++ source code (when embedding fbstring as std::string).
+// To aid in this schizophrenic use, two macros are defined in
+// c++config.h:
+// _LIBSTDCXX_FBSTRING - Set inside libstdc++. This is useful to
+// gate use inside fbcode v. libstdc++
#include <bits/c++config.h>
+#endif
+
#include "folly/CpuId.h"
#include "folly/Traits.h"
#include "folly/Likely.h"
#include "folly/Portability.h"
+// libc++ doesn't provide this header
+#if !FOLLY_USE_LIBCPP
+// This file appears in two locations: inside fbcode and in the
+// libstdc++ source code (when embedding fbstring as std::string).
+// To aid in this schizophrenic use, two macros are defined in
+// c++config.h:
+// _LIBSTDCXX_FBSTRING - Set inside libstdc++. This is useful to
+// gate use inside fbcode v. libstdc++
#include <bits/c++config.h>
+#endif
#include <boost/type_traits.hpp>
#include <boost/mpl/and.hpp>
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h features.h inttypes.h limits.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h malloc.h emmintrin.h byteswap.h])
+AC_CHECK_HEADERS([fcntl.h features.h inttypes.h limits.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h malloc.h emmintrin.h byteswap.h bits/functexcept.h])
AC_CHECK_HEADER(double-conversion.h, [], [AC_MSG_ERROR(
[Couldn't find double-conversion.h, please download from \
AM_CONDITIONAL([HAVE_X86_64], [test "$build_cpu" = "x86_64"])
AM_CONDITIONAL([HAVE_LINUX], [test "$build_os" == "linux-gnu"])
AM_CONDITIONAL([HAVE_WEAK_SYMBOLS], [test "$ac_have_weak_symbols" = "yes"])
+AM_CONDITIONAL([HAVE_BITS_FUNCTEXCEPT], [test "$ac_cv_header_bits_functexcept" = "yes"])
# Output
AC_CONFIG_FILES([Makefile
--- /dev/null
+/*
+ * Copyright 2013 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "folly/detail/FunctionalExcept.h"
+
+#include <stdexcept>
+
+FOLLY_NAMESPACE_STD_BEGIN
+
+void __throw_length_error(const char* msg) FOLLY_NORETURN {
+ throw std::length_error(msg);
+}
+
+void __throw_logic_error(const char* msg) FOLLY_NORETURN {
+ throw std::logic_error(msg);
+}
+
+void __throw_out_of_range(const char* msg) FOLLY_NORETURN {
+ throw std::out_of_range(msg);
+}
+
+FOLLY_NAMESPACE_STD_END
--- /dev/null
+/*
+ * Copyright 2013 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FOLLY_DETAIL_FUNCTIONAL_EXCEPT_H
+#define FOLLY_DETAIL_FUNCTIONAL_EXCEPT_H
+
+#include "folly/Portability.h"
+
+FOLLY_NAMESPACE_STD_BEGIN
+
+void __throw_length_error(const char* msg) FOLLY_NORETURN;
+void __throw_logic_error(const char* msg) FOLLY_NORETURN;
+void __throw_out_of_range(const char* msg) FOLLY_NORETURN;
+
+FOLLY_NAMESPACE_STD_END
+
+#endif