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 <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2019-02-19 12:49:04 -06:00 committed by Kumar Gala
commit e96d02984c
10 changed files with 12 additions and 10 deletions

View file

@ -11,7 +11,7 @@ extern "C" {
#endif
#include <limits.h>
#include "sys/types.h"
#include "posix_types.h"
#ifdef CONFIG_POSIX_FS
#include <fs.h>

View file

@ -9,7 +9,7 @@
#include <kernel.h>
#include <posix/time.h>
#include "sys/types.h"
#include "posix_types.h"
#include "sys/stat.h"
#ifdef __cplusplus

View file

@ -12,7 +12,7 @@ extern "C" {
#endif
#ifndef CONFIG_ARCH_POSIX
#include_next <sys/types.h>
#include <sys/types.h>
#endif
#include <kernel.h>

View file

@ -11,7 +11,7 @@
#include <wait_q.h>
#include <posix/time.h>
#include <posix/unistd.h>
#include "sys/types.h"
#include "posix_types.h"
#include "posix_sched.h"
#include <posix/pthread_key.h>
#include <stdlib.h>

View file

@ -11,7 +11,7 @@ extern "C" {
#endif
#include <posix/time.h>
#include "sys/types.h"
#include "posix_types.h"
int sem_destroy(sem_t *semaphore);
int sem_getvalue(sem_t *restrict semaphore, int *restrict value);

View file

@ -10,7 +10,7 @@
extern "C" {
#endif
#include "sys/types.h"
#include "posix_types.h"
#ifndef SIGEV_NONE
#define SIGEV_NONE 1

View file

@ -27,7 +27,7 @@ struct timeval {
#include <kernel.h>
#include <errno.h>
#include <sys/types.h>
#include "posix_types.h"
#include <posix/signal.h>
#ifndef CLOCK_REALTIME

View file

@ -10,13 +10,16 @@
extern "C" {
#endif
#include "sys/types.h"
#include "posix_types.h"
#include "sys/stat.h"
#ifdef CONFIG_POSIX_API
#include <fs.h>
#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);