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.

(cherry picked from commit 68c0ff4)

Original-Signed-off-by: Chris Friedt <[email protected]>
GitOrigin-RevId: 68c0ff4
Cr-Build-Id: 8726589230171865649
Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8726589230171865649
Copybot-Job-Name: zephyr-main-copybot-downstream
Change-Id: I5dbb503314dff602de0f290de06863c914cfaf29
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/6145208
Tested-by: ChromeOS Prod (Robot) <[email protected]>
Bot-Commit: ChromeOS Prod (Robot) <[email protected]>
Commit-Queue: ChromeOS Prod (Robot) <[email protected]>
  • Loading branch information
Chris Friedt authored and Chromeos LUCI committed Jan 5, 2025
1 parent 6e21128 commit df65a59
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
31 changes: 13 additions & 18 deletions include/zephyr/posix/fcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,23 @@
#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_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
#define O_APPEND ZVFS_O_APPEND
#define O_CREAT ZVFS_O_CREAT
#define O_EXCL ZVFS_O_EXCL
#define O_NONBLOCK ZVFS_O_NONBLOCK
#define O_TRUNC ZVFS_O_TRUNC

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

#define O_EXCL 0x0800
#define O_NONBLOCK 0x4000
#define O_RDONLY ZVFS_O_RDONLY
#define O_RDWR ZVFS_O_RDWR
#define O_WRONLY ZVFS_O_WRONLY

#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_APPEND 0x0400
#define ZVFS_O_CREAT 0x0040
#define ZVFS_O_TRUNC 0x0200
#else
#define ZVFS_O_APPEND 0x0008
#define ZVFS_O_CREAT 0x0200
#define ZVFS_O_TRUNC 0x0400
#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
1 change: 0 additions & 1 deletion lib/os/fdtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <string.h>
#include <stdio.h>

#include <zephyr/posix/fcntl.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/fdtable.h>
#include <zephyr/sys/speculation.h>
Expand Down

0 comments on commit df65a59

Please sign in to comment.