about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-05-08 12:32:47 +0000
committerUlrich Drepper <drepper@redhat.com>1998-05-08 12:32:47 +0000
commitfab6d621377dcd0ace90066684cff09cb26ba725 (patch)
treeebb9ddc285c78bdfdccfa5ba33eba7a2e57d6cae
parentebcd12d4f11fac725e30b49a8dd1635ec0573eb5 (diff)
downloadglibc-fab6d621377dcd0ace90066684cff09cb26ba725.tar.gz
glibc-fab6d621377dcd0ace90066684cff09cb26ba725.tar.xz
glibc-fab6d621377dcd0ace90066684cff09cb26ba725.zip
Update.
1998-05-08 12:26  Ulrich Drepper  <drepper@cygnus.com>

	* iconv/gconv_int.h (struct gconv_module): Remove cost field and add
	cost_hi and cost_lo.
	* iconv/gconv_conf.c (builtin_modules): Initialize cost_hi from
	Cost parameter and set cost_lo to INT_MAX.
	(add_module): Take new parameter and use it to initialize cost_lo.
	(read_conf_file): Count modules being loaded and use counter for
	new parameter to add_module.
	* iconv/gconv_db.c (find_derivation): When look for cost examine
	cost_hi and cost_lo.

1998-05-08 10:52  Ulrich Drepper  <drepper@cygnus.com>

	* string/bits/string2.h: Don't use unsigned char * unless really
	necessary since this disturbs C++.
	* sysdeps/i386/i486/bits/string.h: Likewise.
	Patch by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>.

1998-05-08 13:53  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* malloc/malloc.c (top_check): Fix last change.
-rw-r--r--ChangeLog23
-rw-r--r--iconv/gconv_conf.c20
-rw-r--r--iconv/gconv_db.c15
-rw-r--r--iconv/gconv_int.h3
-rw-r--r--malloc/malloc.c1
-rw-r--r--string/bits/string2.h259
-rw-r--r--sysdeps/i386/i486/bits/string.h15
7 files changed, 193 insertions, 143 deletions
diff --git a/ChangeLog b/ChangeLog
index be527caa94..ed639cbab0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+1998-05-08 12:26  Ulrich Drepper  <drepper@cygnus.com>
+
+	* iconv/gconv_int.h (struct gconv_module): Remove cost field and add
+	cost_hi and cost_lo.
+	* iconv/gconv_conf.c (builtin_modules): Initialize cost_hi from
+	Cost parameter and set cost_lo to INT_MAX.
+	(add_module): Take new parameter and use it to initialize cost_lo.
+	(read_conf_file): Count modules being loaded and use counter for
+	new parameter to add_module.
+	* iconv/gconv_db.c (find_derivation): When look for cost examine
+	cost_hi and cost_lo.
+
+1998-05-08 10:52  Ulrich Drepper  <drepper@cygnus.com>
+
+	* string/bits/string2.h: Don't use unsigned char * unless really
+	necessary since this disturbs C++.
+	* sysdeps/i386/i486/bits/string.h: Likewise.
+	Patch by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>.
+
+1998-05-08 13:53  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+	* malloc/malloc.c (top_check): Fix last change.
+
 1998-05-07  Ulrich Drepper  <drepper@cygnus.com>
 
 	* sysdeps/powerpc/bits/setjmp.h (_JMPBUF_UNWINDS): Define.
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index ae5ba19e5d..6457e37113 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -20,6 +20,7 @@
 
 #include <ctype.h>
 #include <errno.h>
+#include <limits.h>
 #include <search.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -54,7 +55,8 @@ static struct gconv_module builtin_modules[] =
     from_constpfx_len: ConstLen,					      \
     from_regex: NULL,							      \
     to_string: To,							      \
-    cost: Cost,								      \
+    cost_hi: Cost,							      \
+    cost_lo: INT_MAX,							      \
     module_name: Name							      \
   },
 #define BUILTIN_ALIAS(From, To)
@@ -151,7 +153,7 @@ add_alias (char *rp)
 /* Add new module.  */
 static inline void
 add_module (char *rp, const char *directory, size_t dir_len, void **modules,
-	    size_t *nmodules)
+	    size_t *nmodules, int modcounter)
 {
   /* We expect now
      1. `from' name
@@ -164,7 +166,7 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
   size_t const_len;
   int from_is_regex;
   int need_ext;
-  int cost;
+  int cost_hi;
 
   while (isspace (*rp))
     ++rp;
@@ -198,7 +200,7 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
     {
       /* There is no cost, use one by default.  */
       *wp++ = '\0';
-      cost = 1;
+      cost_hi = 1;
     }
   else
     {
@@ -206,10 +208,10 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
       char *endp;
 
       *wp++ = '\0';
-      cost = strtol (rp, &endp, 10);
+      cost_hi = strtol (rp, &endp, 10);
       if (rp == endp)
 	/* No useful information.  */
-	cost = 1;
+	cost_hi = 1;
     }
 
   if (module[0] == '\0')
@@ -264,7 +266,8 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
       new_module->to_string = memcpy ((char *) new_module->from_constpfx
 				      + (to - from), to, module - to);
 
-      new_module->cost = cost;
+      new_module->cost_hi = cost_hi;
+      new_module->cost_lo = modcounter;
 
       new_module->module_name = (char *) new_module->to_string + (module - to);
 
@@ -314,6 +317,7 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
   FILE *fp = fopen (filename, "r");
   char *line = NULL;
   size_t line_len = 0;
+  int modcounter = 0;
 
   /* Don't complain if a file is not present or readable, simply silently
      ignore it.  */
@@ -356,7 +360,7 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
 	add_alias (rp);
       else if (rp - word == sizeof ("module") - 1
 	       && memcmp (word, "module", sizeof ("module") - 1) == 0)
-	add_module (rp, directory, dir_len, modules, nmodules);
+	add_module (rp, directory, dir_len, modules, nmodules, modcounter++);
       /* else */
 	/* Otherwise ignore the line.  */
     }
diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c
index 62d8f0540c..503c5d0c86 100644
--- a/iconv/gconv_db.c
+++ b/iconv/gconv_db.c
@@ -261,7 +261,8 @@ find_derivation (const char *toset, const char *toset_expand,
 {
   __libc_lock_define_initialized (static, lock)
   struct derivation_step *first, *current, **lastp, *best = NULL;
-  int best_cost = 0;
+  int best_cost_hi = 0;
+  int best_cost_lo = 0;
   int result;
 
   result = derivation_lookup (fromset_expand ?: fromset, toset_expand ?: toset,
@@ -429,18 +430,22 @@ find_derivation (const char *toset, const char *toset_expand,
 		  /* Determine the costs.  If they are lower than the
 		     previous solution (or this is the first solution)
 		     remember this solution.  */
-		  int cost = __gconv_modules_db[cnt]->cost;
+		  int cost_hi = __gconv_modules_db[cnt]->cost_hi;
+		  int cost_lo = __gconv_modules_db[cnt]->cost_lo;
 		  struct derivation_step *runp = current;
 		  while (runp->code != NULL)
 		    {
-		      cost += runp->code->cost;
+		      cost_hi += runp->code->cost_hi;
+		      cost_lo += runp->code->cost_lo;
 		      runp = runp->last;
 		    }
-		  if (best == NULL || cost < best_cost)
+		  if (best == NULL || cost_hi < best_cost_hi
+		      || (cost_hi == best_cost_hi && cost_lo < best_cost_lo))
 		    {
 		      best = NEW_STEP (result_set, __gconv_modules_db[cnt],
 				       current);
-		      best_cost = cost;
+		      best_cost_hi = cost_hi;
+		      best_cost_lo = cost_lo;
 		    }
 		}
 	      else
diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h
index 80cced4d4a..e4202f68ea 100644
--- a/iconv/gconv_int.h
+++ b/iconv/gconv_int.h
@@ -70,7 +70,8 @@ struct gconv_module
 
   const char *to_string;
 
-  int cost;
+  int cost_hi;
+  int cost_lo;
 
   const char *module_name;
 };
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 607961a9c6..78e6b399b2 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4250,7 +4250,6 @@ static int
 #if __STD_C
 top_check(void)
 #else
-static int
 top_check()
 #endif
 {
diff --git a/string/bits/string2.h b/string/bits/string2.h
index a84cede465..e26d4df53a 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -52,28 +52,28 @@
 
 # if __BYTE_ORDER == __LITTLE_ENDIAN
 #  define __STRING2_SMALL_GET16(src, idx) \
-     (((__const unsigned char *) (src))[idx + 1] << 8			      \
-      | ((__const unsigned char *) (src))[idx])
+     (((__const unsigned char *) (__const char *) (src))[idx + 1] << 8	      \
+      | ((__const unsigned char *) (__const char *) (src))[idx])
 #  define __STRING2_SMALL_GET32(src, idx) \
-     (((((__const unsigned char *) (src))[idx + 3] << 8			      \
-	| ((__const char *) (src))[idx + 2]) << 8			      \
-       | ((__const unsigned char *) (src))[idx + 1]) << 8		      \
-      | ((__const unsigned char *) (src))[idx])
+     (((((__const unsigned char *) (__const char *) (src))[idx + 3] << 8      \
+	| ((__const unsigned char *) (__const char *) (src))[idx + 2]) << 8   \
+       | ((__const unsigned char *) (__const char *) (src))[idx + 1]) << 8    \
+      | ((__const unsigned char *) (__const char *) (src))[idx])
 # else
 #  define __STRING2_SMALL_GET16(src, idx) \
-     (((__const unsigned char *) (src))[idx] << 8			      \
-      | ((__const unsigned char *) (src))[idx + 1])
+     (((__const unsigned char *) (__const char *) (src))[idx] << 8	      \
+      | ((__const unsigned char *) (__const char *) (src))[idx + 1])
 #  define __STRING2_SMALL_GET32(src, idx) \
-     (((((__const unsigned char *) (src))[idx] << 8			      \
-	| ((__const unsigned char *) (src))[idx + 1]) << 8		      \
-       | ((__const unsigned char *) (src))[idx + 2]) << 8		      \
-      | ((__const unsigned char *) (src))[idx + 3])
+     (((((__const unsigned char *) (__const char *) (src))[idx] << 8	      \
+	| ((__const unsigned char *) (__const char *) (src))[idx + 1]) << 8   \
+       | ((__const unsigned char *) (__const char *) (src))[idx + 2]) << 8    \
+      | ((__const unsigned char *) (__const char *) (src))[idx + 3])
 # endif
 #else
 /* These are a few types we need for the optimizations if we cannot
    use unaligned memory accesses.  */
 # define __STRING2_COPY_TYPE(N) \
-  typedef struct { char __arr[N]; }					      \
+  typedef struct { unsigned char __arr[N]; }				      \
     __STRING2_COPY_ARR##N __attribute__ ((packed))
 __STRING2_COPY_TYPE (2);
 __STRING2_COPY_TYPE (3);
@@ -111,7 +111,7 @@ __STRING2_COPY_TYPE (8);
 
 # if _STRING_ARCH_unaligned
 #  define __strcpy_small(dest, src, srclen) \
-  (__extension__ ({ unsigned char *__dest = (unsigned char *) (dest);	      \
+  (__extension__ ({ char *__dest = (char *) (dest);			      \
 		    switch (srclen)					      \
 		      {							      \
 		      case 1:						      \
@@ -155,10 +155,10 @@ __STRING2_COPY_TYPE (8);
 			  __STRING2_SMALL_GET32 (src, 4);		      \
 			break;						      \
 		      }							      \
-		    (char *) __dest; }))
+		    __dest; }))
 # else
 #  define __strcpy_small(dest, src, srclen) \
-  (__extension__ ({ unsigned char *__dest = (unsigned char *) (dest);	      \
+  (__extension__ ({ char *__dest = (char *) (dest);			      \
 		    switch (srclen)					      \
 		      {							      \
 		      case 1:						      \
@@ -167,68 +167,68 @@ __STRING2_COPY_TYPE (8);
 		      case 2:						      \
 			*((__STRING2_COPY_ARR2 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR2)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
+			   { { ((__const char *) (src))[0],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 3:						      \
 			*((__STRING2_COPY_ARR3 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR3)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 4:						      \
 			*((__STRING2_COPY_ARR4 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR4)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
-			       ((__const unsigned char *) (src))[2],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 5:						      \
 			*((__STRING2_COPY_ARR5 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR5)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
-			       ((__const unsigned char *) (src))[2],	      \
-			       ((__const unsigned char *) (src))[3],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 6:						      \
 			*((__STRING2_COPY_ARR6 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR6)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
-			       ((__const unsigned char *) (src))[2],	      \
-			       ((__const unsigned char *) (src))[3],	      \
-			       ((__const unsigned char *) (src))[4],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
+			       ((__const char *) (src))[4],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 7:						      \
 			*((__STRING2_COPY_ARR7 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR7)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
-			       ((__const unsigned char *) (src))[2],	      \
-			       ((__const unsigned char *) (src))[3],	      \
-			       ((__const unsigned char *) (src))[4],	      \
-			       ((__const unsigned char *) (src))[5],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
+			       ((__const char *) (src))[4],		      \
+			       ((__const char *) (src))[5],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 8:						      \
 			*((__STRING2_COPY_ARR8 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR8)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
-			       ((__const unsigned char *) (src))[2],	      \
-			       ((__const unsigned char *) (src))[3],	      \
-			       ((__const unsigned char *) (src))[4],	      \
-			       ((__const unsigned char *) (src))[5],	      \
-			       ((__const unsigned char *) (src))[6],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
+			       ((__const char *) (src))[4],		      \
+			       ((__const char *) (src))[5],		      \
+			       ((__const char *) (src))[6],		      \
 			       '\0' } });				      \
 			break;						      \
 		    }							      \
-		  (char *) __dest; }))
+		  __dest; }))
 # endif
 #endif
 
@@ -248,7 +248,7 @@ __STRING2_COPY_TYPE (8);
 
 #  if _STRING_ARCH_unaligned
 #   define __stpcpy_small(dest, src, srclen) \
-  (__extension__ ({ unsigned char *__dest = (unsigned char *) (dest);	      \
+  (__extension__ ({ char *__dest = (char *) (dest);			      \
 		    switch (srclen)					      \
 		      {							      \
 		      case 1:						      \
@@ -299,10 +299,10 @@ __STRING2_COPY_TYPE (8);
 			__dest += 7;					      \
 			break;						      \
 		      }							      \
-		    (char *) __dest; }))
+		    __dest; }))
 #  else
 #   define __stpcpy_small(dest, src, srclen) \
-  (__extension__ ({ unsigned char *__dest = (unsigned char *) (dest);	      \
+  (__extension__ ({ char *__dest = (char *) (dest);			      \
 		    switch (srclen)					      \
 		      {							      \
 		      case 1:						      \
@@ -311,68 +311,68 @@ __STRING2_COPY_TYPE (8);
 		      case 2:						      \
 			*((__STRING2_COPY_ARR2 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR2)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
+			   { { ((__const char *) (src))[0],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 3:						      \
 			*((__STRING2_COPY_ARR3 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR3)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 4:						      \
 			*((__STRING2_COPY_ARR4 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR4)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
-			       ((__const unsigned char *) (src))[2],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 5:						      \
 			*((__STRING2_COPY_ARR5 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR5)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
-			       ((__const unsigned char *) (src))[2],	      \
-			       ((__const unsigned char *) (src))[3],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 6:						      \
 			*((__STRING2_COPY_ARR6 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR6)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
-			       ((__const unsigned char *) (src))[2],	      \
-			       ((__const unsigned char *) (src))[3],	      \
-			       ((__const unsigned char *) (src))[4],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
+			       ((__const char *) (src))[4],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 7:						      \
 			*((__STRING2_COPY_ARR7 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR7)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
-			       ((__const unsigned char *) (src))[2],	      \
-			       ((__const unsigned char *) (src))[3],	      \
-			       ((__const unsigned char *) (src))[4],	      \
-			       ((__const unsigned char *) (src))[5],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
+			       ((__const char *) (src))[4],		      \
+			       ((__const char *) (src))[5],		      \
 			       '\0' } });				      \
 			break;						      \
 		      case 8:						      \
 			*((__STRING2_COPY_ARR8 *) __dest) =		      \
 			  ((__STRING2_COPY_ARR8)			      \
-			   { { ((__const unsigned char *) (src))[0],	      \
-			       ((__const unsigned char *) (src))[1],	      \
-			       ((__const unsigned char *) (src))[2],	      \
-			       ((__const unsigned char *) (src))[3],	      \
-			       ((__const unsigned char *) (src))[4],	      \
-			       ((__const unsigned char *) (src))[5],	      \
-			       ((__const unsigned char *) (src))[6],	      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
+			       ((__const char *) (src))[4],		      \
+			       ((__const char *) (src))[5],		      \
+			       ((__const char *) (src))[6],		      \
 			       '\0' } });				      \
 			break;						      \
 		    }							      \
-		  (char *) (__dest + ((srclen) - 1)); }))
+		  __dest + ((srclen) - 1); }))
 #  endif
 # endif
 #endif
@@ -428,8 +428,9 @@ __STRING2_COPY_TYPE (8);
   (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2)      \
 		  && (!__string2_1bptr_p (s1) || strlen (s1) >= 4)	      \
 		  && (!__string2_1bptr_p (s2) || strlen (s2) >= 4)	      \
-		  ? memcmp (s1, s2, (strlen (s1) < strlen (s2)		      \
-				     ? strlen (s1) : strlen (s2)) + 1)	      \
+		  ? memcmp ((__const char *) s1, (__const char *) s2,	      \
+			    (strlen (s1) < strlen (s2)			      \
+			     ? strlen (s1) : strlen (s2)) + 1)		      \
 		  : (__builtin_constant_p (s1) && __string2_1bptr_p (s1)      \
 		     && strlen (s1) < 4					      \
 		     ? (__builtin_constant_p (s2) && __string2_1bptr_p (s2)   \
@@ -444,40 +445,48 @@ __STRING2_COPY_TYPE (8);
 
 # define __strcmp_cc(s1, s2, l) \
   (__extension__ ({ register int __result =				      \
-		      (((__const unsigned char *) (s1))[0]		      \
-		       - ((__const unsigned char *) (s2))[0]);		      \
+		      (((__const unsigned char *) (__const char *) (s1))[0]   \
+		       - ((__const unsigned char *) (__const char *)(s2))[0]);\
 		    if (l > 0 && __result == 0)				      \
 		      {							      \
-			__result = (((__const unsigned char *) (s1))[1]	      \
-				    - ((__const unsigned char *) (s2))[1]);   \
+			__result = (((__const unsigned char *)		      \
+				     (__const char *) (s1))[1]		      \
+				    - ((__const unsigned char *)	      \
+				       (__const char *) (s2))[1]);	      \
 			if (l > 1 && __result == 0)			      \
 			  {						      \
 			    __result =					      \
-			      (((__const unsigned char *) (s1))[2]	      \
-			       - ((__const unsigned char *) (s2))[2]);	      \
+			      (((__const unsigned char *)		      \
+				(__const char *) (s1))[2]		      \
+			       - ((__const unsigned char *)		      \
+				  (__const char *) (s2))[2]);		      \
 			    if (l > 2 && __result == 0)			      \
 			      __result =				      \
-				(((__const unsigned char *) (s1))[3]	      \
-				 - ((__const unsigned char *) (s2))[3]);      \
+				(((__const unsigned char *)		      \
+				  (__const char *) (s1))[3]		      \
+				 - ((__const unsigned char *)		      \
+				    (__const char *) (s2))[3]);		      \
 			  }						      \
 		      }							      \
 		    __result; }))
 
 # define __strcmp_cg(s1, s2, l1) \
   (__extension__ ({ __const unsigned char *__s2 =			      \
-		      (__const unsigned char *) (s2);			      \
+		      (__const unsigned char *) (__const char *) (s2);	      \
 		    register int __result =				      \
-		      (((__const unsigned char *) (s1))[0] - __s2[0]);	      \
+		      (((__const unsigned char *) (__const char *) (s1))[0]   \
+		       - __s2[0]);					      \
 		    if (l1 > 0 && __result == 0)			      \
 		      {							      \
-			__result = (((__const unsigned char *) (s1))[1]	      \
-				    - __s2[1]);				      \
+			__result = (((__const unsigned char *)		      \
+				     (__const char *) (s1))[1] - __s2[1]);    \
 			if (l1 > 1 && __result == 0)			      \
 			  {						      \
-			    __result = (((__const unsigned char *) (s1))[2]   \
-					- __s2[2]);			      \
+			    __result = (((__const unsigned char *)	      \
+					 (__const char *) (s1))[2] - __s2[2]);\
 			    if (l1 > 2 && __result == 0)		      \
-			      __result = (((__const unsigned char *) (s1))[3] \
+			      __result = (((__const unsigned char *)	      \
+					  (__const char *)  (s1))[3]	      \
 					  - __s2[3]);			      \
 			  }						      \
 		      }							      \
@@ -485,21 +494,25 @@ __STRING2_COPY_TYPE (8);
 
 # define __strcmp_gc(s1, s2, l2) \
   (__extension__ ({ __const unsigned char *__s1 =			      \
-		      (__const unsigned char *) (s1);			      \
+		      (__const unsigned char *) (__const char *) (s1);	      \
 		    register int __result =				      \
-		      __s1[0] - ((__const unsigned char *) (s2))[0];	      \
+		      __s1[0] - ((__const unsigned char *)		      \
+				 (__const char *) (s2))[0];		      \
 		    if (l2 > 0 && __result == 0)			      \
 		      {							      \
 			__result = (__s1[1]				      \
-				    - ((__const unsigned char *) (s2))[1]);   \
+				    - ((__const unsigned char *)	      \
+				       (__const char *) (s2))[1]);	      \
 			if (l2 > 1 && __result == 0)			      \
 			  {						      \
 			    __result =					      \
-			      (__s1[2] - ((__const unsigned char *) (s2))[2]);\
+			      (__s1[2] - ((__const unsigned char *)	      \
+					  (__const char *) (s2))[2]);	      \
 			    if (l2 > 2 && __result == 0)		      \
 			      __result =				      \
 				(__s1[3]				      \
-				 - ((__const unsigned char *)(s2))[3]);	      \
+				 - ((__const unsigned char *)		      \
+				    (__const char *) (s2))[3]);		      \
 			  }						      \
 		      }							      \
 		    __result; }))
@@ -522,14 +535,14 @@ __STRING2_COPY_TYPE (8);
 #ifndef _HAVE_STRING_ARCH_strcspn
 # define strcspn(s, reject) \
   (__extension__ (__builtin_constant_p (reject) && __string2_1bptr_p (reject) \
-		  ? (((__const unsigned char *) (reject))[0] == '\0'	      \
+		  ? (((__const char *) (reject))[0] == '\0'		      \
 		     ? strlen (s)					      \
-		     : (((__const unsigned char *) (reject))[1] == '\0'	      \
+		     : (((__const char *) (reject))[1] == '\0'		      \
 			? __strcspn_c1 (s, ((__const char *) (reject))[0])    \
-			: (((__const unsigned char *) (reject))[2] == '\0'    \
+			: (((__const char *) (reject))[2] == '\0'	      \
 			   ? __strcspn_c2 (s, ((__const char *) (reject))[0], \
 					   ((__const char *) (reject))[1])    \
-			   : (((__const unsigned char *) (reject))[3] == '\0' \
+			   : (((__const char *) (reject))[3] == '\0'	      \
 			      ? __strcspn_c3 (s,			      \
 					      ((__const char *) (reject))[0], \
 					      ((__const char *) (reject))[1], \
@@ -579,14 +592,14 @@ __strcspn_c3 (__const char *__s, char __reject1, char __reject2,
 #ifndef _HAVE_STRING_ARCH_strspn
 # define strspn(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && __string2_1bptr_p (accept) \
-		  ? (((__const unsigned char *) (accept))[0] == '\0'	      \
+		  ? (((__const char *) (accept))[0] == '\0'		      \
 		     ? 0						      \
-		     : (((__const unsigned char *) (accept))[1] == '\0'	      \
+		     : (((__const char *) (accept))[1] == '\0'		      \
 			? __strspn_c1 (s, ((__const char *) (accept))[0])     \
-			: (((__const unsigned char *) (accept))[2] == '\0'    \
+			: (((__const char *) (accept))[2] == '\0'	      \
 			   ? __strspn_c2 (s, ((__const char *) (accept))[0],  \
 					  ((__const char *) (accept))[1])     \
-			   : (((__const unsigned char *) (accept))[3] == '\0' \
+			   : (((__const char *) (accept))[3] == '\0'	      \
 			      ? __strspn_c3 (s,				      \
 					     ((__const char *) (accept))[0],  \
 					     ((__const char *) (accept))[1],  \
@@ -636,14 +649,14 @@ __strspn_c3 (__const char *__s, char __accept1, char __accept2, char __accept3)
 #ifndef _HAVE_STRING_ARCH_strpbrk
 # define strpbrk(s, accept) \
   (__extension__ (__builtin_constant_p (accept) && __string2_1bptr_p (accept) \
-		  ? (((__const unsigned char  *) (accept))[0] == '\0'	      \
+		  ? (((__const char  *) (accept))[0] == '\0'		      \
 		     ? NULL						      \
-		     : (((__const unsigned char *) (accept))[1] == '\0'	      \
-			? strchr (s, ((__const unsigned char *) (accept))[0]) \
-			: (((__const unsigned char *) (accept))[2] == '\0'    \
+		     : (((__const char *) (accept))[1] == '\0'		      \
+			? strchr (s, ((__const char *) (accept))[0])	      \
+			: (((__const char *) (accept))[2] == '\0'	      \
 			   ? __strpbrk_c2 (s, ((__const char *) (accept))[0], \
 					   ((__const char *) (accept))[1])    \
-			   : (((__const unsigned char *) (accept))[3] == '\0' \
+			   : (((__const char *) (accept))[3] == '\0'	      \
 			      ? __strpbrk_c3 (s,			      \
 					      ((__const char *) (accept))[0], \
 					      ((__const char *) (accept))[1], \
@@ -681,11 +694,11 @@ __strpbrk_c3 (__const char *__s, char __accept1, char __accept2,
 #ifndef _HAVE_STRING_ARCH_strstr
 # define strstr(haystack, needle) \
   (__extension__ (__builtin_constant_p (needle) && __string2_1bptr_p (needle) \
-		  ? (((__const unsigned char *) (needle))[0] == '\0'	      \
+		  ? (((__const char *) (needle))[0] == '\0'		      \
 		     ? (char *) (haystack)				      \
-		     : (((__const unsigned char *) (needle))[1] == '\0'	      \
+		     : (((__const char *) (needle))[1] == '\0'		      \
 			? strchr (haystack,				      \
-				  ((__const unsigned char *) (needle))[0])    \
+				  ((__const char *) (needle))[0]) 	      \
 			: strstr (haystack, needle)))			      \
 		  : strstr (haystack, needle)))
 #endif
@@ -707,8 +720,8 @@ strnlen (__const char *__string, size_t __maxlen)
 #ifndef _HAVE_STRING_ARCH_strtok_r
 # define __strtok_r(s, sep, nextp) \
   (__extension__ (__builtin_constant_p (sep) && __string2_1bptr_p (sep)	      \
-		  ? (((__const unsigned char *) (sep))[0] != '\0'	      \
-		     && ((__const unsigned char *) (sep))[1] == '\0'	      \
+		  ? (((__const char *) (sep))[0] != '\0'		      \
+		     && ((__const char *) (sep))[1] == '\0'		      \
 		     ? __strtok_r_1c (s, ((__const char *) (sep))[0], nextp)  \
 		     : __strtok_r (s, sep, nextp))			      \
 		  : __strtok_r (s, sep, nextp)))
@@ -749,14 +762,14 @@ __strtok_r_1c (char *__s, char __sep, char **__nextp)
 
 # define __strsep(s, reject) \
   (__extension__ (__builtin_constant_p (reject) && __string2_1bptr_p (reject) \
-		  && ((__const unsigned char *) (reject))[0] != '\0'	      \
-		  ? (((__const unsigned char *) (reject))[1] == '\0'	      \
+		  && ((__const char *) (reject))[0] != '\0'		      \
+		  ? (((__const char *) (reject))[1] == '\0'		      \
 		     ? __strsep_1c (s,					      \
 				    ((__const char *) (reject))[0])	      \
-		     : (((__const unsigned char *) (reject))[2] == '\0'	      \
+		     : (((__const char *) (reject))[2] == '\0'		      \
 			? __strsep_2c (s, ((__const char *) (reject))[0],     \
 				       ((__const char *) (reject))[1])	      \
-			: (((__const unsigned char *) (reject))[3] == '\0'    \
+			: (((__const char *) (reject))[3] == '\0'	      \
 			   ? __strsep_3c (s, ((__const char *) (reject))[0],  \
 					  ((__const char *) (reject))[1],     \
 					  ((__const char *) (reject))[2])     \
@@ -858,7 +871,7 @@ __strsep_g (char **__s, __const char *__reject)
 
 # define __strdup(s) \
   (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s)	      \
-		  ? (((__const unsigned char *) (s))[0] == '\0'		      \
+		  ? (((__const char *) (s))[0] == '\0'			      \
 		     ? (char *) calloc (1, 1)				      \
 		     : ({ size_t __len = strlen (s) + 1;		      \
 			  char *__retval = (char *) malloc (__len);	      \
@@ -881,7 +894,7 @@ __strsep_g (char **__s, __const char *__reject)
 
 # define __strndup(s, n) \
   (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s)	      \
-		  ? (((__const unsigned char *) (s))[0] == '\0'		      \
+		  ? (((__const char *) (s))[0] == '\0'			      \
 		     ? (char *) calloc (1, 1)				      \
 		     : ({ size_t __len = strlen (s) + 1;		      \
 			  size_t __n = (n);				      \
diff --git a/sysdeps/i386/i486/bits/string.h b/sysdeps/i386/i486/bits/string.h
index 3bd8f8922c..7a919a1ac3 100644
--- a/sysdeps/i386/i486/bits/string.h
+++ b/sysdeps/i386/i486/bits/string.h
@@ -386,7 +386,9 @@ __strlen_g (__const char *__str)
   (__extension__ (__builtin_constant_p (src)				      \
 		  ? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8	      \
 		     ? __strcpy_small (dest, src, strlen (src) + 1)	      \
-		     : (char *) memcpy (dest, src, strlen (src) + 1))	      \
+		     : (char *) memcpy ((char *) dest,			      \
+					(__const char *) src,		      \
+					strlen (src) + 1))		      \
 		  : __strcpy_g (dest, src)))
 
 #define __strcpy_small(dest, src, srclen) \
@@ -620,7 +622,8 @@ __stpcpy_g (char *__dest, __const char *__src)
 #define strncpy(dest, src, n) \
   (__extension__ (__builtin_constant_p (src)				      \
 		  ? ((strlen (src) + 1 >= ((size_t) (n))		      \
-		      ? (char *) memcpy (dest, src, n)			      \
+		      ? (char *) memcpy ((char *) dest,			      \
+					 (__const char *) src, n)	      \
 		      : __strncpy_cg (dest, src, strlen (src) + 1, n)))	      \
 		  : __strncpy_gg (dest, src, n)))
 #define __strncpy_cg(dest, src, srclen, n) \
@@ -793,7 +796,8 @@ __strcat_g (char *__dest, __const char *__src)
 		    __builtin_constant_p (src) && __builtin_constant_p (n)    \
 		    ? (strlen (src) < ((size_t) (n))			      \
 		       ? strcat (__dest, src)				      \
-		       : (memcpy (strchr (__dest, '\0'), src, n), __dest))    \
+		       : (memcpy (strchr (__dest, '\0'),		      \
+				  (__const char *) src, n), __dest))	      \
 		    : __strncat_g (__dest, src, n); }))
 
 __STRING_INLINE char *
@@ -851,8 +855,9 @@ __strncat_g (char *__dest, __const char __src[], size_t __n)
   (__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2)      \
 		  && (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4)	      \
 		  && (sizeof ((s2)[0]) != 1 || strlen (s2) >= 4)	      \
-		  ? memcmp (s1, s2, (strlen (s1) < strlen (s2)		      \
-				     ? strlen (s1) : strlen (s2)) + 1)	      \
+		  ? memcmp ((__const char *) s1, (__const char *) s2,	      \
+			    (strlen (s1) < strlen (s2)			      \
+			     ? strlen (s1) : strlen (s2)) + 1)		      \
 		  : (__builtin_constant_p (s1) && sizeof ((s1)[0]) == 1	      \
 		     && sizeof ((s2)[0]) == 1 && strlen (s1) < 4	      \
 		     ? (__builtin_constant_p (s2) && sizeof ((s2)[0]) == 1    \