OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [machine/] [xscale/] [strchr.c] - Blame information for rev 158

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
#if defined __thumb__
2
 
3
#include "../../string/strchr.c"
4
 
5
#else
6
 
7
#include <string.h>
8
#include "xscale.h"
9
 
10
char *
11
strchr (const char *s, int c)
12
{
13
  unsigned int c2;
14
  asm (PRELOADSTR ("%0") : : "r" (s));
15
 
16
  c &= 0xff;
17
 
18
#ifndef __OPTIMIZE_SIZE__
19
  /* Skip unaligned part.  */
20
  if ((long)s & 3)
21
    {
22
      s--;
23
      do
24
        {
25
          int c2 = *++s;
26
          if (c2 == c)
27
            return (char *)s;
28
          if (c2 == '\0')
29
            return 0;
30
        }
31
      while (((long)s & 3) != 0);
32
    }
33
 
34
  c2 = c + (c << 8);
35
  c2 += c2 << 16;
36
 
37
  /* Load two constants:
38
     R6 = 0xfefefeff [ == ~(0x80808080 << 1) ]
39
     R5 = 0x80808080  */
40
 
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
65
 
66
  while (*s && *s != c)
67
    s++;
68
  if (*s == c)
69
    return (char *)s;
70
  return NULL;
71
}
72
 
73
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.