6#ifndef ZEPHYR_INCLUDE_POSIX_UNISTD_H_
7#define ZEPHYR_INCLUDE_POSIX_UNISTD_H_
11#ifdef CONFIG_POSIX_API
14#ifdef CONFIG_NETWORKING
19#ifdef CONFIG_POSIX_SYSCONF
31#define _POSIX_VERSION 200809L
32#define _POSIX2_VERSION (-1L)
33#define _XOPEN_VERSION (-1L)
36#define Z_SC_VAL_IFDEF(_def, _val) COND_CODE_1(_def, (_val), (-1L))
39#define _POSIX_ADVISORY_INFO (-1L)
40#define _POSIX_ASYNCHRONOUS_IO Z_SC_VAL_IFDEF(CONFIG_POSIX_ASYNCHRONOUS_IO, _POSIX_VERSION)
41#define _POSIX_BARRIERS Z_SC_VAL_IFDEF(CONFIG_PTHREAD_BARRIER, _POSIX_VERSION)
42#define _POSIX_CHOWN_RESTRICTED (0)
43#define _POSIX_CLOCK_SELECTION Z_SC_VAL_IFDEF(CONFIG_POSIX_CLOCK, _POSIX_VERSION)
44#define _POSIX_CPUTIME (-1L)
45#define _POSIX_FSYNC Z_SC_VAL_IFDEF(CONFIG_POSIX_FSYNC, _POSIX_VERSION)
46#define _POSIX_IPV6 Z_SC_VAL_IFDEF(CONFIG_NET_IPV6, _POSIX_VERSION)
47#define _POSIX_JOB_CONTROL (-1L)
48#define _POSIX_MAPPED_FILES (-1L)
49#define _POSIX_MEMLOCK (-1L)
50#define _POSIX_MEMLOCK_RANGE (-1L)
51#define _POSIX_MEMORY_PROTECTION (-1L)
52#define _POSIX_MESSAGE_PASSING Z_SC_VAL_IFDEF(CONFIG_POSIX_MQUEUE, _POSIX_VERSION)
53#define _POSIX_MONOTONIC_CLOCK Z_SC_VAL_IFDEF(CONFIG_POSIX_CLOCK, _POSIX_VERSION)
54#define _POSIX_NO_TRUNC (0)
55#define _POSIX_PRIORITIZED_IO (-1L)
56#define _POSIX_PRIORITY_SCHEDULING Z_SC_VAL_IFDEF(CONFIG_POSIX_PRIORITY_SCHEDULING, _POSIX_VERSION)
57#define _POSIX_RAW_SOCKETS Z_SC_VAL_IFDEF(CONFIG_NET_SOCKETS_PACKET, _POSIX_VERSION)
58#define _POSIX_READER_WRITER_LOCKS Z_SC_VAL_IFDEF(CONFIG_PTHREAD_IPC, _POSIX_VERSION)
59#define _POSIX_REALTIME_SIGNALS (-1L)
60#define _POSIX_REGEXP (-1L)
61#define _POSIX_SAVED_IDS (-1L)
62#define _POSIX_SEMAPHORES Z_SC_VAL_IFDEF(CONFIG_PTHREAD_IPC, _POSIX_VERSION)
63#define _POSIX_SHARED_MEMORY_OBJECTS (-1L)
64#define _POSIX_SHELL (-1L)
65#define _POSIX_SPAWN (-1L)
66#define _POSIX_SPIN_LOCKS Z_SC_VAL_IFDEF(CONFIG_PTHREAD_SPINLOCK, _POSIX_VERSION)
67#define _POSIX_SPORADIC_SERVER (-1L)
68#define _POSIX_SYNCHRONIZED_IO (-1L)
69#define _POSIX_THREAD_ATTR_STACKADDR Z_SC_VAL_IFDEF(CONFIG_PTHREAD_IPC, _POSIX_VERSION)
70#define _POSIX_THREAD_ATTR_STACKSIZE Z_SC_VAL_IFDEF(CONFIG_PTHREAD_IPC, _POSIX_VERSION)
71#define _POSIX_THREAD_CPUTIME (-1L)
72#define _POSIX_THREAD_PRIO_INHERIT _POSIX_VERSION
73#define _POSIX_THREAD_PRIO_PROTECT (-1L)
74#define _POSIX_THREAD_PRIORITY_SCHEDULING Z_SC_VAL_IFDEF(CONFIG_PTHREAD_IPC, _POSIX_VERSION)
75#define _POSIX_THREAD_PROCESS_SHARED (-1L)
76#define _POSIX_THREAD_ROBUST_PRIO_INHERIT (-1L)
77#define _POSIX_THREAD_ROBUST_PRIO_PROTECT (-1L)
78#define _POSIX_THREAD_SAFE_FUNCTIONS Z_SC_VAL_IFDEF(CONFIG_PTHREAD_IPC, _POSIX_VERSION)
79#define _POSIX_THREAD_SPORADIC_SERVER (-1L)
82#define _POSIX_THREADS Z_SC_VAL_IFDEF(CONFIG_PTHREAD_IPC, _POSIX_VERSION)
85#define _POSIX_TIMEOUTS Z_SC_VAL_IFDEF(CONFIG_POSIX_CLOCK, _POSIX_VERSION)
86#define _POSIX_TIMERS Z_SC_VAL_IFDEF(CONFIG_POSIX_CLOCK, _POSIX_VERSION)
87#define _POSIX_TRACE (-1L)
88#define _POSIX_TRACE_EVENT_FILTER (-1L)
89#define _POSIX_TRACE_INHERIT (-1L)
90#define _POSIX_TRACE_LOG (-1L)
91#define _POSIX_TYPED_MEMORY_OBJECTS (-1L)
92#define _POSIX_V6_ILP32_OFF32 (-1L)
93#define _POSIX_V6_ILP32_OFFBIG (-1L)
94#define _POSIX_V6_LP64_OFF64 (-1L)
95#define _POSIX_V6_LPBIG_OFFBIG (-1L)
96#define _POSIX_V7_ILP32_OFF32 (-1L)
97#define _POSIX_V7_ILP32_OFFBIG (-1L)
98#define _POSIX_V7_LP64_OFF64 (-1L)
99#define _POSIX_V7_LPBIG_OFFBIG (-1L)
100#define _POSIX2_C_BIND _POSIX_VERSION
101#define _POSIX2_C_DEV (-1L)
102#define _POSIX2_CHAR_TERM (-1L)
103#define _POSIX2_DELAYTIMER_MAX (-1L)
104#define _POSIX2_FORT_DEV (-1L)
105#define _POSIX2_FORT_RUN (-1L)
106#define _POSIX2_LOCALEDEF (-1L)
107#define _POSIX2_PBS (-1L)
108#define _POSIX2_PBS_ACCOUNTING (-1L)
109#define _POSIX2_PBS_CHECKPOINT (-1L)
110#define _POSIX2_PBS_LOCATE (-1L)
111#define _POSIX2_PBS_MESSAGE (-1L)
112#define _POSIX2_PBS_TRACK (-1L)
113#define _POSIX2_SW_DEV (-1L)
114#define _POSIX2_UPE (-1L)
115#define _XOPEN_CRYPT (-1L)
116#define _XOPEN_ENH_I18N (-1L)
117#define _XOPEN_REALTIME (-1L)
118#define _XOPEN_REALTIME_THREADS (-1L)
119#define _XOPEN_SHM (-1L)
120#define _XOPEN_STREAMS (-1L)
121#define _XOPEN_UNIX (-1L)
122#define _XOPEN_UUCP (-1L)
125#define _POSIX_CLOCKRES_MIN (20000000L)
128#define _POSIX_AIO_LISTIO_MAX (2)
129#define _POSIX_AIO_MAX (1)
130#define _POSIX_ARG_MAX (4096)
131#define _POSIX_CHILD_MAX (25)
132#define _POSIX_DELAYTIMER_MAX (32)
133#define _POSIX_HOST_NAME_MAX (255)
134#define _POSIX_LINK_MAX (8)
135#define _POSIX_LOGIN_NAME_MAX (9)
136#define _POSIX_MAX_CANON (255)
137#define _POSIX_MAX_INPUT (255)
138#define _POSIX_MQ_OPEN_MAX Z_SC_VAL_IFDEF(CONFIG_POSIX_MQUEUE, \
139 CONFIG_MSG_COUNT_MAX)
140#define _POSIX_MQ_PRIO_MAX (32)
141#define _POSIX_NAME_MAX (14)
142#define _POSIX_NGROUPS_MAX (8)
143#define _POSIX_OPEN_MAX CONFIG_POSIX_MAX_FDS
144#define _POSIX_PATH_MAX (256)
145#define _POSIX_PIPE_BUF (512)
146#define _POSIX_RE_DUP_MAX (255)
147#define _POSIX_RTSIG_MAX CONFIG_POSIX_RTSIG_MAX
148#define _POSIX_SEM_NSEMS_MAX CONFIG_SEM_NAMELEN_MAX
149#define _POSIX_SEM_VALUE_MAX CONFIG_SEM_VALUE_MAX
150#define _POSIX_SIGQUEUE_MAX (32)
151#define _POSIX_SSIZE_MAX (32767)
152#define _POSIX_SS_REPL_MAX (4)
153#define _POSIX_STREAM_MAX (8)
154#define _POSIX_SYMLINK_MAX (255)
155#define _POSIX_SYMLOOP_MAX (8)
156#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS (4)
157#define _POSIX_THREAD_KEYS_MAX (128)
158#define _POSIX_THREAD_THREADS_MAX (64)
159#define _POSIX_TIMER_MAX (32)
160#define _POSIX_TRACE_EVENT_NAME_MAX (30)
161#define _POSIX_TRACE_NAME_MAX (8)
162#define _POSIX_TRACE_SYS_MAX (8)
163#define _POSIX_TRACE_USER_EVENT_MAX (32)
164#define _POSIX_TTY_NAME_MAX (9)
165#define _POSIX_TZNAME_MAX (6)
166#define _POSIX2_BC_BASE_MAX (99)
167#define _POSIX2_BC_DIM_MAX (2048)
168#define _POSIX2_BC_SCALE_MAX (99)
169#define _POSIX2_BC_STRING_MAX (1000)
170#define _POSIX2_CHARCLASS_NAME_MAX (14)
171#define _POSIX2_COLL_WEIGHTS_MAX (2)
172#define _POSIX2_EXPR_NEST_MAX (32)
173#define _POSIX2_LINE_MAX (2048)
174#define _XOPEN_IOV_MAX (16)
175#define _XOPEN_NAME_MAX (255)
176#define _XOPEN_PATH_MAX (1024)
179#define NL_LANGMAX (14)
180#define NL_MSGMAX (32767)
181#define NL_SETMAX (255)
182#define NL_TEXTMAX (_POSIX2_LINE_MAX)
186#define AIO_LISTIO_MAX _POSIX_AIO_LISTIO_MAX
187#define AIO_MAX _POSIX_AIO_MAX
188#define AIO_PRIO_DELTA_MAX (0)
189#define DELAYTIMER_MAX _POSIX_DELAYTIMER_MAX
190#define HOST_NAME_MAX COND_CODE_1(CONFIG_NETWORKING, \
191 (NET_HOSTNAME_MAX_LEN), \
192 (_POSIX_HOST_NAME_MAX))
193#define LOGIN_NAME_MAX _POSIX_LOGIN_NAME_MAX
194#define MQ_OPEN_MAX _POSIX_MQ_OPEN_MAX
195#define MQ_PRIO_MAX _POSIX_MQ_PRIO_MAX
202#define PAGE_SIZE BIT(CONFIG_POSIX_PAGE_SIZE_BITS)
206#define PAGESIZE PAGE_SIZE
209#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
210#define PTHREAD_KEYS_MAX COND_CODE_1(CONFIG_PTHREAD_IPC, \
211 (CONFIG_MAX_PTHREAD_KEY_COUNT), \
212 (_POSIX_THREAD_KEYS_MAX))
213#define PTHREAD_THREADS_MAX COND_CODE_1(CONFIG_PTHREAD_IPC, \
214 (CONFIG_MAX_PTHREAD_COUNT), \
216#define SEM_NSEMS_MAX _POSIX_SEM_NSEMS_MAX
217#define SEM_VALUE_MAX CONFIG_SEM_VALUE_MAX
218#define SIGQUEUE_MAX _POSIX_SIGQUEUE_MAX
219#define STREAM_MAX _POSIX_STREAM_MAX
220#define SYMLOOP_MAX _POSIX_SYMLOOP_MAX
221#define TIMER_MAX Z_SC_VAL_IFDEF(CONFIG_TIMER, CONFIG_MAX_TIMER_COUNT)
222#define TTY_NAME_MAX _POSIX_TTY_NAME_MAX
223#define TZNAME_MAX _POSIX_TZNAME_MAX
226#define FILESIZEBITS (32)
227#define POSIX_ALLOC_SIZE_MIN (256)
228#define POSIX_REC_INCR_XFER_SIZE (1024)
229#define POSIX_REC_MAX_XFER_SIZE (32767)
230#define POSIX_REC_MIN_XFER_SIZE (1)
231#define POSIX_REC_XFER_ALIGN (4)
232#define SYMLINK_MAX _POSIX_SYMLINK_MAX
234#ifdef CONFIG_POSIX_API
237ssize_t write(
int file,
const void *buffer,
size_t count);
238ssize_t read(
int file,
void *buffer,
size_t count);
239off_t lseek(
int file,
off_t offset,
int whence);
241int ftruncate(
int fd,
off_t length);
244int rename(
const char *old,
const char *newp);
245int unlink(
const char *path);
246int stat(
const char *path,
struct stat *buf);
249FUNC_NORETURN
void _exit(
int status);
251#ifdef CONFIG_NETWORKING
252static inline int gethostname(
char *buf,
size_t len)
261int getopt(
int argc,
char *
const argv[],
const char *optstring);
263extern int opterr, optind, optopt;
268unsigned sleep(
unsigned int seconds);
270#ifdef CONFIG_POSIX_SYSCONF_IMPL_FULL
271long sysconf(
int opt);
273#if _POSIX_C_SOURCE >= 2
274size_t confstr(
int name,
char *buf,
size_t len);
static int gethostname(char *buf, size_t len)
POSIX wrapper for zsock_gethostname.
Definition: socket.h:1023
static int close(int sock)
POSIX wrapper for zsock_close.
Definition: socket.h:880
int zsock_gethostname(char *buf, size_t len)
Get local host name.
Hostname configuration definitions.
int mkdir(const char *_path, mode_t __mode)
__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:27
int pid_t
Definition: posix_types.h:24
int usleep(useconds_t useconds)
int getentropy(void *buffer, size_t length)
unsigned sleep(unsigned int seconds)