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


> Ok.  I will delay the snapshot until you resubmit the patch.  It passes additional
> tests from libc++ so it is a step forward and we might as well make it part of the
> snapshot.

I re-ran the libc++ testsuite with the wchar.h fixes suggested, and
excluding all stdint.h modifications. There are 3 new failures, all
due to stdint.h:
  libc++::input.output/file.streams/c.files/cinttypes.pass.cpp: libc++
  libc++::language.support/cstdint/cstdint.syn/cstdint.pass.cpp: libc++
  libc++::depr/depr.c.headers/stdint_h.pass.cpp: libc++
As discussed on this thread I'll fix stdint.h after the release, and
will also add a configure-time detection of what the default should be
for WCHAR_{MIN,MAX} when the compiler doesn't already define a macro.

FWIW I have exclusions on other tests that I'll fix later. Those that
I think are shortcomings of newlib are caused by:
 * Lack of fenv.h for my particular setup.
 * Lack of uchar.h from C Unicode TR.
 * Lack of C11's [at_]quick_exit.
libc++ also has its own shortcomings, some of which I've submitted a
patch for, and others that I will also fix later. Overall though the
libc++/newlib combination now passes most of libc++'s testsuite when
it used to fail quite a lot of them.


Here is an updated patch. If it looks good, could someone with access commit it?


Index: newlib/libc/include/limits.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/limits.h,v
retrieving revision 1.3
diff -u -r1.3 limits.h
--- newlib/libc/include/limits.h 31 Oct 2008 21:03:41 -0000 1.3
+++ newlib/libc/include/limits.h 17 Dec 2013 00:40:00 -0000
@@ -96,7 +96,8 @@
 #    define __LONG_LONG_MAX__ 9223372036854775807LL
 #   endif

-#   if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#   if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) ||   \
+  (defined(__cplusplus) && __cplusplus >= 201103L)
 /* Minimum and maximum values a `signed long long int' can hold.  */
 #    undef LLONG_MIN
 #    define LLONG_MIN (-LLONG_MAX-1)
@@ -143,4 +144,3 @@
 #ifndef PATH_MAX
 #define PATH_MAX 4096
 #endif
-
Index: newlib/libc/include/stdlib.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdlib.h,v
retrieving revision 1.48
diff -u -r1.48 stdlib.h
--- newlib/libc/include/stdlib.h 20 Nov 2013 09:46:39 -0000 1.48
+++ newlib/libc/include/stdlib.h 17 Dec 2013 00:40:00 -0000
@@ -39,7 +39,9 @@
   long rem; /* remainder */
 } ldiv_t;

-#ifndef __STRICT_ANSI__
+#if !defined(__STRICT_ANSI__) || \
+  (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
+  (defined(__cplusplus) && __cplusplus >= 201103L)
 typedef struct
 {
   long long int quot; /* quotient */
@@ -149,7 +151,13 @@
 char *  _EXFUN(l64a,(long __input));
 char *  _EXFUN(_l64a_r,(struct _reent *,long __input));
 int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg));
-_VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((noreturn)));
+#endif /* ! __STRICT_ANSI__ */
+#if !defined(__STRICT_ANSI__) || \
+  (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
+  (defined(__cplusplus) && __cplusplus >= 201103L)
+_VOID  _EXFUN(_Exit,(int __status) _ATTRIBUTE ((noreturn)));
+#endif
+#ifndef __STRICT_ANSI__
 int _EXFUN(putenv,(char *__string));
 int _EXFUN(_putenv_r,(struct _reent *, char *__string));
 _PTR _EXFUN(_reallocf_r,(struct _reent *, _PTR, size_t));
@@ -187,12 +195,18 @@
        _EXFUN(_seed48_r,(struct _reent *, unsigned short [3]));
 _VOID  _EXFUN(srand48,(long));
 _VOID  _EXFUN(_srand48_r,(struct _reent *, long));
+#endif /* ! __STRICT_ANSI__ */
+#if !defined(__STRICT_ANSI__) || \
+  (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
+  (defined(__cplusplus) && __cplusplus >= 201103L)
 long long _EXFUN(atoll,(const char *__nptr));
+#endif
+#ifndef __STRICT_ANSI__
 long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr));
-long long _EXFUN(llabs,(long long));
-lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom));
 #endif /* ! __STRICT_ANSI__ */
 #if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) ||
(__cplusplus >= 201103L)
+long long _EXFUN(llabs,(long long));
+lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom));
 long long _EXFUN(strtoll,(const char *__restrict __n, char
**__restrict __end_PTR, int __base));
 #endif
 #ifndef __STRICT_ANSI__
@@ -233,7 +247,6 @@
 #if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) ||
(__cplusplus >= 201103L)
 extern long double strtold (const char *__restrict, char **__restrict);
 #endif
-extern long double wcstold (const wchar_t *, wchar_t **);
 #endif /* _LDBL_EQ_DBL */

 _END_STD_C
Index: newlib/libc/include/wchar.h
===================================================================
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 22 Dec 2013 21:39:51 -0000
@@ -25,19 +25,30 @@
 #endif

 #ifndef WCHAR_MIN
-#define WCHAR_MIN 0
+#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 0x7fffffffu
+#define WCHAR_MAX (0x7fffffff + L'\0')
 #endif
 #endif

 _BEGIN_STD_C

+/* As in stdio.h, <sys/reent.h> defines __FILE. */
+typedef __FILE FILE;
+
 /* As required by POSIX.1-2008, declare tm as incomplete type.
    The actual definition is in time.h. */
 struct tm;
@@ -130,6 +141,10 @@
 long long _EXFUN(_wcstoll_r, (struct _reent *, const wchar_t *,
wchar_t **, int));
 unsigned long _EXFUN(_wcstoul_r, (struct _reent *, const wchar_t *,
wchar_t **, int));
 unsigned long long _EXFUN(_wcstoull_r, (struct _reent *, const
wchar_t *, wchar_t **, int));
+/* On platforms where long double equals double.  */
+#ifdef _LDBL_EQ_DBL
+long double _EXFUN(wcstold, (const wchar_t *, wchar_t **));
+#endif /* _LDBL_EQ_DBL */

 wint_t _EXFUN(fgetwc, (__FILE *));
 wchar_t *_EXFUN(fgetws, (wchar_t *__restrict, int, __FILE *__restrict));


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