Line data Source code
1 0 : /*
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 <time.h>
10 :
11 : #include <zephyr/posix/posix_types.h>
12 :
13 : #ifdef CONFIG_POSIX_API
14 : #include <zephyr/fs/fs.h>
15 : #endif
16 : #include <zephyr/posix/sys/confstr.h>
17 : #include <zephyr/posix/sys/stat.h>
18 : #include <zephyr/posix/sys/sysconf.h>
19 :
20 : #include "posix_features.h"
21 :
22 : #ifdef __cplusplus
23 : extern "C" {
24 : #endif
25 :
26 : #ifdef CONFIG_POSIX_API
27 : /* File related operations */
28 : int close(int file);
29 : ssize_t write(int file, const void *buffer, size_t count);
30 : ssize_t read(int file, void *buffer, size_t count);
31 : off_t lseek(int file, off_t offset, int whence);
32 : int fsync(int fd);
33 : int ftruncate(int fd, off_t length);
34 :
35 : #ifdef CONFIG_POSIX_SYNCHRONIZED_IO
36 : int fdatasync(int fd);
37 : #endif /* CONFIG_POSIX_SYNCHRONIZED_IO */
38 :
39 : /* File System related operations */
40 : int rename(const char *old, const char *newp);
41 : int unlink(const char *path);
42 : int stat(const char *path, struct stat *buf);
43 : int mkdir(const char *path, mode_t mode);
44 : int rmdir(const char *path);
45 :
46 : FUNC_NORETURN void _exit(int status);
47 :
48 : int gethostname(char *buf, size_t len);
49 :
50 : #endif /* CONFIG_POSIX_API */
51 :
52 : #ifdef CONFIG_POSIX_C_LIB_EXT
53 : int getopt(int argc, char *const argv[], const char *optstring);
54 : extern char *optarg;
55 : extern int opterr, optind, optopt;
56 : #endif
57 :
58 0 : int getentropy(void *buffer, size_t length);
59 0 : pid_t getpid(void);
60 0 : unsigned sleep(unsigned int seconds);
61 0 : int usleep(useconds_t useconds);
62 : #if _POSIX_C_SOURCE >= 2
63 : size_t confstr(int name, char *buf, size_t len);
64 : #endif
65 :
66 : #ifdef CONFIG_POSIX_SYSCONF_IMPL_MACRO
67 : #define sysconf(x) (long)CONCAT(__z_posix_sysconf, x)
68 : #else
69 0 : long sysconf(int opt);
70 : #endif /* CONFIG_POSIX_SYSCONF_IMPL_FULL */
71 :
72 : #if _XOPEN_SOURCE >= 500
73 : long gethostid(void);
74 : #endif
75 :
76 : #ifdef __cplusplus
77 : }
78 : #endif
79 :
80 : #endif /* ZEPHYR_INCLUDE_POSIX_UNISTD_H_ */
|