From e96d02984c9203620d279cbe253ef7048543fc99 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Tue, 19 Feb 2019 12:49:04 -0600 Subject: [PATCH] lib: posix: Fix compile issue with newer newlib Both SDK 0.10.0-beta2 and the ARM gcc 2018q2 run into a build issue with newlib and conflict definitions of mode_t type. First we need to add some ifdef protection if mode_t is already defined and set _MODE_T_DECLARED if we are the first to define it. Secondarily, we rename include/posix/sys/types.h to include/posix/posix_types.h so that we aren't getting a name collusion with the system sys/types.h and that we can easily and clearily include it (which we need to do to pull in the info from newlib). Fixes: #12224 Signed-off-by: Kumar Gala --- include/posix/dirent.h | 2 +- include/posix/mqueue.h | 2 +- include/posix/{sys/types.h => posix_types.h} | 2 +- include/posix/pthread.h | 2 +- include/posix/semaphore.h | 2 +- include/posix/signal.h | 2 +- include/posix/time.h | 2 +- include/posix/unistd.h | 5 ++++- lib/posix/clock.c | 1 - lib/posix/pthread_rwlock.c | 2 +- 10 files changed, 12 insertions(+), 10 deletions(-) rename include/posix/{sys/types.h => posix_types.h} (98%) diff --git a/include/posix/dirent.h b/include/posix/dirent.h index 8242b990a1e..e2f4133b9b6 100644 --- a/include/posix/dirent.h +++ b/include/posix/dirent.h @@ -11,7 +11,7 @@ extern "C" { #endif #include -#include "sys/types.h" +#include "posix_types.h" #ifdef CONFIG_POSIX_FS #include diff --git a/include/posix/mqueue.h b/include/posix/mqueue.h index ab498f680ce..53210b5f95d 100644 --- a/include/posix/mqueue.h +++ b/include/posix/mqueue.h @@ -9,7 +9,7 @@ #include #include -#include "sys/types.h" +#include "posix_types.h" #include "sys/stat.h" #ifdef __cplusplus diff --git a/include/posix/sys/types.h b/include/posix/posix_types.h similarity index 98% rename from include/posix/sys/types.h rename to include/posix/posix_types.h index 5e657e505ff..86b3f04067c 100644 --- a/include/posix/sys/types.h +++ b/include/posix/posix_types.h @@ -12,7 +12,7 @@ extern "C" { #endif #ifndef CONFIG_ARCH_POSIX -#include_next +#include #endif #include diff --git a/include/posix/pthread.h b/include/posix/pthread.h index 4f187576e67..ce49e565f6c 100644 --- a/include/posix/pthread.h +++ b/include/posix/pthread.h @@ -11,7 +11,7 @@ #include #include #include -#include "sys/types.h" +#include "posix_types.h" #include "posix_sched.h" #include #include diff --git a/include/posix/semaphore.h b/include/posix/semaphore.h index 283e295e923..bea48ffb327 100644 --- a/include/posix/semaphore.h +++ b/include/posix/semaphore.h @@ -11,7 +11,7 @@ extern "C" { #endif #include -#include "sys/types.h" +#include "posix_types.h" int sem_destroy(sem_t *semaphore); int sem_getvalue(sem_t *restrict semaphore, int *restrict value); diff --git a/include/posix/signal.h b/include/posix/signal.h index 830b830813f..d4faff19d31 100644 --- a/include/posix/signal.h +++ b/include/posix/signal.h @@ -10,7 +10,7 @@ extern "C" { #endif -#include "sys/types.h" +#include "posix_types.h" #ifndef SIGEV_NONE #define SIGEV_NONE 1 diff --git a/include/posix/time.h b/include/posix/time.h index 33df6b3eb9b..78b9ea29f6a 100644 --- a/include/posix/time.h +++ b/include/posix/time.h @@ -27,7 +27,7 @@ struct timeval { #include #include -#include +#include "posix_types.h" #include #ifndef CLOCK_REALTIME diff --git a/include/posix/unistd.h b/include/posix/unistd.h index 3195de3048e..e68b46c212c 100644 --- a/include/posix/unistd.h +++ b/include/posix/unistd.h @@ -10,13 +10,16 @@ extern "C" { #endif -#include "sys/types.h" +#include "posix_types.h" #include "sys/stat.h" #ifdef CONFIG_POSIX_API #include +#ifndef _MODE_T_DECLARED typedef unsigned int mode_t; +#define _MODE_T_DECLARED +#endif /* File related operations */ extern int open(const char *name, int flags); diff --git a/lib/posix/clock.c b/lib/posix/clock.c index d179243c573..0805ddda801 100644 --- a/lib/posix/clock.c +++ b/lib/posix/clock.c @@ -6,7 +6,6 @@ #include #include #include -#include /* * `k_uptime_get` returns a timestamp based on an always increasing diff --git a/lib/posix/pthread_rwlock.c b/lib/posix/pthread_rwlock.c index f2c0521df39..fcf5b982d9e 100644 --- a/lib/posix/pthread_rwlock.c +++ b/lib/posix/pthread_rwlock.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #define INITIALIZED 1 #define NOT_INITIALIZED 0