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]

[PATCH] Fix i386 <bits/string.h>


Hi!

It seems several changes which were done to i386/i486/bits/string.h were
not applied to i386/bits/string.h as well and with GCC 3.4 it shows up
in inl-tester.

2004-06-13  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/i386/bits/string.h (memcpy): Add () around arguments.
	(memchr, __memrchr, strlen, strcmp, strncmp, __strchr_g, __strchr_c,
	__strchrnul_g, __strchrnul_c, strspn, strcspn, strpbrk): Add memory
	the asm uses as its input, either of size __n where __n is known or
	0xfffffff.
	(strstr): Add "memory" clobber.

--- libc/sysdeps/i386/bits/string.h.jj	2003-09-05 06:03:03.000000000 -0400
+++ libc/sysdeps/i386/bits/string.h	2004-06-13 15:35:35.000000000 -0400
@@ -43,8 +43,8 @@
 #define _HAVE_STRING_ARCH_memcpy 1
 #define memcpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (n)				      \
-		  ? __memcpy_c (dest, src, n)				      \
-		  : memcpy (dest, src, n)))
+		  ? __memcpy_c ((dest), (src), (n))			      \
+		  : memcpy ((dest), (src), (n))))
 /* This looks horribly ugly, but the compiler can optimize it totally,
    as the count is constant.  */
 __STRING_INLINE void *__memcpy_c (void *__dest, __const void *__src,
@@ -301,7 +301,8 @@ memchr (__const void *__s, int __c, size
      "movl $1,%0\n"
      "1:"
      : "=D" (__res), "=&c" (__d0)
-     : "a" (__c), "0" (__s), "1" (__n)
+     : "a" (__c), "0" (__s), "1" (__n),
+       "m" ( *(struct { __extension__ char __x[__n]; } *)__s)
      : "cc");
   return __res - 1;
 }
@@ -324,7 +325,8 @@ __memrchr (__const void *__s, int __c, s
      "1:\tcld\n\t"
      "incl %0"
      : "=D" (__res), "=&c" (__d0)
-     : "a" (__c), "0" (__s + __n - 1), "1" (__n)
+     : "a" (__c), "0" (__s + __n - 1), "1" (__n),
+       "m" ( *(struct { __extension__ char __x[__n]; } *)__s)
      : "cc");
   return __res;
 }
@@ -346,7 +348,8 @@ strlen (__const char *__str)
      "repne; scasb\n\t"
      "notl %0"
      : "=c" (__res), "=&D" (__d0)
-     : "1" (__str), "a" (0), "0" (0xffffffff)
+     : "1" (__str), "a" (0), "0" (0xffffffff),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__str)
      : "cc");
   return __res - 1;
 }
@@ -475,7 +478,9 @@ strcmp (__const char *__s1, __const char
      "orb	$1,%%al\n"
      "3:"
      : "=a" (__res), "=&S" (__d0), "=&D" (__d1)
-     : "1" (__s1), "2" (__s2)
+     : "1" (__s1), "2" (__s2),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s1),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s2)
      : "cc");
   return __res;
 }
@@ -507,7 +512,9 @@ strncmp (__const char *__s1, __const cha
      "orb	$1,%%al\n"
      "4:"
      : "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2)
-     : "1" (__s1), "2" (__s2), "3" (__n)
+     : "1" (__s1), "2" (__s2), "3" (__n),
+       "m" ( *(struct { __extension__ char __x[__n]; } *)__s1),
+       "m" ( *(struct { __extension__ char __x[__n]; } *)__s2)
      : "cc");
   return __res;
 }
@@ -541,7 +548,8 @@ __strchr_g (__const char *__s, int __c)
      "2:\n\t"
      "movl	%1,%0"
      : "=a" (__res), "=&S" (__d0)
-     : "0" (__c), "1" (__s)
+     : "0" (__c), "1" (__s),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
      : "cc");
   return __res - 1;
 }
@@ -565,7 +573,8 @@ __strchr_c (__const char *__s, int __c)
      "2:\n\t"
      "movl	%1,%0"
      : "=a" (__res), "=&S" (__d0)
-     : "0" (__c), "1" (__s)
+     : "0" (__c), "1" (__s),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
      : "cc");
   return __res - 1;
 }
@@ -599,7 +608,8 @@ __strchrnul_g (__const char *__s, int __
      "2:\n\t"
      "movl	%1,%0"
      : "=a" (__res), "=&S" (__d0)
-     : "0" (__c), "1" (__s)
+     : "0" (__c), "1" (__s),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
      : "cc");
   return __res - 1;
 }
@@ -622,7 +632,8 @@ __strchrnul_c (__const char *__s, int __
      "2:\n\t"
      "movl	%1,%0"
      : "=a" (__res), "=&S" (__d0)
-     : "0" (__c), "1" (__s)
+     : "0" (__c), "1" (__s),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
      : "cc");
   return __res - 1;
 }
@@ -660,7 +671,8 @@ strcspn (__const char *__s, __const char
      "2:\n\t"
      "popl	%%ebx"
      : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
-     : "d" (__reject), "0" (__s), "1" (0), "2" (0xffffffff)
+     : "d" (__reject), "0" (__s), "1" (0), "2" (0xffffffff),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
      : "cc");
   return (__res - 1) - __s;
 }
@@ -687,7 +699,8 @@ strcspn (__const char *__s, __const char
      "jne	1b\n"
      "2:"
      : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3)
-     : "g" (__reject), "0" (__s), "1" (0), "2" (0xffffffff)
+     : "g" (__reject), "0" (__s), "1" (0), "2" (0xffffffff),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
      : "cc");
   return (__res - 1) - __s;
 }
@@ -724,7 +737,8 @@ strspn (__const char *__s, __const char 
      "2:\n\t"
      "popl	%%ebx"
      : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
-     : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff)
+     : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
      : "cc");
   return (__res - 1) - __s;
 }
@@ -751,7 +765,8 @@ strspn (__const char *__s, __const char 
      "je	1b\n"
      "2:"
      : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3)
-     : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff)
+     : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
      : "cc");
   return (__res - 1) - __s;
 }
@@ -791,7 +806,8 @@ strpbrk (__const char *__s, __const char
      "3:\n\t"
      "popl	%%ebx"
      : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
-     : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff)
+     : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
      : "cc");
   return __res;
 }
@@ -822,7 +838,8 @@ strpbrk (__const char *__s, __const char
      "xorl	%0,%0\n"
      "3:"
      : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3)
-     : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff)
+     : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
+       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
      : "cc");
   return __res;
 }
@@ -862,7 +879,7 @@ strstr (__const char *__haystack, __cons
      "popl	%%ebx"
      : "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2)
      : "r" (__needle), "0" (0), "1" (0xffffffff), "2" (__haystack)
-     : "cc");
+     : "memory", "cc");
   return __res;
 }
 # else
@@ -892,7 +909,7 @@ strstr (__const char *__haystack, __cons
      "2:"
      : "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&d" (__d2), "=&D" (__d3)
      : "g" (__needle), "0" (0), "1" (0xffffffff), "2" (__haystack)
-     : "cc");
+     : "memory", "cc");
   return __res;
 }
 # endif

	Jakub


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