From 6631e7c6a976727c38b4e23607fb8062887b2fd9 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 21 Feb 2019 20:31:18 +0300 Subject: [PATCH] posix: unistd.h: Add gethostname() Per POSIX, gethostname() is declared in unistd.h. Signed-off-by: Paul Sokolovsky --- include/posix/unistd.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/posix/unistd.h b/include/posix/unistd.h index 7dc39e9f6fd..48f630cee46 100644 --- a/include/posix/unistd.h +++ b/include/posix/unistd.h @@ -12,6 +12,10 @@ extern "C" { #include "posix_types.h" #include "sys/stat.h" +#ifdef CONFIG_NETWORKING +/* For zsock_gethostname() */ +#include "net/socket.h" +#endif #ifdef CONFIG_POSIX_API #include @@ -33,6 +37,13 @@ extern int mkdir(const char *path, mode_t mode); unsigned sleep(unsigned int seconds); int usleep(useconds_t useconds); +#ifdef CONFIG_NETWORKING +static inline int gethostname(char *buf, size_t len) +{ + return zsock_gethostname(buf, len); +} +#endif + #ifdef __cplusplus } #endif