X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/2a3f24b83026515b6a9ce54a2ff4fb1eab2fe2f9..210066f9dd04de7d7d2f04d320b39a52f28b290b:/lib/unix.h diff --git a/lib/unix.h b/lib/unix.h index 247bb9a..0cba8d8 100644 --- a/lib/unix.h +++ b/lib/unix.h @@ -60,7 +60,7 @@ typedef /*@integraltype@*/ clockid_t; extern void bcopy (char *b1, /*@out@*/ char *b2, int length) /*@modifies *b2@*/ ; /* Yes, the second parameter is the out param! */ -extern int /*@alt lltX_bool@*/ bcmp (char *b1, char *b2, int length) /*@*/ ; +extern int /*@alt _Bool@*/ bcmp (char *b1, char *b2, int length) /*@*/ ; /* Return value is NOT like strcmp! */ extern void bzero (/*@out@*/ char *b1, int length) /*@modifies *b1@*/ ; @@ -105,10 +105,13 @@ extern /*@null@*/ /*@dependent@*/ char * extern /*@null@*/ /*@dependent@*/ char * rindex (/*@returned@*/ char *s, char c) /*@*/ ; +# if 0 +These are in ISO C99. Moved to standard.h: + extern double cbrt (double x) /*@modifies errno@*/ ; + extern double rint (double x) /*@*/ ; + extern double trunc (double x) /*@*/ ; +# endif -extern double cbrt (double x) /*@modifies errno@*/ ; -extern double rint (double x) /*@*/ ; -extern double trunc (double x) /*@*/ ; /*@constant int ENOTBLK@*/ /*@constant int ETXTBSY@*/ @@ -261,7 +264,6 @@ typedef char *addr_t; typedef long physadr_t; typedef short cnt_t; typedef int chan_t; -typedef unsigned long rlim_t; typedef int paddr_t; typedef void *mid_t; typedef char slab_t[12]; @@ -453,6 +455,7 @@ typedef /*@unsignedintegraltype@*/ sa_family_t; ** (updated 26 May 2002) */ +typedef /*@unsignedintegraltype@*/ __socklen_t; /* not in USB, but needed by linux */ typedef /*@unsignedintegraltype@*/ socklen_t; struct sockaddr { @@ -877,41 +880,17 @@ munlock (caddr_t addr, size_t len) /*@constant int MAXHOSTNAMELEN@*/ - extern void -FD_CLR (int n, fd_set *p) - /*@modifies *p@*/; - - extern void -FD_COPY (fd_set *f, /*@out@*/ fd_set *t) - /*@modifies *t@*/; - - extern int /*@alt lltX_bool@*/ -FD_ISSET (int n, fd_set *p) - /*@*/; - - extern void -FD_SET (int n, fd_set *p) - /*@modifies *p@*/; - - extern void -FD_ZERO (fd_set /*@out@*/ *p) - /*@modifies *p@*/; - - extern int -fchdir (int fd) - /*@modifies internalState, errno@*/; - - extern int -fchown (int fd, uid_t owner, gid_t group) - /*@modifies errno, fileSystem@*/; +extern void FD_CLR (/*@sef@*/ int n, /*@sef@*/ fd_set *p) /*@modifies *p@*/ ; +extern void FD_COPY (/*@sef@*/ fd_set *f, /*@out@*/ fd_set *t) /*@modifies *t@*/ ; +extern int /*@alt _Bool@*/ FD_ISSET (/*@sef@*/ int n, /*@sef@*/ fd_set *p) /*@*/ ; +extern void FD_SET (/*@sef@*/ int n, /*@sef@*/ fd_set *p) /*@modifies *p@*/ ; +extern void FD_ZERO (/*@sef@*/ fd_set /*@out@*/ *p) /*@modifies *p@*/; - extern int -fsync (int fd) - /*@modifies errno, fileSystem@*/; +extern int fchdir (int fd) /*@modifies internalState, errno@*/; +extern int fchown (int fd, uid_t owner, gid_t group) /*@modifies errno, fileSystem@*/; +extern int fsync (int fd) /*@modifies errno, fileSystem@*/; - extern int -ftruncate (int fd, off_t length) - /*@modifies errno, fileSystem@*/; +extern int ftruncate (int fd, off_t length) /*@modifies errno, fileSystem@*/; int gethostname (/*@out@*/ char *address, size_t address_len) /*:errorstatus@*/ @@ -923,33 +902,34 @@ int initgroups (const char *name, int basegid) int lchown (const char *path, uid_t owner, gid_t group) /*@modifies errno, fileSystem@*/; -int select (int mfd, fd_set /*@null@*/ *r, fd_set /*@null@*/ *w, fd_set /*@null@*/ *e, /*@null@*/ struct timeval *t) - /*@modifies *r, *w, *e, *t, errno@*/; - /* evans - 2002-05-26: added null for t, bug reported by Enrico Scholz */ +int select (int mfd, fd_set /*@null@*/ *r, fd_set /*@null@*/ *w, + fd_set /*@null@*/ *e, /*@null@*/ struct timeval *t) + /*@modifies *r, *w, *e, *t, errno@*/; + /* evans - 2002-05-26: added null for t, bug reported by Enrico Scholz */ int setegid (gid_t egid) - /*@modifies errno, internalState@*/; + /*@modifies errno, internalState@*/; int seteuid (uid_t euid) - /*@modifies errno, internalState@*/; + /*@modifies errno, internalState@*/; int setgroups (int ngroups, const gid_t *gidset) - /*@modifies errno, internalState@*/; + /*@modifies errno, internalState@*/; int setregid (gid_t rgid, gid_t egid) - /*@modifies errno, internalState@*/; + /*@modifies errno, internalState@*/; int setreuid (gid_t ruid, gid_t euid) - /*@modifies errno, internalState@*/; + /*@modifies errno, internalState@*/; void sync (void) - /*@modifies fileSystem@*/; + /*@modifies fileSystem@*/; int symlink (const char *path, const char *path2) - /*@modifies fileSystem@*/; + /*@modifies fileSystem@*/; int truncate (const char *name, off_t length) - /*@modifies errno, fileSystem@*/; + /*@modifies errno, fileSystem@*/; /*@constant int EBADRPC@*/ /*@constant int ERPCMISMATCH@*/ @@ -1165,153 +1145,11 @@ extern int shmdt (void *addr) extern int shmget (key_t key, int size, int flag) /*@modifies errno@*/ ; -# if 0 - /* - ** this is in stdio.h! - */ - -/* -** stdio.h -*/ /* -** evans 2001-12-30: added from http://www.opengroup.org/onlinepubs/007908799/xsh/stdio.h.html +** stdio.h - in separte file stdio.h */ -/*@constant unsignedintegraltype BUFSIZ@*/ -/*@constant unsignedintegraltype FILENAME_MAX@*/ -/*@constant unsignedintegraltype FOPEN_MAX@*/ -/*@constant bool _IOFBF@*/ -/*@constant bool _IOLBF@*/ -/*@constant bool _IONBF@*/ -/*@constant unsignedintegraltype L_ctermid@*/ -/*@constant unsignedintegraltype L_cuserid@*/ -/*@constant unsignedintegraltype L_tmpnam@*/ -/*@constant unsignedintegraltype SEEK_CUR@*/ -/*@constant unsignedintegraltype SEEK_END@*/ -/*@constant unsignedintegraltype SEEK_SET@*/ -/*@constant unsignedintegraltype TMP_MAX@*/ - -/* EOF */ -/* NULL */ - -/*@constant observer char *P_tmpdir@*/ - -void clearerr (FILE *s) - /*@modifies s@*/ ; - -/*@dependent@*/ char *ctermid (/*@returned@*/ /*@null@*/ char *) /*@*/ ; - /* Result may be static pointer if parameter is NULL, otherwise is fresh. */ - -char *cuserid (/*@null@*/ /*@returned@*/ char *) - /*@warn legacy "cuserid is obsolete"@*/ /*@*/ ; - -/* fclose in standard.h */ - -/*@null@*/ FILE *fdopen (int, const char *) - /*@modifies errno, fileSystem@*/ ; - -/* feof, ferror fflush, fgetc, fgetpos, fgets - in standard.h */ - -int fileno (/*@notnull@*/ FILE *) - /*:errorcode -1:*/ - /*@modifies errno@*/ ; - -void flockfile (/*@notnull@*/ FILE *f) - /*@modifies f, fileSystem@*/ ; - -int fseeko (FILE *stream, off_t offset, int whence) - /*:errorcode -1:*/ - /*@modifies stream, errno@*/ ; - -off_t ftello(FILE *stream) - /*:errorcode -1:*/ /*@modifies errno*/ ; - -int ftrylockfile(FILE *stream) - /*:errorcode !0:*/ - /*@modifies stream, fileSystem, errno*/ ; - -void funlockfile (FILE *stream) - /*@modifies stream, fileSystem*/ ; - -int getc_unlocked(FILE *stream) - /*@warn multithreaded "getc_unlocked is a thread unsafe version of getc"@*/ - /*@modifies *stream, fileSystem, errno@*/ ; - -int getchar_unlocked (void) - /*@warn multithreaded "getchar_unlocked is a thread unsafe version of getchar"@*/ - /*@globals stdin@*/ - /*@modifies *stdin, fileSystem@*/ ; - -int getopt (int, char * const[], const char) - /*@warn legacy@*/ ; - -int getw (FILE *stream) - /*:errorcode EOF:*/ - /*@modifies fileSystem, *stream, errno@*/ ; - -int pclose(FILE *stream) - /*:errorcode -1:*/ - /*@modifies *stream, errno@*/ ; - -/*@null@*/ FILE *popen (const char *command, const char *mode) - /*:errorcode NULL:*/ - /*@modifies fileSystem, errno@*/ ; - -int putc_unlocked (int, FILE *stream) - /*@warn multithreaded "putc_unlocked is a thread unsafe version of putc"@*/ - /*:errorcode EOF:*/ - /*@modifies fileSystem, *stream, errno@*/ ; - -int putchar_unlocked(int) - /*@warn multithreaded "putchar_unlocked is a thread unsafe version of putchar"@*/ - /*:errorcode EOF:*/ - /*@modifies fileSystem, *stdout, errno@*/ ; - -int putw(int, FILE *stream) - /*:errorcode EOF:*/ - /*@modifies fileSystem, *stdout, errno@*/ ; - -int remove (const char *) - /*@modifies fileSystem@*/ ; - -int rename (const char *, const char *) - /*@modifies fileSystem@*/ ; - -void rewind (FILE *stream) - /*@modifies *stream@*/ ; - -void setbuf (FILE *stream, /*@null@*/ /*@dependent@*/ /*@exposed@*/ char *buf) - /*@modifies stream@*/ - -int setvbuf (FILE *stream, /*@null@*/ /*@dependent@*/ /*@exposed@*/ char *buf, int type, size_t size) - /*@modifies stream@*/ - /*:errorcode !0:*/ ; - -int snprintf (char *s, size_t n, const char *format, ...); - - int sprintf(char *, const char *, ...); - int sscanf(const char *, const char *, int ...); - char *tempnam(const char *, const char *); - FILE *tmpfile(void); - char *tmpnam(char *); - int ungetc(int, FILE *); - int vfprintf(FILE *, const char *, va_list); - int vprintf(const char *, va_list); - int vsnprintf(char *, size_t, const char *, va_list); - int vsprintf(char *, const char *, va_list); - - - The following external variables are defined: - - - extern char *optarg; ) - extern int opterr; ) - extern int optind; ) (LEGACY) - extern int optopt; ) - -# endif - /* ** syslog.h */ @@ -1394,29 +1232,20 @@ setpassent (int stayopen) setpwent (void) /*@modifies internalState@*/; -/*________________________________________________________________________ - * grp.h - */ +/* +** grp.h +*/ - extern void -endgrent (void) - /*@modifies internalState@*/; +void endgrent (void) /*@modifies internalState@*/; - extern /*@null@*/ struct group * -getgrent (void) - /*@modifies internalState@*/; +/*@null@*/ /*@observer@*/ struct group *getgrent (void) + /*@modifies internalState@*/; - extern int -setgrent (void) - /*@modifies internalState@*/; +int setgrent (void) /*@modifies internalState@*/; - extern void -setgrfile (const char *name) - /*@modifies internalState@*/; +void setgrfile (const char *name) /*@modifies internalState@*/; - extern int -setgroupent (int stayopen) - /*@modifies internalState@*/; +int setgroupent (int stayopen) /*@modifies internalState@*/; /* ** sys/stat.h @@ -1492,16 +1321,16 @@ struct stat { /*@constant int UF_APPEND@*/ # endif -int /*@alt lltX_bool@*/ S_ISBLK (/*@sef@*/ mode_t m) /*@*/; -int /*@alt lltX_bool@*/ S_ISCHR (/*@sef@*/ mode_t m) /*@*/; -int /*@alt lltX_bool@*/ S_ISDIR (/*@sef@*/ mode_t m) /*@*/; -int /*@alt lltX_bool@*/ S_ISFIFO (/*@sef@*/ mode_t m) /*@*/; -int /*@alt lltX_bool@*/ S_ISREG (/*@sef@*/ mode_t m) /*@*/; -int /*@alt lltX_bool@*/ S_ISLNK (/*@sef@*/ mode_t m) /*@*/; +int /*@alt _Bool@*/ S_ISBLK (/*@sef@*/ __mode_t m) /*@*/; +int /*@alt _Bool@*/ S_ISCHR (/*@sef@*/ __mode_t m) /*@*/; +int /*@alt _Bool@*/ S_ISDIR (/*@sef@*/ __mode_t m) /*@*/; +int /*@alt _Bool@*/ S_ISFIFO (/*@sef@*/ __mode_t m) /*@*/; +int /*@alt _Bool@*/ S_ISREG (/*@sef@*/ __mode_t m) /*@*/; +int /*@alt _Bool@*/ S_ISLNK (/*@sef@*/ __mode_t m) /*@*/; -int /*@alt lltX_bool@*/ S_TYPEISMQ (/*@sef@*/ struct stat *buf) /*@*/ ; -int /*@alt lltX_bool@*/ S_TYPEISSEM (/*@sef@*/ struct stat *buf) /*@*/ ; -int /*@alt lltX_bool@*/ S_TYPEISSHM (/*@sef@*/ struct stat *buf) /*@*/ ; +int /*@alt _Bool@*/ S_TYPEISMQ (/*@sef@*/ struct stat *buf) /*@*/ ; +int /*@alt _Bool@*/ S_TYPEISSEM (/*@sef@*/ struct stat *buf) /*@*/ ; +int /*@alt _Bool@*/ S_TYPEISSHM (/*@sef@*/ struct stat *buf) /*@*/ ; /* in POSIX: chmod, fstat, mkdir, mkfifo, stat, umask */ @@ -1605,78 +1434,59 @@ putmsg (int fd, const struct strbuf *c, const struct strbuf *d, int *f) extern int putpmsg (int fd, const struct strbuf *c, const struct strbuf *d, int b, int *f) /*@modifies internalState, errno@*/; -/*________________________________________________________________________ - * sys/resource.h - */ +/* +** sys/resource.h +** +** Update 2002-07-09 from +** http://www.opengroup.org/onlinepubs/007904975/basedefs/sys/resource.h.html +*/ -/*@constant int RLIMIT_CPU@*/ -/*@constant int RLIMIT_FSIZE@*/ -/*@constant int RLIMIT_DATA@*/ -/*@constant int RLIMIT_STACK@*/ -/*@constant int RLIMIT_CORE@*/ -/*@constant int RLIMIT_RSS@*/ -/*@constant int RLIMIT_MEMLOCK@*/ -/*@constant int RLIMIT_NPROC@*/ -/*@constant int RLIMIT_NOFILE@*/ -/*@constant int RLIM_NLIMITS@*/ -/*@constant int RLIM_INFINITY@*/ -/*@constant int PRIO_MIN@*/ -/*@constant int PRIO_MAX@*/ /*@constant int PRIO_PROCESS@*/ /*@constant int PRIO_PGRP@*/ /*@constant int PRIO_USER@*/ + +typedef /*@unsignedintegraltype@*/ rlim_t; + +/*@constant rlim_t RLIM_INFINITY@*/ +/*@constant rlim_t RLIM_SAVED_MAX@*/ +/*@constant rlim_t RLIM_SAVED_CUR@*/ + /*@constant int RUSAGE_SELF@*/ /*@constant int RUSAGE_CHILDREN@*/ - struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ - long ru_maxrss; /* max resident set size */ - long ru_ixrss; /* integral shared memory size */ - long ru_idrss; /* integral unshared data " */ - long ru_isrss; /* integral unshared stack " */ - long ru_minflt; /* page reclaims */ - long ru_majflt; /* page faults */ - long ru_nswap; /* swaps */ - long ru_inblock; /* block input operations */ - long ru_oublock; /* block output operations */ - long ru_msgsnd; /* messages sent */ - long ru_msgrcv; /* messages received */ - long ru_nsignals; /* signals received */ - long ru_nvcsw; /* voluntary context switches */ - long ru_nivcsw; /* involuntary " */ -}; - - struct rlimit { - long rlim_cur; - long rlim_max; +struct rlimit { + rlim_t rlim_cur; + rlim_t rlim_max; }; - struct loadavg { - unsigned long ldavg[3]; - long fscale; +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + /* other members optional */ }; - extern int -getpriority (int which, int who) - /*@modifies errno@*/; +/*@constant int RLIMIT_CORE@*/ +/*@constant int RLIMIT_CPU@*/ +/*@constant int RLIMIT_DATA@*/ +/*@constant int RLIMIT_FSIZE@*/ +/*@constant int RLIMIT_NOFILE@*/ +/*@constant int RLIMIT_STACK@*/ +/*@constant int RLIMIT_AS@*/ - extern int -getrlimit (int res, /*@out@*/ struct rlimit *rlp) - /*@modifies *rlp, errno@*/; +int getpriority (int which, id_t who) + /*@modifies errno@*/; - extern int -getrusage (int who, /*@out@*/ struct rusage *rusage) - /*@modifies *rusage, errno@*/; +int getrlimit (int res, /*@out@*/ struct rlimit *rlp) + /*@modifies *rlp, errno@*/; - extern int -setpriority (int which, int who, int prio) - /*@modifies errno, internalState@*/; +int getrusage (int who, /*@out@*/ struct rusage *rusage) + /*@modifies *rusage, errno@*/; - extern int -setrlimit (int resource, const struct rlimit *rlp) - /*@modifies errno, internalState@*/; +int setpriority (int which, id_t who, int prio) + /*@modifies errno, internalState@*/; +int setrlimit (int resource, const struct rlimit *rlp) + /*@modifies errno, internalState@*/; /* ** in @@ -2206,13 +2016,13 @@ int fchroot (int fildes) */ # ifdef STRICT -lltX_bool isascii(int) /*@*/ ; -lltX_bool toascii(int) /*@*/ ; +_Bool isascii(int) /*@*/ ; +_Bool toascii(int) /*@*/ ; char _toupper(/*@sef@*/ int) /*@*/ ; char _tolower(/*@sef@*/ int) /*@*/ ; # else -lltX_bool /*@alt int@*/ isascii(int /*@alt unsigned char@*/) /*@*/ ; -lltX_bool /*@alt int@*/ toascii(int /*@alt unsigned char@*/); +_Bool /*@alt int@*/ isascii(int /*@alt unsigned char@*/) /*@*/ ; +_Bool /*@alt int@*/ toascii(int /*@alt unsigned char@*/); char /*@alt int@*/ _toupper(/*@sef@*/ int /*@alt unsigned char@*/); char /*@alt int@*/ _tolower(/*@sef@*/ int /*@alt unsigned char@*/); # endif