ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
wchar.h
Go to the documentation of this file.
1#ifndef __ESBMC_WCHAR_H
2#define __ESBMC_WCHAR_H
3
4#define __need_size_t
5#define __need_wchar_t
6#define __need_wint_t
7#define __need_NULL
8#include <stddef.h>
9#include <stdarg.h> /* va_list, for vswprintf */
10
11// Conversion state for the multibyte routines. The models below never leave
12// the initial state -- they do not implement a shift encoding -- so a single
13// flag is the whole representation.
14//
15// C11 7.28 has <uchar.h> define mbstate_t too, and the C++ model of <uchar.h>
16// forwards to the C library's copy, so both can reach one translation unit.
17// Honour every libc's guard and set them all, so whichever header comes
18// second stands down.
19//
20// The UCRT has no such guard: corecrt.h typedefs mbstate_t unconditionally,
21// and every unshadowed UCRT header drags corecrt.h in. There is no race to
22// win there, so defer to it -- as headers/corecrt_math.h already does.
23#if __has_include(<corecrt.h>)
24# include <corecrt.h>
25#elif !defined(__mbstate_t_defined) /* glibc */ && \
26 !defined(_MBSTATE_T) /* Darwin */ && \
27 !defined(_MBSTATE_T_DECLARED) /* BSD */ && \
28 !defined(__DEFINED_mbstate_t) /* musl */
29# define __mbstate_t_defined 1
30# define _MBSTATE_T
31# define _MBSTATE_T_DECLARED
32# define __DEFINED_mbstate_t
33typedef struct
34{
36} mbstate_t;
37#endif
38
39#ifndef WEOF
40# define WEOF ((wint_t)-1)
41#endif
42
43// Take the limits from the target. <stdint.h> guards its own copies the same
44// way, so a literal here would win on include order and disagree with wchar_t.
45#ifndef WCHAR_MAX
46# define WCHAR_MAX __WCHAR_MAX__
47#endif
48#ifndef WCHAR_MIN
49# if L'\0' - 1 > 0
50# define WCHAR_MIN (L'\0' + 0)
51# else
52# define WCHAR_MIN (-WCHAR_MAX - 1)
53# endif
54#endif
55
56// Only the routines with a model in library/wchar.c are declared. Declaring a
57// mutating routine without one would be worse than leaving it out: the call
58// would return nondet and write nothing, so a later read of the destination
59// sees stale data and can be proved correct when it is not. Add the rest here
60// alongside their models.
61size_t wcslen(const wchar_t *s);
62int wcscmp(const wchar_t *s1, const wchar_t *s2);
63int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);
64wchar_t *wcscpy(wchar_t *dst, const wchar_t *src);
65wchar_t *wcsncpy(wchar_t *dst, const wchar_t *src, size_t n);
66wchar_t *wcscat(wchar_t *dst, const wchar_t *src);
67wchar_t *wcschr(const wchar_t *s, wchar_t c);
68wchar_t *wcsrchr(const wchar_t *s, wchar_t c);
69int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n);
70wchar_t *wmemcpy(wchar_t *dst, const wchar_t *src, size_t n);
71wchar_t *wmemmove(wchar_t *dst, const wchar_t *src, size_t n);
72wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);
73wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
74int mbsinit(const mbstate_t *ps);
75
76/* C11 7.29.2.3/7.29.2.7. The format is not interpreted: ESBMC's printf
77 * modelling (goto_convertt::do_printf, printf_kindt) covers the narrow family
78 * only, so the models over-approximate by writing nondet wide characters. That
79 * keeps the destination written rather than stale, which is what the rule above
80 * is protecting; a caller needing exact contents wants the narrow snprintf. */
81int swprintf(wchar_t *ws, size_t len, const wchar_t *format, ...);
82int vswprintf(wchar_t *ws, size_t len, const wchar_t *format, va_list arg);
83
84#endif
char * va_list
Definition stdarg.h:21
Definition wchar.h:34
int __count
Definition wchar.h:35
int vswprintf(wchar_t *ws, size_t len, const wchar_t *format, va_list arg)
Definition wchar.c:185
wchar_t * wcscat(wchar_t *dst, const wchar_t *src)
Definition wchar.c:69
wchar_t * wcsncpy(wchar_t *dst, const wchar_t *src, size_t n)
Definition wchar.c:51
wchar_t * wmemset(wchar_t *s, wchar_t c, size_t n)
Definition wchar.c:147
wchar_t * wcscpy(wchar_t *dst, const wchar_t *src)
Definition wchar.c:38
int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
Definition wchar.c:27
wchar_t * wcsrchr(const wchar_t *s, wchar_t c)
Definition wchar.c:97
int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n)
Definition wchar.c:113
size_t wcslen(const wchar_t *s)
Definition wchar.c:7
wchar_t * wmemmove(wchar_t *dst, const wchar_t *src, size_t n)
Definition wchar.c:130
wchar_t * wmemchr(const wchar_t *s, wchar_t c, size_t n)
Definition wchar.c:155
int swprintf(wchar_t *ws, size_t len, const wchar_t *format,...)
Definition wchar.c:197
int wcscmp(const wchar_t *s1, const wchar_t *s2)
Definition wchar.c:16
wchar_t * wcschr(const wchar_t *s, wchar_t c)
Definition wchar.c:83
int mbsinit(const mbstate_t *ps)
Definition wchar.c:164
wchar_t * wmemcpy(wchar_t *dst, const wchar_t *src, size_t n)
Definition wchar.c:122