This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Attachment: pgpa7_OZA9J83.pgp
Description: PGP signature


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