Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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
11#ifdef CONFIG_POSIX_API
12#include <zephyr/fs/fs.h>
13#endif
14#ifdef CONFIG_NETWORKING
15/* For zsock_gethostname() */
16#include <zephyr/net/socket.h>
17#include <zephyr/net/hostname.h>
18#endif
22
23#include "posix_features.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#ifdef CONFIG_POSIX_API
30/* File related operations */
31int close(int file);
32ssize_t write(int file, const void *buffer, size_t count);
33ssize_t read(int file, void *buffer, size_t count);
34off_t lseek(int file, off_t offset, int whence);
35int fsync(int fd);
36int ftruncate(int fd, off_t length);
37
38/* File System related operations */
39int rename(const char *old, const char *newp);
40int unlink(const char *path);
41int stat(const char *path, struct stat *buf);
42int mkdir(const char *path, mode_t mode);
43
44FUNC_NORETURN void _exit(int status);
45
46#ifdef CONFIG_NETWORKING
47static inline int gethostname(char *buf, size_t len)
48{
49 return zsock_gethostname(buf, len);
50}
51#endif /* CONFIG_NETWORKING */
52
53#endif /* CONFIG_POSIX_API */
54
55#ifdef CONFIG_POSIX_C_LIB_EXT
56int getopt(int argc, char *const argv[], const char *optstring);
57extern char *optarg;
58extern int opterr, optind, optopt;
59#endif
60
61int getentropy(void *buffer, size_t length);
63unsigned sleep(unsigned int seconds);
64int usleep(useconds_t useconds);
65#if _POSIX_C_SOURCE >= 2
66size_t confstr(int name, char *buf, size_t len);
67#endif
68
69#ifdef CONFIG_POSIX_SYSCONF_IMPL_MACRO
70#define sysconf(x) (long)CONCAT(__z_posix_sysconf, x)
71#else
72long sysconf(int opt);
73#endif /* CONFIG_POSIX_SYSCONF_IMPL_FULL */
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif /* ZEPHYR_INCLUDE_POSIX_UNISTD_H_ */
ZTEST_BMEM int count
Definition main.c:33
static int gethostname(char *buf, size_t len)
POSIX wrapper for zsock_gethostname.
Definition socket.h:1022
static int close(int sock)
POSIX wrapper for zsock_close.
Definition socket.h:879
int zsock_gethostname(char *buf, size_t len)
Get local host name.
Hostname configuration definitions.
__SIZE_TYPE__ ssize_t
Definition types.h:28
__INTPTR_TYPE__ off_t
Definition types.h:36
unsigned int mode_t
Definition types.h:14
BSD Sockets compatible API definitions.
unsigned long useconds_t
Definition posix_types.h:71
int pid_t
Definition posix_types.h:67
int mkdir(const char *_path, mode_t __mode)
Definition stat.h:57
static ZTEST_BMEM char buffer[8]
Definition test_mbox_api.c:433
int usleep(useconds_t useconds)
long sysconf(int opt)
int getentropy(void *buffer, size_t length)
unsigned sleep(unsigned int seconds)
pid_t getpid(void)