Skip to content

Commit cd99161

Browse files
committed
Fix for the crash on big endian machine. (#197)
Signed-off-by: Konstantin Maksimov <[email protected]>
1 parent f383473 commit cd99161

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/v8/v8.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,11 @@ bool V8::setWord(uint64_t pointer, Word word) {
441441
if (pointer + size > memory_->data_size()) {
442442
return false;
443443
}
444+
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
445+
uint32_t word32 = __builtin_bswap32(word.u32());
446+
#else
444447
uint32_t word32 = word.u32();
448+
#endif
445449
::memcpy(memory_->data() + pointer, &word32, size);
446450
return true;
447451
}

0 commit comments

Comments
 (0)