OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / glibc / glibc-2.3.6-string.patch
1 --- glibc-2.3.6/sysdeps/i386/bits/string.h.old  2008-07-20 09:45:26.000000000 +1000
2 +++ glibc-2.3.6/sysdeps/i386/bits/string.h      2008-07-20 10:08:32.000000000 +1000
3 @@ -562,21 +562,20 @@
4    register unsigned long int __d0;
5    register char *__res;
6    __asm__ __volatile__
7 -    ("cld\n\t"
8 -     "1:\n\t"
9 -     "lodsb\n\t"
10 +    ("1:\n\t"
11 +     "movb     (%0),%%al\n\t"
12       "cmpb     %%ah,%%al\n\t"
13       "je       2f\n\t"
14 +     "leal     1(%0),%0\n\t"
15       "testb    %%al,%%al\n\t"
16       "jne      1b\n\t"
17 -     "movl     $1,%1\n"
18 -     "2:\n\t"
19 -     "movl     %1,%0"
20 -     : "=a" (__res), "=&S" (__d0)
21 -     : "0" (__c), "1" (__s),
22 +     "xorl     %0,%0\n"
23 +     "2:"
24 +     : "=r" (__res), "=&a" (__d0)
25 +     : "0" (__s), "1" (__c),
26         "m" ( *(struct { char __x[0xfffffff]; } *)__s)
27       : "cc");
28 -  return __res - 1;
29 +  return __res;
30  }
31  
32  
33 @@ -651,15 +650,14 @@
34  strcspn (__const char *__s, __const char *__reject)
35  {
36    register unsigned long int __d0, __d1, __d2;
37 -  register char *__res;
38 +  register __const char *__res;
39    __asm__ __volatile__
40      ("pushl    %%ebx\n\t"
41 -     "cld\n\t"
42       "movl     %4,%%edi\n\t"
43 +     "cld\n\t"
44       "repne; scasb\n\t"
45       "notl     %%ecx\n\t"
46 -     "decl     %%ecx\n\t"
47 -     "movl     %%ecx,%%ebx\n"
48 +     "leal     -1(%%ecx),%%ebx\n"
49       "1:\n\t"
50       "lodsb\n\t"
51       "testb    %%al,%%al\n\t"
52 @@ -670,10 +668,9 @@
53       "jne      1b\n"
54       "2:\n\t"
55       "popl     %%ebx"
56 -     : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
57 -     : "d" (__reject), "0" (__s), "1" (0), "2" (0xffffffff),
58 -       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
59 -     : "cc");
60 +     : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
61 +     : "r" (__reject), "0" (__s), "1" (0), "2" (0xffffffff)
62 +     : "memory", "cc");
63    return (__res - 1) - __s;
64  }
65  # else
66 @@ -781,21 +778,20 @@
67  __STRING_INLINE char *
68  strpbrk (__const char *__s, __const char *__accept)
69  {
70 -  unsigned long int __d0, __d1, __d2;
71 +  register unsigned long int __d0, __d1, __d2;
72    register char *__res;
73    __asm__ __volatile__
74      ("pushl    %%ebx\n\t"
75 +     "movl     %%edx,%%edi\n\t"
76       "cld\n\t"
77 -     "movl     %4,%%edi\n\t"
78       "repne; scasb\n\t"
79       "notl     %%ecx\n\t"
80 -     "decl     %%ecx\n\t"
81 -     "movl     %%ecx,%%ebx\n"
82 +     "leal     -1(%%ecx),%%ebx\n"
83       "1:\n\t"
84       "lodsb\n\t"
85       "testb    %%al,%%al\n\t"
86       "je       2f\n\t"
87 -     "movl     %4,%%edi\n\t"
88 +     "movl     %%edx,%%edi\n\t"
89       "movl     %%ebx,%%ecx\n\t"
90       "repne; scasb\n\t"
91       "jne      1b\n\t"
92 @@ -805,10 +801,9 @@
93       "xorl     %0,%0\n"
94       "3:\n\t"
95       "popl     %%ebx"
96 -     : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
97 -     : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
98 -       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
99 -     : "cc");
100 +     : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
101 +     : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff)
102 +     : "memory", "cc");
103    return __res;
104  }
105  # else
106 @@ -857,28 +852,27 @@
107    register unsigned long int __d0, __d1, __d2;
108    register char *__res;
109    __asm__ __volatile__
110 -    ("pushl    %%ebx\n\t"
111 -     "cld\n\t" \
112 -     "movl     %4,%%edi\n\t"
113 +    ("cld\n\t"
114       "repne; scasb\n\t"
115       "notl     %%ecx\n\t"
116 +     "pushl    %%ebx\n\t"
117       "decl     %%ecx\n\t"      /* NOTE! This also sets Z if searchstring='' */
118       "movl     %%ecx,%%ebx\n"
119       "1:\n\t"
120 -     "movl     %4,%%edi\n\t"
121 +     "movl     %%edx,%%edi\n\t"
122       "movl     %%esi,%%eax\n\t"
123       "movl     %%ebx,%%ecx\n\t"
124       "repe; cmpsb\n\t"
125       "je       2f\n\t"         /* also works for empty string, see above */
126 -     "xchgl    %%eax,%%esi\n\t"
127 -     "incl     %%esi\n\t"
128 -     "cmpb     $0,-1(%%eax)\n\t"
129 +     "cmpb     $0,-1(%%esi)\n\t"
130 +     "leal     1(%%eax),%%esi\n\t"
131       "jne      1b\n\t"
132 -     "xorl     %%eax,%%eax\n\t"
133 +     "xorl     %%eax,%%eax\n"
134       "2:\n\t"
135       "popl     %%ebx"
136       : "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2)
137 -     : "r" (__needle), "0" (0), "1" (0xffffffff), "2" (__haystack)
138 +     : "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (__needle),
139 +       "d" (__needle)
140       : "memory", "cc");
141    return __res;
142  }