diff options
author | John Criswell <criswell@uiuc.edu> | 2003-06-11 19:44:51 +0000 |
---|---|---|
committer | John Criswell <criswell@uiuc.edu> | 2003-06-11 19:44:51 +0000 |
commit | a277ca84e09312abb0165c9274c21654d44e82b2 (patch) | |
tree | 90ceef965a977617bb8a5fbfc070478ed8a134ec | |
parent | 028936ada14335bb04f377d46a6261dc4c66dafd (diff) |
Changed the LITTLE_ENDIAN and BIG_ENDIAN macros to ENDIAN_LITTLE and ENDIAN_BIG.
This will prevent them from conflicting with macros defined by the system
header files.
When autoconf comes, this will look a lot nicer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6684 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/Support/DataTypes.h | 29 | ||||
-rw-r--r-- | include/llvm/Bytecode/Primitives.h | 10 |
2 files changed, 27 insertions, 12 deletions
diff --git a/include/Support/DataTypes.h b/include/Support/DataTypes.h index 3d377bebe6..ca27df6f86 100644 --- a/include/Support/DataTypes.h +++ b/include/Support/DataTypes.h @@ -4,10 +4,10 @@ // This file is important because different host OS's define different macros, // which makes portability tough. This file exports the following definitions: // -// LITTLE_ENDIAN: is #define'd if the host is little endian -// int64_t : is a typedef for the signed 64 bit system type -// uint64_t : is a typedef for the unsigned 64 bit system type -// INT64_MAX : is a #define specifying the max value for int64_t's +// ENDIAN_LITTLE : is #define'd if the host is little endian +// int64_t : is a typedef for the signed 64 bit system type +// uint64_t : is a typedef for the unsigned 64 bit system type +// INT64_MAX : is a #define specifying the max value for int64_t's // // No library is required when using these functinons. // @@ -44,11 +44,26 @@ # endif #endif -#if (defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)) -#error "Cannot define both LITTLE_ENDIAN and BIG_ENDIAN!" +// +// Convert the information from the header files into our own local +// endian macros. We do this because various strange systems define both +// BIG_ENDIAN and LITTLE_ENDIAN, and we don't want to conflict with them. +// +// Don't worry; once we introduce autoconf, this will look a lot nicer. +// +#ifdef LITTLE_ENDIAN +#define ENDIAN_LITTLE +#endif + +#ifdef BIG_ENDIAN +#define ENDIAN_BIG +#endif + +#if (defined(ENDIAN_LITTLE) && defined(ENDIAN_BIG)) +#error "Cannot define both ENDIAN_LITTLE and ENDIAN_BIG!" #endif -#if (!defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)) || !defined(INT64_MAX) +#if (!defined(ENDIAN_LITTLE) && !defined(ENDIAN_BIG)) || !defined(INT64_MAX) #error "include/Support/DataTypes.h could not determine endianness!" #endif diff --git a/include/llvm/Bytecode/Primitives.h b/include/llvm/Bytecode/Primitives.h index b72bbf2967..ee552c2fbb 100644 --- a/include/llvm/Bytecode/Primitives.h +++ b/include/llvm/Bytecode/Primitives.h @@ -23,7 +23,7 @@ static inline bool read(const unsigned char *&Buf, const unsigned char *EndBuf, unsigned &Result) { if (Buf+4 > EndBuf) return true; -#ifdef LITTLE_ENDIAN +#ifdef ENDIAN_LITTLE Result = *(unsigned*)Buf; #else Result = Buf[0] | (Buf[1] << 8) | (Buf[2] << 16) | (Buf[3] << 24); @@ -36,7 +36,7 @@ static inline bool read(const unsigned char *&Buf, const unsigned char *EndBuf, uint64_t &Result) { if (Buf+8 > EndBuf) return true; -#ifdef LITTLE_ENDIAN +#ifdef ENDIAN_LITTLE Result = *(uint64_t*)Buf; #else Result = Buf[0] | (Buf[1] << 8) | (Buf[2] << 16) | (Buf[3] << 24) | @@ -136,7 +136,7 @@ static inline bool input_data(const unsigned char *&Buf, unsigned char *Start = (unsigned char *)Ptr; unsigned Amount = (unsigned char *)End - Start; if (Buf+Amount > EndBuf) return true; -#ifdef LITTLE_ENDIAN +#ifdef ENDIAN_LITTLE std::copy(Buf, Buf+Amount, Start); Buf += Amount; #else @@ -159,7 +159,7 @@ static inline bool input_data(const unsigned char *&Buf, // static inline void output(unsigned i, std::deque<unsigned char> &Out, int pos = -1) { -#ifdef LITTLE_ENDIAN +#ifdef ENDIAN_LITTLE if (pos == -1) Out.insert(Out.end(), (unsigned char*)&i, (unsigned char*)&i+4); else @@ -257,7 +257,7 @@ static inline void output(const std::string &s, std::deque<unsigned char> &Out, static inline void output_data(void *Ptr, void *End, std::deque<unsigned char> &Out, bool Align = false) { -#ifdef LITTLE_ENDIAN +#ifdef ENDIAN_LITTLE Out.insert(Out.end(), (unsigned char*)Ptr, (unsigned char*)End); #else unsigned char *E = (unsigned char *)End; |