* [PATCH] Fix i386 <bits/string.h>
@ 2004-06-13 19:50 Jakub Jelinek
2004-06-13 21:39 ` Andreas Schwab
2004-06-15 20:12 ` Roland McGrath
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2004-06-13 19:50 UTC (permalink / raw)
To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers
Hi!
It seems several changes which were done to i386/i486/bits/string.h were
not applied to i386/bits/string.h as well and with GCC 3.4 it shows up
in inl-tester.
2004-06-13 Jakub Jelinek <jakub@redhat.com>
* sysdeps/i386/bits/string.h (memcpy): Add () around arguments.
(memchr, __memrchr, strlen, strcmp, strncmp, __strchr_g, __strchr_c,
__strchrnul_g, __strchrnul_c, strspn, strcspn, strpbrk): Add memory
the asm uses as its input, either of size __n where __n is known or
0xfffffff.
(strstr): Add "memory" clobber.
--- libc/sysdeps/i386/bits/string.h.jj 2003-09-05 06:03:03.000000000 -0400
+++ libc/sysdeps/i386/bits/string.h 2004-06-13 15:35:35.000000000 -0400
@@ -43,8 +43,8 @@
#define _HAVE_STRING_ARCH_memcpy 1
#define memcpy(dest, src, n) \
(__extension__ (__builtin_constant_p (n) \
- ? __memcpy_c (dest, src, n) \
- : memcpy (dest, src, n)))
+ ? __memcpy_c ((dest), (src), (n)) \
+ : memcpy ((dest), (src), (n))))
/* This looks horribly ugly, but the compiler can optimize it totally,
as the count is constant. */
__STRING_INLINE void *__memcpy_c (void *__dest, __const void *__src,
@@ -301,7 +301,8 @@ memchr (__const void *__s, int __c, size
"movl $1,%0\n"
"1:"
: "=D" (__res), "=&c" (__d0)
- : "a" (__c), "0" (__s), "1" (__n)
+ : "a" (__c), "0" (__s), "1" (__n),
+ "m" ( *(struct { __extension__ char __x[__n]; } *)__s)
: "cc");
return __res - 1;
}
@@ -324,7 +325,8 @@ __memrchr (__const void *__s, int __c, s
"1:\tcld\n\t"
"incl %0"
: "=D" (__res), "=&c" (__d0)
- : "a" (__c), "0" (__s + __n - 1), "1" (__n)
+ : "a" (__c), "0" (__s + __n - 1), "1" (__n),
+ "m" ( *(struct { __extension__ char __x[__n]; } *)__s)
: "cc");
return __res;
}
@@ -346,7 +348,8 @@ strlen (__const char *__str)
"repne; scasb\n\t"
"notl %0"
: "=c" (__res), "=&D" (__d0)
- : "1" (__str), "a" (0), "0" (0xffffffff)
+ : "1" (__str), "a" (0), "0" (0xffffffff),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__str)
: "cc");
return __res - 1;
}
@@ -475,7 +478,9 @@ strcmp (__const char *__s1, __const char
"orb $1,%%al\n"
"3:"
: "=a" (__res), "=&S" (__d0), "=&D" (__d1)
- : "1" (__s1), "2" (__s2)
+ : "1" (__s1), "2" (__s2),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s1),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s2)
: "cc");
return __res;
}
@@ -507,7 +512,9 @@ strncmp (__const char *__s1, __const cha
"orb $1,%%al\n"
"4:"
: "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2)
- : "1" (__s1), "2" (__s2), "3" (__n)
+ : "1" (__s1), "2" (__s2), "3" (__n),
+ "m" ( *(struct { __extension__ char __x[__n]; } *)__s1),
+ "m" ( *(struct { __extension__ char __x[__n]; } *)__s2)
: "cc");
return __res;
}
@@ -541,7 +548,8 @@ __strchr_g (__const char *__s, int __c)
"2:\n\t"
"movl %1,%0"
: "=a" (__res), "=&S" (__d0)
- : "0" (__c), "1" (__s)
+ : "0" (__c), "1" (__s),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return __res - 1;
}
@@ -565,7 +573,8 @@ __strchr_c (__const char *__s, int __c)
"2:\n\t"
"movl %1,%0"
: "=a" (__res), "=&S" (__d0)
- : "0" (__c), "1" (__s)
+ : "0" (__c), "1" (__s),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return __res - 1;
}
@@ -599,7 +608,8 @@ __strchrnul_g (__const char *__s, int __
"2:\n\t"
"movl %1,%0"
: "=a" (__res), "=&S" (__d0)
- : "0" (__c), "1" (__s)
+ : "0" (__c), "1" (__s),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return __res - 1;
}
@@ -622,7 +632,8 @@ __strchrnul_c (__const char *__s, int __
"2:\n\t"
"movl %1,%0"
: "=a" (__res), "=&S" (__d0)
- : "0" (__c), "1" (__s)
+ : "0" (__c), "1" (__s),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return __res - 1;
}
@@ -660,7 +671,8 @@ strcspn (__const char *__s, __const char
"2:\n\t"
"popl %%ebx"
: "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
- : "d" (__reject), "0" (__s), "1" (0), "2" (0xffffffff)
+ : "d" (__reject), "0" (__s), "1" (0), "2" (0xffffffff),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return (__res - 1) - __s;
}
@@ -687,7 +699,8 @@ strcspn (__const char *__s, __const char
"jne 1b\n"
"2:"
: "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3)
- : "g" (__reject), "0" (__s), "1" (0), "2" (0xffffffff)
+ : "g" (__reject), "0" (__s), "1" (0), "2" (0xffffffff),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return (__res - 1) - __s;
}
@@ -724,7 +737,8 @@ strspn (__const char *__s, __const char
"2:\n\t"
"popl %%ebx"
: "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
- : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff)
+ : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return (__res - 1) - __s;
}
@@ -751,7 +765,8 @@ strspn (__const char *__s, __const char
"je 1b\n"
"2:"
: "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3)
- : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff)
+ : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return (__res - 1) - __s;
}
@@ -791,7 +806,8 @@ strpbrk (__const char *__s, __const char
"3:\n\t"
"popl %%ebx"
: "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
- : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff)
+ : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return __res;
}
@@ -822,7 +838,8 @@ strpbrk (__const char *__s, __const char
"xorl %0,%0\n"
"3:"
: "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3)
- : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff)
+ : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
+ "m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return __res;
}
@@ -862,7 +879,7 @@ strstr (__const char *__haystack, __cons
"popl %%ebx"
: "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2)
: "r" (__needle), "0" (0), "1" (0xffffffff), "2" (__haystack)
- : "cc");
+ : "memory", "cc");
return __res;
}
# else
@@ -892,7 +909,7 @@ strstr (__const char *__haystack, __cons
"2:"
: "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&d" (__d2), "=&D" (__d3)
: "g" (__needle), "0" (0), "1" (0xffffffff), "2" (__haystack)
- : "cc");
+ : "memory", "cc");
return __res;
}
# endif
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix i386 <bits/string.h>
2004-06-13 19:50 [PATCH] Fix i386 <bits/string.h> Jakub Jelinek
@ 2004-06-13 21:39 ` Andreas Schwab
2004-06-15 20:12 ` Roland McGrath
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2004-06-13 21:39 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Ulrich Drepper, Roland McGrath, Glibc hackers
Jakub Jelinek <jakub@redhat.com> writes:
> --- libc/sysdeps/i386/bits/string.h.jj 2003-09-05 06:03:03.000000000 -0400
> +++ libc/sysdeps/i386/bits/string.h 2004-06-13 15:35:35.000000000 -0400
> @@ -43,8 +43,8 @@
> #define _HAVE_STRING_ARCH_memcpy 1
> #define memcpy(dest, src, n) \
> (__extension__ (__builtin_constant_p (n) \
> - ? __memcpy_c (dest, src, n) \
> - : memcpy (dest, src, n)))
> + ? __memcpy_c ((dest), (src), (n)) \
> + : memcpy ((dest), (src), (n))))
These parens are useless. It is impossible to pass a comma inside a macro
argument without putting it in parens itself.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix i386 <bits/string.h>
2004-06-13 19:50 [PATCH] Fix i386 <bits/string.h> Jakub Jelinek
2004-06-13 21:39 ` Andreas Schwab
@ 2004-06-15 20:12 ` Roland McGrath
1 sibling, 0 replies; 3+ messages in thread
From: Roland McGrath @ 2004-06-15 20:12 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Ulrich Drepper, Glibc hackers
> 2004-06-13 Jakub Jelinek <jakub@redhat.com>
>
> * sysdeps/i386/bits/string.h (memcpy): Add () around arguments.
> (memchr, __memrchr, strlen, strcmp, strncmp, __strchr_g, __strchr_c,
> __strchrnul_g, __strchrnul_c, strspn, strcspn, strpbrk): Add memory
> the asm uses as its input, either of size __n where __n is known or
> 0xfffffff.
> (strstr): Add "memory" clobber.
Applied.
Thanks,
Roland
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-06-15 20:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-13 19:50 [PATCH] Fix i386 <bits/string.h> Jakub Jelinek
2004-06-13 21:39 ` Andreas Schwab
2004-06-15 20:12 ` Roland McGrath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).