summary refs log tree commit diff
path: root/sysdeps/i386
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-25 23:21:20 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-25 23:21:20 +0000
commit722c33bbb6d2984cf537f0d3669617fba041fb50 (patch)
tree2a7f596c5e9979123c3833a1684a2d3516c067f9 /sysdeps/i386
parent788e8e7c221825916e6ab11f0079d4c5ede8a057 (diff)
downloadglibc-722c33bbb6d2984cf537f0d3669617fba041fb50.tar.gz
glibc-722c33bbb6d2984cf537f0d3669617fba041fb50.tar.xz
glibc-722c33bbb6d2984cf537f0d3669617fba041fb50.zip
Update.
	* string/bits/string2.h: Fix aliasing problems.
	* sysdeps/i386/i486/bits/string.h: Likewise.
	* sysdeps/i386/bits/string.h: Likewise.

1998-12-28  Geoff Keating  <geoffk@ozemail.com.au>

	* sysdeps/powerpc/dl-machine.c: Handle shared library profiling.
	* elf/rtld.c (dl_main): Don't call malloc() between
	re-relocating the dynamic linker and running the application's crt0.

1999-07-21  Paul D. Smith  <psmith@gnu.org>

	* sysdeps/generic/glob.c: Move getlogin{,_r} prototypes below
	glob.h to get __P() macro.

	* posix/fnmatch.c (internal_fnmatch): Use K&R definition syntax,
	not ANSI.
	(__strchrnul): This won't exist outside GLIBC, so create one.

1999-07-25  Jakub Jelinek   <jj@ultra.linux.cz>

	* sysdeps/unix/sysv/linux/sparc/bits/types.h: Always define __qaddr_t.
	__ino64_t should be 32bit unsigned type on sparc32.
	Define __off64_t to __quad_t instead of __int64_t.
	Make __pic_pid_t unsigned on sparc32.

1999-07-25  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* localedata/tst-rpmatch.sh: Use "&" instead of "§" to avoid a bug
	in bash 2.03.

1999-07-25  Ulrich Drepper  <drepper@cygnus.com>
Diffstat (limited to 'sysdeps/i386')
-rw-r--r--sysdeps/i386/bits/string.h92
-rw-r--r--sysdeps/i386/i486/bits/string.h172
2 files changed, 148 insertions, 116 deletions
diff --git a/sysdeps/i386/bits/string.h b/sysdeps/i386/bits/string.h
index 1ea0571680..5f4f58a6db 100644
--- a/sysdeps/i386/bits/string.h
+++ b/sysdeps/i386/bits/string.h
@@ -54,59 +54,65 @@ __STRING_INLINE void *
 __memcpy_c (void *__dest, __const void *__src, size_t __n)
 {
   register unsigned long int __d0, __d1, __d2;
+  union {
+    unsigned int __ui;
+    unsigned short int __usi;
+    unsigned char __uc;
+  } *__u = __dest;
   switch (__n)
     {
     case 0:
       return __dest;
     case 1:
-      *(unsigned char *) __dest = *(const unsigned char *) __src;
+      __u->__uc = *(const unsigned char *) __src;
       return __dest;
     case 2:
-      *(unsigned short int *) __dest = *(const unsigned short int *) __src;
+      __u->__usi = *(const unsigned short int *) __src;
       return __dest;
     case 3:
-      *(unsigned short int *) __dest = *(const unsigned short int *) __src;
-      *(2 + (unsigned char *) __dest) = *(2 + (const unsigned char *) __src);
+      __u->__usi = *(const unsigned short int *) __src;
+      __u = (void *) __u + 2;
+      __u->__uc = *(2 + (const unsigned char *) __src);
       return __dest;
     case 4:
-      *(unsigned long int *) __dest = *(const unsigned long int *) __src;
+      __u->__ui = *(const unsigned int *) __src;
       return __dest;
-    case 6:	/* for ethernet addresses */
-      *(unsigned long int *) __dest = *(const unsigned long int *) __src;
-      *(2 + (unsigned short int *) __dest) =
-	*(2 + (const unsigned short int *) __src);
+    case 6:
+      __u->__ui = *(const unsigned int *) __src;
+      __u = (void *) __u + 4;
+      __u->__usi = *(2 + (const unsigned short int *) __src);
       return __dest;
     case 8:
-      *(unsigned long int *) __dest = *(const unsigned long int *) __src;
-      *(1 + (unsigned long int *) __dest) =
-	*(1 + (const unsigned long int *) __src);
+      __u->__ui = *(const unsigned int *) __src;
+      __u = (void *) __u + 4;
+      __u->__ui = *(1 + (const unsigned int *) __src);
       return __dest;
     case 12:
-      *(unsigned long int *) __dest = *(const unsigned long int *) __src;
-      *(1 + (unsigned long int *) __dest) =
-	*(1 + (const unsigned long int *) __src);
-      *(2 + (unsigned long int *) __dest) =
-	*(2 + (const unsigned long int *) __src);
+      __u->__ui = *(const unsigned int *) __src;
+      __u = (void *) __u + 4;
+      __u->__ui = *(1 + (const unsigned int *) __src);
+      __u = (void *) __u + 4;
+      __u->__ui = *(2 + (const unsigned int *) __src);
       return __dest;
     case 16:
-      *(unsigned long int *) __dest = *(const unsigned long int *) __src;
-      *(1 + (unsigned long int *) __dest) =
-	*(1 + (const unsigned long int *) __src);
-      *(2 + (unsigned long int *) __dest) =
-	*(2 + (const unsigned long int *) __src);
-      *(3 + (unsigned long int *) __dest) =
-	*(3 + (const unsigned long int *) __src);
+      __u->__ui = *(const unsigned int *) __src;
+      __u = (void *) __u + 4;
+      __u->__ui = *(1 + (const unsigned int *) __src);
+      __u = (void *) __u + 4;
+      __u->__ui = *(2 + (const unsigned int *) __src);
+      __u = (void *) __u + 4;
+      __u->__ui = *(3 + (const unsigned int *) __src);
       return __dest;
     case 20:
-      *(unsigned long int *) __dest = *(const unsigned long int *) __src;
-      *(1 + (unsigned long int *) __dest) =
-	*(1 + (const unsigned long int *) __src);
-      *(2 + (unsigned long int *) __dest) =
-	*(2 + (const unsigned long int *) __src);
-      *(3 + (unsigned long int *) __dest) =
-	*(3 + (const unsigned long int *) __src);
-      *(4 + (unsigned long int *) __dest) =
-	*(4 + (const unsigned long int *) __src);
+      __u->__ui = *(const unsigned int *) __src;
+      __u = (void *) __u + 4;
+      __u->__ui = *(1 + (const unsigned int *) __src);
+      __u = (void *) __u + 4;
+      __u->__ui = *(2 + (const unsigned int *) __src);
+      __u = (void *) __u + 4;
+      __u->__ui = *(3 + (const unsigned int *) __src);
+      __u = (void *) __u + 4;
+      __u->__ui = *(4 + (const unsigned int *) __src);
       return __dest;
     }
 #define __COMMON_CODE(x) \
@@ -115,7 +121,7 @@ __memcpy_c (void *__dest, __const void *__src, size_t __n)
      "rep; movsl"							      \
      x									      \
      : "=&c" (__d0), "=&D" (__d1), "=&S" (__d2)				      \
-     : "0" (__n / 4), "1" (__dest), "2" (__src)				      \
+     : "0" (__n / 4), "1" (&__u->__uc), "2" (__src)			      \
      : "memory");
 
   switch (__n % 4)
@@ -184,22 +190,28 @@ __STRING_INLINE void *
 __memset_cc (void *__s, unsigned long int __pattern, size_t __n)
 {
   register unsigned long int __d0, __d1;
+  union {
+    unsigned int __ui;
+    unsigned short int __usi;
+    unsigned char __uc;
+  } *__u = __s;
   switch (__n)
     {
     case 0:
       return __s;
     case 1:
-      *(unsigned char *) __s = __pattern;
+      __u->__uc = __pattern;
       return __s;
     case 2:
-      *(unsigned short int *) __s = __pattern;
+      __u->__usi = __pattern;
       return __s;
     case 3:
-      *(unsigned short int *) __s = __pattern;
-      *(2 + (unsigned char *) __s) = __pattern;
+      __u->__usi = __pattern;
+      __u = __extension__ ((void *) __u + 1);
+      __u->__uc = __pattern;
       return __s;
     case 4:
-      *(unsigned long *) __s = __pattern;
+      __u->__ui = __pattern;
       return __s;
 	}
 #define __COMMON_CODE(x) \
@@ -208,7 +220,7 @@ __memset_cc (void *__s, unsigned long int __pattern, size_t __n)
      "rep; stosl"							      \
      x									      \
      : "=&c" (__d0), "=&D" (__d1)					      \
-     : "a" (__pattern), "0" (__n / 4), "1" (__s)			      \
+     : "a" (__pattern), "0" (__n / 4), "1" (&__u->__uc)			      \
      : "memory")
 
   switch (__n % 4)
diff --git a/sysdeps/i386/i486/bits/string.h b/sysdeps/i386/i486/bits/string.h
index 39edc6ec56..8857a7178a 100644
--- a/sysdeps/i386/i486/bits/string.h
+++ b/sysdeps/i386/i486/bits/string.h
@@ -211,12 +211,17 @@ memcmp (__const void *__s1, __const void *__s2, size_t __n)
 
 #define __memset_gc(s, c, n) \
   ({ void *__s = (s);							      \
-     unsigned int *__ts = (unsigned int *) __s;				      \
+     union {								      \
+       unsigned int __ui;						      \
+       unsigned short int __usi;					      \
+       unsigned char __uc;						      \
+     } *__u = __s;							      \
      unsigned int __c = ((unsigned int) ((unsigned char) (c))) * 0x01010101;  \
 									      \
      /* We apply a trick here.  `gcc' would implement the following	      \
-	assignments using absolute operands.  But this uses to much	      \
-	memory (7, instead of 4 bytes).  */				      \
+	assignments using immediate operands.  But this uses to much	      \
+	memory (7, instead of 4 bytes).  So we force the value in a	      \
+	registers.  */							      \
      if (n == 3 || n >= 5)						      \
        __asm__ __volatile__ ("" : "=r" (__c) : "0" (__c));		      \
 									      \
@@ -224,44 +229,57 @@ memcmp (__const void *__s1, __const void *__s2, size_t __n)
      switch (n)								      \
        {								      \
        case 15:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 11:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 7:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 3:								      \
-	 *((unsigned short int *) __ts)++ = (unsigned short int) __c;	      \
-	 *((unsigned char *) __ts) = (unsigned char) __c;		      \
+	 __u->__usi = (unsigned short int) __c;				      \
+	 __u = (void *) __u + 2;					      \
+	 __u->__uc = (unsigned char) __c;				      \
 	 break;								      \
 									      \
        case 14:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 10:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 6:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 2:								      \
-	 *((unsigned short int *) __ts) = (unsigned short int) __c;	      \
+	 __u->__usi = (unsigned short int) __c;				      \
 	 break;								      \
 									      \
        case 13:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 9:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 5:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 1:								      \
-	 *((unsigned char *) __ts) = (unsigned char) __c;		      \
+	 __u->__uc = (unsigned char) __c;				      \
 	 break;								      \
 									      \
        case 16:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 12:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 8:								      \
-	 *__ts++ = __c;							      \
+	 __u->__ui = __c;						      \
+	 __u = (void *) __u + 4;					      \
        case 4:								      \
-	 *__ts = __c;							      \
+	 __u->__ui = __c;						      \
        case 0:								      \
 	 break;								      \
        }								      \
@@ -494,48 +512,50 @@ __strlen_g (__const char *__str)
 		  : __strcpy_g (dest, src)))
 
 #define __strcpy_small(dest, src, srclen) \
-  (__extension__ ({ unsigned char *__dest = (unsigned char *) (dest);	      \
+  (__extension__ ({ char *__dest = (dest);				      \
+		    union {						      \
+		      unsigned int __ui;				      \
+		      unsigned short int __usi;				      \
+		      unsigned char __uc;				      \
+		      char __c;						      \
+		    } *__u = (void *) __dest;				      \
 		    switch (srclen)					      \
 		      {							      \
 		      case 1:						      \
-			*__dest = '\0';					      \
+			__u->__uc = '\0';				      \
 			break;						      \
 		      case 2:						      \
-			*((unsigned short int *) __dest) =		      \
-			  __STRING_SMALL_GET16 (src, 0);		      \
+			__u->__usi = __STRING_SMALL_GET16 (src, 0);	      \
 			break;						      \
 		      case 3:						      \
-			*((unsigned short int *) __dest) =		      \
-			  __STRING_SMALL_GET16 (src, 0);		      \
-			*(__dest + 2) = '\0';				      \
+			__u->__usi = __STRING_SMALL_GET16 (src, 0);	      \
+			__u = (void *) __u + 2;				      \
+			__u->__uc = '\0';				      \
 			break;						      \
 		      case 4:						      \
-			*((unsigned int *) __dest) =			      \
-			  __STRING_SMALL_GET32 (src, 0);		      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 0);	      \
 			break;						      \
 		      case 5:						      \
-			*((unsigned int *) __dest) =			      \
-			  __STRING_SMALL_GET32 (src, 0);		      \
-			*(__dest + 4) = '\0';				      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 0);	      \
+			__u = (void *) __u + 4;				      \
+			__u->__uc = '\0';				      \
 			break;						      \
 		      case 6:						      \
-			*((unsigned int *) __dest) =			      \
-			  __STRING_SMALL_GET32 (src, 0);		      \
-			*((unsigned short int *) (__dest + 4)) =	      \
-			  __STRING_SMALL_GET16 (src, 4);		      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 0);	      \
+			__u = (void *) __u + 4;				      \
+			__u->__usi = __STRING_SMALL_GET16 (src, 4);	      \
 			break;						      \
 		      case 7:						      \
-			*((unsigned int *) __dest) =			      \
-			  __STRING_SMALL_GET32 (src, 0);		      \
-			*((unsigned short int *) (__dest + 4)) =	      \
-			  __STRING_SMALL_GET16 (src, 4);		      \
-			*(__dest + 6) = '\0';				      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 0);	      \
+			__u = (void *) __u + 4;				      \
+			__u->__usi = __STRING_SMALL_GET16 (src, 4);	      \
+			__u = (void *) __u + 2;				      \
+			__u->__uc = '\0';				      \
 			break;						      \
 		      case 8:						      \
-			*((unsigned int *) __dest) =			      \
-			  __STRING_SMALL_GET32 (src, 0);		      \
-			*((unsigned int *) (__dest + 4)) =		      \
-			  __STRING_SMALL_GET32 (src, 4);		      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 0);	      \
+			__u = (void *) __u + 4;				      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 4);	      \
 			break;						      \
 		      }							      \
 		    (char *) __dest; }))
@@ -583,56 +603,56 @@ __strcpy_g (char *__dest, __const char *__src)
 # define stpcpy(dest, src) __stpcpy (dest, src)
 
 # define __stpcpy_small(dest, src, srclen) \
-  (__extension__ ({ unsigned char *__dest = (unsigned char *) (dest);	      \
+  (__extension__ ({ union {						      \
+		      unsigned int __ui;				      \
+		      unsigned short int __usi;				      \
+		      unsigned char __uc;				      \
+		      char __c;						      \
+		    } *__u = (void *) (dest);				      \
 		    switch (srclen)					      \
 		      {							      \
 		      case 1:						      \
-			*__dest = '\0';					      \
+			__u->__uc = '\0';				      \
 			break;						      \
 		      case 2:						      \
-			*((unsigned short int *) __dest) =		      \
-			  __STRING_SMALL_GET16 (src, 0);		      \
-			++__dest;					      \
+			__u->__usi = __STRING_SMALL_GET16 (src, 0);	      \
+			__u = (void *) __u + 1;				      \
 			break;						      \
 		      case 3:						      \
-			*((unsigned short int *) __dest)++ =		      \
-			  __STRING_SMALL_GET16 (src, 0);		      \
-			*__dest = '\0';					      \
+			__u->__usi = __STRING_SMALL_GET16 (src, 0);	      \
+			__u = (void *) __u + 2;				      \
+			__u->__uc = '\0';				      \
 			break;						      \
 		      case 4:						      \
-			*((unsigned int *) __dest) =			      \
-			  __STRING_SMALL_GET32 (src, 0);		      \
-			__dest += 3;					      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 0);	      \
+			__u = (void *) __u + 3;				      \
 			break;						      \
 		      case 5:						      \
-			*((unsigned int *) __dest)++ =			      \
-			  __STRING_SMALL_GET32 (src, 0);		      \
-			*__dest = '\0';					      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 0);	      \
+			__u = (void *) __u + 4;				      \
+			__u->__uc = '\0';				      \
 			break;						      \
 		      case 6:						      \
-			*((unsigned int *) __dest) =			      \
-			  __STRING_SMALL_GET32 (src, 0);		      \
-			*((unsigned short int *) (__dest + 4)) =	      \
-			  __STRING_SMALL_GET16 (src, 4);		      \
-			__dest += 5;					      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 0);	      \
+			__u = (void *) __u + 4;				      \
+			__u->__usi = __STRING_SMALL_GET16 (src, 4);	      \
+			__u = (void *) __u + 1;				      \
 			break;						      \
 		      case 7:						      \
-			*((unsigned int *) __dest) =			      \
-			  __STRING_SMALL_GET32 (src, 0);		      \
-			*((unsigned short int *) (__dest + 4)) =	      \
-			  __STRING_SMALL_GET16 (src, 4);		      \
-			__dest += 6;					      \
-			*__dest = '\0';					      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 0);	      \
+			__u = (void *) __u + 4;				      \
+			__u->__usi = __STRING_SMALL_GET16 (src, 4);	      \
+			__u = (void *) __u + 2;				      \
+			__u->__uc = '\0';				      \
 			break;						      \
 		      case 8:						      \
-			*((unsigned int *) __dest) =			      \
-			  __STRING_SMALL_GET32 (src, 0);		      \
-			*((unsigned int *) (__dest + 4)) =		      \
-			  __STRING_SMALL_GET32 (src, 4);		      \
-			__dest += 7;					      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 0);	      \
+			__u = (void *) __u + 4;				      \
+			__u->__ui = __STRING_SMALL_GET32 (src, 4);	      \
+			__u = (void *) __u + 3;				      \
 			break;						      \
 		      }							      \
-		    (char *) __dest; }))
+		    (char *) __u; }))
 
 __STRING_INLINE char *__mempcpy_by4 (char *__dest, __const char *__src,
 				     size_t __srclen);