Skip to content

Commit

Permalink
posix: fcntl.h: define constants in terms of zvfs constants
Browse files Browse the repository at this point in the history
Define fcntl.h constants in terms of zvfs constants.

Signed-off-by: Chris Friedt <[email protected]>
  • Loading branch information
cfriedt committed Dec 27, 2024
1 parent 9d79f1f commit 7ca8fdb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 18 deletions.
32 changes: 14 additions & 18 deletions include/zephyr/posix/fcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,24 @@
#ifndef ZEPHYR_POSIX_FCNTL_H_
#define ZEPHYR_POSIX_FCNTL_H_

#ifdef CONFIG_PICOLIBC
#define O_CREAT 0x0040
#define O_TRUNC 0x0200
#define O_APPEND 0x0400
#else
#define O_CREAT 0x0200
#define O_TRUNC 0x0400
#define O_APPEND 0x0008
#endif
#include <zephyr/sys/fdtable.h>

#define O_CREAT ZVFS_O_CREAT
#define O_TRUNC ZVFS_O_TRUNC
#define O_APPEND ZVFS_O_APPEND

#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
#define O_ACCMODE (ZVFS_O_RDONLY | ZVFS_O_WRONLY | ZVFS_O_RDWR)

#define O_RDONLY 00
#define O_WRONLY 01
#define O_RDWR 02
#define O_RDONLY ZVFS_O_RDONLY
#define O_WRONLY ZVFS_O_WRONLY
#define O_RDWR ZVFS_O_RDWR

#define O_EXCL 0x0800
#define O_NONBLOCK 0x4000
#define O_EXCL ZVFS_O_EXCL
#define O_NONBLOCK ZVFS_O_NONBLOCK

#define F_DUPFD 0
#define F_GETFL 3
#define F_SETFL 4
#define F_DUPFD ZVFS_F_DUPFD
#define F_GETFL ZVFS_F_GETFL
#define F_SETFL ZVFS_F_SETFL

#ifdef __cplusplus
extern "C" {
Expand Down
21 changes: 21 additions & 0 deletions include/zephyr/sys/fdtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@
#include <zephyr/kernel.h>
#include <zephyr/sys/util.h>

#ifdef CONFIG_PICOLIBC
#define ZVFS_O_CREAT 0x0040
#define ZVFS_O_TRUNC 0x0200
#define ZVFS_O_APPEND 0x0400
#else
#define ZVFS_O_CREAT 0x0200
#define ZVFS_O_TRUNC 0x0400
#define ZVFS_O_APPEND 0x0008
#endif

#define ZVFS_O_RDONLY 00
#define ZVFS_O_WRONLY 01
#define ZVFS_O_RDWR 02

#define ZVFS_O_EXCL 0x0800
#define ZVFS_O_NONBLOCK 0x4000

#define ZVFS_F_DUPFD 0
#define ZVFS_F_GETFL 3
#define ZVFS_F_SETFL 4

/* File mode bits */
#define ZVFS_MODE_IFMT 0170000
#define ZVFS_MODE_UNSPEC 0000000
Expand Down

0 comments on commit 7ca8fdb

Please sign in to comment.