ruby-changes:42793
From: naruse <ko1@a...>
Date: Sun, 1 May 2016 22:22:26 +0900 (JST)
Subject: [ruby-changes:42793] naruse:r54867 (trunk): fix for where UNALIGNED_WORD_ACCESS is not allowed
naruse 2016-05-01 23:19:02 +0900 (Sun, 01 May 2016) New Revision: 54867 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54867 Log: fix for where UNALIGNED_WORD_ACCESS is not allowed Modified files: trunk/string.c Index: string.c =================================================================== --- string.c (revision 54866) +++ string.c (revision 54867) @@ -429,22 +429,27 @@ search_nonascii(const char *p, const cha https://github.com/ruby/ruby/blob/trunk/string.c#L429 #endif #if !UNALIGNED_WORD_ACCESS - if (e - p > SIZEOF_VOIDP) { - switch (8 - (uintptr_t)p % 8) { + if (e - p >= SIZEOF_VOIDP) { + if ((uintptr_t)p % SIZEOF_VOIDP) { + int l = SIZEOF_VOIDP - (uintptr_t)p % SIZEOF_VOIDP; + p += l; + switch (l) { + default: UNREACHABLE; #if SIZEOF_VOIDP > 4 - case 7: if (*p&0x80) return p; p++; - case 6: if (*p&0x80) return p; p++; - case 5: if (*p&0x80) return p; p++; - case 4: if (*p&0x80) return p; p++; + case 7: if (p[-7]&0x80) return p-7; + case 6: if (p[-6]&0x80) return p-6; + case 5: if (p[-5]&0x80) return p-5; + case 4: if (p[-4]&0x80) return p-4; #endif - case 3: if (*p&0x80) return p; p++; - case 2: if (*p&0x80) return p; p++; - case 1: if (*p&0x80) return p; p++; + case 3: if (p[-3]&0x80) return p-3; + case 2: if (p[-2]&0x80) return p-2; + case 1: if (p[-1]&0x80) return p-1; + case 0: break; + } } - } -#endif - +#else { +#endif const uintptr_t *s = (const uintptr_t *)p; const uintptr_t *t = (const uintptr_t *)(e - (SIZEOF_VOIDP-1)); for (;s < t; s++) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/