Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posix: add include/posix to search path based on Kconfig #43998

Closed
cfriedt opened this issue Mar 20, 2022 · 1 comment
Closed

posix: add include/posix to search path based on Kconfig #43998

cfriedt opened this issue Mar 20, 2022 · 1 comment
Assignees
Labels
area: POSIX POSIX API Library Enhancement Changes/Updates/Additions to existing features
Milestone

Comments

@cfriedt
Copy link
Member

cfriedt commented Mar 20, 2022

Is your enhancement proposal related to a problem? Please describe.
It is a pain point to prefix standard POSIX APIs (e.g.#include <posix/unistd.h>).

In particular, when integrating third-party code into an external module, a large majority of work is simply applying the following to dozens of files:

#ifdef CONFIG_ARCH_POSIX
#include <posix/unistd.h>
#else
#include <unistd.h>
#endif

Of course, there are ~20 different POSIX headers in the Zephyr tree (netinet/in.h, sys/socket.h, etc), so the process requires a sometimes unsustainable amount of repetition, which is (for the most part) completely unnecessary.

Describe the solution you'd like
There are a few Kconfig values that indicate when the end-user would like to use POSIX headers. For example:

  • CONFIG_POSIX_API
  • CONFIG_PTHREAD_IPC
  • CONFIG_POSIX_CLOCK
  • CONFIG_POSIX_MQUEUE
  • CONFIG_POSIX_FS
  • CONFIG_EVENTFD (not strictly POSIX, but depends on POSIX, in practice)
  • CONFIG_GETOPT
  • CONFIG_NET_SOCKETS_POSIX_NAMES

If a user chooses to use POSIX APIs, then we should mainly just need to include posix/ in the default search path. The original reason against that was to avoid inadvertantly including the native POSIX header by accident. However, CONFIG_POSIX_API and CONFIG_ARCH_POSIX are mutually exclusive options. Thus, if CONFIG_ARCH_POSIX is selected, we do not include Zephyr's version of those headers, in order to avoid conflicting, standard declarations.

Describe alternatives you've considered
The alternative is the status quo, but it is a bit of a nightmare to maintain (coincidentally, we lack a current maintainer for the POSIX subsys).

Additional context

@cfriedt cfriedt added the Enhancement Changes/Updates/Additions to existing features label Mar 20, 2022
@cfriedt cfriedt self-assigned this Mar 20, 2022
cfriedt added a commit to cfriedt/civetweb that referenced this issue Mar 20, 2022
Instead of using `#include <posix/unistd.h>`,
just use `#include <unistd.h>`.

Fixes zephyrproject-rtos/zephyr#43998

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
cfriedt added a commit to cfriedt/hal_ti that referenced this issue Mar 20, 2022
Instead of using #include <posix/unistd.h>, just use #include <unistd.h>.

Fixes zephyrproject-rtos/zephyr#43998

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
cfriedt added a commit to cfriedt/civetweb that referenced this issue Mar 20, 2022
Instead of using `#include <posix/unistd.h>`,
just use `#include <unistd.h>`, etc.

Required-by zephyrproject-rtos/zephyr#43998

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
cfriedt added a commit to cfriedt/hal_ti that referenced this issue Mar 20, 2022
Instead of using `#include <posix/time.h>`, just use `#include <time.h>`.

Required-by zephyrproject-rtos/zephyr#43998

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
@cfriedt cfriedt added the area: POSIX POSIX API Library label Mar 20, 2022
cfriedt added a commit to cfriedt/civetweb that referenced this issue Mar 21, 2022
Instead of using `#include <posix/unistd.h>`,
just use `#include <unistd.h>`, etc.

Required-by zephyrproject-rtos/zephyr#43998

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
cfriedt added a commit to cfriedt/thrift that referenced this issue Aug 11, 2022
This is a temporary workaround until the mountain of
tech-debt is flattened w.r.t the following:

zephyrproject-rtos/zephyr#43987
zephyrproject-rtos/gsoc-2022-thrift#62
zephyrproject-rtos/zephyr#43998
zephyrproject-rtos/zephyr#46910
zephyrproject-rtos/zephyr#45100

but also around the mountain of tech-debt as a result of
poor arch/posix software architecture, CONFIG_ARCH_POSIX
and CONFIG_POSIX_API incompatibility, and the resultant
spillover of moving POSIX definitions into the network
subsystem as a result.

Fixes zephyrproject-rtos/gsoc-2022-thrift#129

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
cfriedt added a commit to zephyrproject-rtos/gsoc-2022-thrift that referenced this issue Aug 11, 2022
This is a temporary workaround until the mountain of
tech-debt is flattened w.r.t the following:

zephyrproject-rtos/zephyr#43987
#62
zephyrproject-rtos/zephyr#43998
zephyrproject-rtos/zephyr#46910
zephyrproject-rtos/zephyr#45100

but also around the mountain of tech-debt as a result of
poor arch/posix software architecture, CONFIG_ARCH_POSIX
and CONFIG_POSIX_API incompatibility, and the resultant
spillover of moving POSIX definitions into the network
subsystem as a result.

Fixes #129

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
cfriedt added a commit to zephyrproject-rtos/gsoc-2022-thrift that referenced this issue Aug 11, 2022
This is a temporary workaround until the mountain of
tech-debt is flattened w.r.t the following:

zephyrproject-rtos/zephyr#43987
#62
zephyrproject-rtos/zephyr#43998
zephyrproject-rtos/zephyr#46910
zephyrproject-rtos/zephyr#45100

but also around the mountain of tech-debt as a result of
poor arch/posix software architecture, CONFIG_ARCH_POSIX
and CONFIG_POSIX_API incompatibility, and the resultant
spillover of moving POSIX definitions into the network
subsystem as a result.

Fixes #129

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
cfriedt added a commit to zephyrproject-rtos/gsoc-2022-thrift that referenced this issue Aug 11, 2022
This is a temporary workaround until the mountain of
tech-debt is flattened w.r.t the following:

zephyrproject-rtos/zephyr#43987
#62
zephyrproject-rtos/zephyr#43998
zephyrproject-rtos/zephyr#46910
zephyrproject-rtos/zephyr#45100

but also around the mountain of tech-debt as a result of
poor arch/posix software architecture, CONFIG_ARCH_POSIX
and CONFIG_POSIX_API incompatibility, and the resultant
spillover of moving POSIX definitions into the network
subsystem as a result.

Fixes #129

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
cfriedt added a commit to zephyrproject-rtos/gsoc-2022-thrift that referenced this issue Aug 11, 2022
This is a temporary workaround until the mountain of
tech-debt is flattened w.r.t the following:

zephyrproject-rtos/zephyr#43987
#62
zephyrproject-rtos/zephyr#43998
zephyrproject-rtos/zephyr#46910
zephyrproject-rtos/zephyr#45100

but also around the mountain of tech-debt as a result of
poor arch/posix software architecture, CONFIG_ARCH_POSIX
and CONFIG_POSIX_API incompatibility, and the resultant
spillover of moving POSIX definitions into the network
subsystem as a result.

Fixes #129

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
cfriedt added a commit to cfriedt/zephyr that referenced this issue Sep 2, 2022
…efix

It is a pain point to prefix standard POSIX APIs (e.g.
`#include <posix/unistd.h>`). This is true, in particular,
when integrating third-party code into an external module.

With this, if users choose to include standard POSIX headers via Kconfig,
then those headers will be part of the default search path. The headers
themselves do not move. POSIX headers will not appear in the default
search path unless so configured.

Additional changes:
* removed `posix/time.h` to circumvent `#include_next` workaround
* gathered `NSEC_PER_MSEC` and `USEC_PER_MSEC` defs into `sys_clock.h`
* restructured some syscalls (unistd, ioctl, clock_getttime)
* sprinkled `#include <unistd.h>` where `close()` is used
* removed a fair amount of duplicate code

Fixes zephyrproject-rtos#43998

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
cfriedt added a commit to cfriedt/thrift that referenced this issue Oct 1, 2022
This is a temporary workaround until the mountain of
tech-debt is flattened w.r.t the following:

zephyrproject-rtos/zephyr#43987
zephyrproject-rtos/gsoc-2022-thrift#62
zephyrproject-rtos/zephyr#43998
zephyrproject-rtos/zephyr#46910
zephyrproject-rtos/zephyr#45100

but also around the mountain of tech-debt as a result of
poor arch/posix software architecture, CONFIG_ARCH_POSIX
and CONFIG_POSIX_API incompatibility, and the resultant
spillover of moving POSIX definitions into the network
subsystem as a result.

Fixes zephyrproject-rtos/gsoc-2022-thrift#129

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
cfriedt added a commit to cfriedt/thrift that referenced this issue Oct 1, 2022
This is a temporary workaround until the mountain of
tech-debt is flattened w.r.t the following:

zephyrproject-rtos/zephyr#43987
zephyrproject-rtos/gsoc-2022-thrift#62
zephyrproject-rtos/zephyr#43998
zephyrproject-rtos/zephyr#46910
zephyrproject-rtos/zephyr#45100

but also around the mountain of tech-debt as a result of
poor arch/posix software architecture, CONFIG_ARCH_POSIX
and CONFIG_POSIX_API incompatibility, and the resultant
spillover of moving POSIX definitions into the network
subsystem as a result.

Fixes zephyrproject-rtos/gsoc-2022-thrift#129

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
cfriedt added a commit to cfriedt/thrift that referenced this issue Oct 25, 2022
This is a temporary workaround until the mountain of
tech-debt is flattened w.r.t the following:

zephyrproject-rtos/zephyr#43987
zephyrproject-rtos/gsoc-2022-thrift#62
zephyrproject-rtos/zephyr#43998
zephyrproject-rtos/zephyr#46910
zephyrproject-rtos/zephyr#45100

but also around the mountain of tech-debt as a result of
poor arch/posix software architecture, CONFIG_ARCH_POSIX
and CONFIG_POSIX_API incompatibility, and the resultant
spillover of moving POSIX definitions into the network
subsystem as a result.

Fixes zephyrproject-rtos/gsoc-2022-thrift#129

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
cfriedt added a commit to cfriedt/thrift that referenced this issue Oct 27, 2022
This is a temporary workaround until the mountain of
tech-debt is flattened w.r.t the following:

zephyrproject-rtos/zephyr#43987
zephyrproject-rtos/gsoc-2022-thrift#62
zephyrproject-rtos/zephyr#43998
zephyrproject-rtos/zephyr#46910
zephyrproject-rtos/zephyr#45100

but also around the mountain of tech-debt as a result of
poor arch/posix software architecture, CONFIG_ARCH_POSIX
and CONFIG_POSIX_API incompatibility, and the resultant
spillover of moving POSIX definitions into the network
subsystem as a result.

Fixes zephyrproject-rtos/gsoc-2022-thrift#129

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
@cfriedt cfriedt added this to the v3.3.0 milestone Nov 22, 2022
@cfriedt
Copy link
Member Author

cfriedt commented Feb 2, 2023

Fixed by #51771

@cfriedt cfriedt closed this as completed Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: POSIX POSIX API Library Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant