Skip to content

Commit

Permalink
src: remove __builtin_bswap16 call
Browse files Browse the repository at this point in the history
Not supported by apple-gcc and I'm not convinced it's worth adding more
preprocessor hacks when it should be easy as pie for the compiler to
to optimize the byteswap.  If it doesn't, fix the compiler.

Fixes: #4284
PR-URL: #4290
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
bnoordhuis authored and Myles Borins committed Feb 17, 2016
1 parent 5058fb9 commit 9b3bc56
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/util-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,8 @@ TypeName* Unwrap(v8::Local<v8::Object> object) {
}

void SwapBytes(uint16_t* dst, const uint16_t* src, size_t buflen) {
for (size_t i = 0; i < buflen; i++) {
// __builtin_bswap16 generates more efficient code with
// g++ 4.8 on PowerPC and other big-endian archs
#ifdef __GNUC__
dst[i] = __builtin_bswap16(src[i]);
#else
for (size_t i = 0; i < buflen; i += 1)
dst[i] = (src[i] << 8) | (src[i] >> 8);
#endif
}
}


Expand Down

0 comments on commit 9b3bc56

Please sign in to comment.