From 61c3b82aafd15670cac36304d33bdb375bb369b3 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Fri, 13 Jan 2017 00:33:06 -0500 Subject: [PATCH] endian.h --- dumpobj.cpp | 8 ++------ endian.h | 17 +++++++++++++++++ link.cpp | 7 ++----- 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 endian.h diff --git a/dumpobj.cpp b/dumpobj.cpp index aa1f496..eb79471 100644 --- a/dumpobj.cpp +++ b/dumpobj.cpp @@ -16,6 +16,8 @@ #include "obj816.h" #include "zrdz_disassembler.h" +#include "endian.h" + #ifndef O_BINARY #define O_BINARY 0 #endif @@ -34,12 +36,6 @@ struct { } flags; -enum class endian { - little = __ORDER_LITTLE_ENDIAN__, - big = __ORDER_BIG_ENDIAN__, - native = __BYTE_ORDER__ -}; - template void swap_if(T &t, std::false_type) {} diff --git a/endian.h b/endian.h new file mode 100644 index 0000000..9e78f2e --- /dev/null +++ b/endian.h @@ -0,0 +1,17 @@ +#ifndef endian_h +#define endian_h + +enum class endian { + +#ifdef _WIN32 + little = 1234, + big = 4321, + native = little +#else + little = __ORDER_LITTLE_ENDIAN__, + big = __ORDER_BIG_ENDIAN__, + native = __BYTE_ORDER__ +#endif +}; + +#endif diff --git a/link.cpp b/link.cpp index 5b93092..06540a0 100644 --- a/link.cpp +++ b/link.cpp @@ -27,6 +27,8 @@ #include "expression.h" #include "omf.h" +#include "endian.h" + #ifndef O_BINARY #define O_BINARY 0 #endif @@ -44,11 +46,6 @@ struct { uint32_t _aux_type; } flags; -enum class endian { - little = __ORDER_LITTLE_ENDIAN__, - big = __ORDER_BIG_ENDIAN__, - native = __BYTE_ORDER__ -}; template