Explorar el Código

newlib: Fix header issues with C++ guards and implicit inclusion

* Added C++ sentinels if missed
* Used #pragma once, removed macro's with leading underscores
* Updated copyright checker to allow "BSD-2-Clause-FreeBSD AND
Apache-2.0" for newlib files
* Fixed minor compilation issues/implicit inclusions
David Cermak hace 3 años
padre
commit
adb79a4852

+ 8 - 0
components/newlib/platform_include/endian.h

@@ -50,6 +50,10 @@
  */
 #include <machine/endian.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * General byte order swapping functions.
  */
@@ -198,3 +202,7 @@ le64enc(void *pp, uint64_t u)
 	le32enc(p, (uint32_t)(u & 0xffffffffU));
 	le32enc(p + 4, (uint32_t)(u >> 32));
 }
+
+#ifdef __cplusplus
+}
+#endif

+ 8 - 3
components/newlib/platform_include/esp_newlib.h

@@ -4,11 +4,14 @@
  * SPDX-License-Identifier: Apache-2.0
  */
 
-#ifndef __ESP_NEWLIB_H__
-#define __ESP_NEWLIB_H__
+#pragma once
 
 #include <sys/reent.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * Initialize newlib time functions
  */
@@ -57,4 +60,6 @@ void esp_sync_timekeeping_timers(void);
  */
 void esp_newlib_locks_init(void);
 
-#endif //__ESP_NEWLIB_H__
+#ifdef __cplusplus
+}
+#endif

+ 8 - 0
components/newlib/platform_include/sys/reent.h

@@ -8,8 +8,16 @@
 
 #include_next<sys/reent.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* This function is not part of the newlib API, it is defined in libc/stdio/local.h
  * There is no nice way to get __cleanup member populated while avoiding __sinit,
  * so extern declaration is used here.
  */
 extern void _cleanup_r(struct _reent* r);
+
+#ifdef __cplusplus
+}
+#endif

+ 8 - 3
components/newlib/platform_include/sys/un.h

@@ -3,8 +3,11 @@
  *
  * SPDX-License-Identifier: Apache-2.0
  */
-#ifndef _ESP_PLATFORM_SYS_UN_H_
-#define _ESP_PLATFORM_SYS_UN_H_
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #define	AF_UNIX		1		/* local to host (pipes) */
 
@@ -13,4 +16,6 @@ struct sockaddr_un {
             char                     sun_path[108];             /*path name */
 };
 
-#endif // _ESP_PLATFORM_SYS_UN_H_
+#ifdef __cplusplus
+}
+#endif

+ 4 - 5
components/newlib/platform_include/sys/unistd.h

@@ -4,20 +4,19 @@
  * SPDX-License-Identifier: Apache-2.0
  */
 
+#pragma once
 
-#ifndef _ESP_SYS_UNISTD_H
-#define _ESP_SYS_UNISTD_H
+#include <sys/types.h>
+
+#include_next <sys/unistd.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include_next <sys/unistd.h>
-
 int truncate(const char *, off_t __length);
 int gethostname(char *__name, size_t __len);
 
 #ifdef __cplusplus
 }
 #endif
-#endif /* _SYS_UNISTD_H */

+ 4 - 4
components/newlib/platform_include/time.h

@@ -4,14 +4,15 @@
  * SPDX-License-Identifier: Apache-2.0
  */
 
+#pragma once
 
-#ifndef _ESP_TIME_H
-#define _ESP_TIME_H
+#include <sys/types.h>
+
+#include_next <time.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
-#include_next <time.h>
 
 #define _POSIX_TIMERS 1
 #ifndef CLOCK_MONOTONIC
@@ -28,4 +29,3 @@ int clock_getres(clockid_t clock_id, struct timespec *res);
 #ifdef __cplusplus
 }
 #endif
-#endif /* _ESP_TIME_H */

+ 8 - 0
tools/ci/check_copyright_config.yaml

@@ -67,6 +67,14 @@ lwip_component:
     - BSD-3-Clause
   license_for_new_files: Apache-2.0
 
+newlib_component:
+  include:
+    - 'components/newlib/**'
+  allowed_licenses:
+    - Apache-2.0
+    - BSD-2-Clause-FreeBSD AND Apache-2.0
+  license_for_new_files: Apache-2.0
+
 asio_component:
   include:
     - 'components/asio/port/**'

+ 0 - 1
tools/ci/check_public_headers_exceptions.txt

@@ -7,7 +7,6 @@ components/xtensa/esp32s2/include/xtensa/config/
 components/xtensa/esp32s3/include/xtensa/config/
 
 
-components/newlib/platform_include/
 
 components/freertos/esp_additions/include/freertos_tasks_c_additions.h
 components/freertos/FreeRTOS-Kernel/include/freertos/