| Index: src/utils.h
|
| diff --git a/src/utils.h b/src/utils.h
|
| index 9b94a2feb1de6a7e9fcc8910ec3008e93f4a3bca..2acc95ef3c07f9a5a565c9fffae1c59db289a14c 100644
|
| --- a/src/utils.h
|
| +++ b/src/utils.h
|
| @@ -1552,6 +1552,33 @@ static inline void WriteUnalignedUInt32(void* p, uint32_t value) {
|
| WriteUnalignedValue(p, value);
|
| }
|
|
|
| +template <typename V>
|
| +static inline V ReadLittleEndianValue(const void* p) {
|
| +#if defined(V8_TARGET_LITTLE_ENDIAN)
|
| + return ReadUnalignedValue<V>(p);
|
| +#elif defined(V8_TARGET_BIG_ENDIAN)
|
| + V ret = 0;
|
| + const byte* src = reinterpret_cast<const byte*>(p);
|
| + byte* dst = reinterpret_cast<byte*>(&ret);
|
| + for (size_t i = 0; i < sizeof(V); i++) {
|
| + dst[i] = src[sizeof(V) - i - 1];
|
| + }
|
| + return ret;
|
| +#endif // V8_TARGET_LITTLE_ENDIAN
|
| +}
|
| +
|
| +template <typename V>
|
| +static inline void WriteLittleEndianValue(void* p, V value) {
|
| +#if defined(V8_TARGET_LITTLE_ENDIAN)
|
| + WriteUnalignedValue<V>(p, value);
|
| +#elif defined(V8_TARGET_BIG_ENDIAN)
|
| + byte* src = reinterpret_cast<byte*>(&value);
|
| + byte* dst = reinterpret_cast<byte*>(p);
|
| + for (size_t i = 0; i < sizeof(V); i++) {
|
| + dst[i] = src[sizeof(V) - i - 1];
|
| + }
|
| +#endif // V8_TARGET_LITTLE_ENDIAN
|
| +}
|
| } // namespace internal
|
| } // namespace v8
|
|
|
|
|