This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Add memory clobber for i486 string inlines



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]