Skip to content

Commit

Permalink
fdtable: avoid pulling in posix header & types
Browse files Browse the repository at this point in the history
Although fdtable sat a layer below posix, as part of
the base os, it was reaching up a layer for posix types,
creating another dependency cycle.

Generally, it would be best to use only ISO or native
zephyr types below POSIX, and these should likely be
removed after LTSv3.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
  • Loading branch information
Chris Friedt committed Jul 3, 2024
1 parent 6700a15 commit 468003b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
6 changes: 2 additions & 4 deletions include/zephyr/posix/sys/select.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
#ifndef ZEPHYR_INCLUDE_POSIX_SYS_SELECT_H_
#define ZEPHYR_INCLUDE_POSIX_SYS_SELECT_H_

#include <zephyr/net/socket_types.h>
#include <zephyr/net/socket_select.h>
#include <zephyr/sys/fdtable.h>

#ifdef __cplusplus
extern "C" {
#endif

#undef fd_set
#define fd_set zsock_fd_set
typedef struct zvfs_fd_set fd_set;

#define FD_SETSIZE ZVFS_FD_SETSIZE

Expand Down
21 changes: 18 additions & 3 deletions include/zephyr/sys/fdtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,29 @@
#ifndef ZEPHYR_INCLUDE_SYS_FDTABLE_H_
#define ZEPHYR_INCLUDE_SYS_FDTABLE_H_

#include <stdint.h>
#include <stdarg.h>
#include <sys/types.h>

/* FIXME: For native_posix ssize_t, off_t. */
#include <zephyr/fs/fs.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/util.h>

/* FIXME: avoid using POSIX types in layers below POSIX */

#ifndef _SSIZE_T_DECLARED
/* compiler complains when 'long' is used for both 32 and 64-bit */
#ifdef CONFIG_64BIT
typedef long ssize_t;
#else
typedef int ssize_t;
#endif
#define _SSIZE_T_DECLARED
#endif

#ifndef _OFF_T_DECLARED
typedef int64_t off_t;
#define _OFF_T_DECLARED
#endif

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

0 comments on commit 468003b

Please sign in to comment.