2 ** ansi.h --- LCLint Standard C Library
4 ** Process with -DSTRICT to get strict library.
9 /*@+globsimpmodifiesnothing@*/
15 /*@constant int EDOM;@*/
16 /*@constant int ERANGE;@*/
17 /*@constant int EILSEQ;@*/
20 /*@checkedstrict@*/ extern int errno;
22 /*@unchecked@*/ extern int errno;
29 typedef /*@integraltype@*/ ptrdiff_t;
30 typedef /*@unsignedintegraltype@*/ size_t;
31 typedef /*@signedintegraltype@*/ ssize_t;
32 typedef /*@integraltype@*/ wchar_t;
35 ** Added by Amendment 1 to ISO.
38 typedef /*@integraltype@*/ wint_t;
39 typedef /*@abstract@*/ mbstate_t;
41 /*@constant null anytype NULL = 0;@*/
47 /*@constant lltX_bool NDEBUG;@*/
50 extern /*@falseexit@*/ void assert (/*@sef@*/ lltX_bool e)
53 extern /*@falseexit@*/ void assert (/*@sef@*/ lltX_bool /*@alt int@*/ e)
63 extern lltX_bool isalnum (int c) /*@*/ ;
64 extern lltX_bool isalpha (int c) /*@*/ ;
65 extern lltX_bool iscntrl (int c) /*@*/ ;
66 extern lltX_bool isdigit (int c) /*@*/ ;
67 extern lltX_bool isgraph (int c) /*@*/ ;
68 extern lltX_bool islower (int c) /*@*/ ;
69 extern lltX_bool isprint (int c) /*@*/ ;
70 extern lltX_bool ispunct (int c) /*@*/ ;
71 extern lltX_bool isspace (int c) /*@*/ ;
72 extern lltX_bool isupper (int c) /*@*/ ;
73 extern lltX_bool isxdigit (int c) /*@*/ ;
74 extern char tolower (int c) /*@*/ ;
75 extern char toupper (int c) /*@*/ ;
77 extern lltX_bool /*@alt int@*/ isalnum (int /*@alt unsigned char@*/ c) /*@*/ ;
78 extern lltX_bool /*@alt int@*/ isalpha (int /*@alt unsigned char@*/ c) /*@*/ ;
79 extern lltX_bool /*@alt int@*/ iscntrl (int /*@alt unsigned char@*/ c) /*@*/ ;
80 extern lltX_bool /*@alt int@*/ isdigit (int /*@alt unsigned char@*/ c) /*@*/ ;
81 extern lltX_bool /*@alt int@*/ isgraph (int /*@alt unsigned char@*/ c) /*@*/ ;
82 extern lltX_bool /*@alt int@*/ islower (int /*@alt unsigned char@*/ c) /*@*/ ;
83 extern lltX_bool /*@alt int@*/ isprint (int /*@alt unsigned char@*/ c) /*@*/ ;
84 extern lltX_bool /*@alt int@*/ ispunct (int /*@alt unsigned char@*/ c) /*@*/ ;
85 extern lltX_bool /*@alt int@*/ isspace (int /*@alt unsigned char@*/ c) /*@*/ ;
86 extern lltX_bool /*@alt int@*/ isupper (int /*@alt unsigned char@*/ c) /*@*/ ;
87 extern lltX_bool /*@alt int@*/ isxdigit (int /*@alt unsigned char@*/ c) /*@*/ ;
88 extern char /*@alt int@*/ tolower (int /*@alt unsigned char@*/ c) /*@*/ ;
89 extern char /*@alt int@*/ toupper (int /*@alt unsigned char@*/ c) /*@*/ ;
101 char *int_curr_symbol;
102 char *currency_symbol;
103 char *mon_decimal_point;
104 char *mon_thousands_sep;
108 char int_frac_digits;
118 /*@constant int LC_ALL;@*/
119 /*@constant int LC_COLLATE;@*/
120 /*@constant int LC_CTYPE;@*/
121 /*@constant int LC_MONETARY;@*/
122 /*@constant int LC_NUMERIC;@*/
123 /*@constant int LC_TIME;@*/
125 extern /*@observer@*/ /*@null@*/ char *setlocale (int category, /*@null@*/ char *locale)
126 /*@modifies internalState, errno@*/ ;
128 extern struct lconv *localeconv (void) /*@*/ ;
135 ** Note, these are defined by macros, but NOT necessarily
136 ** constants. They may be used as lvalues.
139 /*@unchecked@*/ extern int DBL_DIG;
140 /*@unchecked@*/ extern double DBL_EPSILON;
141 /*@unchecked@*/ extern int DBL_MANT_DIG;
142 /*@unchecked@*/ extern double DBL_MAX;
143 /*@unchecked@*/ extern int DBL_MAX_10_EXP;
144 /*@unchecked@*/ extern int DBL_MAX_EXP;
145 /*@unchecked@*/ extern double DBL_MIN;
146 /*@unchecked@*/ extern int DBL_MIN_10_EXP;
147 /*@unchecked@*/ extern int DBL_MIN_EXP;
149 /*@unchecked@*/ extern int FLT_DIG;
150 /*@unchecked@*/ extern float FLT_EPSILON;
151 /*@unchecked@*/ extern int FLT_MANT_DIG;
152 /*@unchecked@*/ extern float FLT_MAX;
153 /*@unchecked@*/ extern int FLT_MAX_10_EXP;
154 /*@unchecked@*/ extern int FLT_MAX_EXP;
155 /*@unchecked@*/ extern float FLT_MIN;
156 /*@unchecked@*/ extern int FLT_MIN_10_EXP;
157 /*@unchecked@*/ extern int FLT_MIN_EXP;
158 /*@constant int FLT_RADIX@*/
159 /*@unchecked@*/ extern int FLT_ROUNDS;
161 /*@unchecked@*/ extern int LDBL_DIG;
162 /*@unchecked@*/ extern long double LDBL_EPSILON;
163 /*@unchecked@*/ extern int LDBL_MANT_DIG;
164 /*@unchecked@*/ extern long double LDBL_MAX;
165 /*@unchecked@*/ extern int LDBL_MAX_10_EXP;
166 /*@unchecked@*/ extern int LDBL_MAX_EXP;
167 /*@unchecked@*/ extern long double LDBL_MIN;
168 /*@unchecked@*/ extern int LDBL_MIN_10_EXP;
169 /*@unchecked@*/ extern int LDBL_MIN_EXP;
175 /*@constant int CHAR_BIT; @*/
176 /*@constant char CHAR_MAX; @*/
177 /*@constant char CHAR_MIN; @*/
178 /*@constant int INT_MAX; @*/
179 /*@constant int INT_MIN; @*/
180 /*@constant long int LONG_MAX; @*/
181 /*@constant long int LONG_MIN; @*/
182 /*@constant long int MB_LEN_MAX@*/
183 /*@constant signed char SCHAR_MAX; @*/
184 /*@constant signed char SCHAR_MIN; @*/
185 /*@constant short SHRT_MAX; @*/
186 /*@constant short SHRT_MIN; @*/
187 /*@constant unsigned char UCHAR_MAX; @*/
188 /*@constant unsigned char UCHAR_MIN; @*/
189 /*@constant unsigned int UINT_MAX; @*/
190 /*@constant unsigned long ULONG_MAX; @*/
191 /*@constant unsigned short USHRT_MAX; @*/
197 /*@constant double HUGE_VAL; @*/
200 ** math functions that may have a range error modify errno
203 extern double sin (double x) /*@*/ ;
204 extern double cos (double x) /*@*/ ;
205 extern double tan (double x) /*@*/ ;
206 extern double asin (double x) /*@modifies errno@*/ ;
207 extern double acos (double x) /*@modifies errno@*/ ;
208 extern double atan (double x) /*@*/ ;
209 extern double atan2 (double y, double x) /*@*/ ;
210 extern double sinh (double x) /*@*/ ;
211 extern double cosh (double x) /*@modifies errno@*/ ;
212 extern double tanh (double x) /*@*/ ;
214 extern double exp (double x) /*@modifies errno@*/ ;
215 extern double ldexp (double x, int n) /*@modifies errno@*/ ;
216 extern double frexp (double x, /*@out@*/ int *xp) /*@modifies *xp;@*/ ;
218 extern double log (double x) /*@modifies errno@*/ ;
219 extern double log10 (double x) /*@modifies errno@*/ ;
221 extern double pow (double x, double y) /*@modifies errno@*/ ;
222 extern double sqrt (double x) /*@modifies errno@*/ ;
224 extern double ceil (double x) /*@*/ ;
225 extern double floor (double x) /*@*/ ;
226 extern double fabs (double x) /*@*/ ;
228 double modf (double x, /*@out@*/ double *ip) /*@modifies *ip;@*/ ;
229 double fmod (double x, double y) /*@*/ ;
232 ** These functions are optional in iso C. An implementation does not
233 ** have to provide them. They are included in comments here, but
234 ** are not required to be part of the standard library.
237 # ifdef OPTIONAL_MATH
239 extern float acosf (float x) /*@modifies errno@*/ ;
240 extern long double acosl (long double x) /*@modifies errno@*/ ;
241 extern float asinf (float x) /*@modifies errno@*/ ;
242 extern long double asinl (long double x) /*@modifies errno@*/ ;
243 extern float atanf (float x) /*@*/ ;
244 extern long double atanl (long double x) /*@*/ ;
245 extern float atan2f (float y, float x) /*@*/ ;
246 extern long double atan2l (long double y, long double x) /*@*/ ;
247 extern float ceilf (float x) /*@*/ ;
248 extern long double ceill (long double x) /*@*/ ;
249 extern float cosf (float x) /*@*/ ;
250 extern long double cosl (long double x) /*@*/ ;
251 extern float coshf (float x) /*@modifies errno@*/ ;
252 extern long double coshl (long double x) /*@modifies errno@*/ ;
253 extern float expf (float x) /*@modifies errno@*/ ;
254 extern long double expl (long double x) /*@modifies errno@*/;
255 extern float fabsf (float x) /*@*/ ;
256 extern long double fabsl (long double x) /*@*/ ;
257 extern float floorf (float x) /*@*/ ;
258 extern long double floorl (long double x) /*@*/ ;
259 extern float fmodf (float x, float y) /*@*/ ;
260 extern long double fmodl (long double x, long double y) /*@*/ ;
261 extern float frexpf (float x, /*@out@*/ int *xp) /*@modifies *xp@*/;
262 extern long double frexpl (long double x, /*@out@*/ int *xp) /*@modifies *xp@*/;
263 extern float ldexpf (float x, int n) /*@modifies errno@*/ ;
264 extern long double ldexpl (long double x, int n) /*@modifies errno@*/ ;
265 extern float logf (float x) /*@modifies errno@*/ ;
266 extern long double logl (long double x) /*@modifies errno@*/ ;
267 extern float log10f (float x) /*@modifies errno@*/;
268 extern long double log10l (long double x) /*@modifies errno@*/;
269 extern float modff (float x, /*@out@*/ float *xp) /*@modifies *xp@*/ ;
270 extern long double modfl (long double x, /*@out@*/ long double *xp) /*@modifies *xp@*/ ;
271 extern float powf (float x, float y) /*@modifies errno@*/ ;
272 extern long double powl (long double x, long double y) /*@modifies errno@*/ ;
273 extern float sinf (float x) /*@*/ ;
274 extern long double sinl (long double x) /*@*/ ;
275 extern float sinhf (float x) /*@*/ ;
276 extern long double sinhl (long double x) /*@*/ ;
277 extern float sqrtf (float x) /*@modifies errno@*/ ;
278 extern long double sqrtl (long double x) /*@modifies errno@*/ ;
279 extern float tanf (float x) /*@*/ ;
280 extern long double tanl (long double x) /*@*/ ;
281 extern float tanhf (float x) /*@*/ ;
282 extern long double tanhl (long double x) /*@*/ ;
290 typedef /*@abstract@*/ /*@mutable@*/ void *jmp_buf;
292 extern int setjmp (/*@out@*/ jmp_buf env) /*@modifies env;@*/ ;
293 extern /*@mayexit@*/ void longjmp (jmp_buf env, int val) /*@*/ ;
299 /*@constant int SIGABRT; @*/
300 /*@constant int SIGFPE; @*/
301 /*@constant int SIGILL; @*/
302 /*@constant int SIGINT; @*/
303 /*@constant int SIGSEGV; @*/
304 /*@constant int SIGTERM; @*/
306 typedef /*@integraltype@*/ sig_atomic_t;
308 /*@constant void (*SIG_DFL)(int); @*/
309 /*@constant void (*SIG_ERR)(int); @*/
310 /*@constant void (*SIG_IGN)(int); @*/
313 ** signal takes an int, and a function takes int returns void, and
314 ** returns the function (or NULL if unsuccessful).
317 extern /*@null@*/ void (*signal (int sig, /*@null@*/ void (*func)(int))) (int)
318 /*@modifies internalState, errno;@*/ ;
320 extern /*@mayexit@*/ int raise (int sig) ;
326 typedef /*@abstract@*/ /*@mutable@*/ void *va_list;
328 extern void va_start (/*@out@*/ va_list ap, ...) /*@modifies ap;@*/ ;
329 extern void va_end (va_list va) /*@modifies va;@*/ ;
339 typedef /*@abstract@*/ /*@mutable@*/ void *FILE;
340 typedef /*@abstract@*/ /*@mutable@*/ void *fpos_t;
342 /*@constant int _IOFBF; @*/
343 /*@constant int _IOLBF; @*/
344 /*@constant int _IONBF; @*/
346 /*@constant int BUFSIZ; @*/
347 /*@constant int EOF; @*/
349 /*@constant int FOPEN_MAX; @*/
350 /*@constant int FILENAME_MAX; @*/
352 /*@constant int L_tmpnam; @*/
354 /*@constant int SEEK_CUR; @*/
355 /*@constant int SEEK_END; @*/
356 /*@constant int SEEK_SET; @*/
358 /*@constant int TMP_MAX; @*/
361 /*@checked@*/ FILE *stderr;
362 /*@checked@*/ FILE *stdin;
363 /*@checked@*/ FILE *stdout;
365 /*@unchecked@*/ FILE *stderr;
366 /*@unchecked@*/ FILE *stdin;
367 /*@unchecked@*/ FILE *stdout;
370 extern int remove (char *filename) /*@modifies fileSystem, errno@*/ ;
371 extern int rename (char *old, char *new) /*@modifies fileSystem, errno@*/ ;
373 extern /*@null@*/ FILE *tmpfile (void) /*@modifies fileSystem@*/ ;
374 extern /*@observer@*/ char *
375 tmpnam (/*@out@*/ /*@null@*/ /*@returned@*/ char *s)
376 /*@modifies *s, internalState@*/ ;
378 extern int fclose (FILE *stream) /*@modifies *stream, errno, fileSystem;@*/ ;
379 extern int fflush (/*@null@*/ FILE *stream)
380 /*@modifies *stream, errno, fileSystem;@*/ ;
382 extern /*@null@*/ /*@dependent@*/ FILE *fopen (char *filename, char *mode)
383 /*@modifies fileSystem@*/ ;
385 extern /*@null@*/ FILE *freopen (char *filename, char *mode, FILE *stream)
386 /*@modifies *stream, fileSystem, errno@*/ ;
388 extern void setbuf (FILE *stream, /*@null@*/ /*@exposed@*/ char *buf)
389 /*@modifies fileSystem, *stream, *buf@*/ ;
391 extern int setvbuf (FILE *stream, /*@null@*/ /*@exposed@*/ char *buf,
392 int mode, size_t size)
393 /*@modifies fileSystem, *stream, *buf@*/ ;
397 extern int fprintf (FILE *stream, char *format, ...)
398 /*@modifies fileSystem, *stream@*/ ;
401 extern int /*@alt void@*/ fprintf (FILE *stream, char *format, ...)
402 /*@modifies fileSystem, *stream@*/ ;
406 extern int fscanf (FILE *stream, char *format, ...)
407 /*@modifies fileSystem, *stream@*/ ;
411 extern int printf (char *format, ...)
413 /*@modifies fileSystem, *stdout@*/ ;
416 extern int /*@alt void@*/ printf (char *format, ...)
418 /*@modifies fileSystem, *stdout@*/ ;
422 extern int scanf(char *format, ...)
424 /*@modifies fileSystem, *stdin@*/ ;
428 extern int sprintf (/*@out@*/ char *s, char *format, ...)
432 extern int /*@alt void@*/ sprintf (/*@out@*/ char *s, char *format, ...)
437 int sscanf (/*@out@*/ char *s, char *format, ...) /*@*/ ;
438 /* modifies extra arguments */
440 extern int vfprintf (FILE *stream, char *format, va_list arg)
441 /*@modifies fileSystem, *stream, arg, errno@*/ ;
443 extern int vprintf (char *format, va_list arg)
445 /*@modifies fileSystem, arg, *stdout@*/ ;
447 extern int vsprintf (/*@out@*/ char *s, char *format, va_list arg)
448 /*@modifies *s, arg@*/ ;
450 extern int fgetc (FILE *stream)
451 /*@modifies fileSystem, *stream, errno@*/ ;
453 extern /*@null@*/ char *
454 fgets (/*@returned@*/ /*@out@*/ char *s, int n, FILE *stream)
455 /*@modifies fileSystem, *s, *stream, errno@*/
456 /*@requires MaxSet(s) >= (n -1); @*/
457 /*@ensures MaxRead(s) <= (n -1) /\ MaxRead(s) >= 0; @*/
460 extern int fputc (int /*@alt char@*/ c, FILE *stream)
461 /*@modifies fileSystem, *stream, errno@*/ ;
463 extern int fputs (char *s, FILE *stream)
464 /*@modifies fileSystem, *stream@*/ ;
466 /* note use of sef --- stream may be evaluated more than once */
467 extern int getc (/*@sef@*/ FILE *stream)
468 /*@modifies fileSystem, *stream@*/ ;
470 extern int getchar (void) /*@globals stdin@*/ /*@modifies fileSystem, *stdin@*/ ;
472 extern /*@null@*/ char *gets (/*@out@*/ char *s)
473 /*@globals stdin@*/ /*@modifies fileSystem, *s, *stdin, errno@*/ ;
475 extern int putc (int /*@alt char@*/ c, /*@sef@*/ FILE *stream)
476 /*@modifies fileSystem, *stream;@*/ ;
478 extern int putchar (int /*@alt char@*/ c)
479 /*@globals stdout@*/ /*@modifies fileSystem, *stdout@*/ ;
481 extern int puts (const char *s)
482 /*@globals stdout@*/ /*@modifies fileSystem, *stdout@*/ ;
484 extern int ungetc (int /*@alt char@*/ c, FILE *stream)
485 /*@modifies fileSystem, *stream, errno@*/ ;
488 fread (/*@out@*/ void *ptr, size_t size, size_t nobj, FILE *stream)
489 /*@modifies fileSystem, *ptr, *stream, errno@*/ ;
491 extern size_t fwrite (void *ptr, size_t size, size_t nobj, FILE *stream)
492 /*@modifies fileSystem, *stream, errno@*/ ;
494 extern int fgetpos (FILE *stream, /*@out@*/ fpos_t *pos)
495 /*@modifies *pos, errno@*/ ;
497 extern int fseek (FILE *stream, long int offset, int whence)
498 /*@modifies fileSystem, *stream, errno@*/ ;
500 extern int fsetpos (FILE *stream, fpos_t *pos)
501 /*@modifies fileSystem, *stream, errno@*/ ;
503 extern long int ftell(FILE *stream) /*@modifies errno@*/ ;
505 extern void rewind (FILE *stream) /*@modifies *stream@*/ ;
506 extern void clearerr (FILE *stream) /*@modifies *stream@*/ ;
508 extern int feof (FILE *stream) /*@modifies errno@*/ ;
509 extern int ferror (FILE *stream) /*@modifies errno@*/ ;
511 extern void perror (/*@null@*/ char *s)
512 /*@globals errno, stderr@*/ /*@modifies fileSystem, *stderr@*/ ;
518 extern double atof (char *s) /*@*/ ;
519 extern int atoi (char *s) /*@*/ ;
520 extern long int atol (char *s) /*@*/ ;
522 extern double strtod (char *s, /*@null@*/ /*@out@*/ char **endp)
523 /*@modifies *endp, errno@*/ ;
525 extern long strtol (char *s, /*@null@*/ /*@out@*/ char **endp, int base)
526 /*@modifies *endp, errno@*/ ;
529 strtoul (char *s, /*@null@*/ /*@out@*/ char **endp, int base)
530 /*@modifies *endp, errno@*/ ;
532 /*@constant int RAND_MAX; @*/
533 extern int rand (void) /*@modifies internalState@*/ ;
534 extern void srand (unsigned int seed) /*@modifies internalState@*/ ;
541 extern /*@null@*/ /*@only@*/ void *calloc (size_t nobj, size_t size) /*@*/
542 /*@ensures MaxSet(result) == nobj; @*/ ;
543 extern /*@null@*/ /*@out@*/ /*@only@*/ void *malloc (size_t size) /*@*/
544 /*@ensures MaxSet(result) == size; @*/ ;
548 /* 11 June 1997: removed out on return value */
551 extern /*@null@*/ /*@only@*/ void *
552 realloc (/*@null@*/ /*@only@*/ /*@special@*/ void *p,
553 size_t size) /*@releases p@*/ /*@modifies *p@*/ ;
557 ** LCLint annotations cannot fully describe realloc. The semantics we
559 ** realloc returns null: ownership of parameter is not changed
560 ** realloc returns non-null: ownership of parameter is transferred to return value
562 ** Otherwise, storage is in the same state before and after the call.
565 extern /*@null@*/ /*@only@*/ void *
566 realloc (/*@null@*/ /*@only@*/ /*@out@*/ /*@returned@*/ void *p, size_t size)
569 extern void free (/*@null@*/ /*@out@*/ /*@only@*/ void *p) /*@modifies *p@*/ ;
571 /*@constant int EXIT_FAILURE; @*/
572 /*@constant int EXIT_SUCCESS; @*/
574 extern /*@exits@*/ void abort (void) /*@*/ ;
575 extern /*@exits@*/ void exit (int status) /*@*/ ;
576 extern int atexit (void (*func)(void)) /*@modifies internalState@*/ ;
578 extern /*@observer@*/ /*@null@*/ char *getenv (char *name) /*@*/ ;
580 extern int system (/*@null@*/ char *s) /*@modifies fileSystem@*/ ;
582 extern /*@null@*/ /*@dependent@*/ void *
583 bsearch (void *key, void *base,
584 size_t n, size_t size,
585 int (*compar)(void *, void *)) /*@*/ ;
587 extern void qsort (void *base, size_t n, size_t size,
588 int (*compar)(void *, void *))
589 /*@modifies *base, errno@*/ ;
591 extern int abs (int n) /*@*/ ;
593 typedef /*@concrete@*/ struct
599 extern div_t div (int num, int denom) /*@*/ ;
601 extern long int labs (long int n) /*@*/ ;
603 typedef /*@concrete@*/ struct
609 extern ldiv_t ldiv (long num, long denom) /*@*/ ;
611 /*@constant size_t MB_CUR_MAX; @*/
614 ** wchar_t and wint_t functions added by Amendment 1 to ISO.
617 /*@constant int WCHAR_MAX@*/
618 /*@constant int WCHAR_MIN@*/
619 /*@constant wint_t WEOF@*/
621 extern wint_t btowc (int c) /*@*/ ;
623 extern wint_t fgetwc (FILE *fp) /*@modifies fileSystem, *fp*/ ;
625 extern /*@null@*/ wchar_t *fgetws (/*@returned@*/ wchar_t *s, int n, FILE *stream)
626 /*@modifies fileSystem, *s, *stream@*/;
628 extern wint_t fputwc (wchar_t c, FILE *stream)
629 /*@modifies fileSystem, *stream@*/;
631 extern int fputws (const wchar_t *s, FILE *stream)
632 /*@modifies fileSystem, *stream@*/ ;
634 extern int fwide (FILE *stream, int mode) /*@*/ ;
635 /* does not modify the stream */
637 /*@printflike@*/ extern int fwprintf (FILE *stream, const wchar_t *format, ...)
638 /*@modifies *stream, fileSystem@*/ ;
640 /*@scanflike@*/ extern int fwscanf (FILE *stream, const wchar_t *format, ...)
641 /*@modifies *stream, fileSystem@*/ ;
643 /* note use of sef --- stream may be evaluated more than once */
644 extern wint_t getwc (/*@sef@*/ FILE *stream) /*@modifies fileSystem, *stream@*/ ;
646 extern wint_t getwchar (void) /*@modifies fileSystem, *stdin@*/;
648 extern size_t mbrlen (const char *s, size_t n, /*@null@*/ mbstate_t *ps) /*@*/ ;
650 extern size_t mbrtowc (/*@null@*/ wchar_t *pwc, const char *s, size_t n,
651 /*@null@*/ mbstate_t *ps)
652 /*@modifies *pwc@*/ ;
654 extern int mbsinit (/*@null@*/ const mbstate_t *ps) /*@*/ ;
656 extern size_t mbsrtowcs (/*@null@*/ wchar_t *dst, const char **src, size_t len,
657 /*@null@*/ mbstate_t *ps)
658 /*@modifies *dst@*/ ;
660 /* note use of sef --- stream may be evaluated more than once */
661 extern wint_t putwc (wchar_t c, /*@sef@*/ FILE *stream) /*@modifies fileSystem, *stream@*/ ;
663 extern wint_t putwchar (wchar_t c) /*@modifies fileSystem, *stdout@*/ ;
665 /*@printflike@*/ extern int swprintf (wchar_t *s, size_t n, const wchar_t *format, ...)
668 /*@scanflike@*/ extern int swscanf (const wchar_t *s, const wchar_t *format, ...)
669 /*@modifies *stdin@*/ ;
671 extern wint_t ungetwc (wint_t c, FILE *stream) /*@modifies fileSystem, *stream@*/ ;
673 extern int vfwprintf (FILE *stream, const wchar_t *format, va_list arg)
674 /*@modifies fileSystem, *stream@*/ ;
676 extern int vswprintf (wchar_t *s, size_t n, const wchar_t *format, va_list arg)
679 extern int vwprintf (const wchar_t *format, va_list arg)
680 /*@modifies fileSystem, *stdout@*/ ;
682 extern size_t wcrtomb (/*@null@*/ /*@out@*/ char *s, wchar_t wc, /*@null@*/ mbstate_t *ps)
685 extern void /*@alt wchar_t *@*/
686 wcscat (/*@unique@*/ /*@returned@*/ /*@out@*/ wchar_t *s1, const wchar_t *s2)
689 extern /*@exposed@*/ /*@null@*/ wchar_t *
690 wcschr (/*@returned@*/ const wchar_t *s, wchar_t c)
693 extern int wcscmp (const wchar_t *s1, const wchar_t *s2) /*@*/ ;
695 extern int wcscoll (const wchar_t *s1, const wchar_t *s2) /*@*/ ;
697 extern void /*@alt wchar_t *@*/
698 wcscpy (/*@unique@*/ /*@out@*/ /*@returned@*/ wchar_t *s1, const wchar_t *s2)
701 extern size_t wcscspn (const wchar_t *s1, const wchar_t *s2) /*@*/ ;
703 extern size_t wcsftime (/*@out@*/ wchar_t *s, size_t maxsize, const wchar_t *format,
704 const struct tm *timeptr)
707 extern size_t wcslen (const wchar_t *s) /*@*/ ;
709 extern void /*@alt wchar_t *@*/
710 wcsncat (/*@unique@*/ /*@returned@*/ /*@out@*/ wchar_t *s1, const wchar_t *s2,
714 extern int wcsncmp (const wchar_t *s1, const wchar_t *s2, size_t n) /*@*/ ;
716 extern void /*@alt wchar_t *@*/
717 wcsncpy (/*@unique@*/ /*@returned@*/ /*@out@*/ wchar_t *s1, const wchar_t *s2,
721 extern /*@null@*/ wchar_t *
722 wcspbrk (/*@returned@*/ const wchar_t *s1, const wchar_t *s2)
725 extern /*@null@*/ wchar_t *
726 wcsrchr (/*@returned@*/ const wchar_t *s, wchar_t c)
730 wcsrtombs (/*@null@*/ char *dst, const wchar_t **src, size_t len,
731 /*@null@*/ mbstate_t *ps)
732 /*@modifies *src@*/ ;
734 extern size_t wcsspn (const wchar_t *s1, const wchar_t *s2) /*@*/ ;
736 extern /*@null@*/ wchar_t *wcsstr (const wchar_t *s1, const wchar_t *s2) /*@*/ ;
738 extern double wcstod (const wchar_t *nptr, /*@null@*/ wchar_t **endptr)
739 /*@modifies *endptr@*/ ;
741 extern /*@null@*/ wchar_t *
742 wcstok (/*@null@*/ wchar_t *s1, const wchar_t *s2, wchar_t **ptr)
745 extern long wcstol (const wchar_t *nptr, /*@null@*/ wchar_t **endptr, int base)
746 /*@modifies *endptr@*/;
749 wcstoul (const wchar_t *nptr, /*@null@*/ wchar_t **endptr, int base)
750 /*@modifies *endptr@*/;
753 wcsxfrm (/*@null@*/ wchar_t *s1, const wchar_t *s2, size_t n)
756 extern int wctob (wint_t c) /*@*/;
758 extern /*@null@*/ wchar_t *wmemchr (const wchar_t *s, wchar_t c, size_t n) /*@*/ ;
760 extern int wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n) /*@*/ ;
762 extern wchar_t *wmemcpy (/*@returned@*/ wchar_t *s1, const wchar_t *s2, size_t n)
765 extern wchar_t *wmemmove (/*@returned@*/ wchar_t *s1, const wchar_t *s2, size_t n)
768 extern wchar_t *wmemset (/*@returned@*/ wchar_t *s, wchar_t c, size_t n)
771 /*@printflike@*/ extern int wprintf (const wchar_t *format, ...)
772 /*@globals stdout@*/ /*@modifies errno, *stdout@*/;
774 /*@scanflike@*/ extern int
775 wscanf (const wchar_t *format, ...)
776 /*@globals stdin@*/ /*@modifies errno, *stdin@*/;
779 ** wctype.h (added by Amendment 1)
782 /* Warning: not sure about these (maybe abstract?): */
783 typedef /*@integraltype@*/ wctype_t;
784 typedef /*@integraltype@*/ wctrans_t;
787 extern lltX_bool iswalnum (wint_t c) /*@*/ ;
788 extern lltX_bool iswalpha (wint_t c) /*@*/ ;
789 extern lltX_bool iswcntrl (wint_t c) /*@*/ ;
790 extern lltX_bool iswctype (wint_t c, wctype_t ctg) /*@*/ ;
791 extern lltX_bool iswdigit (wint_t c) /*@*/ ;
792 extern lltX_bool iswgraph (wint_t c) /*@*/ ;
793 extern lltX_bool iswlower (wint_t c) /*@*/ ;
794 extern lltX_bool iswprint (wint_t c) /*@*/ ;
795 extern lltX_bool iswpunct (wint_t c) /*@*/ ;
796 extern lltX_bool iswspace (wint_t c) /*@*/ ;
797 extern lltX_bool iswupper (wint_t c) /*@*/ ;
798 extern lltX_bool iswxdigit (wint_t c) /*@*/ ;
800 extern wint_t towctrans (wint_t c, wctrans_t ctg) /*@*/ ;
801 extern wint_t towlower (wint_t c) /*@*/ ;
802 extern wint_t towupper (wint_t c) /*@*/ ;
804 extern lltX_bool /*@alt int@*/ iswalnum (wint_t c) /*@*/ ;
805 extern lltX_bool /*@alt int@*/ iswalpha (wint_t c) /*@*/ ;
806 extern lltX_bool /*@alt int@*/ iswcntrl (wint_t c) /*@*/ ;
807 extern lltX_bool /*@alt int@*/ iswctype (wint_t c, wctype_t ctg) /*@*/ ;
808 extern lltX_bool /*@alt int@*/ iswdigit (wint_t c) /*@*/ ;
809 extern lltX_bool /*@alt int@*/ iswgraph (wint_t c) /*@*/ ;
810 extern lltX_bool /*@alt int@*/ iswlower (wint_t c) /*@*/ ;
811 extern lltX_bool /*@alt int@*/ iswprint (wint_t c) /*@*/ ;
812 extern lltX_bool /*@alt int@*/ iswpunct (wint_t c) /*@*/ ;
813 extern lltX_bool /*@alt int@*/ iswspace (wint_t c) /*@*/ ;
814 extern lltX_bool /*@alt int@*/ iswupper (wint_t c) /*@*/ ;
815 extern lltX_bool /*@alt int@*/ iswxdigit (wint_t c) /*@*/ ;
817 extern wint_t /*@alt int@*/ towctrans (wint_t c, wctrans_t ctg) /*@*/ ;
818 extern wint_t /*@alt int@*/ towlower (wint_t c) /*@*/ ;
819 extern wint_t /*@alt int@*/ towupper (wint_t c) /*@*/ ;
822 extern wctrans_t wctrans (const char *property) /*@*/ ;
823 extern wctype_t wctype (const char *property) /*@*/ ;
825 extern int mblen (char *s, size_t n) /*@*/ ;
826 extern int mbtowc (/*@null@*/ wchar_t *pwc, /*@null@*/ char *s, size_t n)
827 /*@modifies *pwc@*/ ;
828 extern int wctomb (/*@out@*/ /*@null@*/ char *s, wchar_t wchar)
830 extern size_t mbstowcs (/*@out@*/ wchar_t *pwcs, char *s, size_t n)
831 /*@modifies *pwcs@*/ ;
832 extern size_t wcstombs (/*@out@*/ char *s, wchar_t *pwcs, size_t n)
839 extern void /*@alt void * @*/
840 memcpy (/*@unique@*/ /*@returned@*/ /*@out@*/ void *s1, void *s2, size_t n)
842 /*@requires MaxRead(s2) >= n /\ MaxSet(s1) >= n; @*/
845 extern void /*@alt void * @*/
846 memmove (/*@returned@*/ /*@out@*/ void *s1, void *s2, size_t n)
848 /*@requires MaxRead(s2) >= n /\ MaxSet(s1) >= n; @*/
855 /* removed returned */
856 extern void /*@alt char * @*/
857 strcpy (/*@unique@*/ /*@out@*/ /*returned*/ char *s1, char *s2)
858 /*@modifies *s1@*/ /*@requires MaxSet(s1) >= MaxRead(s2) @*/ /*@ensures MaxRead(s1) == MaxRead (s2) /\ MaxRead(result) == MaxRead(s2) /\ MaxSet(result) == MaxSet(s1); @*/;
860 extern void /*@alt char * @*/
861 strncpy (/*@unique@*/ /*@out@*/ /*returned*/ char *s1, char *s2, size_t n)
862 /*@modifies *s1@*/ /*@requires MaxSet(s1) >= ( n - 1 ); @*/ /*@ensures MaxRead (s2) >= MaxRead(s1) /\ MaxRead (s1) <= n; @*/;
864 extern void /*@alt char * @*/
865 strcat (/*@unique@*/ /*returned*/ /*@out@*/ char *s1, char *s2)
866 /*@modifies *s1@*/ /*@requires MaxSet(s1) >= (MaxRead(s1) + MaxRead(s2) ); */ /*ensures MaxRead(result) = (MaxRead(s1) + MaxRead(s2) );@*/;
868 extern void /*@alt char * @*/
869 strncat (/*@unique@*/ /*returned*/ /*@out@*/ char *s1, char *s2, int n)
870 /*@modifies *s1@*/ /*@requires MaxSet(s1) >= ( MaxRead(s1) + n); @*/ /*@ensures MaxRead(result) >= (MaxRead(s1) + n); @*/;
874 extern int memcmp (void *s1, void *s2, size_t n) /*@*/ ;
875 extern int strcmp (char *s1, char *s2) /*@*/ ;
876 extern int strcoll (char *s1, char *s2) /*@*/ ;
877 extern int strncmp (char *s1, char *s2, size_t n) /*@*/ ;
878 extern size_t strxfrm (/*@out@*/ /*@null@*/ char *s1, char *s2, size_t n)
879 /*@modifies *s1@*/ ; /* s1 may be null only if n == 0 */
881 extern /*@null@*/ void *memchr (void *s, int c, size_t n) /*@*/ ;
884 extern /*@exposed@*/ /*@null@*/ char *
885 strchr (char *s, char c) /*@*//*@ensures MaxSet(result) >= 0; MaxSet(result) <= MaxRead(s); MaxRead (result) <= MaxRead(s); MaxRead(result) >= 0; @*/ ;
887 extern /*@exposed@*/ /*@null@*/ char *
888 strchr ( char *s, int /*@alt char@*/ c) /*@*/ /*@ensures MaxSet(result) >= 0 /\ MaxSet(result) <= MaxRead(s) /\ MaxRead (result) <= MaxRead(s) /\ MaxRead(result) >= 0; @*/ ;
891 extern size_t strcspn (char *s1, char *s2) /*@*/ ;
892 extern /*@null@*/ /*@exposed@*/ char *
893 strpbrk (/*@returned@*/ char *s, char *t) /*@*/ ;
896 extern /*@null@*/ /*@exposed@*/ char *
897 strrchr (/*@returned@*/ char *s, char c) /*@*/ /*@ensures MaxSet(result) >= 0 /\ MaxSet(result) <= MaxRead(s) /\ MaxRead (result) <= MaxRead(s) /\ MaxRead(result) >= 0; @*/;
899 extern /*@null@*/ /*@exposed@*/ char *
900 strrchr (/*@returned@*/ char *s, int /*@alt char@*/ c) /*@*/ /*@ensures MaxSet(result) >= 0/\ MaxSet(result) <= MaxRead(s)/\ MaxRead (result) <= MaxRead(s) /\ MaxRead(result) >= 0; @*/;
903 extern size_t strspn (char *s, char *t) /*@*/ ;
905 extern /*@null@*/ /*@exposed@*/ char *
906 strstr (/*@returned@*/ /*@unique@*/ char *s, char *t) /*@*/
907 /*@ensures MaxSet(result) >= 0 /\ MaxSet(result) <= MaxRead(s) /\ MaxRead (result) <= MaxRead(s) /\ MaxRead(result) >= 0; @*/;
909 extern /*@null@*/ /*@exposed@*/ char *
910 strtok (/*@returned@*/ /*@null@*/ char *s, char *t)
911 /*@modifies *s, internalState, errno@*/ ;
913 extern void /*@alt void *@*/ memset (/*@out@*/ /*@returned@*/ void *s,
917 extern /*@observer@*/ char *strerror (int errnum) /*@*/ ;
920 extern size_t strlen (char *s) /*@*/ /*@ensures result == MaxRead(s); @*/;
926 /*@constant int CLOCKS_PER_SEC;@*/
928 typedef /*@integraltype@*/ clock_t;
929 typedef /*@integraltype@*/ time_t;
944 extern clock_t clock (void) /*@modifies internalState@*/ ;
945 extern double difftime (time_t time1, time_t time0) /*@*/ ;
946 extern time_t mktime (struct tm *timeptr) /*@*/ ;
948 extern time_t time (/*@null@*/ /*@out@*/ time_t *tp)
951 extern /*@observer@*/ char *asctime (struct tm *timeptr)
952 /*@modifies errno*/ /*@ensures MaxSet(result) == 25 /\ MaxRead(result) == 25; @*/ ;
954 extern /*@observer@*/ char *ctime (time_t *tp) /*@*/
955 /*@ensures MaxSet(result) == 25 /\ MaxRead(result) == 25; @*/;
957 extern /*@null@*/ /*@observer@*/ struct tm *gmtime (time_t *tp) /*@*/ ;
959 extern /*@null@*/ /*@observer@*/ struct tm *localtime (time_t *tp)
960 /*@modifies errno@*/ ;
962 extern size_t strftime (/*@out@*/ char *s, size_t smax,
963 char *fmt, struct tm *timeptr)