Drop support for gcc 4.7 with byteswap shim
authorYedidya Feldblum <yfeldblum@fb.com>
Fri, 24 Feb 2017 22:33:37 +0000 (14:33 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 24 Feb 2017 22:39:30 +0000 (14:39 -0800)
Summary: [Folly] Drop support for gcc 4.7 with byteswap shim

Reviewed By: igorsugak, Orvid

Differential Revision: D4610746

fbshipit-source-id: 092cd432c7bda9ca5507d0230b6fcaa43b96c500

folly/Bits.h
folly/configure.ac

index 7e59ce3093267a7fad7e5bdbe1a8d8c08cb3c42d..cb4234c48f18c62a2b350e8370057adb59e02966 100644 (file)
 #include <folly/detail/BitIteratorDetail.h>
 #include <folly/Likely.h>
 
-#if FOLLY_HAVE_BYTESWAP_H
-# include <byteswap.h>
-#endif
-
 #include <cassert>
 #include <cinttypes>
 #include <iterator>
@@ -242,27 +238,6 @@ struct EndianIntBase {
   static T swap(T x);
 };
 
-#ifndef _MSC_VER
-
-/**
- * If we have the bswap_16 macro from byteswap.h, use it; otherwise, provide our
- * own definition.
- */
-#ifdef bswap_16
-# define our_bswap16 bswap_16
-#else
-
-template<class Int16>
-inline constexpr typename std::enable_if<
-  sizeof(Int16) == 2,
-  Int16>::type
-our_bswap16(Int16 x) {
-  return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
-}
-#endif
-
-#endif
-
 #define FB_GEN(t, fn)                             \
   template <>                                     \
   inline t EndianIntBase<t>::swap(t x) {          \
@@ -270,8 +245,7 @@ our_bswap16(Int16 x) {
   }
 
 // fn(x) expands to (x) if the second argument is empty, which is exactly
-// what we want for [u]int8_t. Also, gcc 4.7 on Intel doesn't have
-// __builtin_bswap16 for some reason, so we have to provide our own.
+// what we want for [u]int8_t.
 FB_GEN( int8_t,)
 FB_GEN(uint8_t,)
 #ifdef _MSC_VER
@@ -286,8 +260,8 @@ FB_GEN( int64_t, __builtin_bswap64)
 FB_GEN(uint64_t, __builtin_bswap64)
 FB_GEN( int32_t, __builtin_bswap32)
 FB_GEN(uint32_t, __builtin_bswap32)
-FB_GEN( int16_t, our_bswap16)
-FB_GEN(uint16_t, our_bswap16)
+FB_GEN( int16_t, __builtin_bswap16)
+FB_GEN(uint16_t, __builtin_bswap16)
 #endif
 
 #undef FB_GEN
index f08d6c2f8cd8fbb459e218eeb11e166d9929cc65..c73da686e20b72b212adcdfdc81a99a721831d84 100644 (file)
@@ -160,7 +160,7 @@ AM_PATH_PYTHON
 
 # Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h features.h inttypes.h limits.h sched.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h malloc.h byteswap.h bits/functexcept.h bits/c++config.h])
+AC_CHECK_HEADERS([fcntl.h features.h inttypes.h limits.h sched.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h malloc.h bits/functexcept.h bits/c++config.h])
 
 AC_CHECK_HEADER(double-conversion/double-conversion.h, [], [AC_MSG_ERROR(
                 [Couldn't find double-conversion.h, please download from \