Explorar o código

Merge branch 'bugfix/newlib_misc_cleanups' into 'master'

newlib: minor cleanup

See merge request idf/esp-idf!4550
Anton Maklakov %!s(int64=7) %!d(string=hai) anos
pai
achega
886d8a6f28

+ 1 - 1
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);
 };
 

+ 2 - 0
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;

+ 1 - 1
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 <=.  */

+ 17 - 0
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 <sys/types.h>
+#define __rtems__
+#include_next <sys/time.h>
+#undef __rtems__

+ 2 - 2
components/newlib/platform_include/sys/unistd.h

@@ -22,8 +22,8 @@ extern "C" {
 
 #include_next <sys/unistd.h>
 
-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
 }

+ 3 - 3
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
 }

+ 1 - 1
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);
 
 

+ 8 - 0
components/wpa_supplicant/port/include/byteswap.h

@@ -5,7 +5,10 @@
 #ifndef BYTESWAP_H
 #define BYTESWAP_H
 
+#include <machine/endian.h>
+
 /* 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 */

+ 1 - 0
components/wpa_supplicant/port/include/endian.h

@@ -30,6 +30,7 @@
 #define _ENDIAN_H_
 
 #include <stdint.h>
+#include <sys/types.h>
 #include "byteswap.h"
 
 #ifndef BIG_ENDIAN