@@ -94,9 +94,15 @@ const char clang_builtin_headers[]=
94
94
#include " clang_builtin_headers.inc"
95
95
; // NOLINT(whitespace/semicolon)
96
96
97
+ const char cprover_builtin_headers[]=
98
+ " # 1 \" cprover_builtin_headers.h\"\n "
99
+ #include " cprover_builtin_headers.inc"
100
+ ; // NOLINT(whitespace/semicolon)
101
+
97
102
const char windows_builtin_headers[]=
98
- " int __noop();\n "
99
- " int __assume(int);\n " ;
103
+ " # 1 \" windows_builtin_headers.h\"\n "
104
+ #include " windows_builtin_headers.inc"
105
+ ; // NOLINT(whitespace/semicolon)
100
106
101
107
static std::string architecture_string (const std::string &value, const char *s)
102
108
{
@@ -114,68 +120,28 @@ static std::string architecture_string(int value, const char *s)
114
120
115
121
void ansi_c_internal_additions (std::string &code)
116
122
{
123
+ // do the built-in types and variables
117
124
code+=
118
125
" # 1 \" <built-in-additions>\"\n "
119
126
" typedef __typeof__(sizeof(int)) __CPROVER_size_t;\n "
120
- " void __CPROVER_assume(__CPROVER_bool assumption);\n "
121
- " void __VERIFIER_assume(__CPROVER_bool assumption);\n "
122
- // NOLINTNEXTLINE(whitespace/line_length)
123
- " void __CPROVER_assert(__CPROVER_bool assertion, const char *description);\n "
124
- // NOLINTNEXTLINE(whitespace/line_length)
125
- " void __CPROVER_precondition(__CPROVER_bool precondition, const char *description);\n "
126
- " void __CPROVER_havoc_object(void *);\n "
127
- " __CPROVER_bool __CPROVER_equal();\n "
128
- " __CPROVER_bool __CPROVER_same_object(const void *, const void *);\n "
129
- " __CPROVER_bool __CPROVER_invalid_pointer(const void *);\n "
130
- " __CPROVER_bool __CPROVER_is_zero_string(const void *);\n "
131
- " __CPROVER_size_t __CPROVER_zero_string_length(const void *);\n "
132
- " __CPROVER_size_t __CPROVER_buffer_size(const void *);\n "
133
-
134
- " __CPROVER_bool __CPROVER_get_flag(const void *, const char *);\n "
135
- " void __CPROVER_set_must(const void *, const char *);\n "
136
- " void __CPROVER_clear_must(const void *, const char *);\n "
137
- " void __CPROVER_set_may(const void *, const char *);\n "
138
- " void __CPROVER_clear_may(const void *, const char *);\n "
139
- " void __CPROVER_cleanup(const void *, const void *);\n "
140
- " __CPROVER_bool __CPROVER_get_must(const void *, const char *);\n "
141
- " __CPROVER_bool __CPROVER_get_may(const void *, const char *);\n "
142
-
143
127
" const unsigned __CPROVER_constant_infinity_uint;\n "
144
128
" typedef void __CPROVER_integer;\n "
145
129
" typedef void __CPROVER_rational;\n "
146
- " void __CPROVER_initialize(void);\n "
147
- " void __CPROVER_input(const char *id, ...);\n "
148
- " void __CPROVER_output(const char *id, ...);\n "
149
- " void __CPROVER_cover(__CPROVER_bool condition);\n "
150
-
151
- // concurrency-related
152
- " void __CPROVER_atomic_begin();\n "
153
- " void __CPROVER_atomic_end();\n "
154
- " void __CPROVER_fence(const char *kind, ...);\n "
155
130
" __CPROVER_thread_local unsigned long __CPROVER_thread_id=0;\n "
156
131
// NOLINTNEXTLINE(whitespace/line_length)
157
132
" __CPROVER_bool __CPROVER_threads_exited[__CPROVER_constant_infinity_uint];\n "
158
133
" unsigned long __CPROVER_next_thread_id=0;\n "
159
-
160
- // traces
161
- " void CBMC_trace(int lvl, const char *event, ...);\n "
162
-
163
- // pointers
164
- " unsigned __CPROVER_POINTER_OBJECT(const void *p);\n "
165
- " signed __CPROVER_POINTER_OFFSET(const void *p);\n "
166
- " __CPROVER_bool __CPROVER_DYNAMIC_OBJECT(const void *p);\n "
167
- " extern unsigned char __CPROVER_memory[__CPROVER_constant_infinity_uint];\n "
168
134
// NOLINTNEXTLINE(whitespace/line_length)
169
- " void __CPROVER_allocated_memory(__CPROVER_size_t address, __CPROVER_size_t extent) ;\n "
135
+ " extern unsigned char __CPROVER_memory[__CPROVER_constant_infinity_uint] ;\n "
170
136
171
137
// malloc
172
- " void *__CPROVER_allocate(__CPROVER_size_t size, __CPROVER_bool zero);\n "
173
138
" const void *__CPROVER_deallocated=0;\n "
174
139
" const void *__CPROVER_dead_object=0;\n "
175
140
" const void *__CPROVER_malloc_object=0;\n "
176
141
" __CPROVER_size_t __CPROVER_malloc_size;\n "
177
142
" __CPROVER_bool __CPROVER_malloc_is_new_array=0;\n " // for C++
178
143
" const void *__CPROVER_memory_leak=0;\n "
144
+ " void *__CPROVER_allocate(__CPROVER_size_t size, __CPROVER_bool zero);\n "
179
145
180
146
// this is ANSI-C
181
147
// NOLINTNEXTLINE(whitespace/line_length)
@@ -188,63 +154,8 @@ void ansi_c_internal_additions(std::string &code)
188
154
" extern __CPROVER_thread_local const char __PRETTY_FUNCTION__[__CPROVER_constant_infinity_uint];\n "
189
155
190
156
// float stuff
191
- " __CPROVER_bool __CPROVER_isnanf(float f);\n "
192
- " __CPROVER_bool __CPROVER_isnand(double f);\n "
193
- " __CPROVER_bool __CPROVER_isnanld(long double f);\n "
194
- " __CPROVER_bool __CPROVER_isfinitef(float f);\n "
195
- " __CPROVER_bool __CPROVER_isfinited(double f);\n "
196
- " __CPROVER_bool __CPROVER_isfiniteld(long double f);\n "
197
- " __CPROVER_bool __CPROVER_isinff(float f);\n "
198
- " __CPROVER_bool __CPROVER_isinfd(double f);\n "
199
- " __CPROVER_bool __CPROVER_isinfld(long double f);\n "
200
- " __CPROVER_bool __CPROVER_isnormalf(float f);\n "
201
- " __CPROVER_bool __CPROVER_isnormald(double f);\n "
202
- " __CPROVER_bool __CPROVER_isnormalld(long double f);\n "
203
- " __CPROVER_bool __CPROVER_signf(float f);\n "
204
- " __CPROVER_bool __CPROVER_signd(double f);\n "
205
- " __CPROVER_bool __CPROVER_signld(long double f);\n "
206
- " double __CPROVER_inf(void);\n "
207
- " float __CPROVER_inff(void);\n "
208
- " long double __CPROVER_infl(void);\n "
209
157
" int __CPROVER_thread_local __CPROVER_rounding_mode=" +
210
158
std::to_string (config.ansi_c .rounding_mode )+" ;\n "
211
- " int __CPROVER_isgreaterf(float f, float g);\n "
212
- " int __CPROVER_isgreaterd(double f, double g);\n "
213
- " int __CPROVER_isgreaterequalf(float f, float g);\n "
214
- " int __CPROVER_isgreaterequald(double f, double g);\n "
215
- " int __CPROVER_islessf(float f, float g);\n "
216
- " int __CPROVER_islessd(double f, double g);\n "
217
- " int __CPROVER_islessequalf(float f, float g);\n "
218
- " int __CPROVER_islessequald(double f, double g);\n "
219
- " int __CPROVER_islessgreaterf(float f, float g);\n "
220
- " int __CPROVER_islessgreaterd(double f, double g);\n "
221
- " int __CPROVER_isunorderedf(float f, float g);\n "
222
- " int __CPROVER_isunorderedd(double f, double g);\n "
223
-
224
- // absolute value
225
- " int __CPROVER_abs(int x);\n "
226
- " long int __CPROVER_labs(long int x);\n "
227
- " long int __CPROVER_llabs(long long int x);\n "
228
- " double __CPROVER_fabs(double x);\n "
229
- " long double __CPROVER_fabsl(long double x);\n "
230
- " float __CPROVER_fabsf(float x);\n "
231
-
232
- // arrays
233
- // NOLINTNEXTLINE(whitespace/line_length)
234
- " __CPROVER_bool __CPROVER_array_equal(const void *array1, const void *array2);\n "
235
- // overwrite all of *dest (possibly using nondet values), even
236
- // if *src is smaller
237
- " void __CPROVER_array_copy(const void *dest, const void *src);\n "
238
- // replace at most size-of-*src bytes in *dest
239
- " void __CPROVER_array_replace(const void *dest, const void *src);\n "
240
- " void __CPROVER_array_set(const void *dest, ...);\n "
241
-
242
- // k-induction
243
- " void __CPROVER_k_induction_hint(unsigned min, unsigned max, "
244
- " unsigned step, unsigned loop_free);\n "
245
-
246
- // format string-related
247
- " int __CPROVER_scanf(const char *, ...);\n "
248
159
249
160
// pipes, write, read, close
250
161
" struct __CPROVER_pipet {\n "
@@ -258,7 +169,10 @@ void ansi_c_internal_additions(std::string &code)
258
169
// offset to make sure we don't collide with other fds
259
170
" extern const int __CPROVER_pipe_offset;\n "
260
171
" unsigned __CPROVER_pipe_count=0;\n "
261
-
172
+ " \n "
173
+ // This function needs to be declared, or otherwise can't be called
174
+ // by the entry-point construction.
175
+ " void __CPROVER_initialize(void);\n "
262
176
" \n " ;
263
177
264
178
// GCC junk stuff, also for CLANG and ARM
0 commit comments