More refactoring of library support.
[splint-patched.git] / lib / include / unistd.h
bloba1eef941ba247ae9bc459d81f01286fcdad75790
1 /*
2 ** unistd.h
3 */
5 /* for access: */
6 /*@constant int F_OK@*/
7 /*@constant int R_OK@*/
8 /*@constant int W_OK@*/
9 /*@constant int X_OK@*/
11 /*@constant int STDERR_FILENO@*/
12 /*@constant int STDIN_FILENO@*/
13 /*@constant int STDOUT_FILENO@*/
14 /*@constant int _PC_CHOWN_RESTRUCTED@*/
15 /*@constant int _PC_MAX_CANON@*/
16 /*@constant int _PC_MAX_INPUT@*/
17 /*@constant int _PC_NAME_MAX@*/
18 /*@constant int _PC_NO_TRUNC@*/
19 /*@constant int _PC_PATH_MAX@*/
20 /*@constant int _PC_PIPE_BUF@*/
21 /*@constant int _PC_VDISABLE@*/
22 /*@constant int _POSIX_CHOWN_RESTRICTED@*/
23 /*@constant int _POSIX_JOB_CONTROL@*/
24 /*@constant int _POSIX_NO_TRUNC@*/
25 /*@constant int _POSIX_SAVED_IDS@*/
26 /*@constant int _POSIX_VDISABLE@*/
27 /*@constant int _POSIX_VERSION@*/
28 /*@constant int _SC_ARG_MAX@*/
29 /*@constant int _SC_CHILD_MAX@*/
30 /*@constant int _SC_CLK_TCK@*/
31 /*@constant int _SC_JOB_CONTROL@*/
32 /*@constant int _SC_NGROUPS_MAX@*/
33 /*@constant int _SC_OPEN_MAX@*/
34 /*@constant int _SC_SAVED_IDS@*/
35 /*@constant int _SC_STREAM_MAX@*/
36 /*@constant int _SC_TZNAME_MAX@*/
37 /*@constant int _SC_VERSION@*/
39 /* for confstr(): */
40 /*@constant int _CS_POSIX_V7_ILP32_OFF32_CFLAGS @*/
41 /*@constant int _CS_POSIX_V7_ILP32_OFF32_LDFLAGS @*/
42 /*@constant int _CS_POSIX_V7_ILP32_OFF32_LIBS @*/
43 /*@constant int _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS @*/
44 /*@constant int _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS @*/
45 /*@constant int _CS_POSIX_V7_ILP32_OFFBIG_LIBS @*/
46 /*@constant int _CS_POSIX_V7_LP64_OFF64_CFLAGS @*/
47 /*@constant int _CS_POSIX_V7_LP64_OFF64_LDFLAGS @*/
48 /*@constant int _CS_POSIX_V7_LP64_OFF64_LIBS @*/
49 /*@constant int _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS @*/
50 /*@constant int _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS @*/
51 /*@constant int _CS_POSIX_V7_LPBIG_OFFBIG_LIBS @*/
52 /*@constant int _CS_POSIX_V7_THREADS_CFLAGS @*/
53 /*@constant int _CS_POSIX_V7_THREADS_LDFLAGS @*/
54 /*@constant int _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS @*/
55 /*@constant int _CS_V7_ENV @*/
56 /* [obsolete constants] for confstr(): */
57 /*@constant int _CS_POSIX_V6_ILP32_OFF32_CFLAGS @*/
58 /*@constant int _CS_POSIX_V6_ILP32_OFF32_LDFLAGS @*/
59 /*@constant int _CS_POSIX_V6_ILP32_OFF32_LIBS @*/
60 /*@constant int _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS @*/
61 /*@constant int _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS @*/
62 /*@constant int _CS_POSIX_V6_ILP32_OFFBIG_LIBS @*/
63 /*@constant int _CS_POSIX_V6_LP64_OFF64_CFLAGS @*/
64 /*@constant int _CS_POSIX_V6_LP64_OFF64_LDFLAGS @*/
65 /*@constant int _CS_POSIX_V6_LP64_OFF64_LIBS @*/
66 /*@constant int _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS @*/
67 /*@constant int _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS @*/
68 /*@constant int _CS_POSIX_V6_LPBIG_OFFBIG_LIBS @*/
69 /*@constant int _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS @*/
70 /*@constant int _CS_V6_ENV @*/
73 /*@unchecked@*/ extern char **environ;
74 /*@unchecked@*/ extern char *optarg;
75 /*@unchecked@*/ extern int optind;
76 /*@unchecked@*/ extern int optopt;
77 /*@unchecked@*/ extern int opterr;
79 /*@exits@*/
80 void _exit (int status) /*@*/;
82 int access (const char *path, int mode)
83 /*@modifies errno@*/;
85 unsigned int alarm (unsigned int)
86 /*@modifies systemState@*/;
88 int chdir (const char *path)
89 /*@modifies errno, internalState@*/;
91 int fchdir (int)
92 /*@modifies errno, fileSystem@*/
93 /*:errorcode -1:*/ ;
95 int chown (const char *path, uid_t owner, gid_t group)
96 /*@modifies fileSystem, errno@*/;
98 int fchown (int, uid_t, gid_t)
99 /*@modifies errno, fileSystem@*/
100 /*:errorcode -1:*/ ;
102 int lchown(const char *, uid_t, gid_t)
103 /*@modifies errno, fileSystem@*/
104 /*:errorcode -1:*/ ;
106 int close (int fd)
107 /*@modifies fileSystem, errno, systemState@*/;
108 /* state: record locks are unlocked */
110 int dup2 (int fd, int fd2)
111 /*@modifies errno, fileSystem@*/;
113 int dup (int fd)
114 /*@modifies errno, fileSystem@*/;
116 /*@mayexit@*/
117 int execl (const char *path, const char *arg, ...)
118 /*@modifies errno, internalState@*/;
120 /*@mayexit@*/
121 int execle (const char *file, const char *arg, ...)
122 /*@modifies errno, internalState@*/;
124 /*@mayexit@*/
125 int execlp (const char *file, const char *arg, ...)
126 /*@modifies errno, internalState@*/;
128 /*@mayexit@*/
129 int execv (const char *path, char *const argv[])
130 /*@modifies errno, internalState@*/;
132 /*@mayexit@*/
133 int execve (const char *path, char *const argv[], char *const *envp)
134 /*@modifies errno, internalState@*/;
136 /*@mayexit@*/
137 int execvp (const char *file, char *const argv[])
138 /*@modifies errno, internalState@*/;
140 pid_t fork (void)
141 /*@modifies errno, fileSystem@*/;
143 long fpathconf (int fd, int name)
144 /*@modifies errno, internalState@*/;
146 /*@null@*/
147 char *getcwd (/*@returned@*/ /*@out@*/ /*@notnull@*/ char *buf, size_t size)
148 /*@requires maxSet(buf) >= (size - 1)@*/
149 /*@ensures maxRead(buf) <= (size - 1)@*/
150 /*@modifies errno, *buf@*/ ;
152 /*@null@*/
153 char *getwd (/*@returned@*/ char *path_name)
154 /*@warn legacy "getwd is obsolete. Use getcwd instead" @*/
155 /*@modifies path_name@*/ ;
158 gid_t getegid (void) /*@*/;
159 uid_t geteuid (void) /*@*/;
160 gid_t getgid (void) /*@*/;
162 int getgroups (int gidsetsize, /*@out@*/ gid_t grouplist[])
163 /*@requires maxSet(grouplist) >= gidsetsize@*/
164 /*@modifies errno, grouplist[]@*/;
166 /*@null@*/ /*@observer@*/
167 char * getlogin (void) /*@modifies errno@*/ ;
169 int getlogin_r (char *name, size_t namesize)
170 /*@requires maxSet(name) >= namesize@*/
171 /*:errorcode !0:*/ ;
173 pid_t getpgrp (void) /*@*/;
174 pid_t getpid (void) /*@*/;
175 pid_t getppid (void) /*@*/;
176 uid_t getuid (void) /*@*/;
178 int isatty (int fd) /*@modifies errno@*/;
180 int link (const char *o, const char *n)
181 /*@modifies errno, fileSystem@*/;
183 off_t lseek (int fd, off_t offset, int whence) /*@modifies errno, fileSystem@*/;
185 long pathconf (const char *path, int name)
186 /*@modifies errno@*/;
188 int pause (void)
189 /*@modifies errno@*/;
191 /* Out parameter noticed by Marc Espie. */
192 int pipe (/*@out@*/ int fd[])
193 /*@requires maxRead(fd) == 1@*/
194 /*@modifies errno@*/;
196 ssize_t read (int fd, /*@out@*/ void *buf, size_t nbyte)
197 /*@modifies errno, *buf@*/
198 /*@requires maxSet(buf) >= (nbyte - 1) @*/
199 /*@ensures maxRead(buf) >= nbyte @*/ ;
201 int rmdir (const char *path)
202 /*@modifies fileSystem, errno@*/;
204 int setgid (gid_t gid)
205 /*@modifies errno, systemState@*/;
207 int setpgid (pid_t pid, pid_t pgid)
208 /*@modifies errno, systemState@*/;
210 pid_t setsid (void) /*@modifies errno, systemState@*/;
212 int setuid (uid_t uid)
213 /*@modifies errno, systemState@*/;
215 unsigned int sleep (unsigned int sec) /*@modifies systemState@*/ ;
217 long sysconf (int name)
218 /*@modifies errno@*/;
220 pid_t tcgetpgrp (int fd)
221 /*@globals systemState@*/
222 /*@modifies errno@*/;
224 int tcsetpgrp (int fd, pid_t pgrpid)
225 /*@modifies errno, systemState@*/;
227 /*@null@*/ /*@observer@*/ /* Question: observer ok? */
228 char *ttyname (int fd)
229 /*@globals systemState@*/
230 /*@modifies errno@*/;
232 int ttyname_r(int, char *name, size_t namesize)
233 /*@requires maxSet(name) >= (namesize - 1)@*/ ;
234 /*:errorcode !0:*/ ;
236 int unlink (const char *path)
237 /*@modifies fileSystem, errno@*/;
239 ssize_t write (int fd, const void *buf, size_t nbyte)
240 /*@requires maxRead(buf) >= nbyte@*/
241 /*@modifies errno@*/;
243 void sync (void)
244 /*@modifies fileSystem@*/;
246 int fsync(int)
247 /*@modifies errno, fileSystem@*/
248 /*:errorcode -1:*/ ;
250 int fdatasync (int)
251 /*@modifies errno, fileSystem@*/
252 /*:errorcode -1:*/ ;
254 int symlink (char *name1, char *name2)
255 /*@modifies errno, fileSystem@*/
256 /*:errorcode -1:*/ ;
258 useconds_t ualarm(useconds_t, useconds_t)
259 /*@warn legacy "ualarm is obsolete" @*/
260 /*@modifies systemState@*/ ;
262 int usleep (useconds_t useconds)
263 /*@warn legacy "usleep is obsolete. Use nanosleep instead" @*/
264 /*@modifies systemState, errno@*/
265 /*error -1 sucess 0 */ ;
267 int truncate(const char *name, off_t length)
268 /*@modifies errno, fileSystem@*/
269 /*:errorcode -1:*/ ;
271 int ftruncate(int fd, off_t length)
272 /*@modifies errno, fileSystem@*/
273 /*:errorcode -1:*/ ;
275 int gethostname (/*@out@*/ char *address, size_t address_len)
276 /*:errorstatus@*/
277 /*@modifies address@*/ ;
279 /*@dependent@*/ /*@null@*/
280 char *getpass(/*@nullterminated@*/ const char *)
281 /*@warn legacy "getpass is obsolete"@*/ ;
283 int brk(void *)
284 /*@modifies errno@*/
285 /*:errorcode -1:*/
286 /*@warn legacy "brk is obsolete"@*/ ;
288 void *sbrk(intptr_t)
289 /*@modifies errno@*/
290 /*:errorcode (void *)-1:*/
291 /*@warn legacy "sbrk is obsolete"@*/ ;
293 size_t confstr(int, /*@null@*/ char *, size_t)
294 /*@globals internalState@*/
295 /*@modifies errno@*/
296 /*:errorcode 0:*/ ;
298 /*@dependent@*/ /*@null@*/
299 char *crypt(const char *, const char *)
300 /*@modifies errno, internalState@*/ ;
302 void encrypt(char p_block[], int)
303 /*@requires maxSet(p_block) == 63@*/
304 /*@modifies p_block, errno@*/ ;
306 int lockf(int, int, off_t)
307 /*@modifies errno, fileSystem@*/
308 /*:errorcode -1:*/ ;
310 int nice(int)
311 /*@modifies errno, fileSystem@*/
312 /*:errorcode -1:*/ ;
314 int getopt (int argc, char * const argv[], const char *optstring)
315 /*@globals optarg, optind, optopt, opterr@*/
316 /*@modifies optarg, optind, optopt@*/
317 /*@requires maxRead(argv) >= (argc - 1) @*/
318 /*:errorcode -1:*/ ;
320 int readlink(const char *, char *buf, size_t bufsize)
321 /*@requires maxSet(buf) >= (bufsize - 1)@*/
322 /*@modifies errno, fileSystem, *buf@*/
323 /*:errorcode -1:*/ ;
325 int getpagesize(void)
326 /*@warn legacy "getpagesize is obsolete"@*/ ;
328 long gethostid (void) /*@globals internalState@*/ ;
330 pid_t vfork(void)
331 /*@warn legacy "vfork is obsolete" @*/
332 /*@modifies errno, fileSystem@*/
333 /*:errorcode -1:*/ ;
335 pid_t getpgid(pid_t)
336 /*@modifies errno@*/
337 /*@globals internalState@*/
338 /*:errorcode (pid_t)-1:*/ ;
340 pid_t getsid(pid_t)
341 /*@modifies errno@*/
342 /*@globals internalState@*/
343 /*:errorcode (pid_t)-1:*/ ;
345 pid_t setpgrp(void) /*@modifies internalState@*/;
347 ssize_t pread(int, /*@out@*/ void *buf, size_t nbyte, off_t offset)
348 /*@modifies errno, fileSystem@*/
349 /*@requires maxSet(buf) >= (nbyte - 1) @*/
350 /*@ensures maxRead(buf) >= nbyte @*/
351 /*:errorcode -1:*/ ;
353 ssize_t pwrite(int, const void *buf, size_t nbyte, off_t)
354 /*@requires maxRead(buf) >= nbyte@*/
355 /*@modifies errno, fileSystem@*/
356 /*:errorcode -1:*/ ;
358 void swab(/*@unique@*/ const void *src, /*@unique@*/ void *dest, ssize_t nbytes)
359 /*@requires maxSet(dest) >= (nbytes - 1)@*/ ;
362 # ifdef UNIX
363 int chroot (/*@notnull@*/ /*@nullterminated@*/ const char *path)
364 /*@modifies internalState, errno@*/
365 /*:errorcode -1:*/
366 /*@warn superuser "Only super-user processes may call chroot."@*/ ;
368 int fchroot (int fildes)
369 /*:statusreturn@*/
370 /*@warn superuser "Only super-user processes may call fchroot."@*/ ;
372 int getdtablesize (void)
373 /*@warn legacy "getdtablesize is obsolete"@*/ ;
375 /*@constant int _POSIX2_VERSION@*/
376 /*@constant int _POSIX2_C_VERSION@*/
377 /*@constant int _XOPEN_VERSION@*/
378 /*@constant int _XOPEN_XCU_VERSION@*/
380 /* for confstr(): */
381 /*@constant int _CS_PATH@*/
382 /*@constant int _CS_XBS5_ILP32_OFF32_CFLAGS@*/
383 /*@constant int _CS_XBS5_ILP32_OFF32_LDFLAGS@*/
384 /*@constant int _CS_XBS5_ILP32_OFF32_LIBS@*/
385 /*@constant int _CS_XBS5_ILP32_OFF32_LINTFLAGS@*/
386 /*@constant int _CS_XBS5_ILP32_OFFBIG_CFLAGS@*/
387 /*@constant int _CS_XBS5_ILP32_OFFBIG_LDFLAGS@*/
388 /*@constant int _CS_XBS5_ILP32_OFFBIG_LIBS@*/
389 /*@constant int _CS_XBS5_ILP32_OFFBIG_LINTFLAGS@*/
390 /*@constant int _CS_XBS5_LP64_OFF64_CFLAGS@*/
391 /*@constant int _CS_XBS5_LP64_OFF64_LDFLAGS@*/
392 /*@constant int _CS_XBS5_LP64_OFF64_LIBS@*/
393 /*@constant int _CS_XBS5_LP64_OFF64_LINTFLAGS@*/
394 /*@constant int _CS_XBS5_LPBIG_OFFBIG_CFLAGS@*/
395 /*@constant int _CS_XBS5_LPBIG_OFFBIG_LDFLAGS@*/
396 /*@constant int _CS_XBS5_LPBIG_OFFBIG_LIBS@*/
397 /*@constant int _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS@*/
400 /* name parameters to sysconf: */
402 /*@constant int _SC_2_C_BIND@*/
403 /*@constant int _SC_2_C_DEV@*/
404 /*@constant int _SC_2_C_VERSION@*/
405 /*@constant int _SC_2_FORT_DEV@*/
406 /*@constant int _SC_2_FORT_RUN@*/
407 /*@constant int _SC_2_LOCALEDEF@*/
408 /*@constant int _SC_2_SW_DEV@*/
409 /*@constant int _SC_2_UPE@*/
410 /*@constant int _SC_2_VERSION@*/
411 /*@constant int _SC_AIO_LISTIO_MAX@*/
412 /*@constant int _SC_AIO_MAX@*/
413 /*@constant int _SC_AIO_PRIO_DELTA_MAX@*/
414 /*@constant int _SC_ASYNCHRONOUS_IO@*/
415 /*@constant int _SC_ATEXIT_MAX@*/
416 /*@constant int _SC_BC_BASE_MAX@*/
417 /*@constant int _SC_BC_DIM_MAX@*/
418 /*@constant int _SC_BC_SCALE_MAX@*/
419 /*@constant int _SC_BC_STRING_MAX@*/
420 /*@constant int _SC_COLL_WEIGHTS_MAX@*/
421 /*@constant int _SC_DELAYTIMER_MAX@*/
422 /*@constant int _SC_EXPR_NEST_MAX@*/
423 /*@constant int _SC_FSYNC@*/
424 /*@constant int _SC_GETGR_R_SIZE_MAX@*/
425 /*@constant int _SC_GETPW_R_SIZE_MAX@*/
426 /*@constant int _SC_IOV_MAX@*/
427 /*@constant int _SC_LINE_MAX@*/
428 /*@constant int _SC_LOGIN_NAME_MAX@*/
429 /*@constant int _SC_MAPPED_FILES@*/
430 /*@constant int _SC_MEMLOCK@*/
431 /*@constant int _SC_MEMLOCK_RANGE@*/
432 /*@constant int _SC_MEMORY_PROTECTION@*/
433 /*@constant int _SC_MESSAGE_PASSING@*/
434 /*@constant int _SC_MQ_OPEN_MAX@*/
435 /*@constant int _SC_MQ_PRIO_MAX@*/
436 /*@constant int _SC_PAGESIZE@*/
437 /*@constant int _SC_PAGE_SIZE@*/
438 /*@constant int _SC_PASS_MAX@*/
439 /*@constant int _SC_PRIORITIZED_IO@*/
440 /*@constant int _SC_PRIORITY_SCHEDULING@*/
441 /*@constant int _SC_RE_DUP_MAX@*/
442 /*@constant int _SC_REALTIME_SIGNALS@*/
443 /*@constant int _SC_RTSIG_MAX@*/
444 /*@constant int _SC_SEMAPHORES@*/
445 /*@constant int _SC_SEM_NSEMS_MAX@*/
446 /*@constant int _SC_SEM_VALUE_MAX@*/
447 /*@constant int _SC_SHARED_MEMORY_OBJECTS@*/
448 /*@constant int _SC_SIGQUEUE_MAX@*/
449 /*@constant int _SC_SYNCHRONIZED_IO@*/
450 /*@constant int _SC_THREADS@*/
451 /*@constant int _SC_THREAD_ATTR_STACKADDR@*/
452 /*@constant int _SC_THREAD_ATTR_STACKSIZE@*/
453 /*@constant int _SC_THREAD_DESTRUCTOR_ITERATIONS@*/
454 /*@constant int _SC_THREAD_KEYS_MAX@*/
455 /*@constant int _SC_THREAD_PRIORITY_SCHEDULING@*/
456 /*@constant int _SC_THREAD_PRIO_INHERIT@*/
457 /*@constant int _SC_THREAD_PRIO_PROTECT@*/
458 /*@constant int _SC_THREAD_PROCESS_SHARED@*/
459 /*@constant int _SC_THREAD_SAFE_FUNCTIONS@*/
460 /*@constant int _SC_THREAD_STACK_MIN@*/
461 /*@constant int _SC_THREAD_THREADS_MAX@*/
462 /*@constant int _SC_TIMERS@*/
463 /*@constant int _SC_TIMER_MAX@*/
464 /*@constant int _SC_TTY_NAME_MAX@*/
465 /*@constant int _SC_XOPEN_VERSION@*/
466 /*@constant int _SC_XOPEN_CRYPT@*/
467 /*@constant int _SC_XOPEN_ENH_I18N@*/
468 /*@constant int _SC_XOPEN_SHM@*/
469 /*@constant int _SC_XOPEN_UNIX@*/
470 /*@constant int _SC_XOPEN_XCU_VERSION@*/
471 /*@constant int _SC_XOPEN_LEGACY@*/
472 /*@constant int _SC_XOPEN_REALTIME@*/
473 /*@constant int _SC_XOPEN_REALTIME_THREADS@*/
474 /*@constant int _SC_XBS5_ILP32_OFF32@*/
475 /*@constant int _SC_XBS5_ILP32_OFFBIG@*/
476 /*@constant int _SC_XBS5_LP64_OFF64@*/
477 /*@constant int _SC_XBS5_LPBIG_OFFBIG@*/
479 int pthread_atfork(void (*)(void), void (*)(void), void(*)(void))
480 /*@modifies errno, fileSystem@*/
481 /*:errorcode !0:*/ ;
482 # endif