]> andersk Git - splint.git/blame - lib/ansi.h
*** empty log message ***
[splint.git] / lib / ansi.h
CommitLineData
885824d3 1/*
2** ansi.h --- LCLint Standard C Library
3**
4** Process with -DSTRICT to get strict library.
5*/
6
7/*@-nextlinemacros@*/
8/*@+allimponly@*/
9/*@+globsimpmodifiesnothing@*/
10
11/*
12** errno.h
13*/
14
15/*@constant int EDOM;@*/
16/*@constant int ERANGE;@*/
17/*@constant int EILSEQ;@*/
18
19# ifdef STRICT
20/*@checkedstrict@*/ extern int errno;
21# else
22/*@unchecked@*/ extern int errno;
23# endif
24
25/*
26** types
27*/
28
29typedef /*@integraltype@*/ ptrdiff_t;
30typedef /*@unsignedintegraltype@*/ size_t;
31typedef /*@signedintegraltype@*/ ssize_t;
32typedef /*@integraltype@*/ wchar_t;
33
34/*
35** Added by Amendment 1 to ISO.
36*/
37
38typedef /*@integraltype@*/ wint_t;
39typedef /*@abstract@*/ mbstate_t;
40
41/*@constant null anytype NULL = 0;@*/
42
43/*
44** assert.h
45*/
46
47/*@constant lltX_bool NDEBUG;@*/
48
49# ifdef STRICT
50extern /*@falseexit@*/ void assert (/*@sef@*/ lltX_bool e)
51 /*@*/ ;
52# else
53extern /*@falseexit@*/ void assert (/*@sef@*/ lltX_bool /*@alt int@*/ e)
54 /*@*/ ;
55# endif
56
57
58/*
59** ctype.h
60*/
61
62# ifdef STRICT
d249c973 63extern lltX_bool isalnum (int c) /*@*/ ;
64extern lltX_bool isalpha (int c) /*@*/ ;
65extern lltX_bool iscntrl (int c) /*@*/ ;
66extern lltX_bool isdigit (int c) /*@*/ ;
67extern lltX_bool isgraph (int c) /*@*/ ;
68extern lltX_bool islower (int c) /*@*/ ;
69extern lltX_bool isprint (int c) /*@*/ ;
70extern lltX_bool ispunct (int c) /*@*/ ;
71extern lltX_bool isspace (int c) /*@*/ ;
72extern lltX_bool isupper (int c) /*@*/ ;
73extern lltX_bool isxdigit (int c) /*@*/ ;
74extern char tolower (int c) /*@*/ ;
75extern char toupper (int c) /*@*/ ;
885824d3 76# else
d249c973 77extern lltX_bool /*@alt int@*/ isalnum (int /*@alt unsigned char@*/ c) /*@*/ ;
78extern lltX_bool /*@alt int@*/ isalpha (int /*@alt unsigned char@*/ c) /*@*/ ;
79extern lltX_bool /*@alt int@*/ iscntrl (int /*@alt unsigned char@*/ c) /*@*/ ;
80extern lltX_bool /*@alt int@*/ isdigit (int /*@alt unsigned char@*/ c) /*@*/ ;
81extern lltX_bool /*@alt int@*/ isgraph (int /*@alt unsigned char@*/ c) /*@*/ ;
82extern lltX_bool /*@alt int@*/ islower (int /*@alt unsigned char@*/ c) /*@*/ ;
83extern lltX_bool /*@alt int@*/ isprint (int /*@alt unsigned char@*/ c) /*@*/ ;
84extern lltX_bool /*@alt int@*/ ispunct (int /*@alt unsigned char@*/ c) /*@*/ ;
85extern lltX_bool /*@alt int@*/ isspace (int /*@alt unsigned char@*/ c) /*@*/ ;
86extern lltX_bool /*@alt int@*/ isupper (int /*@alt unsigned char@*/ c) /*@*/ ;
87extern lltX_bool /*@alt int@*/ isxdigit (int /*@alt unsigned char@*/ c) /*@*/ ;
88extern char /*@alt int@*/ tolower (int /*@alt unsigned char@*/ c) /*@*/ ;
89extern char /*@alt int@*/ toupper (int /*@alt unsigned char@*/ c) /*@*/ ;
885824d3 90# endif
91
92/*
93** locale.h
94*/
95
96struct lconv
97{
98 char *decimal_point;
99 char *thousands_sep;
100 char *grouping;
101 char *int_curr_symbol;
102 char *currency_symbol;
103 char *mon_decimal_point;
104 char *mon_thousands_sep;
105 char *mon_grouping;
106 char *positive_sign;
107 char *negative_sign;
108 char int_frac_digits;
109 char frac_digits;
110 char p_cs_precedes;
111 char p_sep_by_space;
112 char n_cs_precedes;
113 char n_sep_by_space;
114 char p_sign_posn;
115 char n_sign_posn;
116} ;
117
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;@*/
124
125extern /*@observer@*/ /*@null@*/ char *setlocale (int category, /*@null@*/ char *locale)
126 /*@modifies internalState, errno@*/ ;
127
128extern struct lconv *localeconv (void) /*@*/ ;
129
130/*
131** float.h
132*/
133
134/*
135** Note, these are defined by macros, but NOT necessarily
136** constants. They may be used as lvalues.
137*/
138
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;
148
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;
160
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;
170
171/*
172** limits.h
173*/
174
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; @*/
192
193/*
194** math.h
195*/
196
197/*@constant double HUGE_VAL; @*/
198
199/*
200** math functions that may have a range error modify errno
201*/
202
203extern double sin (double x) /*@*/ ;
204extern double cos (double x) /*@*/ ;
205extern double tan (double x) /*@*/ ;
206extern double asin (double x) /*@modifies errno@*/ ;
207extern double acos (double x) /*@modifies errno@*/ ;
208extern double atan (double x) /*@*/ ;
209extern double atan2 (double y, double x) /*@*/ ;
210extern double sinh (double x) /*@*/ ;
211extern double cosh (double x) /*@modifies errno@*/ ;
212extern double tanh (double x) /*@*/ ;
213
214extern double exp (double x) /*@modifies errno@*/ ;
215extern double ldexp (double x, int n) /*@modifies errno@*/ ;
216extern double frexp (double x, /*@out@*/ int *xp) /*@modifies *xp;@*/ ;
217
218extern double log (double x) /*@modifies errno@*/ ;
219extern double log10 (double x) /*@modifies errno@*/ ;
220
221extern double pow (double x, double y) /*@modifies errno@*/ ;
222extern double sqrt (double x) /*@modifies errno@*/ ;
223
224extern double ceil (double x) /*@*/ ;
225extern double floor (double x) /*@*/ ;
226extern double fabs (double x) /*@*/ ;
227
228double modf (double x, /*@out@*/ double *ip) /*@modifies *ip;@*/ ;
229double fmod (double x, double y) /*@*/ ;
230
231/*
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.
235*/
236
237# ifdef OPTIONAL_MATH
238
239extern float acosf (float x) /*@modifies errno@*/ ;
240extern long double acosl (long double x) /*@modifies errno@*/ ;
241extern float asinf (float x) /*@modifies errno@*/ ;
242extern long double asinl (long double x) /*@modifies errno@*/ ;
243extern float atanf (float x) /*@*/ ;
244extern long double atanl (long double x) /*@*/ ;
245extern float atan2f (float y, float x) /*@*/ ;
246extern long double atan2l (long double y, long double x) /*@*/ ;
247extern float ceilf (float x) /*@*/ ;
248extern long double ceill (long double x) /*@*/ ;
249extern float cosf (float x) /*@*/ ;
250extern long double cosl (long double x) /*@*/ ;
251extern float coshf (float x) /*@modifies errno@*/ ;
252extern long double coshl (long double x) /*@modifies errno@*/ ;
253extern float expf (float x) /*@modifies errno@*/ ;
254extern long double expl (long double x) /*@modifies errno@*/;
255extern float fabsf (float x) /*@*/ ;
256extern long double fabsl (long double x) /*@*/ ;
257extern float floorf (float x) /*@*/ ;
258extern long double floorl (long double x) /*@*/ ;
259extern float fmodf (float x, float y) /*@*/ ;
260extern long double fmodl (long double x, long double y) /*@*/ ;
261extern float frexpf (float x, /*@out@*/ int *xp) /*@modifies *xp@*/;
262extern long double frexpl (long double x, /*@out@*/ int *xp) /*@modifies *xp@*/;
263extern float ldexpf (float x, int n) /*@modifies errno@*/ ;
264extern long double ldexpl (long double x, int n) /*@modifies errno@*/ ;
265extern float logf (float x) /*@modifies errno@*/ ;
266extern long double logl (long double x) /*@modifies errno@*/ ;
267extern float log10f (float x) /*@modifies errno@*/;
268extern long double log10l (long double x) /*@modifies errno@*/;
269extern float modff (float x, /*@out@*/ float *xp) /*@modifies *xp@*/ ;
270extern long double modfl (long double x, /*@out@*/ long double *xp) /*@modifies *xp@*/ ;
271extern float powf (float x, float y) /*@modifies errno@*/ ;
272extern long double powl (long double x, long double y) /*@modifies errno@*/ ;
273extern float sinf (float x) /*@*/ ;
274extern long double sinl (long double x) /*@*/ ;
275extern float sinhf (float x) /*@*/ ;
276extern long double sinhl (long double x) /*@*/ ;
277extern float sqrtf (float x) /*@modifies errno@*/ ;
278extern long double sqrtl (long double x) /*@modifies errno@*/ ;
279extern float tanf (float x) /*@*/ ;
280extern long double tanl (long double x) /*@*/ ;
281extern float tanhf (float x) /*@*/ ;
282extern long double tanhl (long double x) /*@*/ ;
283
284# endif
285
286/*
287** setjmp.h
288*/
289
290typedef /*@abstract@*/ /*@mutable@*/ void *jmp_buf;
291
292extern int setjmp (/*@out@*/ jmp_buf env) /*@modifies env;@*/ ;
293extern /*@mayexit@*/ void longjmp (jmp_buf env, int val) /*@*/ ;
294
295/*
296** signal.h
297*/
298
299/*@constant int SIGABRT; @*/
300/*@constant int SIGFPE; @*/
301/*@constant int SIGILL; @*/
302/*@constant int SIGINT; @*/
303/*@constant int SIGSEGV; @*/
304/*@constant int SIGTERM; @*/
305
306typedef /*@integraltype@*/ sig_atomic_t;
307
308/*@constant void (*SIG_DFL)(int); @*/
309/*@constant void (*SIG_ERR)(int); @*/
310/*@constant void (*SIG_IGN)(int); @*/
311
312/*
313** signal takes an int, and a function takes int returns void, and
314** returns the function (or NULL if unsuccessful).
315*/
316
317extern /*@null@*/ void (*signal (int sig, /*@null@*/ void (*func)(int))) (int)
318 /*@modifies internalState, errno;@*/ ;
319
320extern /*@mayexit@*/ int raise (int sig) ;
321
322/*
323** stdarg.h
324*/
325
326typedef /*@abstract@*/ /*@mutable@*/ void *va_list;
327
328extern void va_start (/*@out@*/ va_list ap, ...) /*@modifies ap;@*/ ;
329extern void va_end (va_list va) /*@modifies va;@*/ ;
330
331/*
332** va_arg is builtin
333*/
334
335/*
336** stdio.h
337*/
338
339typedef /*@abstract@*/ /*@mutable@*/ void *FILE;
340typedef /*@abstract@*/ /*@mutable@*/ void *fpos_t;
341
342/*@constant int _IOFBF; @*/
343/*@constant int _IOLBF; @*/
344/*@constant int _IONBF; @*/
345
346/*@constant int BUFSIZ; @*/
347/*@constant int EOF; @*/
348
349/*@constant int FOPEN_MAX; @*/
350/*@constant int FILENAME_MAX; @*/
351
352/*@constant int L_tmpnam; @*/
353
354/*@constant int SEEK_CUR; @*/
355/*@constant int SEEK_END; @*/
356/*@constant int SEEK_SET; @*/
357
358/*@constant int TMP_MAX; @*/
359
360# ifdef STRICT
361/*@checked@*/ FILE *stderr;
362/*@checked@*/ FILE *stdin;
363/*@checked@*/ FILE *stdout;
364# else
365/*@unchecked@*/ FILE *stderr;
366/*@unchecked@*/ FILE *stdin;
367/*@unchecked@*/ FILE *stdout;
368# endif
369
370extern int remove (char *filename) /*@modifies fileSystem, errno@*/ ;
371extern int rename (char *old, char *new) /*@modifies fileSystem, errno@*/ ;
372
373extern /*@null@*/ FILE *tmpfile (void) /*@modifies fileSystem@*/ ;
374extern /*@observer@*/ char *
375 tmpnam (/*@out@*/ /*@null@*/ /*@returned@*/ char *s)
376 /*@modifies *s, internalState@*/ ;
377
378extern int fclose (FILE *stream) /*@modifies *stream, errno, fileSystem;@*/ ;
379extern int fflush (/*@null@*/ FILE *stream)
380 /*@modifies *stream, errno, fileSystem;@*/ ;
381
382extern /*@null@*/ /*@dependent@*/ FILE *fopen (char *filename, char *mode)
383 /*@modifies fileSystem@*/ ;
384
385extern /*@null@*/ FILE *freopen (char *filename, char *mode, FILE *stream)
386 /*@modifies *stream, fileSystem, errno@*/ ;
387
388extern void setbuf (FILE *stream, /*@null@*/ /*@exposed@*/ char *buf)
389 /*@modifies fileSystem, *stream, *buf@*/ ;
390
391extern int setvbuf (FILE *stream, /*@null@*/ /*@exposed@*/ char *buf,
392 int mode, size_t size)
393 /*@modifies fileSystem, *stream, *buf@*/ ;
394
395# ifdef STRICT
396/*@printflike@*/
397extern int fprintf (FILE *stream, char *format, ...)
398 /*@modifies fileSystem, *stream@*/ ;
399# else
400/*@printflike@*/
401extern int /*@alt void@*/ fprintf (FILE *stream, char *format, ...)
402 /*@modifies fileSystem, *stream@*/ ;
403# endif
404
405/*@scanflike@*/
406extern int fscanf (FILE *stream, char *format, ...)
407 /*@modifies fileSystem, *stream@*/ ;
408
409# ifdef STRICT
410/*@printflike@*/
411extern int printf (char *format, ...)
412 /*@globals stdout@*/
413 /*@modifies fileSystem, *stdout@*/ ;
414# else
415/*@printflike@*/
416extern int /*@alt void@*/ printf (char *format, ...)
417 /*@globals stdout@*/
418 /*@modifies fileSystem, *stdout@*/ ;
419# endif
420
421/*@scanflike@*/
422extern int scanf(char *format, ...)
423 /*@globals stdin@*/
424 /*@modifies fileSystem, *stdin@*/ ;
425
426# ifdef STRICT
427/*@printflike@*/
428extern int sprintf (/*@out@*/ char *s, char *format, ...)
429 /*@modifies *s@*/ ;
430# else
431/*@printflike@*/
432extern int /*@alt void@*/ sprintf (/*@out@*/ char *s, char *format, ...)
433 /*@modifies *s@*/ ;
434# endif
435
436/*@scanflike@*/
437int sscanf (/*@out@*/ char *s, char *format, ...) /*@*/ ;
438 /* modifies extra arguments */
439
440extern int vfprintf (FILE *stream, char *format, va_list arg)
441 /*@modifies fileSystem, *stream, arg, errno@*/ ;
442
443extern int vprintf (char *format, va_list arg)
444 /*@globals stdout@*/
445 /*@modifies fileSystem, arg, *stdout@*/ ;
446
447extern int vsprintf (/*@out@*/ char *s, char *format, va_list arg)
448 /*@modifies *s, arg@*/ ;
449
450extern int fgetc (FILE *stream)
451 /*@modifies fileSystem, *stream, errno@*/ ;
452
453extern /*@null@*/ char *
454 fgets (/*@returned@*/ /*@out@*/ char *s, int n, FILE *stream)
d9a28762 455 /*@modifies fileSystem, *s, *stream, errno@*/
456 /*@requires MaxSet(s) >= (n -1); @*/
457 /*@ensures MaxRead(s) <= (n -1) /\ MaxRead(s) >= 0; @*/
470b7798 458 ;
885824d3 459
460extern int fputc (int /*@alt char@*/ c, FILE *stream)
461 /*@modifies fileSystem, *stream, errno@*/ ;
462
463extern int fputs (char *s, FILE *stream)
464 /*@modifies fileSystem, *stream@*/ ;
465
466/* note use of sef --- stream may be evaluated more than once */
467extern int getc (/*@sef@*/ FILE *stream)
468 /*@modifies fileSystem, *stream@*/ ;
469
470extern int getchar (void) /*@globals stdin@*/ /*@modifies fileSystem, *stdin@*/ ;
471
472extern /*@null@*/ char *gets (/*@out@*/ char *s)
9a8f3010 473 /*@warn bufferoverflowhigh
474 "Use of gets leads to a buffer overflow vulnerability. Use fgets instead."@*/
885824d3 475 /*@globals stdin@*/ /*@modifies fileSystem, *s, *stdin, errno@*/ ;
476
477extern int putc (int /*@alt char@*/ c, /*@sef@*/ FILE *stream)
478 /*@modifies fileSystem, *stream;@*/ ;
479
480extern int putchar (int /*@alt char@*/ c)
481 /*@globals stdout@*/ /*@modifies fileSystem, *stdout@*/ ;
482
483extern int puts (const char *s)
484 /*@globals stdout@*/ /*@modifies fileSystem, *stdout@*/ ;
485
486extern int ungetc (int /*@alt char@*/ c, FILE *stream)
487 /*@modifies fileSystem, *stream, errno@*/ ;
488
489extern size_t
490 fread (/*@out@*/ void *ptr, size_t size, size_t nobj, FILE *stream)
491 /*@modifies fileSystem, *ptr, *stream, errno@*/ ;
492
493extern size_t fwrite (void *ptr, size_t size, size_t nobj, FILE *stream)
494 /*@modifies fileSystem, *stream, errno@*/ ;
495
496extern int fgetpos (FILE *stream, /*@out@*/ fpos_t *pos)
497 /*@modifies *pos, errno@*/ ;
498
499extern int fseek (FILE *stream, long int offset, int whence)
500 /*@modifies fileSystem, *stream, errno@*/ ;
501
502extern int fsetpos (FILE *stream, fpos_t *pos)
503 /*@modifies fileSystem, *stream, errno@*/ ;
504
505extern long int ftell(FILE *stream) /*@modifies errno@*/ ;
506
507extern void rewind (FILE *stream) /*@modifies *stream@*/ ;
508extern void clearerr (FILE *stream) /*@modifies *stream@*/ ;
509
510extern int feof (FILE *stream) /*@modifies errno@*/ ;
511extern int ferror (FILE *stream) /*@modifies errno@*/ ;
512
513extern void perror (/*@null@*/ char *s)
514 /*@globals errno, stderr@*/ /*@modifies fileSystem, *stderr@*/ ;
515
516/*
517** stdlib.h
518*/
519
520extern double atof (char *s) /*@*/ ;
521extern int atoi (char *s) /*@*/ ;
522extern long int atol (char *s) /*@*/ ;
523
524extern double strtod (char *s, /*@null@*/ /*@out@*/ char **endp)
525 /*@modifies *endp, errno@*/ ;
526
527extern long strtol (char *s, /*@null@*/ /*@out@*/ char **endp, int base)
528 /*@modifies *endp, errno@*/ ;
529
530extern unsigned long
531 strtoul (char *s, /*@null@*/ /*@out@*/ char **endp, int base)
532 /*@modifies *endp, errno@*/ ;
533
534/*@constant int RAND_MAX; @*/
535extern int rand (void) /*@modifies internalState@*/ ;
536extern void srand (unsigned int seed) /*@modifies internalState@*/ ;
537
470b7798 538/*
539 drl
540 changed 12/29/2000
541*/
885824d3 542
470b7798 543extern /*@null@*/ /*@only@*/ void *calloc (size_t nobj, size_t size) /*@*/
d9a28762 544 /*@ensures MaxSet(result) == (nobj - 1); @*/ ;
470b7798 545extern /*@null@*/ /*@out@*/ /*@only@*/ void *malloc (size_t size) /*@*/
d9a28762 546 /*@ensures MaxSet(result) == (size - 1); @*/ ;
470b7798 547
548/*end drl changed */
549
885824d3 550/* 11 June 1997: removed out on return value */
551
552# if 0
553extern /*@null@*/ /*@only@*/ void *
554 realloc (/*@null@*/ /*@only@*/ /*@special@*/ void *p,
920a3797 555 size_t size) /*@releases p@*/ /*@modifies *p@*/
d9a28762 556 /*@ensures MaxSet(result) >= (size - 1) @*/;
885824d3 557# endif
558
559/*
560** LCLint annotations cannot fully describe realloc. The semantics we
561** want are:
562** realloc returns null: ownership of parameter is not changed
563** realloc returns non-null: ownership of parameter is transferred to return value
564**
565** Otherwise, storage is in the same state before and after the call.
566*/
567
568extern /*@null@*/ /*@only@*/ void *
569 realloc (/*@null@*/ /*@only@*/ /*@out@*/ /*@returned@*/ void *p, size_t size)
d9a28762 570 /*@modifies *p @*/ /*@ensures MaxSet(result) >= (size - 1) @*/;
885824d3 571
572extern void free (/*@null@*/ /*@out@*/ /*@only@*/ void *p) /*@modifies *p@*/ ;
573
574/*@constant int EXIT_FAILURE; @*/
575/*@constant int EXIT_SUCCESS; @*/
576
577extern /*@exits@*/ void abort (void) /*@*/ ;
578extern /*@exits@*/ void exit (int status) /*@*/ ;
579extern int atexit (void (*func)(void)) /*@modifies internalState@*/ ;
580
581extern /*@observer@*/ /*@null@*/ char *getenv (char *name) /*@*/ ;
582
583extern int system (/*@null@*/ char *s) /*@modifies fileSystem@*/ ;
584
585extern /*@null@*/ /*@dependent@*/ void *
586 bsearch (void *key, void *base,
587 size_t n, size_t size,
588 int (*compar)(void *, void *)) /*@*/ ;
589
590extern void qsort (void *base, size_t n, size_t size,
591 int (*compar)(void *, void *))
592 /*@modifies *base, errno@*/ ;
593
594extern int abs (int n) /*@*/ ;
595
596typedef /*@concrete@*/ struct
597{
598 int quot;
599 int rem;
600} div_t ;
601
602extern div_t div (int num, int denom) /*@*/ ;
603
604extern long int labs (long int n) /*@*/ ;
605
606typedef /*@concrete@*/ struct
607{
608 long int quot;
609 long int rem;
610} ldiv_t ;
611
612extern ldiv_t ldiv (long num, long denom) /*@*/ ;
613
614/*@constant size_t MB_CUR_MAX; @*/
615
616/*
617** wchar_t and wint_t functions added by Amendment 1 to ISO.
618*/
619
620/*@constant int WCHAR_MAX@*/
621/*@constant int WCHAR_MIN@*/
622/*@constant wint_t WEOF@*/
623
624extern wint_t btowc (int c) /*@*/ ;
625
626extern wint_t fgetwc (FILE *fp) /*@modifies fileSystem, *fp*/ ;
627
628extern /*@null@*/ wchar_t *fgetws (/*@returned@*/ wchar_t *s, int n, FILE *stream)
629 /*@modifies fileSystem, *s, *stream@*/;
630
631extern wint_t fputwc (wchar_t c, FILE *stream)
632 /*@modifies fileSystem, *stream@*/;
633
634extern int fputws (const wchar_t *s, FILE *stream)
635 /*@modifies fileSystem, *stream@*/ ;
636
637extern int fwide (FILE *stream, int mode) /*@*/ ;
638 /* does not modify the stream */
639
640/*@printflike@*/ extern int fwprintf (FILE *stream, const wchar_t *format, ...)
641 /*@modifies *stream, fileSystem@*/ ;
642
643/*@scanflike@*/ extern int fwscanf (FILE *stream, const wchar_t *format, ...)
644 /*@modifies *stream, fileSystem@*/ ;
645
646/* note use of sef --- stream may be evaluated more than once */
647extern wint_t getwc (/*@sef@*/ FILE *stream) /*@modifies fileSystem, *stream@*/ ;
648
649extern wint_t getwchar (void) /*@modifies fileSystem, *stdin@*/;
650
651extern size_t mbrlen (const char *s, size_t n, /*@null@*/ mbstate_t *ps) /*@*/ ;
652
653extern size_t mbrtowc (/*@null@*/ wchar_t *pwc, const char *s, size_t n,
654 /*@null@*/ mbstate_t *ps)
655 /*@modifies *pwc@*/ ;
656
657extern int mbsinit (/*@null@*/ const mbstate_t *ps) /*@*/ ;
658
659extern size_t mbsrtowcs (/*@null@*/ wchar_t *dst, const char **src, size_t len,
660 /*@null@*/ mbstate_t *ps)
661 /*@modifies *dst@*/ ;
662
663/* note use of sef --- stream may be evaluated more than once */
664extern wint_t putwc (wchar_t c, /*@sef@*/ FILE *stream) /*@modifies fileSystem, *stream@*/ ;
665
666extern wint_t putwchar (wchar_t c) /*@modifies fileSystem, *stdout@*/ ;
667
668/*@printflike@*/ extern int swprintf (wchar_t *s, size_t n, const wchar_t *format, ...)
669 /*@modifies *s@*/ ;
670
671/*@scanflike@*/ extern int swscanf (const wchar_t *s, const wchar_t *format, ...)
672 /*@modifies *stdin@*/ ;
673
674extern wint_t ungetwc (wint_t c, FILE *stream) /*@modifies fileSystem, *stream@*/ ;
675
676extern int vfwprintf (FILE *stream, const wchar_t *format, va_list arg)
677 /*@modifies fileSystem, *stream@*/ ;
678
679extern int vswprintf (wchar_t *s, size_t n, const wchar_t *format, va_list arg)
680 /*@modifies *s@*/ ;
681
682extern int vwprintf (const wchar_t *format, va_list arg)
683 /*@modifies fileSystem, *stdout@*/ ;
684
685extern size_t wcrtomb (/*@null@*/ /*@out@*/ char *s, wchar_t wc, /*@null@*/ mbstate_t *ps)
686 /*@modifies *s@*/;
687
688extern void /*@alt wchar_t *@*/
689 wcscat (/*@unique@*/ /*@returned@*/ /*@out@*/ wchar_t *s1, const wchar_t *s2)
690 /*@modifies *s1@*/ ;
691
692extern /*@exposed@*/ /*@null@*/ wchar_t *
693 wcschr (/*@returned@*/ const wchar_t *s, wchar_t c)
694 /*@*/ ;
695
696extern int wcscmp (const wchar_t *s1, const wchar_t *s2) /*@*/ ;
697
698extern int wcscoll (const wchar_t *s1, const wchar_t *s2) /*@*/ ;
699
700extern void /*@alt wchar_t *@*/
701 wcscpy (/*@unique@*/ /*@out@*/ /*@returned@*/ wchar_t *s1, const wchar_t *s2)
702 /*@modifies *s1@*/ ;
703
704extern size_t wcscspn (const wchar_t *s1, const wchar_t *s2) /*@*/ ;
705
706extern size_t wcsftime (/*@out@*/ wchar_t *s, size_t maxsize, const wchar_t *format,
707 const struct tm *timeptr)
708 /*@modifies *s@*/ ;
709
710extern size_t wcslen (const wchar_t *s) /*@*/ ;
711
712extern void /*@alt wchar_t *@*/
713 wcsncat (/*@unique@*/ /*@returned@*/ /*@out@*/ wchar_t *s1, const wchar_t *s2,
714 size_t n)
715 /*@modifies *s1@*/ ;
716
717extern int wcsncmp (const wchar_t *s1, const wchar_t *s2, size_t n) /*@*/ ;
718
719extern void /*@alt wchar_t *@*/
720 wcsncpy (/*@unique@*/ /*@returned@*/ /*@out@*/ wchar_t *s1, const wchar_t *s2,
721 size_t n)
722 /*@modifies *s1@*/ ;
723
724extern /*@null@*/ wchar_t *
725 wcspbrk (/*@returned@*/ const wchar_t *s1, const wchar_t *s2)
726 /*@*/ ;
727
728extern /*@null@*/ wchar_t *
729 wcsrchr (/*@returned@*/ const wchar_t *s, wchar_t c)
730 /*@*/ ;
731
732extern size_t
733 wcsrtombs (/*@null@*/ char *dst, const wchar_t **src, size_t len,
734 /*@null@*/ mbstate_t *ps)
735 /*@modifies *src@*/ ;
736
737extern size_t wcsspn (const wchar_t *s1, const wchar_t *s2) /*@*/ ;
738
739extern /*@null@*/ wchar_t *wcsstr (const wchar_t *s1, const wchar_t *s2) /*@*/ ;
740
741extern double wcstod (const wchar_t *nptr, /*@null@*/ wchar_t **endptr)
742 /*@modifies *endptr@*/ ;
743
744extern /*@null@*/ wchar_t *
745 wcstok (/*@null@*/ wchar_t *s1, const wchar_t *s2, wchar_t **ptr)
746 /*@modifies *ptr@*/;
747
748extern long wcstol (const wchar_t *nptr, /*@null@*/ wchar_t **endptr, int base)
749 /*@modifies *endptr@*/;
750
751extern unsigned long
752 wcstoul (const wchar_t *nptr, /*@null@*/ wchar_t **endptr, int base)
753 /*@modifies *endptr@*/;
754
755extern size_t
756 wcsxfrm (/*@null@*/ wchar_t *s1, const wchar_t *s2, size_t n)
757 /*@modifies *s1@*/;
758
759extern int wctob (wint_t c) /*@*/;
760
761extern /*@null@*/ wchar_t *wmemchr (const wchar_t *s, wchar_t c, size_t n) /*@*/ ;
762
763extern int wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n) /*@*/ ;
764
765extern wchar_t *wmemcpy (/*@returned@*/ wchar_t *s1, const wchar_t *s2, size_t n)
766 /*@modifies *s1@*/;
767
768extern wchar_t *wmemmove (/*@returned@*/ wchar_t *s1, const wchar_t *s2, size_t n)
769 /*@modifies *s1@*/;
770
771extern wchar_t *wmemset (/*@returned@*/ wchar_t *s, wchar_t c, size_t n)
772 /*@modifies *s@*/;
773
774/*@printflike@*/ extern int wprintf (const wchar_t *format, ...)
775 /*@globals stdout@*/ /*@modifies errno, *stdout@*/;
776
777/*@scanflike@*/ extern int
778 wscanf (const wchar_t *format, ...)
779 /*@globals stdin@*/ /*@modifies errno, *stdin@*/;
780
781/*
782** wctype.h (added by Amendment 1)
783*/
784
785/* Warning: not sure about these (maybe abstract?): */
786typedef /*@integraltype@*/ wctype_t;
787typedef /*@integraltype@*/ wctrans_t;
788
789# ifdef STRICT
790extern lltX_bool iswalnum (wint_t c) /*@*/ ;
791extern lltX_bool iswalpha (wint_t c) /*@*/ ;
792extern lltX_bool iswcntrl (wint_t c) /*@*/ ;
793extern lltX_bool iswctype (wint_t c, wctype_t ctg) /*@*/ ;
794extern lltX_bool iswdigit (wint_t c) /*@*/ ;
795extern lltX_bool iswgraph (wint_t c) /*@*/ ;
796extern lltX_bool iswlower (wint_t c) /*@*/ ;
797extern lltX_bool iswprint (wint_t c) /*@*/ ;
798extern lltX_bool iswpunct (wint_t c) /*@*/ ;
799extern lltX_bool iswspace (wint_t c) /*@*/ ;
800extern lltX_bool iswupper (wint_t c) /*@*/ ;
801extern lltX_bool iswxdigit (wint_t c) /*@*/ ;
802
803extern wint_t towctrans (wint_t c, wctrans_t ctg) /*@*/ ;
804extern wint_t towlower (wint_t c) /*@*/ ;
805extern wint_t towupper (wint_t c) /*@*/ ;
806# else
807extern lltX_bool /*@alt int@*/ iswalnum (wint_t c) /*@*/ ;
808extern lltX_bool /*@alt int@*/ iswalpha (wint_t c) /*@*/ ;
809extern lltX_bool /*@alt int@*/ iswcntrl (wint_t c) /*@*/ ;
810extern lltX_bool /*@alt int@*/ iswctype (wint_t c, wctype_t ctg) /*@*/ ;
811extern lltX_bool /*@alt int@*/ iswdigit (wint_t c) /*@*/ ;
812extern lltX_bool /*@alt int@*/ iswgraph (wint_t c) /*@*/ ;
813extern lltX_bool /*@alt int@*/ iswlower (wint_t c) /*@*/ ;
814extern lltX_bool /*@alt int@*/ iswprint (wint_t c) /*@*/ ;
815extern lltX_bool /*@alt int@*/ iswpunct (wint_t c) /*@*/ ;
816extern lltX_bool /*@alt int@*/ iswspace (wint_t c) /*@*/ ;
817extern lltX_bool /*@alt int@*/ iswupper (wint_t c) /*@*/ ;
818extern lltX_bool /*@alt int@*/ iswxdigit (wint_t c) /*@*/ ;
819
820extern wint_t /*@alt int@*/ towctrans (wint_t c, wctrans_t ctg) /*@*/ ;
821extern wint_t /*@alt int@*/ towlower (wint_t c) /*@*/ ;
822extern wint_t /*@alt int@*/ towupper (wint_t c) /*@*/ ;
823# endif
824
825extern wctrans_t wctrans (const char *property) /*@*/ ;
826extern wctype_t wctype (const char *property) /*@*/ ;
827
828extern int mblen (char *s, size_t n) /*@*/ ;
829extern int mbtowc (/*@null@*/ wchar_t *pwc, /*@null@*/ char *s, size_t n)
830 /*@modifies *pwc@*/ ;
831extern int wctomb (/*@out@*/ /*@null@*/ char *s, wchar_t wchar)
832 /*@modifies *s@*/ ;
833extern size_t mbstowcs (/*@out@*/ wchar_t *pwcs, char *s, size_t n)
834 /*@modifies *pwcs@*/ ;
835extern size_t wcstombs (/*@out@*/ char *s, wchar_t *pwcs, size_t n)
836 /*@modifies *s@*/ ;
837
838/*
839** string.h
840*/
841
842extern void /*@alt void * @*/
843 memcpy (/*@unique@*/ /*@returned@*/ /*@out@*/ void *s1, void *s2, size_t n)
470b7798 844 /*@modifies *s1@*/
d9a28762 845 /*@requires MaxRead(s2) >= n /\ MaxSet(s1) >= n; @*/
470b7798 846 ;
885824d3 847
848extern void /*@alt void * @*/
849 memmove (/*@returned@*/ /*@out@*/ void *s1, void *s2, size_t n)
470b7798 850 /*@modifies *s1@*/
d9a28762 851 /*@requires MaxRead(s2) >= n /\ MaxSet(s1) >= n; @*/
470b7798 852 ;
853
854
855 /* drl
856 modifed 12/29/2000
857 */
7b1629ab 858
885824d3 859extern void /*@alt char * @*/
9a8f3010 860 strcpy (/*@unique@*/ /*@out@*/ /*@returned@*/ char *s1, char *s2)
346fab44 861 /*@modifies *s1@*/
862 /*@requires MaxSet(s1) >= MaxRead(s2) @*/
863 /*@ensures MaxRead(s1) == MaxRead (s2) /\ MaxRead(result) == MaxRead(s2) /\ MaxSet(result) == MaxSet(s1); @*/;
885824d3 864
865extern void /*@alt char * @*/
9a8f3010 866 strncpy (/*@unique@*/ /*@out@*/ /*@returned@*/ char *s1, char *s2, size_t n)
d9a28762 867 /*@modifies *s1@*/ /*@requires MaxSet(s1) >= ( n - 1 ); @*/ /*@ensures MaxRead (s2) >= MaxRead(s1) /\ MaxRead (s1) <= n; @*/;
885824d3 868
869extern void /*@alt char * @*/
119f0b93 870 strcat (/*@unique@*/ /*@returned@*/ char *s1, char *s2)
d9a28762 871 /*@modifies *s1@*/ /*@requires MaxSet(s1) >= (MaxRead(s1) + MaxRead(s2) );@*/
872 /*@ensures MaxRead(result) == (MaxRead(s1) + MaxRead(s2) );@*/;
885824d3 873
874extern void /*@alt char * @*/
119f0b93 875 strncat (/*@unique@*/ /*@returned@*/ char *s1, char *s2, size_t n)
d9a28762 876 /*@modifies *s1@*/ /*@requires MaxSet(s1) >= ( MaxRead(s1) + n); @*/ /*@ensures MaxRead(result) >= (MaxRead(s1) + n); @*/;
885824d3 877
470b7798 878 /*drl end*/
879
885824d3 880extern int memcmp (void *s1, void *s2, size_t n) /*@*/ ;
881extern int strcmp (char *s1, char *s2) /*@*/ ;
882extern int strcoll (char *s1, char *s2) /*@*/ ;
883extern int strncmp (char *s1, char *s2, size_t n) /*@*/ ;
884extern size_t strxfrm (/*@out@*/ /*@null@*/ char *s1, char *s2, size_t n)
885 /*@modifies *s1@*/ ; /* s1 may be null only if n == 0 */
886
887extern /*@null@*/ void *memchr (void *s, int c, size_t n) /*@*/ ;
888
889# ifdef STRICT
890extern /*@exposed@*/ /*@null@*/ char *
d9a28762 891strchr (char *s, char c) /*@*/ /*@ensures MaxSet(result) >= 0 /\ MaxSet(result) <= MaxSet(s) /\ MaxRead (result) <= MaxRead(s) /\ MaxRead(result) >= 0 @*/ ;
885824d3 892# else
893extern /*@exposed@*/ /*@null@*/ char *
d9a28762 894 strchr ( char *s, int /*@alt char@*/ c) /*@*/ /*@ensures MaxSet(result) >= 0 /\ MaxSet(result) <= MaxSet(s) /\ MaxRead (result) <= MaxRead(s) /\ MaxRead(result) >= 0; @*/ ;
885824d3 895# endif
896
897extern size_t strcspn (char *s1, char *s2) /*@*/ ;
898extern /*@null@*/ /*@exposed@*/ char *
899 strpbrk (/*@returned@*/ char *s, char *t) /*@*/ ;
900
901# ifdef STRICT
902extern /*@null@*/ /*@exposed@*/ char *
d9a28762 903 strrchr (/*@returned@*/ char *s, char c) /*@*/ /*@ensures MaxSet(result) >= 0 /\ MaxSet(result) <= MaxSet(s) /\ MaxRead (result) <= MaxRead(s) /\ MaxRead(result) >= 0 @*/ ;
885824d3 904# else
905extern /*@null@*/ /*@exposed@*/ char *
d9a28762 906 strrchr (/*@returned@*/ char *s, int /*@alt char@*/ c) /*@*/ /*@ensures MaxSet(result) >= 0 /\ MaxSet(result) <= MaxSet(s) /\ MaxRead (result) <= MaxRead(s) /\ MaxRead(result) >= 0 @*/ ;
885824d3 907# endif
908
909extern size_t strspn (char *s, char *t) /*@*/ ;
470b7798 910
885824d3 911extern /*@null@*/ /*@exposed@*/ char *
470b7798 912 strstr (/*@returned@*/ /*@unique@*/ char *s, char *t) /*@*/
d9a28762 913 /*@ensures MaxSet(result) >= 0 /\ MaxSet(result) <= MaxSet(s) /\ MaxRead (result) <= MaxRead(s) /\ MaxRead(result) >= 0 @*/ ;
470b7798 914
885824d3 915extern /*@null@*/ /*@exposed@*/ char *
916 strtok (/*@returned@*/ /*@null@*/ char *s, char *t)
917 /*@modifies *s, internalState, errno@*/ ;
918
919extern void /*@alt void *@*/ memset (/*@out@*/ /*@returned@*/ void *s,
920 int c, size_t n)
d9a28762 921 /*@modifies *s@*/ /*@requires MaxSet(s) >= (n - 1) @*/ /*@ensures MaxRead(s) >= (n - 1) @*/ ;
885824d3 922
923extern /*@observer@*/ char *strerror (int errnum) /*@*/ ;
924
470b7798 925/*drl */
d9a28762 926extern size_t strlen (char *s) /*@*/ /*@ensures result == MaxRead(s); @*/;
885824d3 927
928/*
929** time.h
930*/
931
932/*@constant int CLOCKS_PER_SEC;@*/
933
934typedef /*@integraltype@*/ clock_t;
935typedef /*@integraltype@*/ time_t;
936
937struct tm
938 {
939 int tm_sec;
940 int tm_min;
941 int tm_hour;
942 int tm_mday;
943 int tm_mon;
944 int tm_year;
945 int tm_wday;
946 int tm_yday;
947 int tm_isdst;
948 } ;
949
950extern clock_t clock (void) /*@modifies internalState@*/ ;
951extern double difftime (time_t time1, time_t time0) /*@*/ ;
952extern time_t mktime (struct tm *timeptr) /*@*/ ;
953
954extern time_t time (/*@null@*/ /*@out@*/ time_t *tp)
955 /*@modifies *tp@*/ ;
956
957extern /*@observer@*/ char *asctime (struct tm *timeptr)
d9a28762 958 /*@modifies errno*/ /*@ensures MaxSet(result) == 25 /\ MaxRead(result) == 25; @*/ ;
885824d3 959
470b7798 960extern /*@observer@*/ char *ctime (time_t *tp) /*@*/
d9a28762 961 /*@ensures MaxSet(result) == 25 /\ MaxRead(result) == 25; @*/;
885824d3 962
963extern /*@null@*/ /*@observer@*/ struct tm *gmtime (time_t *tp) /*@*/ ;
964
965extern /*@null@*/ /*@observer@*/ struct tm *localtime (time_t *tp)
966 /*@modifies errno@*/ ;
967
968extern size_t strftime (/*@out@*/ char *s, size_t smax,
969 char *fmt, struct tm *timeptr)
970 /*@modifies *s@*/ ;
This page took 0.201979 seconds and 5 git commands to generate.