Zephyr API Documentation 4.0.0-rc3
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
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#ifdef CONFIG_POSIX_SYNCHRONIZED_IO
39int fdatasync(int fd);
40#endif /* CONFIG_POSIX_SYNCHRONIZED_IO */
41
42/* File System related operations */
43int rename(const char *old, const char *newp);
44int unlink(const char *path);
45int stat(const char *path, struct stat *buf);
46int mkdir(const char *path, mode_t mode);
47int rmdir(const char *path);
48
49FUNC_NORETURN void _exit(int status);
50
51#ifdef CONFIG_NETWORKING
52static inline int gethostname(char *buf, size_t len)
53{
54 return zsock_gethostname(buf, len);
55}
56#endif /* CONFIG_NETWORKING */
57
58#endif /* CONFIG_POSIX_API */
59
60#ifdef CONFIG_POSIX_C_LIB_EXT
61int getopt(int argc, char *const argv[], const char *optstring);
62extern char *optarg;
63extern int opterr, optind, optopt;
64#endif
65
66int getentropy(void *buffer, size_t length);
68unsigned sleep(unsigned int seconds);
69int usleep(useconds_t useconds);
70#if _POSIX_C_SOURCE >= 2
71size_t confstr(int name, char *buf, size_t len);
72#endif
73
74#ifdef CONFIG_POSIX_SYSCONF_IMPL_MACRO
75#define sysconf(x) (long)CONCAT(__z_posix_sysconf, x)
76#else
77long sysconf(int opt);
78#endif /* CONFIG_POSIX_SYSCONF_IMPL_FULL */
79
80#ifdef __cplusplus
81}
82#endif
83
84#endif /* ZEPHYR_INCLUDE_POSIX_UNISTD_H_ */
static int gethostname(char *buf, size_t len)
POSIX wrapper for zsock_gethostname.
Definition socket.h:973
static int close(int sock)
POSIX wrapper for zsock_close.
Definition socket.h:830
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:83
int pid_t
Definition posix_types.h:79
int stat(const char *__restrict __path, struct stat *__restrict __sbuf)
int mkdir(const char *_path, mode_t __mode)
Definition stat.h:57
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)