ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
stdio.h
Go to the documentation of this file.
1#pragma once
2
3#include <__esbmc/stddefs.h>
4#include <stddef.h> /* size_t, NULL */
5#include <stdarg.h> /* va_list */
6
7/* glibc/Apple expose __int64_t via stdio.h; replicate since our bundled header skips that chain. */
8#ifndef _WIN32
9# if defined(__linux__) && defined(__LP64__)
10typedef long __int64_t;
11# else
12__extension__ typedef long long __int64_t;
13# endif
14#endif
15
17
18/*
19 * Opaque FILE type. Must be a complete type so that sizeof(FILE) compiles
20 * in io.c (e.g. malloc(sizeof(FILE))). The exact layout is irrelevant for
21 * verification — ESBMC never reads its fields.
22 */
23typedef struct __esbmc_file_t
24{
25 unsigned char __dummy[64];
27
28/* Standard streams */
29extern FILE *stdin;
30extern FILE *stdout;
31extern FILE *stderr;
32
33#define EOF (-1)
34#define BUFSIZ 8192
35#define SEEK_SET 0
36#define SEEK_CUR 1
37#define SEEK_END 2
38#define FILENAME_MAX 4096
39#define FOPEN_MAX 16
40#define L_tmpnam 20
41
42/* setvbuf buffering modes, C17 7.21.1 */
43#define _IOFBF 0
44#define _IOLBF 1
45#define _IONBF 2
46
47/* C17 7.21.1: an object type holding a stream's position. Opaque here; only
48 fgetpos/fsetpos consume it. */
49typedef long fpos_t;
50
51/* printf family — plain declarations so ESBMC's do_function_call sees the
52 * base_name "printf" and routes them through symex_printf rather than
53 * leaving them uninterpreted (the Windows SDK expands printf to an inline
54 * calling __stdio_common_vfprintf, which ESBMC has no model for). */
55int printf(const char *__ESBMC_restrict format, ...);
56int fprintf(FILE *__ESBMC_restrict stream, const char *__ESBMC_restrict format,
57 ...);
58int sprintf(char *__ESBMC_restrict str, const char *__ESBMC_restrict format,
59 ...);
61 char *__ESBMC_restrict str,
62 size_t size,
63 const char *__ESBMC_restrict format,
64 ...);
65int dprintf(int fd, const char *__ESBMC_restrict format, ...);
66
67int vprintf(const char *__ESBMC_restrict format, va_list ap);
69 FILE *__ESBMC_restrict stream,
70 const char *__ESBMC_restrict format,
71 va_list ap);
73 char *__ESBMC_restrict str,
74 const char *__ESBMC_restrict format,
75 va_list ap);
77 char *__ESBMC_restrict str,
78 size_t size,
79 const char *__ESBMC_restrict format,
80 va_list ap);
81
82/* scanf family */
83int scanf(const char *__ESBMC_restrict format, ...);
85 FILE *__ESBMC_restrict stream,
86 const char *__ESBMC_restrict format,
87 ...);
89 const char *__ESBMC_restrict str,
90 const char *__ESBMC_restrict format,
91 ...);
92
93/* File operations */
95 const char *__ESBMC_restrict pathname,
96 const char *__ESBMC_restrict mode);
98 const char *__ESBMC_restrict pathname,
99 const char *__ESBMC_restrict mode,
100 FILE *__ESBMC_restrict stream);
101FILE *fdopen(int fd, const char *mode);
102FILE *fmemopen(void *buf, size_t size, const char *mode);
103int fclose(FILE *stream);
104int fflush(FILE *stream);
105size_t fread(
106 void *__ESBMC_restrict ptr,
107 size_t size,
108 size_t nmemb,
109 FILE *__ESBMC_restrict stream);
110size_t fwrite(
111 const void *__ESBMC_restrict ptr,
112 size_t size,
113 size_t nmemb,
114 FILE *__ESBMC_restrict stream);
115int fseek(FILE *stream, long offset, int whence);
116long ftell(FILE *stream);
117void rewind(FILE *stream);
119int fsetpos(FILE *stream, const fpos_t *pos);
120int feof(FILE *stream);
121int ferror(FILE *stream);
122void clearerr(FILE *stream);
123int fileno(FILE *stream);
124int fpurge(FILE *stream);
125
126/* Character I/O */
127int fgetc(FILE *stream);
128int fputc(int c, FILE *stream);
129int getc(FILE *stream);
130int putc(int c, FILE *stream);
131int getchar(void);
132int putchar(int c);
133char *fgets(char *__ESBMC_restrict str, int n, FILE *__ESBMC_restrict stream);
134int fputs(const char *__ESBMC_restrict str, FILE *__ESBMC_restrict stream);
135char *gets(char *str);
136int puts(const char *str);
137int getw(FILE *stream);
138int ungetc(int c, FILE *stream);
139
140/* getline is POSIX.1-2008, which also has <stdio.h> expose ssize_t. Guards
141 * and spelling as in <sys/socket.h>, so including both is not a redefinition. */
142#if !defined(_SSIZE_T_DEFINED) && !defined(__ssize_t_defined) && \
143 !defined(_SSIZE_T)
144#define _SSIZE_T_DEFINED
145#define __ssize_t_defined
146#define _SSIZE_T
147#ifdef __APPLE__
148typedef long ssize_t;
149#else
150typedef __PTRDIFF_TYPE__ ssize_t;
151#endif
152#endif
153
155 char **__ESBMC_restrict lineptr,
156 size_t *__ESBMC_restrict n,
157 FILE *__ESBMC_restrict stream);
158
159/* Misc */
160int remove(const char *pathname);
161int rename(const char *oldpath, const char *newpath);
163char *tmpnam(char *str);
164void perror(const char *s);
167 FILE *__ESBMC_restrict stream,
168 char *__ESBMC_restrict buf,
169 int mode,
170 size_t size);
171
#define __extension__
Definition linux.hpp:86
literalt pos(literalt a)
Definition literal.h:130
char * va_list
Definition stdarg.h:21
#define __ESBMC_C_CPP_END
Definition stddefs.h:9
#define __ESBMC_restrict
Definition stddefs.h:10
#define __ESBMC_C_CPP_BEGIN
Definition stddefs.h:8
int remove(const char *pathname)
__PTRDIFF_TYPE__ ssize_t
Definition stdio.h:150
ssize_t getline(char **__ESBMC_restrict lineptr, size_t *__ESBMC_restrict n, FILE *__ESBMC_restrict stream)
int fputs(const char *__ESBMC_restrict str, FILE *__ESBMC_restrict stream)
FILE * tmpfile(void)
int vfprintf(FILE *__ESBMC_restrict stream, const char *__ESBMC_restrict format, va_list ap)
int puts(const char *str)
Definition io.c:47
char * gets(char *str)
Definition io.c:64
int fprintf(FILE *__ESBMC_restrict stream, const char *__ESBMC_restrict format,...)
char * fgets(char *__ESBMC_restrict str, int n, FILE *__ESBMC_restrict stream)
size_t fread(void *__ESBMC_restrict ptr, size_t size, size_t nmemb, FILE *__ESBMC_restrict stream)
int putc(int c, FILE *stream)
int getchar(void)
Definition io.c:355
int fscanf(FILE *__ESBMC_restrict stream, const char *__ESBMC_restrict format,...)
long fpos_t
Definition stdio.h:49
FILE * fopen(const char *__ESBMC_restrict pathname, const char *__ESBMC_restrict mode)
int ferror(FILE *stream)
Definition io.c:268
int rename(const char *oldpath, const char *newpath)
FILE * freopen(const char *__ESBMC_restrict pathname, const char *__ESBMC_restrict mode, FILE *__ESBMC_restrict stream)
int ungetc(int c, FILE *stream)
char * tmpnam(char *str)
long ftell(FILE *stream)
Definition io.c:379
int dprintf(int fd, const char *__ESBMC_restrict format,...)
int fseek(FILE *stream, long offset, int whence)
Definition io.c:367
int printf(const char *__ESBMC_restrict format,...)
FILE * fmemopen(void *buf, size_t size, const char *mode)
Definition io.c:411
int snprintf(char *__ESBMC_restrict str, size_t size, const char *__ESBMC_restrict format,...)
int getw(FILE *stream)
Definition io.c:361
int fclose(FILE *stream)
Definition io.c:105
int fsetpos(FILE *stream, const fpos_t *pos)
__extension__ typedef long long __int64_t
Definition stdio.h:12
int vsprintf(char *__ESBMC_restrict str, const char *__ESBMC_restrict format, va_list ap)
int vsnprintf(char *__ESBMC_restrict str, size_t size, const char *__ESBMC_restrict format, va_list ap)
int scanf(const char *__ESBMC_restrict format,...)
int feof(FILE *stream)
Definition io.c:261
void rewind(FILE *stream)
Definition io.c:385
int vprintf(const char *__ESBMC_restrict format, va_list ap)
int sprintf(char *__ESBMC_restrict str, const char *__ESBMC_restrict format,...)
size_t fwrite(const void *__ESBMC_restrict ptr, size_t size, size_t nmemb, FILE *__ESBMC_restrict stream)
int fgetpos(FILE *__ESBMC_restrict stream, fpos_t *__ESBMC_restrict pos)
int fgetc(FILE *stream)
Definition io.c:343
void perror(const char *s)
void clearerr(FILE *stream)
int fputc(int c, FILE *stream)
Definition io.c:465
int setvbuf(FILE *__ESBMC_restrict stream, char *__ESBMC_restrict buf, int mode, size_t size)
FILE * stdout
FILE * stderr
FILE * stdin
int getc(FILE *stream)
Definition io.c:349
int fflush(FILE *stream)
Definition io.c:307
void setbuf(FILE *__ESBMC_restrict stream, char *__ESBMC_restrict buf)
__ESBMC_C_CPP_BEGIN struct __esbmc_file_t FILE
int putchar(int c)
Definition io.c:39
int fpurge(FILE *stream)
Definition io.c:315
int fileno(FILE *stream)
Definition io.c:274
FILE * fdopen(int fd, const char *mode)
Definition io.c:121
int sscanf(const char *__ESBMC_restrict str, const char *__ESBMC_restrict format,...)
Definition stdio.h:24
unsigned char __dummy[64]
Definition stdio.h:25