From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20714 invoked by alias); 12 Mar 2002 19:38:56 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 20680 invoked from network); 12 Mar 2002 19:38:54 -0000 Received: from unknown (HELO Cantor.suse.de) (213.95.15.193) by sources.redhat.com with SMTP; 12 Mar 2002 19:38:54 -0000 Received: from Hermes.suse.de (Hermes.suse.de [213.95.15.136]) by Cantor.suse.de (Postfix) with ESMTP id 079BF1EE7D; Tue, 12 Mar 2002 20:38:54 +0100 (MET) Received: from aj by arthur.inka.de with local (Exim 3.34 #1) id 16ks6l-0002yK-00; Tue, 12 Mar 2002 20:38:51 +0100 To: GNU libc hacker Cc: Richard Henderson Subject: Add memory clobber for i486 string inlines From: Andreas Jaeger Date: Tue, 12 Mar 2002 11:38:00 -0000 Message-ID: User-Agent: Gnus/5.090006 (Oort Gnus v0.06) XEmacs/21.4 (Artificial Intelligence, i386-suse-linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-03/txt/msg00038.txt.bz2 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 * 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