* Add memory clobber for i486 string inlines @ 2002-03-12 11:38 Andreas Jaeger 2002-03-13 0:58 ` Ulrich Drepper [not found] ` <20020312135013.B23294@redhat.com> 0 siblings, 2 replies; 7+ messages in thread From: Andreas Jaeger @ 2002-03-12 11:38 UTC (permalink / raw) To: GNU libc hacker; +Cc: Richard Henderson As Richard Henderson mentioned on the gcc list (see: http://gcc.gnu.org/ml/gcc-patches/2002-03/msg00534.html), we need to add a memory clobber even for reading memory. I'm adding a patch for the i486 functions. Ok to commit? Andreas 2002-03-12 Andreas Jaeger <aj@suse.de> * sysdeps/i386/i486/bits/string.h (memcmp): Add memory clobber. (__strpbrk_cg): Likewise. (__strpbrk_g): Likewise. (__strcat_c): Likewise. (__strrchr_g): Likewise. (__strrchr_c): Likewise. (__strcspn_c1): Likewise. (__strcspn_cg): Likewise. (__strspn_c1): Likewise. (__strspn_cg): Likewise. (__strspn_g): Likewise. (__strstr_g): Likewise. ============================================================ Index: sysdeps/i386/i486/bits/string.h --- sysdeps/i386/i486/bits/string.h 2001/09/25 01:39:10 1.47 +++ sysdeps/i386/i486/bits/string.h 2002/03/12 19:38:15 @@ -1,5 +1,5 @@ /* Optimized, inlined string functions. i486 version. - Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -184,7 +184,7 @@ memcmp (__const void *__s1, __const void "1:" : "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) : "0" (0), "1" (__s1), "2" (__s2), "3" (__n) - : "cc"); + : "cc", "memory"); return __res; } # endif @@ -431,7 +431,7 @@ memchr (__const void *__s, int __c, size "cmovne %2,%0" : "=D" (__res), "=&c" (__d0), "=&r" (__d1) : "a" (__c), "0" (__s), "1" (__n), "2" (1) - : "cc"); + : "cc", "memory"); #else __asm__ __volatile__ ("cld\n\t" @@ -441,7 +441,7 @@ memchr (__const void *__s, int __c, size "1:" : "=D" (__res), "=&c" (__d0) : "a" (__c), "0" (__s), "1" (__n) - : "cc"); + : "cc", "memory"); #endif return __res - 1; } @@ -467,7 +467,7 @@ __memrchr (__const void *__s, int __c, s "cld" : "=D" (__res), "=&c" (__d0), "=&r" (__d1) : "a" (__c), "0" (__s + __n - 1), "1" (__n), "2" (-1) - : "cc"); + : "cc", "memory"); # else __asm__ __volatile__ ("std\n\t" @@ -477,7 +477,7 @@ __memrchr (__const void *__s, int __c, s "1:\tcld" : "=D" (__res), "=&c" (__d0) : "a" (__c), "0" (__s + __n - 1), "1" (__n) - : "cc"); + : "cc", "memory"); # endif return __res + 1; } @@ -501,7 +501,7 @@ __rawmemchr (const void *__s, int __c) "repne; scasb\n\t" : "=D" (__res), "=&c" (__d0) : "a" (__c), "0" (__s), "1" (0xffffffff) - : "cc"); + : "cc", "memory"); return __res - 1; } # ifdef __USE_GNU @@ -938,7 +938,7 @@ __strcat_c (char *__dest, __const char _ ("repne; scasb" : "=D" (__tmp), "=&c" (__d0) : "0" (__dest), "1" (0xffffffff), "a" (0) - : "cc"); + : "cc", "memory"); --__tmp; #else register char *__tmp = __dest - 1; @@ -949,7 +949,7 @@ __strcat_c (char *__dest, __const char _ "jne 1b\n" : "=r" (__tmp) : "0" (__tmp) - : "cc"); + : "cc", "memory"); #endif (void) memcpy (__tmp, __src, __srclen); return __dest; @@ -1142,7 +1142,7 @@ __strcmp_gg (__const char *__s1, __const "3:" : "=q" (__res), "=&r" (__s1), "=&r" (__s2) : "1" (__s1), "2" (__s2) - : "cc"); + : "cc", "memory"); return __res; } @@ -1184,7 +1184,7 @@ __strncmp_g (__const char *__s1, __const "4:" : "=q" (__res), "=&r" (__s1), "=&r" (__s2), "=&r" (__n) : "1" (__s1), "2" (__s2), "3" (__n) - : "cc"); + : "cc", "memory"); return __res; } @@ -1218,7 +1218,7 @@ __strchr_c (__const char *__s, int __c) "2:" : "=r" (__res), "=&a" (__d0) : "0" (__s), "1" (__c) - : "cc"); + : "cc", "memory"); return __res; } @@ -1242,7 +1242,7 @@ __strchr_g (__const char *__s, int __c) "2:" : "=r" (__res), "=&a" (__d0) : "0" (__s), "1" (__c) - : "cc"); + : "cc", "memory"); return __res; } @@ -1275,7 +1275,7 @@ __strchrnul_c (__const char *__s, int __ "2:" : "=r" (__res), "=&a" (__d0) : "0" (__s), "1" (__c) - : "cc"); + : "cc", "memory"); return __res; } @@ -1299,7 +1299,7 @@ __strchrnul_g (__const char *__s, int __ "2:" : "=r" (__res), "=&a" (__d0) : "0" (__s), "1" (__c) - : "cc"); + : "cc", "memory"); return __res; } #ifdef __USE_GNU @@ -1342,7 +1342,7 @@ __strrchr_c (__const char *__s, int __c) "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) : "0" (1), "1" (__s), "2" (__c) - : "cc"); + : "cc", "memory"); return __res - 1; } @@ -1364,7 +1364,7 @@ __strrchr_g (__const char *__s, int __c) "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) : "0" (1), "1" (__s), "2" (__c) - : "cc"); + : "cc", "memory"); return __res - 1; } #else @@ -1387,7 +1387,7 @@ __strrchr_c (__const char *__s, int __c) "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) : "0" (0), "1" (__s), "2" (__c) - : "cc"); + : "cc", "memory"); return __res; } @@ -1411,7 +1411,7 @@ __strrchr_g (__const char *__s, int __c) "jne 1b" : "=r" (__res), "=&S" (__d0), "=&a" (__d1) : "0" (0), "1" (__s), "2" (__c) - : "cc"); + : "cc", "memory"); return __res; } #endif @@ -1458,7 +1458,7 @@ __strcspn_c1 (__const char *__s, int __r "2:" : "=r" (__res), "=&a" (__d0) : "0" (__s), "1" (__reject) - : "cc"); + : "cc", "memory"); return (__res - 1) - __s; } #endif @@ -1484,7 +1484,7 @@ __strcspn_cg (__const char *__s, __const "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) : "0" (__s), "d" (__reject), "g" (__reject_len) - : "cc"); + : "cc", "memory"); return (__res - 1) - __s; } @@ -1515,7 +1515,7 @@ __strcspn_g (__const char *__s, __const "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) : "r" (__reject), "0" (__s), "1" (0), "2" (0xffffffff) - : "cc"); + : "cc", "memory"); return (__res - 1) - __s; } #else @@ -1540,7 +1540,7 @@ __strcspn_g (__const char *__s, __const "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3) : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__reject), "b" (__reject) - : "cc"); + : "cc", "memory"); return (__res - 1) - __s; } #endif @@ -1575,7 +1575,7 @@ __strspn_c1 (__const char *__s, int __ac "je 1b" : "=r" (__res), "=&q" (__d0) : "0" (__s), "1" (__accept) - : "cc"); + : "cc", "memory"); return (__res - 1) - __s; } #endif @@ -1601,7 +1601,7 @@ __strspn_cg (__const char *__s, __const "2:" : "=S" (__res), "=&d" (__d0), "=&c" (__d1), "=&D" (__d2) : "0" (__s), "1" (__accept), "g" (__accept_len) - : "cc"); + : "cc", "memory"); return (__res - 1) - __s; } @@ -1631,7 +1631,7 @@ __strspn_g (__const char *__s, __const c "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept) - : "cc"); + : "cc", "memory"); return (__res - 1) - __s; } #else @@ -1656,7 +1656,7 @@ __strspn_g (__const char *__s, __const c "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3) : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept), "b" (__accept) - : "cc"); + : "cc", "memory"); return (__res - 1) - __s; } #endif @@ -1698,7 +1698,7 @@ __strpbrk_cg (__const char *__s, __const "3:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) : "0" (__s), "d" (__accept), "g" (__accept_len) - : "cc"); + : "cc", "memory"); return __res; } @@ -1733,7 +1733,7 @@ __strpbrk_g (__const char *__s, __const "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff) - : "cc"); + : "cc", "memory"); return __res; } #else @@ -1763,7 +1763,7 @@ __strpbrk_g (__const char *__s, __const "3:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3) : "0" (__s), "1" (0), "2" (0xffffffff), "b" (__accept) - : "cc"); + : "cc", "memory"); return __res; } #endif @@ -1806,7 +1806,7 @@ __strstr_cg (__const char *__haystack, _ "2:" : "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) : "g" (__needle_len), "1" (__haystack), "d" (__needle) - : "cc"); + : "cc", "memory"); return __res; } @@ -1840,7 +1840,7 @@ __strstr_g (__const char *__haystack, __ : "=a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) : "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (__needle), "d" (__needle) - : "cc"); + : "cc", "memory"); return __res; } #else @@ -1869,7 +1869,7 @@ __strstr_g (__const char *__haystack, __ : "=a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), "=&d" (__d3) : "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (__needle), "b" (__needle) - : "cc"); + : "cc", "memory"); return __res; } #endif -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de http://www.suse.de/~aj ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add memory clobber for i486 string inlines 2002-03-12 11:38 Add memory clobber for i486 string inlines Andreas Jaeger @ 2002-03-13 0:58 ` Ulrich Drepper [not found] ` <20020312135013.B23294@redhat.com> 1 sibling, 0 replies; 7+ messages in thread From: Ulrich Drepper @ 2002-03-13 0:58 UTC (permalink / raw) To: Andreas Jaeger; +Cc: GNU libc hacker, Richard Henderson [-- Attachment #1: Type: text/plain, Size: 318 bytes --] On Tue, 2002-03-12 at 11:38, Andreas Jaeger wrote: > Ok to commit? If rth says so... -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 232 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <20020312135013.B23294@redhat.com>]
* Re: Add memory clobber for i486 string inlines [not found] ` <20020312135013.B23294@redhat.com> @ 2002-03-13 1:57 ` Andreas Jaeger 2002-03-13 2:02 ` Jakub Jelinek [not found] ` <20020313110247.C24360@redhat.com> 0 siblings, 2 replies; 7+ messages in thread From: Andreas Jaeger @ 2002-03-13 1:57 UTC (permalink / raw) To: Richard Henderson; +Cc: GNU libc hacker Richard Henderson <rth@redhat.com> writes: > On Tue, Mar 12, 2002 at 08:38:51PM +0100, Andreas Jaeger wrote: >> As Richard Henderson mentioned on the gcc list (see: >> http://gcc.gnu.org/ml/gcc-patches/2002-03/msg00534.html), we need to >> add a memory clobber even for reading memory. > > Err, no, I said you should describe the read from memory. > For memcmp you have the length of the access; for the others > you can just use an array size of 0xffffffff or something. A length of 0xffffffff does not work, it gives: str.c:56: size of array `__x' is too large I used one f less. But the following two examples compile. Are these ok? void * memcpy_g (void *__dest, __const void *__src, size_t __n) { register unsigned long int __d0, __d1, __d2; register void *__tmp = __dest; __asm__ __volatile__ ("cld\n\t" "shrl $1,%%ecx\n\t" "jnc 1f\n\t" "movsb\n" "1:\n\t" "shrl $1,%%ecx\n\t" "jnc 2f\n\t" "movsw\n" "2:\n\t" "rep; movsl" : "=&c" (__d0), "=&D" (__d1), "=&S" (__d2), "=m" ( *(struct { char __x[__n]; } *)__dest) : "0" (__n), "1" (__tmp), "2" (__src), "m" ( *(struct { char __x[__n]; } *)__src) : "cc"); return __dest; } char * __strpbrk_g (__const char *__s, __const char *__accept) { register unsigned long int __d0, __d1, __d2, __d3; register char *__res; __asm__ __volatile__ ("movl %%ebx,%%edi\n\t" "cld\n\t" "repne; scasb\n\t" "notl %%ecx\n\t" "leal -1(%%ecx),%%edx\n" "1:\n\t" "lodsb\n\t" "testb %%al,%%al\n\t" "je 2f\n\t" "movl %%ebx,%%edi\n\t" "movl %%edx,%%ecx\n\t" "repne; scasb\n\t" "jne 1b\n\t" "decl %0\n\t" "jmp 3f\n" "2:\n\t" "xorl %0,%0\n" "3:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3) : "0" (__s), "1" (0), "2" (0xffffffff), "b" (__accept), "m" ( *(struct { char __x[0xfffffff]; } *)__s), "m" ( *(struct { char __x[0xfffffff]; } *)__accept) : "cc"); return __res; } Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de http://www.suse.de/~aj ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add memory clobber for i486 string inlines 2002-03-13 1:57 ` Andreas Jaeger @ 2002-03-13 2:02 ` Jakub Jelinek [not found] ` <20020313110247.C24360@redhat.com> 1 sibling, 0 replies; 7+ messages in thread From: Jakub Jelinek @ 2002-03-13 2:02 UTC (permalink / raw) To: Andreas Jaeger; +Cc: Richard Henderson, GNU libc hacker On Wed, Mar 13, 2002 at 10:57:08AM +0100, Andreas Jaeger wrote: > Richard Henderson <rth@redhat.com> writes: > > > On Tue, Mar 12, 2002 at 08:38:51PM +0100, Andreas Jaeger wrote: > >> As Richard Henderson mentioned on the gcc list (see: > >> http://gcc.gnu.org/ml/gcc-patches/2002-03/msg00534.html), we need to > >> add a memory clobber even for reading memory. > > > > Err, no, I said you should describe the read from memory. > > For memcmp you have the length of the access; for the others > > you can just use an array size of 0xffffffff or something. > > A length of 0xffffffff does not work, it gives: > str.c:56: size of array `__x' is too large > I used one f less. > > But the following two examples compile. Are these ok? Don't you need __extension__ there too? Also, I think at least memcpy/memset should go for recent gcc, gcc does a better job. Jakub ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <20020313110247.C24360@redhat.com>]
* Re: Add memory clobber for i486 string inlines [not found] ` <20020313110247.C24360@redhat.com> @ 2002-03-15 2:04 ` Andreas Jaeger 2002-03-15 2:58 ` Andreas Jaeger 0 siblings, 1 reply; 7+ messages in thread From: Andreas Jaeger @ 2002-03-15 2:04 UTC (permalink / raw) To: Richard Henderson; +Cc: GNU libc hacker Richard Henderson <rth@redhat.com> writes: > On Wed, Mar 13, 2002 at 10:57:08AM +0100, Andreas Jaeger wrote: >> But the following two examples compile. Are these ok? > > Yes, that's the idea. Thanks. I've also followed Jakub's suggestion to use __extension__ and here's the final patch. Richard, are these now ok to commit? Andreas 2002-03-15 Andreas Jaeger <aj@suse.de> * sysdeps/i386/i486/bits/string.h (__memcpy_by4): Describe memory read and write accesses as detailed as possible. (__memcpy_by2): Likewise. (__memcpy_g): Likewise. (memmove): Likewise. (memcmp): Likewise. (__memset_ccn_by4): Likewise. (__memset_ccn_by2): Likewise. (__memset_gcn_by4): Likewise. (__memset_gcn_by2): Likewise. (memchr): Likewise. (__memrchr): Likewise. (rawmemchr): Likewise. (__strlen_g): Likewise. (__strcpy_g): Likewise. (__mempcpy_by4): Likewise. (__mempcpy_by2): Likewise. (__mempcpy_byn): Likewise. (__stpcpy_g): Likewise. (__strncpy_by4): Likewise. (__strncpy_by2): Likewise. (__strncpy_byn): Likewise. (__strncpy_gg): Likewise. (__strcat_c): Likewise. (__strcat_g): Likewise. (__strncat_g): Likewise. (__strcmp_gg): Likewise. (__strncmp_g): Likewise. (__strchr_c): Likewise. (__strchr_g): Likewise. (__strchrnul_c): Likewise. (__strchrnul_g): Likewise. (__strrchr_c): Likewise. (__strrchr_g): Likewise. (__strrchr_c): Likewise. (__strrchr_g): Likewise. (__strcspn_c1): Likewise. (__strcspn_cg): Likewise. (__strcspn_g): Likewise. (__strcspn_g): Likewise. (__strspn_c1): Likewise. (__strspn_cg): Likewise. (__strspn_g): Likewise. (__strspn_g): Likewise. (__strpbrk_cg): Likewise. (__strpbrk_g): Likewise. (__strstr_cg): Likewise. (__strstr_g): Likewise. ============================================================ Index: sysdeps/i386/i486/bits/string.h --- sysdeps/i386/i486/bits/string.h 2001/09/25 01:39:10 1.47 +++ sysdeps/i386/i486/bits/string.h 2002/03/15 10:03:02 @@ -1,5 +1,5 @@ /* Optimized, inlined string functions. i486 version. - Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -77,9 +77,11 @@ __memcpy_by4 (void *__dest, __const void "leal 4(%1),%1\n\t" "decl %3\n\t" "jnz 1b" - : "=&r" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1) - : "1" (__tmp), "2" (__src), "3" (__n / 4) - : "memory", "cc"); + : "=&r" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__n / 4), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); return __dest; } @@ -104,9 +106,11 @@ __memcpy_by2 (void *__dest, __const void "2:\n\t" "movw (%2),%w0\n\t" "movw %w0,(%1)" - : "=&q" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1) - : "1" (__tmp), "2" (__src), "3" (__n / 2) - : "memory", "cc"); + : "=&q" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__n / 2), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); return __dest; } @@ -129,9 +133,11 @@ __memcpy_g (void *__dest, __const void * "movsw\n" "2:\n\t" "rep; movsl" - : "=&c" (__d0), "=&D" (__d1), "=&S" (__d2) - : "0" (__n), "1" (__tmp), "2" (__src) - : "memory", "cc"); + : "=&c" (__d0), "=&D" (__d1), "=&S" (__d2), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "0" (__n), "1" (__tmp), "2" (__src), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); return __dest; } @@ -148,18 +154,20 @@ memmove (void *__dest, __const void *__s __asm__ __volatile__ ("cld\n\t" "rep; movsb" - : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) - : "0" (__n), "1" (__src), "2" (__tmp) - : "memory"); + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "0" (__n), "1" (__src), "2" (__tmp), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src)); else __asm__ __volatile__ ("std\n\t" "rep; movsb\n\t" "cld" - : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) : "0" (__n), "1" (__n - 1 + (__const char *) __src), - "2" (__n - 1 + (char *) __tmp) - : "memory"); + "2" (__n - 1 + (char *) __tmp), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src)); return __dest; } #endif @@ -183,7 +191,9 @@ memcmp (__const void *__s1, __const void "orl $1,%0\n" "1:" : "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) - : "0" (0), "1" (__s1), "2" (__s2), "3" (__n) + : "0" (0), "1" (__s1), "2" (__s2), "3" (__n), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s1), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s2) : "cc"); return __res; } @@ -309,9 +319,10 @@ __memset_ccn_by4 (void *__s, unsigned in __asm__ __volatile__ ("cld\n\t" "rep; stosl" - : "=&a" (__c), "=&D" (__tmp), "=&c" (__d0) + : "=&a" (__c), "=&D" (__tmp), "=&c" (__d0), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #else __asm__ __volatile__ ("1:\n\t" @@ -319,9 +330,10 @@ __memset_ccn_by4 (void *__s, unsigned in "addl $4,%1\n\t" "decl %2\n\t" "jnz 1b\n" - : "=&r" (__c), "=&r" (__tmp), "=&r" (__d0) + : "=&r" (__c), "=&r" (__tmp), "=&r" (__d0), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #endif return __s; } @@ -339,9 +351,10 @@ __memset_ccn_by2 (void *__s, unsigned in ("cld\n\t" "rep; stosl\n" "stosw" - : "=&a" (__d0), "=&D" (__tmp), "=&c" (__d1) + : "=&a" (__d0), "=&D" (__tmp), "=&c" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #else __asm__ __volatile__ ("1:\tmovl %0,(%1)\n\t" @@ -349,9 +362,10 @@ __memset_ccn_by2 (void *__s, unsigned in "decl %2\n\t" "jnz 1b\n" "movw %w0,(%1)" - : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1) + : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #endif return __s; } @@ -380,9 +394,10 @@ __memset_gcn_by4 (void *__s, int __c, si "addl $4,%1\n\t" "decl %2\n\t" "jnz 1b\n" - : "=&q" (__c), "=&r" (__tmp), "=&r" (__d0) + : "=&q" (__c), "=&r" (__tmp), "=&r" (__d0), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); return __s; } @@ -404,9 +419,10 @@ __memset_gcn_by2 (void *__s, int __c, si "decl %2\n\t" "jnz 1b\n" "movw %w0,(%1)" - : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1) + : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); return __s; } @@ -430,7 +446,8 @@ memchr (__const void *__s, int __c, size "repne; scasb\n\t" "cmovne %2,%0" : "=D" (__res), "=&c" (__d0), "=&r" (__d1) - : "a" (__c), "0" (__s), "1" (__n), "2" (1) + : "a" (__c), "0" (__s), "1" (__n), "2" (1), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "cc"); #else __asm__ __volatile__ @@ -440,7 +457,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"); #endif return __res - 1; @@ -466,7 +484,8 @@ __memrchr (__const void *__s, int __c, s "cmovne %2,%0\n\t" "cld" : "=D" (__res), "=&c" (__d0), "=&r" (__d1) - : "a" (__c), "0" (__s + __n - 1), "1" (__n), "2" (-1) + : "a" (__c), "0" (__s + __n - 1), "1" (__n), "2" (-1), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "cc"); # else __asm__ __volatile__ @@ -476,7 +495,8 @@ __memrchr (__const void *__s, int __c, s "orl $-1,%0\n" "1:\tcld" : "=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"); # endif return __res + 1; @@ -500,7 +520,8 @@ __rawmemchr (const void *__s, int __c) ("cld\n\t" "repne; scasb\n\t" : "=D" (__res), "=&c" (__d0) - : "a" (__c), "0" (__s), "1" (0xffffffff) + : "a" (__c), "0" (__s), "1" (0xffffffff), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res - 1; } @@ -534,8 +555,9 @@ __strlen_g (__const char *__str) "testb %b1,%b1\n\t" "jne 1b" : "=r" (__tmp), "=&q" (__dummy) - : "0" (__str) - : "memory", "cc" ); + : "0" (__str), + "m" ( *(struct { char __x[0xfffffff]; } *)__str) + : "cc" ); return __tmp - __str - 1; } @@ -617,8 +639,9 @@ __strcpy_g (char *__dest, __const char * "testb %b2,%b2\n\t" "jne 1b" : "=&r" (__src), "=&r" (__tmp), "=&q" (__dummy) - : "0" (__src), "1" (__tmp) - : "memory", "cc"); + : "0" (__src), "1" (__tmp), + "m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "cc"); return __dest; } @@ -710,9 +733,11 @@ __mempcpy_by4 (char *__dest, __const cha "leal 4(%1),%1\n\t" "decl %3\n\t" "jnz 1b" - : "=&r" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1) - : "1" (__tmp), "2" (__src), "3" (__srclen / 4) - : "memory", "cc"); + : "=&r" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__srclen / 4), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); return __tmp; } @@ -737,9 +762,11 @@ __mempcpy_by2 (char *__dest, __const cha "2:\n\t" "movw (%2),%w0\n\t" "movw %w0,(%1)" - : "=&q" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1) - : "1" (__tmp), "2" (__src), "3" (__srclen / 2) - : "memory", "cc"); + : "=&q" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__srclen / 2), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); return __tmp + 2; } @@ -762,9 +789,11 @@ __mempcpy_byn (char *__dest, __const cha "movsw\n" "2:\n\t" "rep; movsl" - : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1) - : "0" (__tmp), "1" (__srclen), "2" (__src) - : "memory", "cc"); + : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "0" (__tmp), "1" (__srclen), "2" (__src), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); return __tmp; } @@ -785,8 +814,10 @@ __stpcpy_g (char *__dest, __const char * "testb %b2,%b2\n\t" "jne 1b" : "=&r" (__src), "=r" (__tmp), "=&q" (__dummy) + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) : "0" (__src), "1" (__tmp) - : "memory", "cc"); + "m" ( *(struct { char __x[0xfffffff]; } *)__src) + : "cc"); return __tmp - 1; } #endif @@ -824,9 +855,11 @@ __strncpy_by4 (char *__dest, __const cha "leal 4(%1),%1\n\t" "decl %3\n\t" "jnz 1b" - : "=&r" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2) - : "1" (__tmp), "2" (__src), "3" (__srclen / 4) - : "memory", "cc"); + : "=&r" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__srclen / 4), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); (void) memset (__tmp, '\0', __n - __srclen); return __dest; } @@ -853,8 +886,10 @@ __strncpy_by2 (char *__dest, __const cha "movw (%2),%w0\n\t" "movw %w0,(%1)\n\t" : "=&q" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2) + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) : "1" (__tmp), "2" (__src), "3" (__srclen / 2) - : "memory", "cc"); + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); (void) memset (__tmp + 2, '\0', __n - __srclen); return __dest; } @@ -878,9 +913,11 @@ __strncpy_byn (char *__dest, __const cha "movsw\n" "2:\n\t" "rep; movsl" - : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1) - : "1" (__srclen), "0" (__tmp),"2" (__src) - : "memory", "cc"); + : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__srclen), "0" (__tmp),"2" (__src), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); (void) memset (__tmp, '\0', __n - __srclen); return __dest; } @@ -910,9 +947,11 @@ __strncpy_gg (char *__dest, __const char "decl %3\n\t" "jne 2b\n\t" "3:" - : "=&r" (__src), "=&r" (__tmp), "=&q" (__dummy), "=&r" (__n) - : "0" (__src), "1" (__tmp), "3" (__n) - : "memory", "cc"); + : "=&r" (__src), "=&r" (__tmp), "=&q" (__dummy), "=&r" (__n), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "0" (__src), "1" (__tmp), "3" (__n), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); return __dest; } @@ -936,8 +975,10 @@ __strcat_c (char *__dest, __const char _ register char *__tmp; __asm__ __volatile__ ("repne; scasb" - : "=D" (__tmp), "=&c" (__d0) + : "=D" (__tmp), "=&c" (__d0), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) : "0" (__dest), "1" (0xffffffff), "a" (0) + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) : "cc"); --__tmp; #else @@ -947,8 +988,10 @@ __strcat_c (char *__dest, __const char _ "incl %0\n\t" "cmpb $0,(%0)\n\t" "jne 1b\n" - : "=r" (__tmp) - : "0" (__tmp) + : "=r" (__tmp), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "0" (__tmp), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) : "cc"); #endif (void) memcpy (__tmp, __src, __srclen); @@ -974,8 +1017,10 @@ __strcat_g (char *__dest, __const char * "incl %1\n\t" "testb %b0,%b0\n\t" "jne 2b\n" - : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src) - : "1" (__tmp), "2" (__src) + : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "1" (__tmp), "2" (__src), + "m" ( *(struct { char __x[0xfffffff]; } *)__src) : "memory", "cc"); return __dest; } @@ -1015,9 +1060,11 @@ __strncat_g (char *__dest, __const char "decl %1\n" "2:\n\t" "movb $0,(%1)" - : "=&a" (__dummy), "=&D" (__tmp), "=&S" (__src), "=&c" (__n) - : "0" (0), "1" (__tmp), "2" (__src), "3" (__n) - : "memory", "cc"); + : "=&a" (__dummy), "=&D" (__tmp), "=&S" (__src), "=&c" (__n), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "0" (0), "1" (__tmp), "2" (__src), "3" (__n), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); #else --__tmp; __asm__ __volatile__ @@ -1037,9 +1084,11 @@ __strncat_g (char *__dest, __const char "decl %1\n" "3:\n\t" "movb $0,(%1)" - : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src), "=&r" (__n) - : "1" (__tmp), "2" (__src), "3" (__n) - : "memory", "cc"); + : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src), "=&r" (__n), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__n), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); #endif return __dest; } @@ -1141,7 +1190,9 @@ __strcmp_gg (__const char *__s1, __const "negl %0\n" "3:" : "=q" (__res), "=&r" (__s1), "=&r" (__s2) - : "1" (__s1), "2" (__s2) + : "1" (__s1), "2" (__s2), + "m" ( *(struct { char __x[0xfffffff]; } *)__s1), + "m" ( *(struct { char __x[0xfffffff]; } *)__s2) : "cc"); return __res; } @@ -1183,7 +1234,9 @@ __strncmp_g (__const char *__s1, __const "negl %0\n" "4:" : "=q" (__res), "=&r" (__s1), "=&r" (__s2), "=&r" (__n) - : "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; } @@ -1217,7 +1270,8 @@ __strchr_c (__const char *__s, int __c) "xorl %0,%0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1241,7 +1295,8 @@ __strchr_g (__const char *__s, int __c) "xorl %0,%0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1274,7 +1329,8 @@ __strchrnul_c (__const char *__s, int __ "decl %0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1298,7 +1354,8 @@ __strchrnul_g (__const char *__s, int __ "decl %0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1341,7 +1398,8 @@ __strrchr_c (__const char *__s, int __c) "testb %b2,%b2\n\t" "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (1), "1" (__s), "2" (__c) + : "0" (1), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res - 1; } @@ -1363,7 +1421,8 @@ __strrchr_g (__const char *__s, int __c) "testb %b2,%b2\n\t" "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (1), "1" (__s), "2" (__c) + : "0" (1), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res - 1; } @@ -1386,7 +1445,8 @@ __strrchr_c (__const char *__s, int __c) "testb %%al,%%al\n\t" "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (0), "1" (__s), "2" (__c) + : "0" (0), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1410,7 +1470,8 @@ __strrchr_g (__const char *__s, int __c) "testb %%al,%%al\n\t" "jne 1b" : "=r" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (0), "1" (__s), "2" (__c) + : "0" (0), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1457,7 +1518,8 @@ __strcspn_c1 (__const char *__s, int __r "jne 1b\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__reject) + : "0" (__s), "1" (__reject), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return (__res - 1) - __s; } @@ -1483,7 +1545,9 @@ __strcspn_cg (__const char *__s, __const "jne 1b\n" "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "0" (__s), "d" (__reject), "g" (__reject_len) + : "0" (__s), "d" (__reject), "g" (__reject_len), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { __extension__ char __x[__reject_len]; } *)__reject) : "cc"); return (__res - 1) - __s; } @@ -1514,7 +1578,9 @@ __strcspn_g (__const char *__s, __const "2:\n\t" "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "r" (__reject), "0" (__s), "1" (0), "2" (0xffffffff) + : "r" (__reject), "0" (__s), "1" (0), "2" (0xffffffff), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__reject) : "cc"); return (__res - 1) - __s; } @@ -1539,7 +1605,9 @@ __strcspn_g (__const char *__s, __const "jne 1b\n" "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3) - : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__reject), "b" (__reject) + : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__reject), "b" (__reject), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__reject) : "cc"); return (__res - 1) - __s; } @@ -1574,7 +1642,8 @@ __strspn_c1 (__const char *__s, int __ac "cmpb %h1,%b1\n\t" "je 1b" : "=r" (__res), "=&q" (__d0) - : "0" (__s), "1" (__accept) + : "0" (__s), "1" (__accept), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return (__res - 1) - __s; } @@ -1600,7 +1669,9 @@ __strspn_cg (__const char *__s, __const "je 1b\n" "2:" : "=S" (__res), "=&d" (__d0), "=&c" (__d1), "=&D" (__d2) - : "0" (__s), "1" (__accept), "g" (__accept_len) + : "0" (__s), "1" (__accept), "g" (__accept_len), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { __extension__ char __x[__accept_len]; } *)__accept) : "cc"); return (__res - 1) - __s; } @@ -1630,7 +1701,9 @@ __strspn_g (__const char *__s, __const c "2:\n\t" "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept) + : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__accept) : "cc"); return (__res - 1) - __s; } @@ -1655,7 +1728,9 @@ __strspn_g (__const char *__s, __const c "je 1b\n" "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3) - : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept), "b" (__accept) + : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept), "b" (__accept), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__accept) : "cc"); return (__res - 1) - __s; } @@ -1697,7 +1772,9 @@ __strpbrk_cg (__const char *__s, __const "xorl %0,%0\n" "3:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "0" (__s), "d" (__accept), "g" (__accept_len) + : "0" (__s), "d" (__accept), "g" (__accept_len), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { __extension__ char __x[__accept_len]; } *)__accept) : "cc"); return __res; } @@ -1732,7 +1809,10 @@ __strpbrk_g (__const char *__s, __const "3:\n\t" "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff) + : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), + /* Since we do not know how large the memory we access it, use a really large amount. */ + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__accept) : "cc"); return __res; } @@ -1762,7 +1842,9 @@ __strpbrk_g (__const char *__s, __const "xorl %0,%0\n" "3:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3) - : "0" (__s), "1" (0), "2" (0xffffffff), "b" (__accept) + : "0" (__s), "1" (0), "2" (0xffffffff), "b" (__accept), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__accept) : "cc"); return __res; } @@ -1805,7 +1887,9 @@ __strstr_cg (__const char *__haystack, _ "xorl %%eax,%%eax\n" "2:" : "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) - : "g" (__needle_len), "1" (__haystack), "d" (__needle) + : "g" (__needle_len), "1" (__haystack), "d" (__needle), + "m" ( *(struct { char __x[0xfffffff]; } *)__haystack), + "m" ( *(struct { __extension__ char __x[__needle_len]; } *)__needle) : "cc"); return __res; } @@ -1839,7 +1923,9 @@ __strstr_g (__const char *__haystack, __ "popl %%ebx" : "=a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) : "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (__needle), - "d" (__needle) + "d" (__needle), + "m" ( *(struct { char __x[0xfffffff]; } *)__haystack), + "m" ( *(struct { char __x[0xfffffff]; } *)__needle) : "cc"); return __res; } @@ -1868,7 +1954,9 @@ __strstr_g (__const char *__haystack, __ "2:" : "=a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), "=&d" (__d3) : "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (__needle), - "b" (__needle) + "b" (__needle), + "m" ( *(struct { char __x[0xfffffff]; } *)__haystack), + "m" ( *(struct { char __x[0xfffffff]; } *)__needle) : "cc"); return __res; } -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de http://www.suse.de/~aj ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add memory clobber for i486 string inlines 2002-03-15 2:04 ` Andreas Jaeger @ 2002-03-15 2:58 ` Andreas Jaeger [not found] ` <20020315102414.A25885@redhat.com> 0 siblings, 1 reply; 7+ messages in thread From: Andreas Jaeger @ 2002-03-15 2:58 UTC (permalink / raw) To: Richard Henderson; +Cc: GNU libc hacker Andreas Jaeger <aj@suse.de> writes: > Richard Henderson <rth@redhat.com> writes: > >> On Wed, Mar 13, 2002 at 10:57:08AM +0100, Andreas Jaeger wrote: >>> But the following two examples compile. Are these ok? >> >> Yes, that's the idea. > > Thanks. I've also followed Jakub's suggestion to use __extension__ > and here's the final patch. > > Richard, are these now ok to commit? Here's an updated patch - but it has some problems: ../sysdeps/i386/i486/bits/string.h: In function `__strcspn_g': ../sysdeps/i386/i486/bits/string.h:1593: can't find a register in class `GENERAL_REGS' while reloading `asm' ../sysdeps/i386/i486/bits/string.h: In function `__strspn_g': ../sysdeps/i386/i486/bits/string.h:1716: can't find a register in class `GENERAL_REGS' while reloading `asm' ../sysdeps/i386/i486/bits/string.h: In function `__strstr_g': ../sysdeps/i386/i486/bits/string.h:1938: can't find a register in class `GENERAL_REGS' while reloading `asm' make[2]: *** [/builds/glibc/gcc-3.2/string/string-inlines.o] Error 1 What can be done about those functions? Should I just use "memory" as clobber? Andreas ============================================================ Index: sysdeps/i386/i486/bits/string.h --- sysdeps/i386/i486/bits/string.h 2001/09/25 01:39:10 1.47 +++ sysdeps/i386/i486/bits/string.h 2002/03/15 10:52:34 @@ -1,5 +1,5 @@ /* Optimized, inlined string functions. i486 version. - Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -77,9 +77,11 @@ __memcpy_by4 (void *__dest, __const void "leal 4(%1),%1\n\t" "decl %3\n\t" "jnz 1b" - : "=&r" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1) - : "1" (__tmp), "2" (__src), "3" (__n / 4) - : "memory", "cc"); + : "=&r" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__n / 4), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); return __dest; } @@ -104,9 +106,11 @@ __memcpy_by2 (void *__dest, __const void "2:\n\t" "movw (%2),%w0\n\t" "movw %w0,(%1)" - : "=&q" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1) - : "1" (__tmp), "2" (__src), "3" (__n / 2) - : "memory", "cc"); + : "=&q" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__n / 2), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); return __dest; } @@ -129,9 +133,11 @@ __memcpy_g (void *__dest, __const void * "movsw\n" "2:\n\t" "rep; movsl" - : "=&c" (__d0), "=&D" (__d1), "=&S" (__d2) - : "0" (__n), "1" (__tmp), "2" (__src) - : "memory", "cc"); + : "=&c" (__d0), "=&D" (__d1), "=&S" (__d2), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "0" (__n), "1" (__tmp), "2" (__src), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); return __dest; } @@ -148,18 +154,20 @@ memmove (void *__dest, __const void *__s __asm__ __volatile__ ("cld\n\t" "rep; movsb" - : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) - : "0" (__n), "1" (__src), "2" (__tmp) - : "memory"); + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "0" (__n), "1" (__src), "2" (__tmp), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src)); else __asm__ __volatile__ ("std\n\t" "rep; movsb\n\t" "cld" - : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) : "0" (__n), "1" (__n - 1 + (__const char *) __src), - "2" (__n - 1 + (char *) __tmp) - : "memory"); + "2" (__n - 1 + (char *) __tmp), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src)); return __dest; } #endif @@ -183,7 +191,9 @@ memcmp (__const void *__s1, __const void "orl $1,%0\n" "1:" : "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) - : "0" (0), "1" (__s1), "2" (__s2), "3" (__n) + : "0" (0), "1" (__s1), "2" (__s2), "3" (__n), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s1), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s2) : "cc"); return __res; } @@ -309,9 +319,10 @@ __memset_ccn_by4 (void *__s, unsigned in __asm__ __volatile__ ("cld\n\t" "rep; stosl" - : "=&a" (__c), "=&D" (__tmp), "=&c" (__d0) + : "=&a" (__c), "=&D" (__tmp), "=&c" (__d0), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #else __asm__ __volatile__ ("1:\n\t" @@ -319,9 +330,10 @@ __memset_ccn_by4 (void *__s, unsigned in "addl $4,%1\n\t" "decl %2\n\t" "jnz 1b\n" - : "=&r" (__c), "=&r" (__tmp), "=&r" (__d0) + : "=&r" (__c), "=&r" (__tmp), "=&r" (__d0), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #endif return __s; } @@ -339,9 +351,10 @@ __memset_ccn_by2 (void *__s, unsigned in ("cld\n\t" "rep; stosl\n" "stosw" - : "=&a" (__d0), "=&D" (__tmp), "=&c" (__d1) + : "=&a" (__d0), "=&D" (__tmp), "=&c" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #else __asm__ __volatile__ ("1:\tmovl %0,(%1)\n\t" @@ -349,9 +362,10 @@ __memset_ccn_by2 (void *__s, unsigned in "decl %2\n\t" "jnz 1b\n" "movw %w0,(%1)" - : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1) + : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #endif return __s; } @@ -380,9 +394,10 @@ __memset_gcn_by4 (void *__s, int __c, si "addl $4,%1\n\t" "decl %2\n\t" "jnz 1b\n" - : "=&q" (__c), "=&r" (__tmp), "=&r" (__d0) + : "=&q" (__c), "=&r" (__tmp), "=&r" (__d0), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); return __s; } @@ -404,9 +419,10 @@ __memset_gcn_by2 (void *__s, int __c, si "decl %2\n\t" "jnz 1b\n" "movw %w0,(%1)" - : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1) + : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); return __s; } @@ -430,7 +446,8 @@ memchr (__const void *__s, int __c, size "repne; scasb\n\t" "cmovne %2,%0" : "=D" (__res), "=&c" (__d0), "=&r" (__d1) - : "a" (__c), "0" (__s), "1" (__n), "2" (1) + : "a" (__c), "0" (__s), "1" (__n), "2" (1), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "cc"); #else __asm__ __volatile__ @@ -440,7 +457,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"); #endif return __res - 1; @@ -466,7 +484,8 @@ __memrchr (__const void *__s, int __c, s "cmovne %2,%0\n\t" "cld" : "=D" (__res), "=&c" (__d0), "=&r" (__d1) - : "a" (__c), "0" (__s + __n - 1), "1" (__n), "2" (-1) + : "a" (__c), "0" (__s + __n - 1), "1" (__n), "2" (-1), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "cc"); # else __asm__ __volatile__ @@ -476,7 +495,8 @@ __memrchr (__const void *__s, int __c, s "orl $-1,%0\n" "1:\tcld" : "=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"); # endif return __res + 1; @@ -500,7 +520,8 @@ __rawmemchr (const void *__s, int __c) ("cld\n\t" "repne; scasb\n\t" : "=D" (__res), "=&c" (__d0) - : "a" (__c), "0" (__s), "1" (0xffffffff) + : "a" (__c), "0" (__s), "1" (0xffffffff), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res - 1; } @@ -534,8 +555,9 @@ __strlen_g (__const char *__str) "testb %b1,%b1\n\t" "jne 1b" : "=r" (__tmp), "=&q" (__dummy) - : "0" (__str) - : "memory", "cc" ); + : "0" (__str), + "m" ( *(struct { char __x[0xfffffff]; } *)__str) + : "cc" ); return __tmp - __str - 1; } @@ -617,8 +639,9 @@ __strcpy_g (char *__dest, __const char * "testb %b2,%b2\n\t" "jne 1b" : "=&r" (__src), "=&r" (__tmp), "=&q" (__dummy) - : "0" (__src), "1" (__tmp) - : "memory", "cc"); + : "0" (__src), "1" (__tmp), + "m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "cc"); return __dest; } @@ -710,9 +733,11 @@ __mempcpy_by4 (char *__dest, __const cha "leal 4(%1),%1\n\t" "decl %3\n\t" "jnz 1b" - : "=&r" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1) - : "1" (__tmp), "2" (__src), "3" (__srclen / 4) - : "memory", "cc"); + : "=&r" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__srclen / 4), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); return __tmp; } @@ -737,9 +762,11 @@ __mempcpy_by2 (char *__dest, __const cha "2:\n\t" "movw (%2),%w0\n\t" "movw %w0,(%1)" - : "=&q" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1) - : "1" (__tmp), "2" (__src), "3" (__srclen / 2) - : "memory", "cc"); + : "=&q" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__srclen / 2), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); return __tmp + 2; } @@ -762,9 +789,11 @@ __mempcpy_byn (char *__dest, __const cha "movsw\n" "2:\n\t" "rep; movsl" - : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1) - : "0" (__tmp), "1" (__srclen), "2" (__src) - : "memory", "cc"); + : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "0" (__tmp), "1" (__srclen), "2" (__src), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); return __tmp; } @@ -784,9 +813,11 @@ __stpcpy_g (char *__dest, __const char * "leal 1(%1),%1\n\t" "testb %b2,%b2\n\t" "jne 1b" - : "=&r" (__src), "=r" (__tmp), "=&q" (__dummy) - : "0" (__src), "1" (__tmp) - : "memory", "cc"); + : "=&r" (__src), "=r" (__tmp), "=&q" (__dummy), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "0" (__src), "1" (__tmp), + "m" ( *(struct { char __x[0xfffffff]; } *)__src) + : "cc"); return __tmp - 1; } #endif @@ -824,9 +855,11 @@ __strncpy_by4 (char *__dest, __const cha "leal 4(%1),%1\n\t" "decl %3\n\t" "jnz 1b" - : "=&r" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2) - : "1" (__tmp), "2" (__src), "3" (__srclen / 4) - : "memory", "cc"); + : "=&r" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__srclen / 4), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); (void) memset (__tmp, '\0', __n - __srclen); return __dest; } @@ -852,9 +885,11 @@ __strncpy_by2 (char *__dest, __const cha "2:\n\t" "movw (%2),%w0\n\t" "movw %w0,(%1)\n\t" - : "=&q" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2) - : "1" (__tmp), "2" (__src), "3" (__srclen / 2) - : "memory", "cc"); + : "=&q" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__srclen / 2), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); (void) memset (__tmp + 2, '\0', __n - __srclen); return __dest; } @@ -878,9 +913,11 @@ __strncpy_byn (char *__dest, __const cha "movsw\n" "2:\n\t" "rep; movsl" - : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1) - : "1" (__srclen), "0" (__tmp),"2" (__src) - : "memory", "cc"); + : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__srclen), "0" (__tmp),"2" (__src), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); (void) memset (__tmp, '\0', __n - __srclen); return __dest; } @@ -910,9 +947,11 @@ __strncpy_gg (char *__dest, __const char "decl %3\n\t" "jne 2b\n\t" "3:" - : "=&r" (__src), "=&r" (__tmp), "=&q" (__dummy), "=&r" (__n) - : "0" (__src), "1" (__tmp), "3" (__n) - : "memory", "cc"); + : "=&r" (__src), "=&r" (__tmp), "=&q" (__dummy), "=&r" (__n), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "0" (__src), "1" (__tmp), "3" (__n), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); return __dest; } @@ -936,8 +975,10 @@ __strcat_c (char *__dest, __const char _ register char *__tmp; __asm__ __volatile__ ("repne; scasb" - : "=D" (__tmp), "=&c" (__d0) - : "0" (__dest), "1" (0xffffffff), "a" (0) + : "=D" (__tmp), "=&c" (__d0), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "0" (__dest), "1" (0xffffffff), "a" (0), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) : "cc"); --__tmp; #else @@ -947,8 +988,10 @@ __strcat_c (char *__dest, __const char _ "incl %0\n\t" "cmpb $0,(%0)\n\t" "jne 1b\n" - : "=r" (__tmp) - : "0" (__tmp) + : "=r" (__tmp), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "0" (__tmp), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) : "cc"); #endif (void) memcpy (__tmp, __src, __srclen); @@ -974,8 +1017,10 @@ __strcat_g (char *__dest, __const char * "incl %1\n\t" "testb %b0,%b0\n\t" "jne 2b\n" - : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src) - : "1" (__tmp), "2" (__src) + : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "1" (__tmp), "2" (__src), + "m" ( *(struct { char __x[0xfffffff]; } *)__src) : "memory", "cc"); return __dest; } @@ -1015,9 +1060,11 @@ __strncat_g (char *__dest, __const char "decl %1\n" "2:\n\t" "movb $0,(%1)" - : "=&a" (__dummy), "=&D" (__tmp), "=&S" (__src), "=&c" (__n) - : "0" (0), "1" (__tmp), "2" (__src), "3" (__n) - : "memory", "cc"); + : "=&a" (__dummy), "=&D" (__tmp), "=&S" (__src), "=&c" (__n), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "0" (0), "1" (__tmp), "2" (__src), "3" (__n), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); #else --__tmp; __asm__ __volatile__ @@ -1037,9 +1084,11 @@ __strncat_g (char *__dest, __const char "decl %1\n" "3:\n\t" "movb $0,(%1)" - : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src), "=&r" (__n) - : "1" (__tmp), "2" (__src), "3" (__n) - : "memory", "cc"); + : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src), "=&r" (__n), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__n), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); #endif return __dest; } @@ -1141,7 +1190,9 @@ __strcmp_gg (__const char *__s1, __const "negl %0\n" "3:" : "=q" (__res), "=&r" (__s1), "=&r" (__s2) - : "1" (__s1), "2" (__s2) + : "1" (__s1), "2" (__s2), + "m" ( *(struct { char __x[0xfffffff]; } *)__s1), + "m" ( *(struct { char __x[0xfffffff]; } *)__s2) : "cc"); return __res; } @@ -1183,7 +1234,9 @@ __strncmp_g (__const char *__s1, __const "negl %0\n" "4:" : "=q" (__res), "=&r" (__s1), "=&r" (__s2), "=&r" (__n) - : "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; } @@ -1217,7 +1270,8 @@ __strchr_c (__const char *__s, int __c) "xorl %0,%0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1241,7 +1295,8 @@ __strchr_g (__const char *__s, int __c) "xorl %0,%0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1274,7 +1329,8 @@ __strchrnul_c (__const char *__s, int __ "decl %0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1298,7 +1354,8 @@ __strchrnul_g (__const char *__s, int __ "decl %0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1341,7 +1398,8 @@ __strrchr_c (__const char *__s, int __c) "testb %b2,%b2\n\t" "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (1), "1" (__s), "2" (__c) + : "0" (1), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res - 1; } @@ -1363,7 +1421,8 @@ __strrchr_g (__const char *__s, int __c) "testb %b2,%b2\n\t" "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (1), "1" (__s), "2" (__c) + : "0" (1), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res - 1; } @@ -1386,7 +1445,8 @@ __strrchr_c (__const char *__s, int __c) "testb %%al,%%al\n\t" "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (0), "1" (__s), "2" (__c) + : "0" (0), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1410,7 +1470,8 @@ __strrchr_g (__const char *__s, int __c) "testb %%al,%%al\n\t" "jne 1b" : "=r" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (0), "1" (__s), "2" (__c) + : "0" (0), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1457,7 +1518,8 @@ __strcspn_c1 (__const char *__s, int __r "jne 1b\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__reject) + : "0" (__s), "1" (__reject), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return (__res - 1) - __s; } @@ -1483,7 +1545,9 @@ __strcspn_cg (__const char *__s, __const "jne 1b\n" "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "0" (__s), "d" (__reject), "g" (__reject_len) + : "0" (__s), "d" (__reject), "g" (__reject_len), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { __extension__ char __x[__reject_len]; } *)__reject) : "cc"); return (__res - 1) - __s; } @@ -1514,7 +1578,9 @@ __strcspn_g (__const char *__s, __const "2:\n\t" "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "r" (__reject), "0" (__s), "1" (0), "2" (0xffffffff) + : "r" (__reject), "0" (__s), "1" (0), "2" (0xffffffff), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__reject) : "cc"); return (__res - 1) - __s; } @@ -1539,7 +1605,9 @@ __strcspn_g (__const char *__s, __const "jne 1b\n" "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3) - : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__reject), "b" (__reject) + : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__reject), "b" (__reject), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__reject) : "cc"); return (__res - 1) - __s; } @@ -1574,7 +1642,8 @@ __strspn_c1 (__const char *__s, int __ac "cmpb %h1,%b1\n\t" "je 1b" : "=r" (__res), "=&q" (__d0) - : "0" (__s), "1" (__accept) + : "0" (__s), "1" (__accept), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return (__res - 1) - __s; } @@ -1600,7 +1669,9 @@ __strspn_cg (__const char *__s, __const "je 1b\n" "2:" : "=S" (__res), "=&d" (__d0), "=&c" (__d1), "=&D" (__d2) - : "0" (__s), "1" (__accept), "g" (__accept_len) + : "0" (__s), "1" (__accept), "g" (__accept_len), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { __extension__ char __x[__accept_len]; } *)__accept) : "cc"); return (__res - 1) - __s; } @@ -1630,7 +1701,9 @@ __strspn_g (__const char *__s, __const c "2:\n\t" "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept) + : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__accept) : "cc"); return (__res - 1) - __s; } @@ -1655,7 +1728,9 @@ __strspn_g (__const char *__s, __const c "je 1b\n" "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3) - : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept), "b" (__accept) + : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept), "b" (__accept), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__accept) : "cc"); return (__res - 1) - __s; } @@ -1697,7 +1772,9 @@ __strpbrk_cg (__const char *__s, __const "xorl %0,%0\n" "3:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "0" (__s), "d" (__accept), "g" (__accept_len) + : "0" (__s), "d" (__accept), "g" (__accept_len), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { __extension__ char __x[__accept_len]; } *)__accept) : "cc"); return __res; } @@ -1732,7 +1809,10 @@ __strpbrk_g (__const char *__s, __const "3:\n\t" "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff) + : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), + /* Since we do not know how large the memory we access it, use a really large amount. */ + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__accept) : "cc"); return __res; } @@ -1762,7 +1842,9 @@ __strpbrk_g (__const char *__s, __const "xorl %0,%0\n" "3:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3) - : "0" (__s), "1" (0), "2" (0xffffffff), "b" (__accept) + : "0" (__s), "1" (0), "2" (0xffffffff), "b" (__accept), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { char __x[0xfffffff]; } *)__accept) : "cc"); return __res; } @@ -1805,7 +1887,9 @@ __strstr_cg (__const char *__haystack, _ "xorl %%eax,%%eax\n" "2:" : "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) - : "g" (__needle_len), "1" (__haystack), "d" (__needle) + : "g" (__needle_len), "1" (__haystack), "d" (__needle), + "m" ( *(struct { char __x[0xfffffff]; } *)__haystack), + "m" ( *(struct { __extension__ char __x[__needle_len]; } *)__needle) : "cc"); return __res; } @@ -1839,7 +1923,9 @@ __strstr_g (__const char *__haystack, __ "popl %%ebx" : "=a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) : "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (__needle), - "d" (__needle) + "d" (__needle), + "m" ( *(struct { char __x[0xfffffff]; } *)__haystack), + "m" ( *(struct { char __x[0xfffffff]; } *)__needle) : "cc"); return __res; } @@ -1868,7 +1954,9 @@ __strstr_g (__const char *__haystack, __ "2:" : "=a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), "=&d" (__d3) : "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (__needle), - "b" (__needle) + "b" (__needle), + "m" ( *(struct { char __x[0xfffffff]; } *)__haystack), + "m" ( *(struct { char __x[0xfffffff]; } *)__needle) : "cc"); return __res; } -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de http://www.suse.de/~aj ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <20020315102414.A25885@redhat.com>]
* Re: Add memory clobber for i486 string inlines [not found] ` <20020315102414.A25885@redhat.com> @ 2002-03-15 12:36 ` Andreas Jaeger 0 siblings, 0 replies; 7+ messages in thread From: Andreas Jaeger @ 2002-03-15 12:36 UTC (permalink / raw) To: Richard Henderson; +Cc: GNU libc hacker Richard Henderson <rth@redhat.com> writes: > On Fri, Mar 15, 2002 at 11:58:44AM +0100, Andreas Jaeger wrote: >> Here's an updated patch - but it has some problems: > > Yeah, I was wondering about those while looking at the patch. > > See what happens if you use "X" as the constraint instead of "m". > But failing that, yes, just use a memory clobber. "X" didn't help, I'm using a memory clobber now. gcc 2.95.3 even complained about this :-( ../sysdeps/i386/i486/bits/string.h: In function `__strpbrk_g': ../sysdeps/i386/i486/bits/string.h:1841: more than 10 operands in `asm' And gcc 3.2 gave e.g.: ../sysdeps/i386/i486/bits/string.h: In function `__memcpy_by2': ../sysdeps/i386/i486/bits/string.h:94: can't find a register in class `GENERAL_REGS' while reloading `asm' I now removed several patches and added memory clobbers again so that it did compile glibc again :-(. Ok to commit this now? I build a glibc on my Athlon with both GCC 3.2 CVS and gcc 2.95.3 using the patch. Andreas Index: sysdeps/i386/i486/bits/string.h =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i486/bits/string.h,v retrieving revision 1.47 diff -u -p -r1.47 string.h --- string.h 2001/09/25 01:39:10 1.47 +++ string.h 2002/03/15 20:18:15 @@ -1,5 +1,5 @@ /* Optimized, inlined string functions. i486 version. - Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -129,9 +129,11 @@ __memcpy_g (void *__dest, __const void * "movsw\n" "2:\n\t" "rep; movsl" - : "=&c" (__d0), "=&D" (__d1), "=&S" (__d2) - : "0" (__n), "1" (__tmp), "2" (__src) - : "memory", "cc"); + : "=&c" (__d0), "=&D" (__d1), "=&S" (__d2), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "0" (__n), "1" (__tmp), "2" (__src), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src) + : "cc"); return __dest; } @@ -148,18 +150,20 @@ memmove (void *__dest, __const void *__s __asm__ __volatile__ ("cld\n\t" "rep; movsb" - : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) - : "0" (__n), "1" (__src), "2" (__tmp) - : "memory"); + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) + : "0" (__n), "1" (__src), "2" (__tmp), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src)); else __asm__ __volatile__ ("std\n\t" "rep; movsb\n\t" "cld" - : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__dest) : "0" (__n), "1" (__n - 1 + (__const char *) __src), - "2" (__n - 1 + (char *) __tmp) - : "memory"); + "2" (__n - 1 + (char *) __tmp), + "m" ( *(struct { __extension__ char __x[__n]; } *)__src)); return __dest; } #endif @@ -183,7 +187,9 @@ memcmp (__const void *__s1, __const void "orl $1,%0\n" "1:" : "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) - : "0" (0), "1" (__s1), "2" (__s2), "3" (__n) + : "0" (0), "1" (__s1), "2" (__s2), "3" (__n), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s1), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s2) : "cc"); return __res; } @@ -309,9 +315,10 @@ __memset_ccn_by4 (void *__s, unsigned in __asm__ __volatile__ ("cld\n\t" "rep; stosl" - : "=&a" (__c), "=&D" (__tmp), "=&c" (__d0) + : "=&a" (__c), "=&D" (__tmp), "=&c" (__d0), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #else __asm__ __volatile__ ("1:\n\t" @@ -319,9 +326,10 @@ __memset_ccn_by4 (void *__s, unsigned in "addl $4,%1\n\t" "decl %2\n\t" "jnz 1b\n" - : "=&r" (__c), "=&r" (__tmp), "=&r" (__d0) + : "=&r" (__c), "=&r" (__tmp), "=&r" (__d0), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #endif return __s; } @@ -339,9 +347,10 @@ __memset_ccn_by2 (void *__s, unsigned in ("cld\n\t" "rep; stosl\n" "stosw" - : "=&a" (__d0), "=&D" (__tmp), "=&c" (__d1) + : "=&a" (__d0), "=&D" (__tmp), "=&c" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #else __asm__ __volatile__ ("1:\tmovl %0,(%1)\n\t" @@ -349,9 +358,10 @@ __memset_ccn_by2 (void *__s, unsigned in "decl %2\n\t" "jnz 1b\n" "movw %w0,(%1)" - : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1) + : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); #endif return __s; } @@ -380,9 +390,10 @@ __memset_gcn_by4 (void *__s, int __c, si "addl $4,%1\n\t" "decl %2\n\t" "jnz 1b\n" - : "=&q" (__c), "=&r" (__tmp), "=&r" (__d0) + : "=&q" (__c), "=&r" (__tmp), "=&r" (__d0), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); return __s; } @@ -404,9 +415,10 @@ __memset_gcn_by2 (void *__s, int __c, si "decl %2\n\t" "jnz 1b\n" "movw %w0,(%1)" - : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1) + : "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4) - : "memory", "cc"); + : "cc"); return __s; } @@ -430,7 +442,8 @@ memchr (__const void *__s, int __c, size "repne; scasb\n\t" "cmovne %2,%0" : "=D" (__res), "=&c" (__d0), "=&r" (__d1) - : "a" (__c), "0" (__s), "1" (__n), "2" (1) + : "a" (__c), "0" (__s), "1" (__n), "2" (1), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "cc"); #else __asm__ __volatile__ @@ -440,7 +453,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"); #endif return __res - 1; @@ -466,7 +480,8 @@ __memrchr (__const void *__s, int __c, s "cmovne %2,%0\n\t" "cld" : "=D" (__res), "=&c" (__d0), "=&r" (__d1) - : "a" (__c), "0" (__s + __n - 1), "1" (__n), "2" (-1) + : "a" (__c), "0" (__s + __n - 1), "1" (__n), "2" (-1), + "m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "cc"); # else __asm__ __volatile__ @@ -476,7 +491,8 @@ __memrchr (__const void *__s, int __c, s "orl $-1,%0\n" "1:\tcld" : "=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"); # endif return __res + 1; @@ -500,7 +516,8 @@ __rawmemchr (const void *__s, int __c) ("cld\n\t" "repne; scasb\n\t" : "=D" (__res), "=&c" (__d0) - : "a" (__c), "0" (__s), "1" (0xffffffff) + : "a" (__c), "0" (__s), "1" (0xffffffff), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res - 1; } @@ -534,8 +551,9 @@ __strlen_g (__const char *__str) "testb %b1,%b1\n\t" "jne 1b" : "=r" (__tmp), "=&q" (__dummy) - : "0" (__str) - : "memory", "cc" ); + : "0" (__str), + "m" ( *(struct { char __x[0xfffffff]; } *)__str) + : "cc" ); return __tmp - __str - 1; } @@ -617,8 +635,9 @@ __strcpy_g (char *__dest, __const char * "testb %b2,%b2\n\t" "jne 1b" : "=&r" (__src), "=&r" (__tmp), "=&q" (__dummy) - : "0" (__src), "1" (__tmp) - : "memory", "cc"); + : "0" (__src), "1" (__tmp), + "m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "cc"); return __dest; } @@ -710,9 +729,11 @@ __mempcpy_by4 (char *__dest, __const cha "leal 4(%1),%1\n\t" "decl %3\n\t" "jnz 1b" - : "=&r" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1) - : "1" (__tmp), "2" (__src), "3" (__srclen / 4) - : "memory", "cc"); + : "=&r" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__srclen / 4), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); return __tmp; } @@ -737,9 +758,11 @@ __mempcpy_by2 (char *__dest, __const cha "2:\n\t" "movw (%2),%w0\n\t" "movw %w0,(%1)" - : "=&q" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1) - : "1" (__tmp), "2" (__src), "3" (__srclen / 2) - : "memory", "cc"); + : "=&q" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__srclen / 2), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); return __tmp + 2; } @@ -762,9 +785,11 @@ __mempcpy_byn (char *__dest, __const cha "movsw\n" "2:\n\t" "rep; movsl" - : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1) - : "0" (__tmp), "1" (__srclen), "2" (__src) - : "memory", "cc"); + : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "0" (__tmp), "1" (__srclen), "2" (__src), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); return __tmp; } @@ -784,9 +809,11 @@ __stpcpy_g (char *__dest, __const char * "leal 1(%1),%1\n\t" "testb %b2,%b2\n\t" "jne 1b" - : "=&r" (__src), "=r" (__tmp), "=&q" (__dummy) - : "0" (__src), "1" (__tmp) - : "memory", "cc"); + : "=&r" (__src), "=r" (__tmp), "=&q" (__dummy), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "0" (__src), "1" (__tmp), + "m" ( *(struct { char __x[0xfffffff]; } *)__src) + : "cc"); return __tmp - 1; } #endif @@ -824,9 +851,11 @@ __strncpy_by4 (char *__dest, __const cha "leal 4(%1),%1\n\t" "decl %3\n\t" "jnz 1b" - : "=&r" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2) - : "1" (__tmp), "2" (__src), "3" (__srclen / 4) - : "memory", "cc"); + : "=&r" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__srclen / 4), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); (void) memset (__tmp, '\0', __n - __srclen); return __dest; } @@ -852,9 +881,11 @@ __strncpy_by2 (char *__dest, __const cha "2:\n\t" "movw (%2),%w0\n\t" "movw %w0,(%1)\n\t" - : "=&q" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2) - : "1" (__tmp), "2" (__src), "3" (__srclen / 2) - : "memory", "cc"); + : "=&q" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__tmp), "2" (__src), "3" (__srclen / 2), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); (void) memset (__tmp + 2, '\0', __n - __srclen); return __dest; } @@ -878,9 +909,11 @@ __strncpy_byn (char *__dest, __const cha "movsw\n" "2:\n\t" "rep; movsl" - : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1) - : "1" (__srclen), "0" (__tmp),"2" (__src) - : "memory", "cc"); + : "=D" (__tmp), "=&c" (__d0), "=&S" (__d1), + "=m" ( *(struct { __extension__ char __x[__srclen]; } *)__dest) + : "1" (__srclen), "0" (__tmp),"2" (__src), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) + : "cc"); (void) memset (__tmp, '\0', __n - __srclen); return __dest; } @@ -936,8 +969,10 @@ __strcat_c (char *__dest, __const char _ register char *__tmp; __asm__ __volatile__ ("repne; scasb" - : "=D" (__tmp), "=&c" (__d0) - : "0" (__dest), "1" (0xffffffff), "a" (0) + : "=D" (__tmp), "=&c" (__d0), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "0" (__dest), "1" (0xffffffff), "a" (0), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) : "cc"); --__tmp; #else @@ -947,8 +982,10 @@ __strcat_c (char *__dest, __const char _ "incl %0\n\t" "cmpb $0,(%0)\n\t" "jne 1b\n" - : "=r" (__tmp) - : "0" (__tmp) + : "=r" (__tmp), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "0" (__tmp), + "m" ( *(struct { __extension__ char __x[__srclen]; } *)__src) : "cc"); #endif (void) memcpy (__tmp, __src, __srclen); @@ -974,8 +1011,10 @@ __strcat_g (char *__dest, __const char * "incl %1\n\t" "testb %b0,%b0\n\t" "jne 2b\n" - : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src) - : "1" (__tmp), "2" (__src) + : "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src), + "=m" ( *(struct { char __x[0xfffffff]; } *)__dest) + : "1" (__tmp), "2" (__src), + "m" ( *(struct { char __x[0xfffffff]; } *)__src) : "memory", "cc"); return __dest; } @@ -1141,7 +1180,9 @@ __strcmp_gg (__const char *__s1, __const "negl %0\n" "3:" : "=q" (__res), "=&r" (__s1), "=&r" (__s2) - : "1" (__s1), "2" (__s2) + : "1" (__s1), "2" (__s2), + "m" ( *(struct { char __x[0xfffffff]; } *)__s1), + "m" ( *(struct { char __x[0xfffffff]; } *)__s2) : "cc"); return __res; } @@ -1183,7 +1224,9 @@ __strncmp_g (__const char *__s1, __const "negl %0\n" "4:" : "=q" (__res), "=&r" (__s1), "=&r" (__s2), "=&r" (__n) - : "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; } @@ -1217,7 +1260,8 @@ __strchr_c (__const char *__s, int __c) "xorl %0,%0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1241,7 +1285,8 @@ __strchr_g (__const char *__s, int __c) "xorl %0,%0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1274,7 +1319,8 @@ __strchrnul_c (__const char *__s, int __ "decl %0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1298,7 +1344,8 @@ __strchrnul_g (__const char *__s, int __ "decl %0\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__c) + : "0" (__s), "1" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1341,7 +1388,8 @@ __strrchr_c (__const char *__s, int __c) "testb %b2,%b2\n\t" "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (1), "1" (__s), "2" (__c) + : "0" (1), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res - 1; } @@ -1363,7 +1411,8 @@ __strrchr_g (__const char *__s, int __c) "testb %b2,%b2\n\t" "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (1), "1" (__s), "2" (__c) + : "0" (1), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res - 1; } @@ -1386,7 +1435,8 @@ __strrchr_c (__const char *__s, int __c) "testb %%al,%%al\n\t" "jne 1b" : "=d" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (0), "1" (__s), "2" (__c) + : "0" (0), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1410,7 +1460,8 @@ __strrchr_g (__const char *__s, int __c) "testb %%al,%%al\n\t" "jne 1b" : "=r" (__res), "=&S" (__d0), "=&a" (__d1) - : "0" (0), "1" (__s), "2" (__c) + : "0" (0), "1" (__s), "2" (__c), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return __res; } @@ -1457,7 +1508,8 @@ __strcspn_c1 (__const char *__s, int __r "jne 1b\n" "2:" : "=r" (__res), "=&a" (__d0) - : "0" (__s), "1" (__reject) + : "0" (__s), "1" (__reject), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return (__res - 1) - __s; } @@ -1483,7 +1535,9 @@ __strcspn_cg (__const char *__s, __const "jne 1b\n" "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "0" (__s), "d" (__reject), "g" (__reject_len) + : "0" (__s), "d" (__reject), "g" (__reject_len), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { __extension__ char __x[__reject_len]; } *)__reject) : "cc"); return (__res - 1) - __s; } @@ -1515,7 +1569,7 @@ __strcspn_g (__const char *__s, __const "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) : "r" (__reject), "0" (__s), "1" (0), "2" (0xffffffff) - : "cc"); + : "memory", "cc"); return (__res - 1) - __s; } #else @@ -1540,7 +1594,8 @@ __strcspn_g (__const char *__s, __const "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3) : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__reject), "b" (__reject) - : "cc"); + /* Clobber memory, otherwise GCC cannot handle this. */ + : "memory", "cc"); return (__res - 1) - __s; } #endif @@ -1574,7 +1629,8 @@ __strspn_c1 (__const char *__s, int __ac "cmpb %h1,%b1\n\t" "je 1b" : "=r" (__res), "=&q" (__d0) - : "0" (__s), "1" (__accept) + : "0" (__s), "1" (__accept), + "m" ( *(struct { char __x[0xfffffff]; } *)__s) : "cc"); return (__res - 1) - __s; } @@ -1600,7 +1656,9 @@ __strspn_cg (__const char *__s, __const "je 1b\n" "2:" : "=S" (__res), "=&d" (__d0), "=&c" (__d1), "=&D" (__d2) - : "0" (__s), "1" (__accept), "g" (__accept_len) + : "0" (__s), "1" (__accept), "g" (__accept_len), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { __extension__ char __x[__accept_len]; } *)__accept) : "cc"); return (__res - 1) - __s; } @@ -1631,7 +1689,7 @@ __strspn_g (__const char *__s, __const c "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept) - : "cc"); + : "memory", "cc"); return (__res - 1) - __s; } #else @@ -1656,7 +1714,7 @@ __strspn_g (__const char *__s, __const c "2:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3) : "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept), "b" (__accept) - : "cc"); + : "memory", "cc"); return (__res - 1) - __s; } #endif @@ -1697,7 +1755,9 @@ __strpbrk_cg (__const char *__s, __const "xorl %0,%0\n" "3:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "0" (__s), "d" (__accept), "g" (__accept_len) + : "0" (__s), "d" (__accept), "g" (__accept_len), + "m" ( *(struct { char __x[0xfffffff]; } *)__s), + "m" ( *(struct { __extension__ char __x[__accept_len]; } *)__accept) : "cc"); return __res; } @@ -1733,7 +1793,7 @@ __strpbrk_g (__const char *__s, __const "popl %%ebx" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) : "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff) - : "cc"); + : "memory", "cc"); return __res; } #else @@ -1763,7 +1823,7 @@ __strpbrk_g (__const char *__s, __const "3:" : "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3) : "0" (__s), "1" (0), "2" (0xffffffff), "b" (__accept) - : "cc"); + : "memory", "cc"); return __res; } #endif @@ -1805,7 +1865,10 @@ __strstr_cg (__const char *__haystack, _ "xorl %%eax,%%eax\n" "2:" : "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) - : "g" (__needle_len), "1" (__haystack), "d" (__needle) + : "g" (__needle_len), "1" (__haystack), "d" (__needle), + /* Since we do not know how large the memory we access it, use a really large amount. */ + "m" ( *(struct { char __x[0xfffffff]; } *)__haystack), + "m" ( *(struct { __extension__ char __x[__needle_len]; } *)__needle) : "cc"); return __res; } @@ -1840,7 +1903,7 @@ __strstr_g (__const char *__haystack, __ : "=a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) : "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (__needle), "d" (__needle) - : "cc"); + : "memory", "cc"); return __res; } #else @@ -1869,7 +1932,7 @@ __strstr_g (__const char *__haystack, __ : "=a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), "=&d" (__d3) : "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (__needle), "b" (__needle) - : "cc"); + : "memory", "cc"); return __res; } #endif -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de http://www.suse.de/~aj ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-03-15 20:36 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-03-12 11:38 Add memory clobber for i486 string inlines Andreas Jaeger 2002-03-13 0:58 ` Ulrich Drepper [not found] ` <20020312135013.B23294@redhat.com> 2002-03-13 1:57 ` Andreas Jaeger 2002-03-13 2:02 ` Jakub Jelinek [not found] ` <20020313110247.C24360@redhat.com> 2002-03-15 2:04 ` Andreas Jaeger 2002-03-15 2:58 ` Andreas Jaeger [not found] ` <20020315102414.A25885@redhat.com> 2002-03-15 12:36 ` Andreas Jaeger
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).