From 76d4b0150d231de68281ef6a535cd0b7f86adae1 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 8 Mar 2019 15:26:04 +0800 Subject: [PATCH 1/4] Revert "feat(time): enable the macro timeradd, timersub, timerclear, etc." This reverts commit 8f994b9dce3fb563370cc0ed4958b907016ccb57. --- components/newlib/include/sys/time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/newlib/include/sys/time.h b/components/newlib/include/sys/time.h index 8e3ef80881..be16497fc5 100644 --- a/components/newlib/include/sys/time.h +++ b/components/newlib/include/sys/time.h @@ -20,7 +20,7 @@ struct timeval { }; /* BSD time macros used by RTEMS code */ -#if defined (__rtems__) || defined (__CYGWIN__) || defined(__XTENSA__) +#if defined (__rtems__) || defined (__CYGWIN__) /* Convenience macros for operations on timevals. NOTE: `timercmp' does not work for >= or <=. */ From ac612b54228308756da0afd8654f503c70a1edc0 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 8 Mar 2019 15:16:26 +0800 Subject: [PATCH 2/4] newlib: enable timeradd, timersub, and similar macros This uses a hack (temporarily defining __rtems__ from a wrapper header file) to include timeradd, timersub, and similar macros, without modifying newlib headers. --- components/newlib/platform_include/sys/time.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 components/newlib/platform_include/sys/time.h diff --git a/components/newlib/platform_include/sys/time.h b/components/newlib/platform_include/sys/time.h new file mode 100644 index 0000000000..ecf3f70e74 --- /dev/null +++ b/components/newlib/platform_include/sys/time.h @@ -0,0 +1,17 @@ +#pragma once +/* Newlib sys/time.h defines timerisset, timerclear, timercmp, timeradd, timersub macros + for __CYGWIN__ and __rtems__. We want to define these macros in IDF as well. + Since we wish to use un-modified newlib headers until a patched newlib version is + available, temporarily define __rtems__ here before including sys/time.h. + __rtems__ is chosen instead of __CYGWIN__ since there are no other checks in sys/time.h + which depend on __rtems__. + + Also, so that __rtems__ define does not affect other headers included from sys/time.h, + we include them here in advance (_ansi.h and sys/types.h). + */ + +#include <_ansi.h> +#include +#define __rtems__ +#include_next +#undef __rtems__ From 068b700786abc014726ad6dadfc0d22fa788ad09 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 19 Mar 2019 19:57:20 +0800 Subject: [PATCH 3/4] newlib: remove usage of pre-ANSI defines --- components/esp32/include/rom/libc_stubs.h | 2 +- components/newlib/platform_include/sys/unistd.h | 4 ++-- components/newlib/platform_include/time.h | 6 +++--- components/newlib/syscall_table.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/esp32/include/rom/libc_stubs.h b/components/esp32/include/rom/libc_stubs.h index 90c0b44688..6c6366c306 100644 --- a/components/esp32/include/rom/libc_stubs.h +++ b/components/esp32/include/rom/libc_stubs.h @@ -75,7 +75,7 @@ struct syscall_stub_table int (*_lock_try_acquire_recursive)(_lock_t *lock); void (*_lock_release)(_lock_t *lock); void (*_lock_release_recursive)(_lock_t *lock); - int (*_printf_float)(struct _reent *data, void *pdata, FILE * fp, int (*pfunc) (struct _reent *, FILE *, _CONST char *, size_t len), va_list * ap); + int (*_printf_float)(struct _reent *data, void *pdata, FILE * fp, int (*pfunc) (struct _reent *, FILE *, const char *, size_t len), va_list * ap); int (*_scanf_float) (struct _reent *rptr, void *pdata, FILE *fp, va_list *ap); }; diff --git a/components/newlib/platform_include/sys/unistd.h b/components/newlib/platform_include/sys/unistd.h index e09b68be25..c3149486a2 100644 --- a/components/newlib/platform_include/sys/unistd.h +++ b/components/newlib/platform_include/sys/unistd.h @@ -22,8 +22,8 @@ extern "C" { #include_next -int _EXFUN(truncate, (const char *, off_t __length)); -int _EXFUN(gethostname, (char *__name, size_t __len)); +int truncate(const char *, off_t __length); +int gethostname(char *__name, size_t __len); #ifdef __cplusplus } diff --git a/components/newlib/platform_include/time.h b/components/newlib/platform_include/time.h index 954d824d13..e633bd4ec0 100644 --- a/components/newlib/platform_include/time.h +++ b/components/newlib/platform_include/time.h @@ -25,9 +25,9 @@ extern "C" { #define CLOCK_MONOTONIC (clockid_t)4 #define CLOCK_BOOTTIME (clockid_t)4 -int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp)); -int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp)); -int _EXFUN(clock_getres, (clockid_t clock_id, struct timespec *res)); +int clock_settime(clockid_t clock_id, const struct timespec *tp); +int clock_gettime(clockid_t clock_id, struct timespec *tp); +int clock_getres(clockid_t clock_id, struct timespec *res); #ifdef __cplusplus } diff --git a/components/newlib/syscall_table.c b/components/newlib/syscall_table.c index 85a0f125e4..697d050fad 100644 --- a/components/newlib/syscall_table.c +++ b/components/newlib/syscall_table.c @@ -32,7 +32,7 @@ static struct _reent s_reent; extern int _printf_float(struct _reent *rptr, void *pdata, FILE * fp, - int (*pfunc) (struct _reent *, FILE *, _CONST char *, size_t len), + int (*pfunc) (struct _reent *, FILE *, const char *, size_t len), va_list * ap); From 1d0bffb20acf156621b40f0337f384704495b896 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 19 Mar 2019 19:58:42 +0800 Subject: [PATCH 4/4] lwip, wpa_supplicant: use endianness macros from libc if possible --- components/lwip/port/esp32/include/arch/cc.h | 2 ++ components/wpa_supplicant/port/include/byteswap.h | 8 ++++++++ components/wpa_supplicant/port/include/endian.h | 1 + 3 files changed, 11 insertions(+) diff --git a/components/lwip/port/esp32/include/arch/cc.h b/components/lwip/port/esp32/include/arch/cc.h index cba0b365ea..1841e3f45a 100644 --- a/components/lwip/port/esp32/include/arch/cc.h +++ b/components/lwip/port/esp32/include/arch/cc.h @@ -41,7 +41,9 @@ #include "arch/sys_arch.h" +#ifndef BYTE_ORDER #define BYTE_ORDER LITTLE_ENDIAN +#endif // BYTE_ORDER typedef uint8_t u8_t; typedef int8_t s8_t; diff --git a/components/wpa_supplicant/port/include/byteswap.h b/components/wpa_supplicant/port/include/byteswap.h index 1a8bb8fd15..d65503ba39 100644 --- a/components/wpa_supplicant/port/include/byteswap.h +++ b/components/wpa_supplicant/port/include/byteswap.h @@ -5,7 +5,10 @@ #ifndef BYTESWAP_H #define BYTESWAP_H +#include + /* Swap bytes in 16 bit value. */ +#ifndef __bswap_16 #ifdef __GNUC__ # define __bswap_16(x) \ (__extension__ \ @@ -18,8 +21,10 @@ __bswap_16 (unsigned short int __bsx) return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); } #endif +#endif // __bswap_16 /* Swap bytes in 32 bit value. */ +#ifndef __bswap_32 #ifdef __GNUC__ # define __bswap_32(x) \ (__extension__ \ @@ -34,7 +39,9 @@ __bswap_32 (unsigned int __bsx) (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); } #endif +#endif // __bswap_32 +#ifndef __bswap_64 #if defined __GNUC__ && __GNUC__ >= 2 /* Swap bytes in 64 bit value. */ # define __bswap_constant_64(x) \ @@ -61,5 +68,6 @@ __bswap_32 (unsigned int __bsx) } \ __r.__ll; })) #endif +#endif // __bswap_64 #endif /* BYTESWAP_H */ diff --git a/components/wpa_supplicant/port/include/endian.h b/components/wpa_supplicant/port/include/endian.h index 1e2453f164..655bc30135 100644 --- a/components/wpa_supplicant/port/include/endian.h +++ b/components/wpa_supplicant/port/include/endian.h @@ -30,6 +30,7 @@ #define _ENDIAN_H_ #include +#include #include "byteswap.h" #ifndef BIG_ENDIAN