posix: unistd.h: Add gethostname()

Per POSIX, gethostname() is declared in unistd.h.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
Paul Sokolovsky 2019-02-21 20:31:18 +03:00 committed by Kumar Gala
parent a614a026b7
commit 6631e7c6a9

View file

@ -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 <fs.h>
@ -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