Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SamuelMarks/7369603 to your computer and use it in GitHub Desktop.
Save SamuelMarks/7369603 to your computer and use it in GitHub Desktop.
Endianness checks replacement for LLVM (posted to llvm-commits)
From 346740535fe71b34218fa1137a14e6ed8f6833ae Mon Sep 17 00:00:00 2001
From: Samuel Marks <samuelmarks@gmail.com>
Date: Fri, 8 Nov 2013 22:04:06 +1100
Subject: [PATCH] Added support for the BSDs and Solaris endianness; code from
ChromiumOS project (LevelDB ppl)
---
include/llvm/Support/Host.h | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/include/llvm/Support/Host.h b/include/llvm/Support/Host.h
index 0f45d4b..5ac7b2d 100644
--- a/include/llvm/Support/Host.h
+++ b/include/llvm/Support/Host.h
@@ -16,6 +16,7 @@
#include "llvm/ADT/StringMap.h"
+
#if defined(OS_MACOSX)
#include <machine/endian.h>
#elif defined(OS_SOLARIS)
@@ -29,8 +30,10 @@
defined(OS_DRAGONFLYBSD)
#include <sys/types.h>
#include <sys/endian.h>
-#else
- #include <endian.h>
+ #else
+ #if !defined(BYTE_ORDER) && !defined(LLVM_ON_WIN32)
+ #include <endian.h>
+ #endif
#endif
#include <string>
@@ -38,11 +41,11 @@
namespace llvm {
namespace sys {
-#if defined(BIG_ENDIAN)
- static const bool IsBigEndianHost = true, IsLittleEndianHost = false;
-#else
- static const bool IsBigEndianHost = false, IsLittleEndianHost = true;
-#endif
+ #if defined(BIG_ENDIAN)
+ static const bool IsBigEndianHost = true, IsLittleEndianHost = false;
+ #else
+ static const bool IsBigEndianHost = false, IsLittleEndianHost = true;
+ #endif
/// getDefaultTargetTriple() - Return the default target triple the compiler
/// has been configured to produce code for.
--
1.8.3.msysgit.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment