Commit ce4dec4c authored by Owen Yamauchi's avatar Owen Yamauchi Committed by Sara Golemon

Break dependency on features.h

Summary:
It doesn't exist on some systems (at least Mac OS X). We're only using
it for __GNUC_PREREQ, which is easy to provide our own definition for.

I moved the definitions of FOLLY_FINAL and FOLLY_OVERRIDE into
folly-config.h so we can autoconf them in the open-source build. The
hardcoded stuff for the internal build is a little ugly, unfortunately.

folly can't be built with gcc versions earlier than 4.6, so that check
in ThreadLocal.h is pointless by now. (Plus we use noexcept without a
macro wrapper all over the place.) That stuff was also not
clang-friendly. clang has supported static_assert since 2.9 and noexcept
since... I'm not sure but at least 3.0.

Test Plan:
fbconfig/fbmake runtests, with gcc 4.6 and 4.7. clang can't
build folly right now, but I verified separately that it supports
noexcept and static_assert.

Reviewed By: simpkins@fb.com

FB internal diff: D799143
parent bbe8ee53
......@@ -26,32 +26,6 @@
#endif
#endif
// Define macro wrappers for C++11's "final" and "override" keywords, which
// are supported in gcc 4.7 but not gcc 4.6.
//
// TODO(tudorb/agallagher): Autotoolize this.
#undef FOLLY_FINAL
#undef FOLLY_OVERRIDE
#if defined(__clang__)
# define FOLLY_FINAL final
# define FOLLY_OVERRIDE override
#elif defined(__GNUC__)
# include <features.h>
# if __GNUC_PREREQ(4,7)
# define FOLLY_FINAL final
# define FOLLY_OVERRIDE override
# endif
#endif
#ifndef FOLLY_FINAL
# define FOLLY_FINAL
#endif
#ifndef FOLLY_OVERRIDE
# define FOLLY_OVERRIDE
#endif
// MaxAlign: max_align_t isn't supported by gcc
#ifdef __GNUC__
......
......@@ -242,8 +242,7 @@ fbstring errnoStr(int err) {
fbstring result;
// http://www.kernel.org/doc/man-pages/online/pages/man3/strerror.3.html
#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || \
!FOLLY_HAVE_FEATURES_H) && !_GNU_SOURCE
#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE
// Using XSI-compatible strerror_r
int r = strerror_r(err, buf, sizeof(buf));
......
......@@ -42,22 +42,6 @@
#include "folly/Likely.h"
#include <type_traits>
// Use noexcept on gcc 4.6 or higher
#undef FOLLY_NOEXCEPT
#ifdef __GNUC__
# ifdef HAVE_FEATURES_H
# include <features.h>
# if __GNUC_PREREQ(4,6)
# define FOLLY_NOEXCEPT noexcept
# define FOLLY_ASSERT(x) x
# endif
# endif
#endif
#ifndef FOLLY_NOEXCEPT
# define FOLLY_NOEXCEPT
# define FOLLY_ASSERT(x) /**/
#endif
namespace folly {
enum class TLPDestructionMode {
......@@ -283,7 +267,7 @@ class ThreadLocalPtr {
Accessor(const Accessor&) = delete;
Accessor& operator=(const Accessor&) = delete;
Accessor(Accessor&& other) FOLLY_NOEXCEPT
Accessor(Accessor&& other) noexcept
: meta_(other.meta_),
lock_(other.lock_),
id_(other.id_) {
......@@ -291,7 +275,7 @@ class ThreadLocalPtr {
other.lock_ = nullptr;
}
Accessor& operator=(Accessor&& other) FOLLY_NOEXCEPT {
Accessor& operator=(Accessor&& other) noexcept {
// Each Tag has its own unique meta, and accessors with different Tags
// have different types. So either *this is empty, or this and other
// have the same tag. But if they have the same tag, they have the same
......@@ -331,8 +315,8 @@ class ThreadLocalPtr {
// accessor allows a client to iterate through all thread local child
// elements of this ThreadLocal instance. Holds a global lock for each <Tag>
Accessor accessAllThreads() const {
FOLLY_ASSERT(static_assert(!std::is_same<Tag, void>::value,
"Must use a unique Tag to use the accessAllThreads feature"));
static_assert(!std::is_same<Tag, void>::value,
"Must use a unique Tag to use the accessAllThreads feature");
return Accessor(id_);
}
......@@ -350,8 +334,6 @@ class ThreadLocalPtr {
int id_; // every instantiation has a unique id
};
#undef FOLLY_NOEXCEPT
} // namespace folly
#endif /* FOLLY_THREADLOCAL_H_ */
......@@ -38,7 +38,7 @@ AX_BOOST_SYSTEM
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h features.h malloc.h emmintrin.h])
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h malloc.h emmintrin.h])
AC_CHECK_HEADER(double-conversion.h, [], [AC_MSG_ERROR(
[Couldn't find double-conversion.h, please download from \
......@@ -63,6 +63,18 @@ AC_COMPILE_IFELSE(
[AC_DEFINE([HAVE_IFUNC], [1], [Define to 1 if the compiler supports ifunc])],
[AC_DEFINE([HAVE_IFUNC], [0], [Define to 0 if the compiler doesn't support ifunc])]
)
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE[class C { virtual void f() final {} virtual void g() {} };
class D : public C { virtual void g() override {} };]],
[AC_DEFINE([FINAL], [final],
[Define to "final" if the compiler supports C++11 "final"]),
AC_DEFINE([OVERRIDE], [override],
[Define to "override" if the compiler supports C++11 "override"])],
[AC_DEFINE([FINAL], [],
[Define to "final" if the compiler supports C++11 "final"]),
AC_DEFINE([OVERRIDE], [],
[Define to "override" if the compiler supports C++11 "override"])]
)
# Checks for library functions.
AC_CHECK_FUNCS([getdelim \
......
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