libc: update to upstream master.

This commit is contained in:
Our Air Quality 2017-09-21 21:46:20 +10:00
parent 1e76ce25d5
commit 6080bb6ef2
19 changed files with 281 additions and 24 deletions

View file

@ -139,7 +139,7 @@
/** Set this to 1 on platforms where strnstr is not available */ /** Set this to 1 on platforms where strnstr is not available */
#ifndef LWIP_HTTPD_STRNSTR_PRIVATE #ifndef LWIP_HTTPD_STRNSTR_PRIVATE
#define LWIP_HTTPD_STRNSTR_PRIVATE 1 #define LWIP_HTTPD_STRNSTR_PRIVATE 0
#endif #endif
/** Set this to one to show error pages when parsing a request fails instead /** Set this to one to show error pages when parsing a request fails instead

View file

@ -102,7 +102,7 @@ void sntp_update_rtc(time_t t, uint32_t us) {
// DEBUG: Compute and print drift // DEBUG: Compute and print drift
int64_t sntp_current = sntp_base + TIMER_COUNT - tim_ref; int64_t sntp_current = sntp_base + TIMER_COUNT - tim_ref;
int64_t sntp_correct = (((uint64_t)us + (uint64_t)t * 1000000U)<<12) / cal; int64_t sntp_correct = (((uint64_t)us + (uint64_t)t * 1000000U)<<12) / cal;
printf("\nRTC Adjust: drift = %ld ticks, cal = %d\n", (time_t)(sntp_correct - sntp_current), cal); printf("\nRTC Adjust: drift = %lld ticks, cal = %d\n", (time_t)(sntp_correct - sntp_current), (uint32_t)cal);
tim_ref = TIMER_COUNT; tim_ref = TIMER_COUNT;
cal = sdk_system_rtc_clock_cali_proc(); cal = sdk_system_rtc_clock_cali_proc();

View file

@ -1 +1 @@
Newlib from git://sourceware.org/git/newlib-cygwin.git with xtensa & locking patches see https://github.com/ourairquality/newlib and built from commit cca8337a4eff8d590c54ce0a9cf335041d949296 Newlib from git://sourceware.org/git/newlib-cygwin.git with xtensa & locking patches see https://github.com/ourairquality/newlib and built from commit 7bcbbff5f7e3600806f352e88ec23ae0300edc29

View file

@ -16,10 +16,15 @@
#include <newlib.h> #include <newlib.h>
#include <sys/config.h> #include <sys/config.h>
#include <sys/_intsup.h> #include <sys/_intsup.h>
#include "_ansi.h"
#include <stdint.h> #include <stdint.h>
#define __need_wchar_t #define __need_wchar_t
#include <stddef.h> #include <stddef.h>
#if __BSD_VISIBLE
#include <xlocale.h>
#endif
#define __STRINGIFY(a) #a #define __STRINGIFY(a) #a
/* 8-bit types */ /* 8-bit types */
@ -309,6 +314,8 @@ typedef struct {
intmax_t rem; intmax_t rem;
} imaxdiv_t; } imaxdiv_t;
struct _reent;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -316,9 +323,20 @@ extern "C" {
extern intmax_t imaxabs(intmax_t j); extern intmax_t imaxabs(intmax_t j);
extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer); extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer);
extern intmax_t strtoimax(const char *__restrict, char **__restrict, int); extern intmax_t strtoimax(const char *__restrict, char **__restrict, int);
extern intmax_t _strtoimax_r(struct _reent *, const char *__restrict, char **__restrict, int);
extern uintmax_t strtoumax(const char *__restrict, char **__restrict, int); extern uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
extern uintmax_t _strtoumax_r(struct _reent *, const char *__restrict, char **__restrict, int);
extern intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int); extern intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
extern intmax_t _wcstoimax_r(struct _reent *, const wchar_t *__restrict, wchar_t **__restrict, int);
extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int); extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
extern uintmax_t _wcstoumax_r(struct _reent *, const wchar_t *__restrict, wchar_t **__restrict, int);
#if __BSD_VISIBLE
extern intmax_t strtoimax_l(const char *__restrict, char **_restrict, int, locale_t);
extern uintmax_t strtoumax_l(const char *__restrict, char **_restrict, int, locale_t);
extern intmax_t wcstoimax_l(const wchar_t *__restrict, wchar_t **_restrict, int, locale_t);
extern uintmax_t wcstoumax_l(const wchar_t *__restrict, wchar_t **_restrict, int, locale_t);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -170,6 +170,10 @@
#define __IEEE_LITTLE_ENDIAN #define __IEEE_LITTLE_ENDIAN
#endif #endif
#ifdef __riscv
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __i960__ #ifdef __i960__
#define __IEEE_LITTLE_ENDIAN #define __IEEE_LITTLE_ENDIAN
#endif #endif

View file

@ -385,6 +385,15 @@ _BEGIN_STD_C
#define _JBLEN 12 #define _JBLEN 12
#endif #endif
#ifdef __riscv
#define _JBTYPE long
#ifdef __riscv_32e
#define _JBLEN ((4*sizeof(long))/sizeof(long))
#else
#define _JBLEN ((14*sizeof(long) + 12*sizeof(double))/sizeof(long))
#endif
#endif
#ifdef _JBLEN #ifdef _JBLEN
#ifdef _JBTYPE #ifdef _JBTYPE
typedef _JBTYPE jmp_buf[_JBLEN]; typedef _JBTYPE jmp_buf[_JBLEN];
@ -395,7 +404,7 @@ typedef int jmp_buf[_JBLEN];
_END_STD_C _END_STD_C
#if defined(__CYGWIN__) || defined(__rtems__) #if (defined(__CYGWIN__) || defined(__rtems__)) && __POSIX_VISIBLE
#include <signal.h> #include <signal.h>
#ifdef __cplusplus #ifdef __cplusplus
@ -477,4 +486,4 @@ extern int _setjmp (jmp_buf);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __CYGWIN__ or __rtems__ */ #endif /* (__CYGWIN__ or __rtems__) and __POSIX_VISIBLE */

View file

@ -1,7 +1,7 @@
#ifndef _MACHTIME_H_ #ifndef _MACHTIME_H_
#define _MACHTIME_H_ #define _MACHTIME_H_
#if defined(__rtems__) || defined(__VISIUM__) #if defined(__rtems__) || defined(__VISIUM__) || defined(__riscv)
#define _CLOCKS_PER_SEC_ 1000000 #define _CLOCKS_PER_SEC_ 1000000
#elif defined(__aarch64__) || defined(__arm__) || defined(__thumb__) #elif defined(__aarch64__) || defined(__arm__) || defined(__thumb__)
#define _CLOCKS_PER_SEC_ 100 #define _CLOCKS_PER_SEC_ 100

View file

@ -91,6 +91,9 @@
/* Define if using retargetable functions for default lock routines. */ /* Define if using retargetable functions for default lock routines. */
/* #undef _RETARGETABLE_LOCKING */ /* #undef _RETARGETABLE_LOCKING */
/* Define to use type long for time_t. */
/* #undef _WANT_USE_LONG_TIME_T */
/* /*
* Iconv encodings enabled ("to" direction) * Iconv encodings enabled ("to" direction)
*/ */

View file

@ -384,6 +384,9 @@ int _EXFUN(vdprintf, (int, const char *__restrict, __VALIST)
#endif #endif
#if __ATFILE_VISIBLE #if __ATFILE_VISIBLE
int _EXFUN(renameat, (int, const char *, int, const char *)); int _EXFUN(renameat, (int, const char *, int, const char *));
# ifdef __CYGWIN__
int _EXFUN(renameat2, (int, const char *, int, const char *, unsigned int));
# endif
#endif #endif
/* /*
@ -735,12 +738,35 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define fileno(p) __sfileno(p) #define fileno(p) __sfileno(p)
#endif #endif
#ifndef __CYGWIN__ static __inline int
#ifndef lint _getchar_unlocked(void)
#define getc(fp) __sgetc_r(_REENT, fp) {
#define putc(x, fp) __sputc_r(_REENT, x, fp) struct _reent *_ptr;
#endif /* lint */
#endif /* __CYGWIN__ */ _ptr = _REENT;
return (__sgetc_r(_ptr, _stdin_r(_ptr)));
}
static __inline int
_putchar_unlocked(int _c)
{
struct _reent *_ptr;
_ptr = _REENT;
return (__sputc_r(_ptr, _c, _stdout_r(_ptr)));
}
#ifdef __SINGLE_THREAD__
#define getc(_p) __sgetc_r(_REENT, _p)
#define putc(_c, _p) __sputc_r(_REENT, _c, _p)
#define getchar() _getchar_unlocked()
#define putchar(_c) _putchar_unlocked(_c)
#endif /* __SINGLE_THREAD__ */
#if __MISC_VISIBLE || __POSIX_VISIBLE
#define getchar_unlocked() _getchar_unlocked()
#define putchar_unlocked(_c) _putchar_unlocked(_c)
#endif
#endif /* __cplusplus */ #endif /* __cplusplus */
#if __MISC_VISIBLE #if __MISC_VISIBLE
@ -756,7 +782,7 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define L_ctermid 16 #define L_ctermid 16
#endif #endif
#endif /* !__CUSTOM_FILE_IO__ */ #else /* __CUSTOM_FILE_IO__ */
#define getchar() getc(stdin) #define getchar() getc(stdin)
#define putchar(x) putc(x, stdout) #define putchar(x) putc(x, stdout)
@ -766,6 +792,8 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define putchar_unlocked(x) putc_unlocked(x, stdout) #define putchar_unlocked(x) putc_unlocked(x, stdout)
#endif #endif
#endif /* !__CUSTOM_FILE_IO__ */
_END_STD_C _END_STD_C
#endif /* _STDIO_H_ */ #endif /* _STDIO_H_ */

View file

@ -121,6 +121,9 @@ size_t _EXFUN(strnlen,(const char *, size_t));
#if __BSD_VISIBLE #if __BSD_VISIBLE
char *_EXFUN(strsep,(char **, const char *)); char *_EXFUN(strsep,(char **, const char *));
#endif #endif
#if __BSD_VISIBLE
char *strnstr(const char *, const char *, size_t) __pure;
#endif
#if __MISC_VISIBLE #if __MISC_VISIBLE
char *_EXFUN(strlwr,(char *)); char *_EXFUN(strlwr,(char *));

View file

@ -50,12 +50,14 @@ void bzero(void *, size_t); /* LEGACY */
#if __BSD_VISIBLE #if __BSD_VISIBLE
void explicit_bzero(void *, size_t); void explicit_bzero(void *, size_t);
#endif #endif
#if __XSI_VISIBLE #if __MISC_VISIBLE || __POSIX_VISIBLE < 200809 || __XSI_VISIBLE >= 700
int ffs(int) __pure2; int ffs(int) __pure2;
#endif #endif
#if __BSD_VISIBLE #if __GNU_VISIBLE
int ffsl(long) __pure2; int ffsl(long) __pure2;
int ffsll(long long) __pure2; int ffsll(long long) __pure2;
#endif
#if __BSD_VISIBLE
int fls(int) __pure2; int fls(int) __pure2;
int flsl(long) __pure2; int flsl(long) __pure2;
int flsll(long long) __pure2; int flsll(long long) __pure2;

View file

@ -4,8 +4,6 @@
* *
* Permission to use, copy, modify, and distribute this software * Permission to use, copy, modify, and distribute this software
* is freely granted, provided that this notice is preserved. * is freely granted, provided that this notice is preserved.
*
* Modified for xtensa arch & non-long int32_t, removes automatic setting of __have_long32.
*/ */
#ifndef _SYS__INTSUP_H #ifndef _SYS__INTSUP_H
@ -13,8 +11,185 @@
#include <sys/features.h> #include <sys/features.h>
#if __GNUC_PREREQ (3, 2)
/* gcc > 3.2 implicitly defines the values we are interested */
#define __STDINT_EXP(x) __##x##__ #define __STDINT_EXP(x) __##x##__
#else
#define __STDINT_EXP(x) x
#include <limits.h>
#endif
#define __have_longlong64 1 /* Determine how intptr_t and intN_t fastN_t and leastN_t are defined by gcc
for this target. This is used to determine the correct printf() constant in
inttypes.h and other constants in stdint.h.
So we end up with
?(signed|unsigned) char == 0
?(signed|unsigned) short == 1
?(signed|unsigned) int == 2
?(signed|unsigned) short int == 3
?(signed|unsigned) long == 4
?(signed|unsigned) long int == 6
?(signed|unsigned) long long == 8
?(signed|unsigned) long long int == 10
*/
#pragma push_macro("signed")
#pragma push_macro("unsigned")
#pragma push_macro("char")
#pragma push_macro("short")
#pragma push_macro("__int20")
#pragma push_macro("int")
#pragma push_macro("long")
#undef signed
#undef unsigned
#undef char
#undef short
#undef int
#undef __int20
#undef long
#define signed +0
#define unsigned +0
#define char +0
#define short +1
#define __int20 +2
#define int +2
#define long +4
#if (__INTPTR_TYPE__ == 8 || __INTPTR_TYPE__ == 10)
#define _INTPTR_EQ_LONGLONG
#elif (__INTPTR_TYPE__ == 4 || __INTPTR_TYPE__ == 6)
#define _INTPTR_EQ_LONG
/* Note - the tests for _INTPTR_EQ_INT and _INTPTR_EQ_SHORT are currently
redundant as the values are not used. But one day they may be needed
and so the tests remain. */
#elif __INTPTR_TYPE__ == 2
#define _INTPTR_EQ_INT
#elif (__INTPTR_TYPE__ == 1 || __INTPTR_TYPE__ == 3)
#define _INTPTR_EQ_SHORT
#else
#error "Unable to determine type definition of intptr_t"
#endif
#if (__INT32_TYPE__ == 4 || __INT32_TYPE__ == 6)
#define _INT32_EQ_LONG
#elif __INT32_TYPE__ == 2
/* Nothing to define because int32_t is safe to print as an int. */
#else
#error "Unable to determine type definition of int32_t"
#endif
#if (__INT8_TYPE__ == 0)
#define __INT8 "hh"
#elif (__INT8_TYPE__ == 1 || __INT8_TYPE__ == 3)
#define __INT8 "h"
#elif (__INT8_TYPE__ == 2)
#define __INT8
#elif (__INT8_TYPE__ == 4 || __INT8_TYPE__ == 6)
#define __INT8 "l"
#elif (__INT8_TYPE__ == 8 || __INT8_TYPE__ == 10)
#define __INT8 "ll"
#endif
#if (__INT16_TYPE__ == 1 || __INT16_TYPE__ == 3)
#define __INT16 "h"
#elif (__INT16_TYPE__ == 2)
#define __INT16
#elif (__INT16_TYPE__ == 4 || __INT16_TYPE__ == 6)
#define __INT16 "l"
#elif (__INT16_TYPE__ == 8 || __INT16_TYPE__ == 10)
#define __INT16 "ll"
#endif
#if (__INT32_TYPE__ == 2)
#define __INT32
#elif (__INT32_TYPE__ == 4 || __INT32_TYPE__ == 6)
#define __INT32 "l"
#elif (__INT32_TYPE__ == 8 || __INT32_TYPE__ == 10)
#define __INT32 "ll"
#endif
#if (__INT64_TYPE__ == 2)
#define __INT64
#elif (__INT64_TYPE__ == 4 || __INT64_TYPE__ == 6)
#define __INT64 "l"
#elif (__INT64_TYPE__ == 8 || __INT64_TYPE__ == 10)
#define __INT64 "ll"
#endif
#if (__INT_FAST8_TYPE__ == 0)
#define __FAST8 "hh"
#elif (__INT_FAST8_TYPE__ == 1 || __INT_FAST8_TYPE__ == 3)
#define __FAST8 "h"
#elif (__INT_FAST8_TYPE__ == 2)
#define __FAST8
#elif (__INT_FAST8_TYPE__ == 4 || __INT_FAST8_TYPE__ == 6)
#define __FAST8 "l"
#elif (__INT_FAST8_TYPE__ == 8 || __INT_FAST8_TYPE__ == 10)
#define __FAST8 "ll"
#endif
#if (__INT_FAST16_TYPE__ == 1 || __INT_FAST16_TYPE__ == 3)
#define __FAST16 "h"
#elif (__INT_FAST16_TYPE__ == 2)
#define __FAST16
#elif (__INT_FAST16_TYPE__ == 4 || __INT_FAST16_TYPE__ == 6)
#define __FAST16 "l"
#elif (__INT_FAST16_TYPE__ == 8 || __INT_FAST16_TYPE__ == 10)
#define __FAST16 "ll"
#endif
#if (__INT_FAST32_TYPE__ == 2)
#define __FAST32
#elif (__INT_FAST32_TYPE__ == 4 || __INT_FAST32_TYPE__ == 6)
#define __FAST32 "l"
#elif (__INT_FAST32_TYPE__ == 8 || __INT_FAST32_TYPE__ == 10)
#define __FAST32 "ll"
#endif
#if (__INT_FAST64_TYPE__ == 2)
#define __FAST64
#elif (__INT_FAST64_TYPE__ == 4 || __INT_FAST64_TYPE__ == 6)
#define __FAST64 "l"
#elif (__INT_FAST64_TYPE__ == 8 || __INT_FAST64_TYPE__ == 10)
#define __FAST64 "ll"
#endif
#if (__INT_LEAST8_TYPE__ == 0)
#define __LEAST8 "hh"
#elif (__INT_LEAST8_TYPE__ == 1 || __INT_LEAST8_TYPE__ == 3)
#define __LEAST8 "h"
#elif (__INT_LEAST8_TYPE__ == 2)
#define __LEAST8
#elif (__INT_LEAST8_TYPE__ == 4 || __INT_LEAST8_TYPE__ == 6)
#define __LEAST8 "l"
#elif (__INT_LEAST8_TYPE__ == 8 || __INT_LEAST8_TYPE__ == 10)
#define __LEAST8 "ll"
#endif
#if (__INT_LEAST16_TYPE__ == 1 || __INT_LEAST16_TYPE__ == 3)
#define __LEAST16 "h"
#elif (__INT_LEAST16_TYPE__ == 2)
#define __LEAST16
#elif (__INT_LEAST16_TYPE__ == 4 || __INT_LEAST16_TYPE__ == 6)
#define __LEAST16 "l"
#elif (__INT_LEAST16_TYPE__ == 8 || __INT_LEAST16_TYPE__ == 10)
#define __LEAST16 "ll"
#endif
#if (__INT_LEAST32_TYPE__ == 2)
#define __LEAST32
#elif (__INT_LEAST32_TYPE__ == 4 || __INT_LEAST32_TYPE__ == 6)
#define __LEAST32 "l"
#elif (__INT_LEAST32_TYPE__ == 8 || __INT_LEAST32_TYPE__ == 10)
#define __LEAST32 "ll"
#endif
#if (__INT_LEAST64_TYPE__ == 2)
#define __LEAST64
#elif (__INT_LEAST64_TYPE__ == 4 || __INT_LEAST64_TYPE__ == 6)
#define __LEAST64 "l"
#elif (__INT_LEAST64_TYPE__ == 8 || __INT_LEAST64_TYPE__ == 10)
#define __LEAST64 "ll"
#endif
#undef signed
#undef unsigned
#undef char
#undef short
#undef int
#undef long
#pragma pop_macro("signed")
#pragma pop_macro("unsigned")
#pragma pop_macro("char")
#pragma pop_macro("short")
#pragma pop_macro("__int20")
#pragma pop_macro("int")
#pragma pop_macro("long")
#endif /* _SYS__INTSUP_H */ #endif /* _SYS__INTSUP_H */

View file

@ -180,10 +180,17 @@ typedef _LOCK_RECURSIVE_T _flock_t;
typedef void *_iconv_t; typedef void *_iconv_t;
#endif #endif
#ifndef __machine_clock_t_defined
#define _CLOCK_T_ unsigned long /* clock() */ #define _CLOCK_T_ unsigned long /* clock() */
#endif
typedef _CLOCK_T_ __clock_t; typedef _CLOCK_T_ __clock_t;
#define _TIME_T_ long /* time() */ #if defined(_USE_LONG_TIME_T) || __LONG_MAX__ > 0x7fffffffL
#define _TIME_T_ long
#else
#define _TIME_T_ __int_least64_t
#endif
typedef _TIME_T_ __time_t; typedef _TIME_T_ __time_t;
#define _CLOCKID_T_ unsigned long #define _CLOCKID_T_ unsigned long

View file

@ -681,6 +681,8 @@
#endif #endif
/* Structure implements a lock. */ /* Structure implements a lock. */
/* FIXME: Use __lockable__, etc. to avoid colliding with user namespace macros,
* once clang is fixed: https://bugs.llvm.org/show_bug.cgi?id=34319 */
#define __lockable __lock_annotate(lockable) #define __lockable __lock_annotate(lockable)
/* Function acquires an exclusive or shared lock. */ /* Function acquires an exclusive or shared lock. */

View file

@ -75,7 +75,7 @@
#define _POINTER_INT short #define _POINTER_INT short
#endif #endif
#if defined(__m68k__) || defined(__mc68000__) #if defined(__m68k__) || defined(__mc68000__) || defined(__riscv)
#define _READ_WRITE_RETURN_TYPE _ssize_t #define _READ_WRITE_RETURN_TYPE _ssize_t
#endif #endif
@ -154,6 +154,7 @@
#define _REENT_SMALL #define _REENT_SMALL
#endif #endif
#define __BUFSIZ__ 256
#define __SMALL_BITFIELDS #define __SMALL_BITFIELDS
#ifdef __MSP430X_LARGE__ #ifdef __MSP430X_LARGE__
@ -289,6 +290,12 @@
#endif #endif
#endif #endif
#ifdef _WANT_USE_LONG_TIME_T
#ifndef _USE_LONG_TIME_T
#define _USE_LONG_TIME_T
#endif
#endif
/* If _MB_EXTENDED_CHARSETS_ALL is set, we want all of the extended /* If _MB_EXTENDED_CHARSETS_ALL is set, we want all of the extended
charsets. The extended charsets add a few functions and a couple charsets. The extended charsets add a few functions and a couple
of tables of a few K each. */ of tables of a few K each. */

View file

@ -505,10 +505,9 @@ extern "C" {
/* #define _XOPEN_UNIX -1 */ /* #define _XOPEN_UNIX -1 */
#endif /* __XSI_VISIBLE */ #endif /* __XSI_VISIBLE */
/* The value corresponds to UNICODE version 4.0, which is the version /* The value corresponds to UNICODE version 5.2, which is the current
supported by XP. Newlib supports 5.2 (2011) but so far Cygwin needs state of newlib's wide char conversion functions. */
the MS conversions for double-byte charsets. */ #define __STDC_ISO_10646__ 200910L
#define __STDC_ISO_10646__ 200305L
#endif /* __CYGWIN__ */ #endif /* __CYGWIN__ */

Binary file not shown.

Binary file not shown.

Binary file not shown.