fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / machine / xscale / strchr.c
blob3b736c53c52e89d7d068f2282d1208bcf267e70a
1 #if defined __thumb__
3 #include "../../string/strchr.c"
5 #else
7 #include <string.h>
8 #include "xscale.h"
10 char *
11 strchr (const char *s, int c)
13 unsigned int c2;
14 asm (PRELOADSTR ("%0") : : "r" (s));
16 c &= 0xff;
18 #ifndef __OPTIMIZE_SIZE__
19 /* Skip unaligned part. */
20 if ((long)s & 3)
22 s--;
25 int c2 = *++s;
26 if (c2 == c)
27 return (char *)s;
28 if (c2 == '\0')
29 return 0;
31 while (((long)s & 3) != 0);
34 c2 = c + (c << 8);
35 c2 += c2 << 16;
37 /* Load two constants:
38 R6 = 0xfefefeff [ == ~(0x80808080 << 1) ]
39 R5 = 0x80808080 */
41 asm (PRELOADSTR ("%0") "\n\
42 mov r5, #0x80\n\
43 add r5, r5, #0x8000\n\
44 add r5, r5, r5, lsl #16\n\
45 mvn r6, r5, lsl #1\n\
46 \n\
47 sub %0, %0, #4\n\
48 0:\n\
49 ldr r1, [%0, #4]!\n\
50 " PRELOADSTR ("%0") "\n\
51 add r3, r1, r6\n\
52 bic r3, r3, r1\n\
53 ands r2, r3, r5\n\
54 bne 1f\n\
55 eor r2, r1, %1\n\
56 add r3, r2, r6\n\
57 bic r3, r3, r2\n\
58 ands r1, r3, r5\n\
59 beq 0b\n\
60 1:"
61 : "=&r" (s)
62 : "r" (c2), "0" (s)
63 : "r1", "r2", "r3", "r5", "r6", "cc");
64 #endif
66 while (*s && *s != c)
67 s++;
68 if (*s == c)
69 return (char *)s;
70 return NULL;
73 #endif