Skip to content

Commit 5cfbcdf

Browse files
committed
posix: unistd.h: Add gethostname()
Per POSIX, gethostname() is declared in unistd.h. Signed-off-by: Paul Sokolovsky <[email protected]>
1 parent 0fb8a91 commit 5cfbcdf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/posix/unistd.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ extern "C" {
1212

1313
#include "posix_types.h"
1414
#include "sys/stat.h"
15+
#ifdef CONFIG_NETWORKING
16+
/* For zsock_gethostname() */
17+
#include "net/socket.h"
18+
#endif
1519

1620
#ifdef CONFIG_POSIX_API
1721
#include <fs.h>
@@ -33,6 +37,13 @@ extern int mkdir(const char *path, mode_t mode);
3337
unsigned sleep(unsigned int seconds);
3438
int usleep(useconds_t useconds);
3539

40+
#ifdef CONFIG_NETWORKING
41+
static inline int gethostname(char *buf, size_t len)
42+
{
43+
return zsock_gethostname(buf, len);
44+
}
45+
#endif
46+
3647
#ifdef __cplusplus
3748
}
3849
#endif

0 commit comments

Comments
 (0)