Skip to content

Commit 68c0ff4

Browse files
cfriedthenrikbrixandersen
authored andcommitted
posix: fcntl.h: define constants in terms of zvfs constants
Define fcntl.h constants in terms of zvfs constants. Signed-off-by: Chris Friedt <[email protected]>
1 parent e08cc50 commit 68c0ff4

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

include/zephyr/posix/fcntl.h

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,23 @@
77
#ifndef ZEPHYR_POSIX_FCNTL_H_
88
#define ZEPHYR_POSIX_FCNTL_H_
99

10-
#ifdef CONFIG_PICOLIBC
11-
#define O_CREAT 0x0040
12-
#define O_TRUNC 0x0200
13-
#define O_APPEND 0x0400
14-
#else
15-
#define O_CREAT 0x0200
16-
#define O_TRUNC 0x0400
17-
#define O_APPEND 0x0008
18-
#endif
10+
#include <zephyr/sys/fdtable.h>
1911

20-
#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
12+
#define O_APPEND ZVFS_O_APPEND
13+
#define O_CREAT ZVFS_O_CREAT
14+
#define O_EXCL ZVFS_O_EXCL
15+
#define O_NONBLOCK ZVFS_O_NONBLOCK
16+
#define O_TRUNC ZVFS_O_TRUNC
2117

22-
#define O_RDONLY 00
23-
#define O_WRONLY 01
24-
#define O_RDWR 02
18+
#define O_ACCMODE (ZVFS_O_RDONLY | ZVFS_O_RDWR | ZVFS_O_WRONLY)
2519

26-
#define O_EXCL 0x0800
27-
#define O_NONBLOCK 0x4000
20+
#define O_RDONLY ZVFS_O_RDONLY
21+
#define O_RDWR ZVFS_O_RDWR
22+
#define O_WRONLY ZVFS_O_WRONLY
2823

29-
#define F_DUPFD 0
30-
#define F_GETFL 3
31-
#define F_SETFL 4
24+
#define F_DUPFD ZVFS_F_DUPFD
25+
#define F_GETFL ZVFS_F_GETFL
26+
#define F_SETFL ZVFS_F_SETFL
3227

3328
#ifdef __cplusplus
3429
extern "C" {

include/zephyr/sys/fdtable.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,27 @@
1414
#include <zephyr/kernel.h>
1515
#include <zephyr/sys/util.h>
1616

17+
#ifdef CONFIG_PICOLIBC
18+
#define ZVFS_O_APPEND 0x0400
19+
#define ZVFS_O_CREAT 0x0040
20+
#define ZVFS_O_TRUNC 0x0200
21+
#else
22+
#define ZVFS_O_APPEND 0x0008
23+
#define ZVFS_O_CREAT 0x0200
24+
#define ZVFS_O_TRUNC 0x0400
25+
#endif
26+
27+
#define ZVFS_O_RDONLY 00
28+
#define ZVFS_O_WRONLY 01
29+
#define ZVFS_O_RDWR 02
30+
31+
#define ZVFS_O_EXCL 0x0800
32+
#define ZVFS_O_NONBLOCK 0x4000
33+
34+
#define ZVFS_F_DUPFD 0
35+
#define ZVFS_F_GETFL 3
36+
#define ZVFS_F_SETFL 4
37+
1738
/* File mode bits */
1839
#define ZVFS_MODE_IFMT 0170000
1940
#define ZVFS_MODE_UNSPEC 0000000

lib/os/fdtable.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <string.h>
1919
#include <stdio.h>
2020

21-
#include <zephyr/posix/fcntl.h>
2221
#include <zephyr/kernel.h>
2322
#include <zephyr/sys/fdtable.h>
2423
#include <zephyr/sys/speculation.h>

0 commit comments

Comments
 (0)