-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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: header fixups #51771
posix: header fixups #51771
Commits on Jan 13, 2023
-
lib: posix: standard include paths with CONFIG_POSIX_API
With the `<zephyr/posix/...> prefix, it became exponentially more difficult to integrate 3rd-party libraries that depend on the POSIX API. Standard POSIX headers should be available in standard include paths - and that should most certainly the case when `CONFIG_POSIX_API=y`. With this change: * When `CONFIG_POSIX_API=y` - applications have explicitly chosen to use POSIX APIs. - all standard POSIX includes are in the default include path. * When `CONFIG_POSIX_API=n` - applications *may* include POSIX headers explicitly with the namespaced prefix - e.g. `#include <zephyr/posix/unistd.h>` - individual Kconfig options can be used to enable POSIX features selectively, such as `getopt` or `eventfd`. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 90b1950 - Browse repository at this point
Copy the full SHA 90b1950View commit details -
posix: rename posix_sched.h to sched.h
Rename the `posix_sched.h` to conform to the spec. IEEE Std 1003.1 Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 17a871b - Browse repository at this point
Copy the full SHA 17a871bView commit details -
posix: treat pthread_key.h as an implementation detail
The `pthread_key.h` header is nonstandard and is an implementation detail of `pthread.h`. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for bea5b9a - Browse repository at this point
Copy the full SHA bea5b9aView commit details -
posix: getopt: select getopt by default with CONFIG_POSIX_API
The `getopt()` function is part of POSIX and should be available when applications choose to enable general POSIX API support. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 45242f6 - Browse repository at this point
Copy the full SHA 45242f6View commit details -
posix: eventfd: select eventfd by default with CONFIG_POSIX_API
Although the eventfd API is not (yet) a part of POSIX, it's pretty well ubiquitous on POSIX systems now. Enable it by default when `CONFIG_POSIX_API=y`. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 202f260 - Browse repository at this point
Copy the full SHA 202f260View commit details -
posix: fs: avoid adding open() alias with newlib and picolibc
Newlib and PicoLibc both already alias `open` to `_open`. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for a540ae7 - Browse repository at this point
Copy the full SHA a540ae7View commit details -
posix: unistd.h: add declaration for _exit()
The `_exit()` function should be declared in `<unistd.h>`. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 5dbbad3 - Browse repository at this point
Copy the full SHA 5dbbad3View commit details -
posix: avoid redefinition errors in network and posix headers
The networking subsystem defines a rather large amount of POSIX prototypes. However, it's done in a somewhat subversive way via ``` CONFIG_NET_SOCKETS_POSIX_NAMES ``` This option should be removed (or moved to POSIX) and the networking implementations should be properly namespaced. With that, the POSIX interface for network-related functions can simply be a thin wrapper around the z-namespaced variants, where applicable, or proper POSIX functions should actually be moved to `lib/posix`. This will also require a better solution to testing network functionality on `native_posix` though. The ability to run those tests and the supposed incompatibility between `CONFIG_ARCH_POSIX` and `CONFIG_POSIX_API` was the main motivation for adding `CONFIG_NET_SOCKETS_POSIX_NAMES`. Eventually, with proper namespacing, these preprocessor guards against redefining the same symbols can be removed. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b47f435 - Browse repository at this point
Copy the full SHA b47f435View commit details -
posix: mqueue: do not typedef mq_attr
The specification actually requires this to be a plain `struct mq_attr`, without the typedef. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 39a6128 - Browse repository at this point
Copy the full SHA 39a6128View commit details -
posix: ioctl: actually declare a function prototype
The `<sys/ioctl.h>` header never actually declared the `ioctl(2)` function prototype, so this fixes that. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for f089cb8 - Browse repository at this point
Copy the full SHA f089cb8View commit details -
posix: define in_port_t and in_addr_t in netinet/in.h
The spec requires that these two types be defined in `<netinet/in.h>`. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 6dbd9cd - Browse repository at this point
Copy the full SHA 6dbd9cdView commit details -
posix: ensure in_addr_t and in_port_t defined via arpa/inet.h
The spec requires that `in_addr_t` and `in_port_t` are both defined when `<arpa/inet.h>` is included. They were added to `<netinet/in.h>` in the previous commit. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 7fb8b99 - Browse repository at this point
Copy the full SHA 7fb8b99View commit details -
posix: netdb: ensure that EAI constants are defined
Constants like `EAI_SYSTEM` should be defined in `<netdb.h>` according to the spec. In Zephyr, they should be defined via appropriately namespaced z-variants (currently `DNS_EAI_SYSTEM` and so on). Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 81de964 - Browse repository at this point
Copy the full SHA 81de964View commit details -
posix: ioctl: define FIONREAD as some applications require it
The `FIONREAD` ioctl is usually used to query how many bytes are available to read immediately from a specific file descriptor. It's quite useful. Define it here so that it can be used by applications. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 9a1c149 - Browse repository at this point
Copy the full SHA 9a1c149View commit details -
posix: define struct linger in sys/socket.h
The spec requires `<sys/socket.h>` to declare struct linger. Define it so that applications and libraries do not get compile errors when building against Zephyr. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for e2103ab - Browse repository at this point
Copy the full SHA e2103abView commit details -
posix: netdb: provide NI_MAXSERV for reasonable app defaults
The `<netdb.h>` header typically defines `NI_MAXSERV` as a reasonable default buffer size to use in applications that use `getnameinfo()` to query a service name. Most GNU and BSD systems define it by default so provide it as a convenience so applications and 3rd-party libraries do not encounter a compile error. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 97b51cc - Browse repository at this point
Copy the full SHA 97b51ccView commit details
Commits on Jan 16, 2023
-
net: socket: additional POSIX constants
The POSIX spec requires that `SO_LINGER`, `SO_RCVLOWAT`, and `SO_SNDLOWAT`, and `SOMAXCONN` are defined in `<sys/socket.h>`. However, most of the existing socket options and related constants are defined in `<zephyr/net/socket.h>`. For now, we'll co-locate them. It would be good to properly namespace things. Additionally, a no-op for setsockopt for `SO_LINGER` to make things Just Work (TM) for now. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for f19242a - Browse repository at this point
Copy the full SHA f19242aView commit details -
tests: posix: existence tests for standard POSIX includes
Add a trivial suite that simply ensures headers exist and that they supply standard symbols and constants. These tests are intended to be ordered exactly as the respective feature appears in the respective specification at https://pubs.opengroup.org/onlinepubs/9699919799 Over time, as POSIX support improves, we can enable additional checks. If `CONFIG_POSIX_API=n`, then we simply ensure that the header can be included, that constants and structures exist, including the existence of required fields in each structure. We check that a constant exist, by comparing its value against an arbitrary number. If the constant does not exist, it would of course be a compile error. ``` zassert_not_equal(-1, POLLIN); ``` We check that a structure contains required fields by comparing the field offset with an arbitrary number. If the field does not exist, of course, there would be a compile error. ``` zassert_not_equal(-1, offsetof(struct pollfd, fd)); ``` For non-scalar constants, we simply attempt to assign a value to the specific type: ``` struct in6_addr any6 = IN6ADDR_ANY_INIT; ``` If `CONFIG_POSIX_API=y`, then we additionally check that required functions are non-NULL (limited to what is currently supported in Zephyr). ``` zassert_not_null(pthread_create); ``` Note: functional verification tests should be done outside of this test suite. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 49a04c2 - Browse repository at this point
Copy the full SHA 49a04c2View commit details -
net: sockets: conditionally include zephyr/posix/fcntl.h
Only include `<fcntl.h>` for `CONFIG_ARCH_POSIX`. Otherwise, include `<zephyr/posix/fcntl.h>`. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 6fd104c - Browse repository at this point
Copy the full SHA 6fd104cView commit details -
include: posix: add c++ extern scope
`<fcntl.h>`, `<net/if.h>`, and `<netinet/tcp.h>` were missing `extern "C" { .. }"` which is required to avoid C++ name mangling. Signed-off-by: Chris Friedt <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 759dc8d - Browse repository at this point
Copy the full SHA 759dc8dView commit details