Bug 1287671 - Replace IS_{LITTLE|BIG}_ENDIAN with MOZ_{LITTLE|BIG}_ENDIAN in js/. r?njn draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 04 Oct 2016 15:31:45 +0900
changeset 420690 e5c6d2c6f71c7d9816e9bdb2966c385dde20347b
parent 420421 44715a6d285ce19505c2979fc4cd2a0adfdfcab4
child 420691 884a935cf32303930bfce8c664a95ad01225933c
push id31255
push userbmo:mh+mozilla@glandium.org
push dateTue, 04 Oct 2016 12:59:47 +0000
reviewersnjn
bugs1287671
milestone52.0a1
Bug 1287671 - Replace IS_{LITTLE|BIG}_ENDIAN with MOZ_{LITTLE|BIG}_ENDIAN in js/. r?njn
js/public/Value.h
js/src/jit/Lowering.cpp
js/src/jit/MacroAssembler.h
js/src/jsatom.cpp
js/src/jscpucfg.h
js/src/jsdtoa.cpp
js/src/vm/TypedArrayObject.cpp
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -232,17 +232,17 @@ typedef enum JSWhyMagic
     JS_UNINITIALIZED_LEXICAL,
 
     /** for local use */
     JS_GENERIC_MAGIC,
 
     JS_WHY_MAGIC_COUNT
 } JSWhyMagic;
 
-#if defined(IS_LITTLE_ENDIAN)
+#if MOZ_LITTLE_ENDIAN
 # if defined(JS_NUNBOX32)
 typedef union jsval_layout
 {
     uint64_t asBits;
     struct {
         union {
             int32_t        i32;
             uint32_t       u32;
@@ -280,17 +280,17 @@ typedef union jsval_layout
         } payload;
     } s;
     double asDouble;
     void* asPtr;
     size_t asWord;
     uintptr_t asUIntPtr;
 } JSVAL_ALIGNMENT jsval_layout;
 # endif  /* JS_PUNBOX64 */
-#else   /* defined(IS_LITTLE_ENDIAN) */
+#else   /* MOZ_LITTLE_ENDIAN */
 # if defined(JS_NUNBOX32)
 typedef union jsval_layout
 {
     uint64_t asBits;
     struct {
         JSValueTag tag;
         union {
             int32_t        i32;
@@ -326,17 +326,17 @@ typedef union jsval_layout
         } payload;
     } s;
     double asDouble;
     void* asPtr;
     size_t asWord;
     uintptr_t asUIntPtr;
 } JSVAL_ALIGNMENT jsval_layout;
 # endif /* JS_PUNBOX64 */
-#endif  /* defined(IS_LITTLE_ENDIAN) */
+#endif  /* MOZ_LITTLE_ENDIAN */
 
 JS_STATIC_ASSERT(sizeof(jsval_layout) == 8);
 
 /*
  * For codesize purposes on some platforms, it's important that the
  * compiler know that JS::Values constructed from constant values can be
  * folded to constant bit patterns at compile time, rather than
  * constructed at runtime.  Doing this requires a fair amount of C++11
--- a/js/src/jit/Lowering.cpp
+++ b/js/src/jit/Lowering.cpp
@@ -61,17 +61,17 @@ LIRGenerator::visitParameter(MParameter*
     else
         offset = 1 + param->index();
 
     LParameter* ins = new(alloc()) LParameter;
     defineBox(ins, param, LDefinition::FIXED);
 
     offset *= sizeof(Value);
 #if defined(JS_NUNBOX32)
-# if defined(IS_BIG_ENDIAN)
+# if MOZ_BIG_ENDIAN
     ins->getDef(0)->setOutput(LArgument(offset));
     ins->getDef(1)->setOutput(LArgument(offset + 4));
 # else
     ins->getDef(0)->setOutput(LArgument(offset + 4));
     ins->getDef(1)->setOutput(LArgument(offset));
 # endif
 #elif defined(JS_PUNBOX64)
     ins->getDef(0)->setOutput(LArgument(offset));
--- a/js/src/jit/MacroAssembler.h
+++ b/js/src/jit/MacroAssembler.h
@@ -174,17 +174,17 @@ using mozilla::FloatingPoint;
 
 # define DEFINED_ON(...)                                \
     DEFINED_ON_MAP_ON_ARCHS((none, __VA_ARGS__))
 
 # define PER_ARCH DEFINED_ON(ALL_ARCH)
 # define PER_SHARED_ARCH DEFINED_ON(ALL_SHARED_ARCH)
 
 
-#ifdef IS_LITTLE_ENDIAN
+#if MOZ_LITTLE_ENDIAN
 #define IMM32_16ADJ(X) X << 16
 #else
 #define IMM32_16ADJ(X) X
 #endif
 
 namespace js {
 namespace jit {
 
--- a/js/src/jsatom.cpp
+++ b/js/src/jsatom.cpp
@@ -563,17 +563,17 @@ js::XDRAtom(XDRState<mode>* xdr, Mutable
     bool latin1 = lengthAndEncoding & 0x1;
 
     JSContext* cx = xdr->cx();
     JSAtom* atom;
     if (latin1) {
         const Latin1Char* chars = reinterpret_cast<const Latin1Char*>(xdr->buf.read(length));
         atom = AtomizeChars(cx, chars, length);
     } else {
-#if IS_LITTLE_ENDIAN
+#if MOZ_LITTLE_ENDIAN
         /* Directly access the little endian chars in the XDR buffer. */
         const char16_t* chars = reinterpret_cast<const char16_t*>(xdr->buf.read(length * sizeof(char16_t)));
         atom = AtomizeChars(cx, chars, length);
 #else
         /*
          * We must copy chars to a temporary buffer to convert between little and
          * big endian data.
          */
@@ -591,17 +591,17 @@ js::XDRAtom(XDRState<mode>* xdr, Mutable
             if (!chars)
                 return false;
         }
 
         JS_ALWAYS_TRUE(xdr->codeChars(chars, length));
         atom = AtomizeChars(cx, chars, length);
         if (chars != stackChars)
             js_free(chars);
-#endif /* !IS_LITTLE_ENDIAN */
+#endif /* !MOZ_LITTLE_ENDIAN */
     }
 
     if (!atom)
         return false;
     atomp.set(atom);
     return true;
 }
 
--- a/js/src/jscpucfg.h
+++ b/js/src/jscpucfg.h
@@ -4,26 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jscpucfg_h
 #define jscpucfg_h
 
 #include "mozilla/EndianUtils.h"
 
-#if defined(MOZ_LITTLE_ENDIAN)
-# define IS_LITTLE_ENDIAN 1
-# undef  IS_BIG_ENDIAN
-#elif defined(MOZ_BIG_ENDIAN)
-# undef  IS_LITTLE_ENDIAN
-# define IS_BIG_ENDIAN 1
-#else
-# error "Cannot determine endianness of your platform. Please add support to jscpucfg.h."
-#endif
-
 #ifndef JS_STACK_GROWTH_DIRECTION
 # ifdef __hppa
 #  define JS_STACK_GROWTH_DIRECTION (1)
 # else
 #  define JS_STACK_GROWTH_DIRECTION (-1)
 # endif
 #endif
 
--- a/js/src/jsdtoa.cpp
+++ b/js/src/jsdtoa.cpp
@@ -11,17 +11,17 @@
 #include "jsdtoa.h"
 
 #include "jsprf.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
 using namespace js;
 
-#ifdef IS_LITTLE_ENDIAN
+#if MOZ_LITTLE_ENDIAN
 #define IEEE_8087
 #else
 #define IEEE_MC68k
 #endif
 
 #ifndef Long
 #define Long int32_t
 #endif
--- a/js/src/vm/TypedArrayObject.cpp
+++ b/js/src/vm/TypedArrayObject.cpp
@@ -1779,17 +1779,17 @@ DataViewObject::getDataPointer(JSContext
 
     MOZ_ASSERT(offset < UINT32_MAX);
     return static_cast<uint8_t*>(obj->dataPointer()) + uint32_t(offset);
 }
 
 static inline bool
 needToSwapBytes(bool littleEndian)
 {
-#if IS_LITTLE_ENDIAN
+#if MOZ_LITTLE_ENDIAN
     return !littleEndian;
 #else
     return littleEndian;
 #endif
 }
 
 static inline uint8_t
 swapBytes(uint8_t x)