From 3693f858051c1b0812ffa52cfdc349b7f8f8371f Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Wed, 5 Jun 2019 08:49:52 +0300 Subject: [PATCH] posix: Move sys/stat.h to minimal libc Newlib libc already provides sys/stat.h, so trying to have sys/stat.h on the level of POSIX subsys inevitable leads to include order and definition conflicts. Instead (as most of other sys/* includes) should come from the underlying libc. While moving, made unrelated change of removing #include , to accommodate the change reviewers. Signed-off-by: Paul Sokolovsky --- include/posix/sys/stat.h | 54 ----------------------------- lib/libc/minimal/include/sys/stat.h | 46 ++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 57 deletions(-) delete mode 100644 include/posix/sys/stat.h diff --git a/include/posix/sys/stat.h b/include/posix/sys/stat.h deleted file mode 100644 index 7b4b2eadab8..00000000000 --- a/include/posix/sys/stat.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef ZEPHYR_INCLUDE_POSIX_SYS_STAT_H_ -#define ZEPHYR_INCLUDE_POSIX_SYS_STAT_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef CONFIG_POSIX_API -#include - -#define S_IRWXU 00700 -#define S_IRUSR 00400 -#define S_IWUSR 00200 -#define S_IXUSR 00100 - -#define S_IRWXG 00070 -#define S_IRGRP 00040 -#define S_IWGRP 00020 -#define S_IXGRP 00010 - -#define S_IRWXO 00007 -#define S_IROTH 00004 -#define S_IWOTH 00002 -#define S_IXOTH 00001 - -/* File open modes */ -#define O_ACCMODE 0003 -#define O_RDONLY 00 -#define O_WRONLY 01 -#define O_RDWR 02 - -#define SEEK_SET 0 /* Seek from beginning of file. */ -#define SEEK_CUR 1 /* Seek from current position. */ -#define SEEK_END 2 /* Seek from end of file. */ - -struct stat { - unsigned long st_size; - unsigned long st_blksize; - unsigned long st_blocks; -}; - -#endif /* CONFIG_POSIX_API */ - -#ifdef __cplusplus -} -#endif - -#endif /* ZEPHYR_INCLUDE_POSIX_SYS_STAT_H_ */ diff --git a/lib/libc/minimal/include/sys/stat.h b/lib/libc/minimal/include/sys/stat.h index 4636b540050..54f05bdd64d 100644 --- a/lib/libc/minimal/include/sys/stat.h +++ b/lib/libc/minimal/include/sys/stat.h @@ -1,9 +1,49 @@ /* - * Copyright (c) 2018 Linaro Limited + * Copyright (c) 2018 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ +#ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_STAT_H_ +#define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_STAT_H_ -/* Dummy sys/stat.h to fulfill the requirements of certain libraries. - */ +#ifdef __cplusplus +extern "C" { +#endif + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +/* File open modes */ +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 + +#define SEEK_SET 0 /* Seek from beginning of file. */ +#define SEEK_CUR 1 /* Seek from current position. */ +#define SEEK_END 2 /* Seek from end of file. */ + +struct stat { + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_STAT_H_ */