Skip to content

Commit 2a45e76

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
C model library: implement __stdio_common_vfprintf, __acrt_iob_func
(only for Windows) These functions are used by Visual Studio, which provides an inline implementation of printf (and variants of printf) that boils down to the newly added functions.
1 parent c564b75 commit 2a45e76

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

src/ansi-c/library/stdio.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,3 +1026,64 @@ inline int vasprintf(char **ptr, const char *fmt, va_list ap)
10261026

10271027
return i;
10281028
}
1029+
1030+
/* FUNCTION: __acrt_iob_func */
1031+
1032+
#ifdef _WIN32
1033+
1034+
# ifndef __CPROVER_STDIO_H_INCLUDED
1035+
# include <stdio.h>
1036+
# define __CPROVER_STDIO_H_INCLUDED
1037+
# endif
1038+
1039+
inline FILE *__acrt_iob_func(unsigned fd)
1040+
{
1041+
static FILE stdin_file;
1042+
static FILE stdout_file;
1043+
static FILE stderr_file;
1044+
1045+
switch(fd)
1046+
{
1047+
case 0:
1048+
return &stdin_file;
1049+
case 1:
1050+
return &stdout_file;
1051+
case 2:
1052+
return &stderr_file;
1053+
default:
1054+
return (FILE *)0;
1055+
}
1056+
}
1057+
1058+
#endif
1059+
1060+
/* FUNCTION: __stdio_common_vfprintf */
1061+
1062+
#ifdef _WIN32
1063+
1064+
# ifndef __CPROVER_STDIO_H_INCLUDED
1065+
# include <stdio.h>
1066+
# define __CPROVER_STDIO_H_INCLUDED
1067+
# endif
1068+
1069+
# ifndef __CPROVER_STDARG_H_INCLUDED
1070+
# include <stdarg.h>
1071+
# define __CPROVER_STDARG_H_INCLUDED
1072+
# endif
1073+
1074+
inline int __stdio_common_vfprintf(
1075+
unsigned __int64 options,
1076+
FILE *stream,
1077+
char const *format,
1078+
_locale_t locale,
1079+
va_list args)
1080+
{
1081+
(void)options;
1082+
(void)locale;
1083+
1084+
if(stream == __acrt_iob_func(1))
1085+
__CPROVER_printf(format, args);
1086+
return 0;
1087+
}
1088+
1089+
#endif

0 commit comments

Comments
 (0)