From ce2471673fdba3fddea728c0659b9c14230fa008 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 15 Dec 2015 12:49:03 +0100 Subject: [PATCH 1/2] src: remove unused BITS_PER_LONG macro Remove the unused and broken BITS_PER_LONG macro. Broken because x64 is the only 64 bits architecture where it produces the right result. PR-URL: https://github.com/nodejs/node/pull/4290 Reviewed-By: Colin Ihrig --- src/node_internals.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/node_internals.h b/src/node_internals.h index e1ba9e22941e31..c720f70eda0d62 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -109,12 +109,6 @@ inline static int snprintf(char *buffer, size_t n, const char *format, ...) { #endif #endif -#if defined(__x86_64__) -# define BITS_PER_LONG 64 -#else -# define BITS_PER_LONG 32 -#endif - #ifndef ARRAY_SIZE # define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) #endif From f176b31e749d0a692431940e44fd8b16fca75620 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 15 Dec 2015 12:57:49 +0100 Subject: [PATCH 2/2] src: remove __builtin_bswap16 call 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: https://github.com/nodejs/node/issues/4284 PR-URL: https://github.com/nodejs/node/pull/4290 Reviewed-By: Colin Ihrig --- src/util-inl.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/util-inl.h b/src/util-inl.h index 669b7e7535884b..69dc5b2a61a1a9 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -199,15 +199,8 @@ TypeName* Unwrap(v8::Local 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 - } }