From 7420835390bcf44696349fad0498390959816acd Mon Sep 17 00:00:00 2001 From: Zach Bjornson Date: Wed, 21 Sep 2016 18:02:45 -0700 Subject: src: fix build for older clang Removes use of builtins that are unavailable for older clang. Per benchmarks, only uses builtins on Windows, where speedup is significant. Also adds test for unaligned ucs2 buffer write. Between #3410 and #7645, bytes were swapped twice on bigendian platforms if buffer was not two-byte aligned. See comment in #7645. PR-URL: https://github.com/nodejs/node/pull/7645 Fixes: https://github.com/nodejs/node/issues/7618 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- src/util.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/util.h') diff --git a/src/util.h b/src/util.h index 25f2eb01783..e2f9df02bc4 100644 --- a/src/util.h +++ b/src/util.h @@ -254,7 +254,11 @@ inline void ClearWrap(v8::Local object); template inline TypeName* Unwrap(v8::Local object); -inline void SwapBytes(uint16_t* dst, const uint16_t* src, size_t buflen); +// Swaps bytes in place. nbytes is the number of bytes to swap and must be a +// multiple of the word size (checked by function). +inline void SwapBytes16(char* data, size_t nbytes); +inline void SwapBytes32(char* data, size_t nbytes); +inline void SwapBytes64(char* data, size_t nbytes); // tolower() is locale-sensitive. Use ToLower() instead. inline char ToLower(char c); -- cgit v1.2.3