Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
unistd.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef ZEPHYR_INCLUDE_POSIX_UNISTD_H_
7#define ZEPHYR_INCLUDE_POSIX_UNISTD_H_
8
9#include "posix_types.h"
10#include "sys/stat.h"
11#ifdef CONFIG_NETWORKING
12/* For zsock_gethostname() */
13#include "net/socket.h"
14#endif
15
16#ifdef CONFIG_POSIX_API
17#include <fs/fs.h>
18#endif
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#ifdef CONFIG_POSIX_API
25/* File related operations */
26extern int close(int file);
27extern ssize_t write(int file, const void *buffer, size_t count);
28extern ssize_t read(int file, void *buffer, size_t count);
29extern off_t lseek(int file, off_t offset, int whence);
30
31/* File System related operations */
32extern int rename(const char *old, const char *newp);
33extern int unlink(const char *path);
34extern int stat(const char *path, struct stat *buf);
35extern int mkdir(const char *path, mode_t mode);
36
37#ifdef CONFIG_NETWORKING
38static inline int gethostname(char *buf, size_t len)
39{
40 return zsock_gethostname(buf, len);
41}
42#endif /* CONFIG_NETWORKING */
43
44#endif /* CONFIG_POSIX_API */
45
46unsigned sleep(unsigned int seconds);
47int usleep(useconds_t useconds);
48
49#ifdef __cplusplus
50}
51#endif
52
53#endif /* ZEPHYR_INCLUDE_POSIX_UNISTD_H_ */
ZTEST_BMEM int count
Definition: main.c:33
int zsock_gethostname(char *buf, size_t len)
Get local host name.
static ZTEST_BMEM char buffer[8]
Test mailbox enhance capabilities.
Definition: test_mbox_api.c:566
__SIZE_TYPE__ ssize_t
Definition: types.h:28
unsigned int mode_t
Definition: types.h:14
BSD Sockets compatible API definitions.
unsigned long useconds_t
Definition: posix_types.h:21
Definition: stat.h:39
int usleep(useconds_t useconds)
unsigned sleep(unsigned int seconds)
NMI_API sint8 close(SOCKET sock)