Bug 1202012: P2. Make stagefright works on big-endian systems. r=rillian

This commit is contained in:
Jean-Yves Avenard 2015-09-12 02:29:36 +10:00
parent c6d2e5e3fa
commit 123ded9cd5

View File

@ -60,11 +60,18 @@ uint64_t U64LE_AT(const uint8_t *ptr) {
return ((uint64_t)U32LE_AT(ptr + 4)) << 32 | U32LE_AT(ptr);
}
// XXX warning: these won't work on big-endian host.
uint64_t ntoh64(uint64_t x) {
return ((uint64_t)ntohl(x & 0xffffffff) << 32) | ntohl(x >> 32);
return ((x & 0xFF00000000000000ull) >> 56) |
((x & 0x00FF000000000000ull) >> 40) |
((x & 0x0000FF0000000000ull) >> 24) |
((x & 0x000000FF00000000ull) >> 8) |
((x & 0x00000000FF000000ull) << 8) |
((x & 0x0000000000FF0000ull) << 24) |
((x & 0x000000000000FF00ull) << 40) |
((x & 0x00000000000000FFull) << 56);
}
// XXX warning: this won't work on big-endian host.
uint64_t hton64(uint64_t x) {
return ((uint64_t)htonl(x & 0xffffffff) << 32) | htonl(x >> 32);
}