libc: minimal: include: move fcntl.h to posix

The `fcntl.h` header has never been a part of ISO C so move it to
`include/zephyr/posix`.

To ensure a smooth migration, a header was left in
`lib/libc/minimal/include` that prints a deprecation warning.

Users should either include `<zephyr/posix/fcntl.h>` or switch to
`CONFIG_POSIX_API=y`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
This commit is contained in:
Chris Friedt 2022-11-16 17:04:17 -05:00 committed by Stephanos Ioannidis
commit 8659e2f69e
13 changed files with 64 additions and 14 deletions

View file

@ -9,7 +9,7 @@ LOG_MODULE_DECLARE(LOG_MODULE_NAME);
#include <stdlib.h>
#include <limits.h>
#include <fcntl.h>
#include <zephyr/posix/fcntl.h>
#include <zephyr/kernel.h>
/* Define sockaddr, etc, before simplelink.h */

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2018 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_POSIX_FCNTL_H_
#define ZEPHYR_POSIX_FCNTL_H_
#define O_CREAT 0x0200
#define O_APPEND 0x0400
#define O_EXCL 0x0800
#define O_NONBLOCK 0x4000
#define F_DUPFD 0
#define F_GETFL 3
#define F_SETFL 4
int open(const char *name, int flags, ...);
#endif /* ZEPHYR_POSIX_FCNTL_H_ */

View file

@ -11,7 +11,7 @@
#include <zephyr/sys/fdtable.h>
#include <sys/types.h>
#include <fcntl.h>
#include <zephyr/posix/fcntl.h>
#ifdef __cplusplus
extern "C" {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Linaro Limited
* Copyright (c) 2022 Meta
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -7,15 +7,10 @@
#ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_FCNTL_H_
#define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_FCNTL_H_
#define O_CREAT 0x0200
#define O_APPEND 0x0400
#define O_EXCL 0x0800
#define O_NONBLOCK 0x4000
#define F_DUPFD 0
#define F_GETFL 3
#define F_SETFL 4
int open(const char *name, int flags, ...);
#ifndef CONFIG_POSIX_API
#pragma message("#include <fcntl.h> without CONFIG_POSIX_API is deprecated. " \
"Please use CONFIG_POSIX_API or #include <zephyr/posix/fcntl.h>")
#endif
#include <zephyr/posix/fcntl.h>
#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_FCNTL_H_ */

View file

@ -12,7 +12,7 @@
#include <string.h>
#include <zephyr/sys/fdtable.h>
#include <zephyr/posix/sys/stat.h>
#include <fcntl.h>
#include <zephyr/posix/fcntl.h>
#include <zephyr/fs/fs.h>
BUILD_ASSERT(PATH_MAX >= MAX_FILE_NAME, "PATH_MAX is less than MAX_FILE_NAME");

View file

@ -4,7 +4,12 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef CONFIG_ARCH_POSIX
#include <fcntl.h>
#else
#include <zephyr/posix/fcntl.h>
#endif
#include <string.h>
#include <zephyr/logging/log.h>

View file

@ -2,7 +2,11 @@
*
* Copyright (c) 2020 Friedt Professional Engineering Services, Inc
*/
#ifdef CONFIG_ARCH_POSIX
#include <fcntl.h>
#else
#include <zephyr/posix/fcntl.h>
#endif
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL);

View file

@ -4,7 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef CONFIG_ARCH_POSIX
#include <fcntl.h>
#else
#include <zephyr/posix/fcntl.h>
#endif
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL);

View file

@ -4,7 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef CONFIG_ARCH_POSIX
#include <fcntl.h>
#else
#include <zephyr/posix/fcntl.h>
#endif
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL);

View file

@ -4,7 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef CONFIG_ARCH_POSIX
#include <fcntl.h>
#else
#include <zephyr/posix/fcntl.h>
#endif
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL);

View file

@ -4,7 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef CONFIG_ARCH_POSIX
#include <fcntl.h>
#else
#include <zephyr/posix/fcntl.h>
#endif
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL);

View file

@ -4,7 +4,12 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef CONFIG_ARCH_POSIX
#include <fcntl.h>
#else
#include <zephyr/posix/fcntl.h>
#endif
#include <string.h>
#include <zephyr/logging/log.h>

View file

@ -4,7 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef CONFIG_ARCH_POSIX
#include <fcntl.h>
#else
#include <zephyr/posix/fcntl.h>
#endif
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL);