[PATCH] Update newlib so that it passes libc++'s tests

Corinna Vinschen vinschen@redhat.com
Tue Dec 17 21:54:00 GMT 2013


On Dec 16 16:54, JF Bastien wrote:
> Index: newlib/libc/include/stdint.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/stdint.h,v
> retrieving revision 1.17
> diff -u -r1.17 stdint.h
> --- newlib/libc/include/stdint.h	3 Dec 2013 16:04:41 -0000	1.17
> +++ newlib/libc/include/stdint.h	17 Dec 2013 00:40:00 -0000
> @@ -423,23 +423,42 @@
>  #endif
>  #define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
>  
> +#ifndef WCHAR_MIN
> +#ifdef __WCHAR_MIN__
> +#define WCHAR_MIN __WCHAR_MIN__
> +#elif defined(__WCHAR_UNSIGNED__)
> +#define WCHAR_MIN 0
> +#else
> +#define WCHAR_MIN (-0x7fffffff - 1)
> +#endif
> +#endif

This...

> +#ifndef WCHAR_MAX
>  #ifdef __WCHAR_MAX__
>  #define WCHAR_MAX __WCHAR_MAX__
> +#elif defined(__WCHAR_UNSIGNED__)
> +#define WCHAR_MAX 0xffffffffu
> +#else
> +#define WCHAR_MAX 0x7fffffffu
>  #endif

and this is not quite ok.  You're assuming that wchar_t is 4 bytes, but it
isn't on all platforms.  The fallbacks should take that into account,
along the lines of

  #define WCHAR_MAX ((wchar_t)-1)

etc.

> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/wchar.h,v
> retrieving revision 1.33
> diff -u -r1.33 wchar.h
> --- newlib/libc/include/wchar.h	26 Nov 2013 17:20:59 -0000	1.33
> +++ newlib/libc/include/wchar.h	17 Dec 2013 00:40:00 -0000
> @@ -25,12 +25,20 @@
>  #endif
>  
>  #ifndef WCHAR_MIN
> +#ifdef __WCHAR_MIN__
> +#define WCHAR_MIN __WCHAR_MIN__
> +#elif defined(__WCHAR_UNSIGNED__)
>  #define WCHAR_MIN 0
> +#else
> +#define WCHAR_MIN (-0x7fffffff - 1)
> +#endif
>  #endif
>  
>  #ifndef WCHAR_MAX
>  #ifdef __WCHAR_MAX__
>  #define WCHAR_MAX __WCHAR_MAX__
> +#elif defined(__WCHAR_UNSIGNED__)
> +#define WCHAR_MAX 0xffffffffu
>  #else
>  #define WCHAR_MAX 0x7fffffffu
>  #endif
> @@ -38,6 +46,9 @@

Same here in wchar.h.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20131217/7ffb6917/attachment.sig>


More information about the Newlib mailing list