aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Support/Host.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Support/Host.h')
-rw-r--r--include/llvm/Support/Host.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/include/llvm/Support/Host.h b/include/llvm/Support/Host.h
index 3a44405739..9a4036a8af 100644
--- a/include/llvm/Support/Host.h
+++ b/include/llvm/Support/Host.h
@@ -15,23 +15,27 @@
#define LLVM_SUPPORT_HOST_H
#include "llvm/ADT/StringMap.h"
+
+#if defined(__linux__)
+#include <endian.h>
+#else
+#ifndef LLVM_ON_WIN32
+#include <machine/endian.h>
+#endif
+#endif
+
#include <string>
namespace llvm {
namespace sys {
- inline bool isLittleEndianHost() {
- union {
- int i;
- char c;
- };
- i = 1;
- return c;
- }
+#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
+ static const bool IsBigEndianHost = true;
+#else
+ static const bool IsBigEndianHost = false;
+#endif
- inline bool isBigEndianHost() {
- return !isLittleEndianHost();
- }
+ static const bool IsLittleEndianHost = !IsBigEndianHost;
/// getDefaultTargetTriple() - Return the default target triple the compiler
/// has been configured to produce code for.