net: sockets: Add configurable option to provide raw POSIX API names
With CONFIG_NET_SOCKETS_POSIX_NAMES=y, "raw" POSIX names like socket(), recv(), close() will be exposed (using macro defines). The close() is the biggest culprit here, because in POSIX it applies to any file descriptor, but in this implementation - only to sockets. Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
parent
041d38740d
commit
386c5bacd1
|
@ -7,6 +7,9 @@
|
|||
#ifndef __NET_SOCKET_H
|
||||
#define __NET_SOCKET_H
|
||||
|
||||
#include <zephyr/types.h>
|
||||
#include <net/net_ip.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -14,6 +17,11 @@ extern "C" {
|
|||
int zsock_socket(int family, int type, int proto);
|
||||
int zsock_close(int sock);
|
||||
|
||||
#if defined(CONFIG_NET_SOCKETS_POSIX_NAMES)
|
||||
#define socket zsock_socket
|
||||
#define close zsock_close
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,17 @@ menuconfig NET_SOCKETS
|
|||
|
||||
if NET_SOCKETS
|
||||
|
||||
config NET_SOCKETS_POSIX_NAMES
|
||||
bool "Standard POSIX names for Sockets API"
|
||||
default n
|
||||
help
|
||||
By default, Sockets API function are prefixed with `zsock_` to avoid
|
||||
namespacing issues. If this option is enabled, they will be provided
|
||||
with standard POSIX names like socket(), recv(), and close(), to help
|
||||
with porting existing code. Note that close() may require a special
|
||||
attention, as in POSIX it closes any file descriptor, while with this
|
||||
option enaled, it will still apply only to sockets.
|
||||
|
||||
config NET_DEBUG_SOCKETS
|
||||
bool "Debug BSD Sockets like API calls"
|
||||
default n
|
||||
|
|
Loading…
Reference in New Issue