Commit ddce9087 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by facebook-github-bot-1

Extract endianness checks into Portability.h

Summary: [Folly] Extract endianness checks into Portability.h.

Reviewed By: fugalh

Differential Revision: D2857924

fb-gh-sync-id: 23ecd2a3cad661024acb62769cd85df394786c59
parent 68a47850
......@@ -289,13 +289,6 @@ private:
* to extract capacity/category.
*/
template <class Char> class fbstring_core {
protected:
static constexpr bool kIsLittleEndian =
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__;
static constexpr bool kIsBigEndian =
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__;
static_assert(
kIsLittleEndian || kIsBigEndian, "unable to identify endianness");
public:
fbstring_core() noexcept { reset(); }
......
......@@ -305,6 +305,21 @@ typedef SSIZE_T ssize_t;
#endif
// Endianness
namespace folly {
#ifdef _MSC_VER
// It's MSVC, so we just have to guess ... and allow an override
#ifdef FOLLY_ENDIAN_BE
constexpr auto kIsLittleEndian = false;
#else
constexpr auto kIsLittleEndian = true;
#endif
#else
constexpr auto kIsLittleEndian = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__;
#endif
constexpr auto kIsBigEndian = !kIsLittleEndian;
}
#ifndef FOLLY_SSE
# if defined(__SSE4_2__)
# define FOLLY_SSE 4
......
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