- CONST Bufbyte *end = ptr + len;
-
-#if (LONGBITS == 32 || LONGBITS == 64)
-
-# if (LONGBITS == 32)
-# define LONG_BYTES 4
-# define ALIGN_MASK 0xFFFFFFFCU
-# define HIGH_BIT_MASK 0x80808080U
-# else
-# define LONG_BYTES 8
-# define ALIGN_MASK 0xFFFFFFFFFFFFFFF8UL
- /* I had a dream, I was being overrun with early Intel processors ... */
-# define HIGH_BIT_MASK 0x8080808080808080UL
-# endif
-
- /* When we have a large number of bytes to scan, we can be trickier
- and significantly faster by scanning them in chunks of the CPU word
- size (assuming that they're all ASCII -- we cut out as soon as
- we find something non-ASCII). */
- if (len >= 12)
- {
- /* Determine the section in the middle of the string that's
- amenable to this treatment. Everything has to be aligned
- on CPU word boundaries. */
- CONST Bufbyte *aligned_ptr =
- (CONST Bufbyte *) (((unsigned long) (ptr + LONG_BYTES - 1)) &
- ALIGN_MASK);
- CONST Bufbyte *aligned_end =
- (CONST Bufbyte *) (((unsigned long) end) & ALIGN_MASK);
-
- /* Handle unaligned stuff at the beginning. */
- while (ptr < aligned_ptr)
+ const Bufbyte *end = ptr + len;
+
+#if SIZEOF_LONG == 8
+# define STRIDE_TYPE long
+# define HIGH_BIT_MASK 0x8080808080808080UL
+#elif SIZEOF_LONG_LONG == 8 && !(defined (i386) || defined (__i386__))
+# define STRIDE_TYPE long long
+# define HIGH_BIT_MASK 0x8080808080808080ULL
+#elif SIZEOF_LONG == 4
+# define STRIDE_TYPE long
+# define HIGH_BIT_MASK 0x80808080UL
+#else
+# error Add support for 128-bit systems here
+#endif
+
+#define ALIGN_BITS ((EMACS_UINT) (ALIGNOF (STRIDE_TYPE) - 1))
+#define ALIGN_MASK (~ ALIGN_BITS)
+#define ALIGNED(ptr) ((((EMACS_UINT) ptr) & ALIGN_BITS) == 0)
+#define STRIDE sizeof (STRIDE_TYPE)
+
+ while (ptr < end)
+ {
+ if (BYTE_ASCII_P (*ptr))