Bug 1525173 - prbit.h should use builtin function on aarch64. r=glandium
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 07 Feb 2019 15:50:31 -0700
changeset 4801 753fe0f7964c3faef5e4410ed7e0c965df7b180b
parent 4800 5f4fed68d661de81638c8e1f108aff075a33d46e
child 4802 e61b118b47e6bda53067db0d3a755b4a6ed02c79
push id308
push userjjones@mozilla.com
push dateThu, 07 Feb 2019 22:53:41 +0000
reviewersglandium
bugs1525173
Bug 1525173 - prbit.h should use builtin function on aarch64. r=glandium
pr/include/prbit.h
--- a/pr/include/prbit.h
+++ b/pr/include/prbit.h
@@ -9,17 +9,18 @@
 #include "prtypes.h"
 PR_BEGIN_EXTERN_C
 
 /*
 ** Replace compare/jump/add/shift sequence with compiler built-in/intrinsic
 ** functions.
 */
 #if defined(_WIN32) && (_MSC_VER >= 1300) && \
-    (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM))
+    (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) || \
+     defined(_M_ARM64))
 # include <intrin.h>
 # pragma  intrinsic(_BitScanForward,_BitScanReverse)
   __forceinline static int __prBitScanForward32(unsigned int val)
   { 
     unsigned long idx;
     _BitScanForward(&idx, (unsigned long)val);
     return( (int)idx );
   }
@@ -28,17 +29,18 @@ PR_BEGIN_EXTERN_C
     unsigned long idx;
     _BitScanReverse(&idx, (unsigned long)val);
     return( (int)(31-idx) );
   }
 # define pr_bitscan_ctz32(val)  __prBitScanForward32(val)
 # define pr_bitscan_clz32(val)  __prBitScanReverse32(val)
 # define  PR_HAVE_BUILTIN_BITSCAN32
 #elif ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && \
-       (defined(__i386__) || defined(__x86_64__) || defined(__arm__))
+       (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
+        defined(__aarch64__))
 # define pr_bitscan_ctz32(val)  __builtin_ctz(val)
 # define pr_bitscan_clz32(val)  __builtin_clz(val)
 # define  PR_HAVE_BUILTIN_BITSCAN32
 #endif /* MSVC || GCC */
 
 /*
 ** A prbitmap_t is a long integer that can be used for bitmaps
 */
@@ -131,17 +133,17 @@ NSPR_API(PRIntn) PR_FloorLog2(PRUint32 i
 ** To get MSVC to generate a rotate instruction, we have to use the _rotl
 ** or _rotr intrinsic and use a pragma to make it inline.
 **
 ** Note: MSVC in VS2005 will do an inline rotate instruction on the above
 ** construct.
 */
 
 #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \
-    defined(_M_X64) || defined(_M_ARM))
+    defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64))
 #include <stdlib.h>
 #pragma intrinsic(_rotl, _rotr)
 #define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits)
 #define PR_ROTATE_RIGHT32(a, bits) _rotr(a, bits)
 #else
 #define PR_ROTATE_LEFT32(a, bits) (((a) << (bits)) | ((a) >> (32 - (bits))))
 #define PR_ROTATE_RIGHT32(a, bits) (((a) >> (bits)) | ((a) << (32 - (bits))))
 #endif