*/
static inline uint32_t switch_toupper(uint32_t eax)
{
- uint32_t ebx = (0x7f7f7f7ful & eax) + 0x05050505ul;
- ebx = (0x7f7f7f7ful & ebx) + 0x1a1a1a1aul;
- ebx = ((ebx & ~eax) >> 2 ) & 0x20202020ul;
- return eax - ebx;
+uint32_t ebx = (0x7f7f7f7ful & eax) + 0x05050505ul;
+ebx = (0x7f7f7f7ful & ebx) + 0x1a1a1a1aul;
+ ebx = ((ebx & ~eax) >> 2 ) & 0x20202020ul;
+ return eax - ebx;
}
/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
return eax + ebx;
}
+
#ifdef FS_64BIT
+/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
+ http://www.azillionmonkeys.com/qed/asmexample.html
+*/
+static inline uint64_t switch_toupper64(uint64_t eax)
+{
+uint64_t ebx = (0x7f7f7f7f7f7f7f7full & eax) + 0x0505050505050505ull;
+ ebx = (0x7f7f7f7f7f7f7f7full & ebx) + 0x1a1a1a1a1a1a1a1aull;
+ ebx = ((ebx & ~eax) >> 2 ) & 0x2020202020202020ull;
+ return eax - ebx;
+}
+
+/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
+ http://www.azillionmonkeys.com/qed/asmexample.html
+*/
+static inline uint64_t switch_tolower64(uint64_t eax)
+{
+ uint64_t ebx = (0x7f7f7f7f7f7f7f7full & eax) + 0x2525252525252525ull;
+ ebx = (0x7f7f7f7f7f7f7f7full & ebx) + 0x1a1a1a1a1a1a1a1aull;
+ ebx = ((ebx & ~eax) >> 2) & 0x2020202020202020ull;
+ return eax + ebx;
+}
+
static inline void switch_toupper_max(char *s)
{
uint64_t *b,*p;
while (l > 8) {
b = p;
- *b = (uint32_t) switch_toupper(*b);
+ *b = (uint64_t) switch_toupper64(*b);
b++;
p++;
l -= 8;
while (l > 8) {
b = p;
- *b = (uint32_t) switch_tolower(*b);
+ *b = (uint64_t) switch_tolower64(*b);
b++;
p++;
l -= 8;
#endif
+
+
SWITCH_DECLARE(int) old_switch_toupper(int c);
SWITCH_DECLARE(int) old_switch_tolower(int c);
SWITCH_DECLARE(int) switch_isalnum(int c);