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

Craig Howland howland@LGSInnovations.com
Fri Dec 20 20:25:00 GMT 2013


On 12/20/2013 01:43 PM, Jeff Johnston wrote:
> FWIW, I'm willing to wait if you guys are close to consensus on patch.  Otherwise, my intention
> was to make the snapshot today.
>
> My opinion is, if you can make it as good or better than it was and you can achieve the libc++
> criteria, then fix the exceptions later.  It is a minor issue to add a macro in sys/config.h for
> any platforms that don't have their compiler setting __WCHAR_MIN__ / __WCHAR_MAX__ and don't want
> the logic below.
>
> -- Jeff J.
>
> ----- Original Message -----
> From: "JF Bastien" <jfb@chromium.org>
> To: "Craig Howland" <howland@lgsinnovations.com>, "Joseph S. Myers" <joseph@codesourcery.com>
> Cc: newlib@sourceware.org
> Sent: Thursday, December 19, 2013 11:23:31 AM
> Subject: Re: [PATCH] Update newlib so that it passes libc++'s tests
>
>> There is a better way than guessing, but it is ugly:  add a configure-time
>> check that determines what the value is and puts it into the generated
>> newlib.h (in a manner analogous to how _LDBL_EQ_DBL is, for example).
> ...The present wchar.h is broken in this manner already for WCHAR_MAX, so it
> might not be unreasonable to do this for wchar.h now and follow up with a
> fix for the existing MAX issue.  It probably is not good, however, to add
> the breakage to stdint.h.
> I assume you mean the "u" suffix Joseph also pointed out? I indeed
> inadvertently carried it over from the previous wchar.h, but I don't
> mind fixing it in this patch since (at Joel Sherrill's request) this
> change probably won't land before the newlib release.
No, I was referring to the breakage of making the assumption when you don't 
know.  (I was assuming the fix that Joseph pointed out.) The idea was to apply 
the patch now only to wchar.h--an improvement over what is there now, but still 
with the issue of a possibly-incorrect fallback value--but to not make the 
addition to stdint.h.  At a future time, do the config mess and then add to 
stdint.h.  This is just a thought to avoid introducing an issue to stdint.h.
If this does not achieve the goal of fixing the libc++ test, then I tend to 
agree with Jeff as to it's being an improvement worth doing, even if it could 
use a (complicated) cleanup.
>
> So make stdint.h and wchar.h:
>
> #ifndef WCHAR_MIN
> #ifdef __WCHAR_MIN__
> #define WCHAR_MIN __WCHAR_MIN__
> #elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0)
> #define WCHAR_MIN (0 + L'\0')
> #else
> #define WCHAR_MIN (-0x7fffffff - 1 + L'\0')
> #endif
> #endif
>
> #ifndef WCHAR_MAX
> #ifdef __WCHAR_MAX__
> #define WCHAR_MAX __WCHAR_MAX__
> #elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0)
> #define WCHAR_MAX (0xffffffffu + L'\0')
> #else
> #define WCHAR_MAX (0x7fffffff + L'\0')
> #endif



More information about the Newlib mailing list