This has (almost) been tried before. Then it was -fsigned-char,
but I think this thread from 2007 still bears meaning (especially
Mike's mail):

http://lists.busybox.net/pipermail/uclibc/2007-April/038622.html

//Peter

> -----Original Message-----
> From: [email protected] [mailto:uclibc-cvs-
> [email protected]] On Behalf Of [email protected]
> Sent: den 26 december 2008 03:50
> To: [email protected]
> Subject: svn commit: trunk/uClibc: include
> 
> Author: vda
> Date: 2008-12-26 02:50:13 +0000 (Fri, 26 Dec 2008)
> New Revision: 24546
> 
> Log:
> include/libc-string_i386.h: fix a bug where memset('\xff') misbehaves
> Rules.mak: add -funsigned-char, to forestall future PITA
> 
> 
> 
> Modified:
>    trunk/uClibc/Rules.mak
>    trunk/uClibc/include/libc-string_i386.h
> 
> 
> Changeset:
> Modified: trunk/uClibc/Rules.mak
> ===================================================================
> --- trunk/uClibc/Rules.mak    2008-12-25 19:26:23 UTC (rev 24545)
> +++ trunk/uClibc/Rules.mak    2008-12-26 02:50:13 UTC (rev 24546)
> @@ -467,9 +467,11 @@
> 
>  NOSTDLIB_CFLAGS:=$(call check_gcc,-nostdlib,)
>  # Some nice CFLAGS to work with
> +# Why -funsigned-char: I hunted a bug related to incorrect
> +# sign extension of 'char' type for 10 hours straight. Not fun.
>  CFLAGS := -include $(top_builddir)include/libc-symbols.h \
>       $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \
> -     -fno-builtin -nostdinc -I$(top_builddir)include -I. \
> +     -funsigned-char -fno-builtin -nostdinc -I$(top_builddir)include -
> I. \
>       -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)
> 
>  # Make sure that we can be built with non-C99 compilers, too.
> 
> Modified: trunk/uClibc/include/libc-string_i386.h
> ===================================================================
> --- trunk/uClibc/include/libc-string_i386.h   2008-12-25 19:26:23 UTC
> (rev 24545)
> +++ trunk/uClibc/include/libc-string_i386.h   2008-12-26 02:50:13 UTC
> (rev 24546)
> @@ -26,7 +26,9 @@
>               return s;
>       }
> 
> -     eax *= 0x01010101; /* done at compile time */
> +     /* You wonder why & 0xff is needed? Try memset(p, '\xff', size).
> +      * If char is signed, '\xff' == -1! */
> +     eax = (eax & 0xff) * 0x01010101; /* done at compile time */
> 
>       if (count == 2) {
>               *(short *)(s + 0) = eax;
> 
> _______________________________________________
> uClibc-cvs mailing list
> [email protected]
> http://lists.busybox.net/mailman/listinfo/uclibc-cvs
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to