Skip to content

Commit 5295845

Browse files
committed
C library check: use cprover_builtin_library.h
library/cprover.h exists for the sole purpose of syntax-checking the C library using the system's C compiler. The declarations in there, however, did not always match those of the authoritative cprover_builtin_library.h. To avoid this split-brain problem, just include cprover_builtin_library.h after providing a few declarations otherwise generated by ansi_c_internal_additions.cpp.
1 parent 28ae1a4 commit 5295845

File tree

2 files changed

+13
-146
lines changed

2 files changed

+13
-146
lines changed

src/ansi-c/library/cprover.h

+12-146
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************\
22
3-
Module:
3+
Module: C library check
44
55
Author: Daniel Kroening, [email protected]
66
@@ -9,170 +9,36 @@ Author: Daniel Kroening, [email protected]
99
#ifndef CPROVER_ANSI_C_LIBRARY_CPROVER_H
1010
#define CPROVER_ANSI_C_LIBRARY_CPROVER_H
1111

12+
/// \file
13+
/// CPROVER built-in declarations to perform library checks. This file is only
14+
/// used by library_check.sh.
15+
16+
// NOLINTNEXTLINE(readability/identifiers)
1217
typedef __typeof__(sizeof(int)) __CPROVER_size_t;
18+
// NOLINTNEXTLINE(readability/identifiers)
19+
typedef signed long long __CPROVER_ssize_t;
20+
1321
void *__CPROVER_allocate(__CPROVER_size_t size, __CPROVER_bool zero);
1422
extern const void *__CPROVER_deallocated;
1523
extern const void *__CPROVER_new_object;
16-
extern _Bool __CPROVER_malloc_is_new_array;
24+
extern __CPROVER_bool __CPROVER_malloc_is_new_array;
1725
extern const void *__CPROVER_memory_leak;
1826

1927
extern int __CPROVER_malloc_failure_mode;
2028
extern __CPROVER_size_t __CPROVER_max_malloc_size;
21-
extern _Bool __CPROVER_malloc_may_fail;
29+
extern __CPROVER_bool __CPROVER_malloc_may_fail;
2230

2331
// malloc failure modes
2432
extern int __CPROVER_malloc_failure_mode_return_null;
2533
extern int __CPROVER_malloc_failure_mode_assert_then_assume;
2634

27-
void __CPROVER_assume(__CPROVER_bool assumption) __attribute__((__noreturn__));
28-
void __CPROVER_assert(__CPROVER_bool assertion, const char *description);
29-
void __CPROVER_precondition(__CPROVER_bool assertion, const char *description);
30-
void __CPROVER_postcondition(__CPROVER_bool assertion, const char *description);
31-
32-
_Bool __CPROVER_is_zero_string(const void *);
33-
__CPROVER_size_t __CPROVER_zero_string_length(const void *);
34-
__CPROVER_size_t __CPROVER_buffer_size(const void *);
35-
__CPROVER_bool __CPROVER_r_ok();
36-
__CPROVER_bool __CPROVER_w_ok();
37-
__CPROVER_bool __CPROVER_rw_ok();
38-
39-
#if 0
40-
__CPROVER_bool __CPROVER_equal();
41-
__CPROVER_bool __CPROVER_same_object(const void *, const void *);
42-
43-
const unsigned __CPROVER_constant_infinity_uint;
44-
typedef void __CPROVER_integer;
45-
typedef void __CPROVER_rational;
46-
void __CPROVER_initialize(void);
47-
void __CPROVER_cover(__CPROVER_bool condition);
48-
#endif
49-
50-
void __CPROVER_printf(const char *format, ...);
51-
void __CPROVER_input(const char *id, ...);
52-
void __CPROVER_output(const char *id, ...);
53-
54-
// concurrency-related
55-
void __CPROVER_atomic_begin();
56-
void __CPROVER_atomic_end();
57-
void __CPROVER_fence(const char *kind, ...);
58-
#if 0
59-
__CPROVER_thread_local unsigned long __CPROVER_thread_id=0;
60-
__CPROVER_bool __CPROVER_threads_exited[__CPROVER_constant_infinity_uint];
61-
unsigned long __CPROVER_next_thread_id=0;
62-
63-
// traces
64-
void CBMC_trace(int lvl, const char *event, ...);
65-
#endif
66-
67-
// pointers
68-
unsigned __CPROVER_POINTER_OBJECT(const void *p);
69-
signed __CPROVER_POINTER_OFFSET(const void *p);
70-
__CPROVER_bool __CPROVER_DYNAMIC_OBJECT(const void *p);
71-
#if 0
72-
extern unsigned char __CPROVER_memory[__CPROVER_constant_infinity_uint];
73-
void __CPROVER_allocated_memory(
74-
__CPROVER_size_t address, __CPROVER_size_t extent);
75-
76-
// this is ANSI-C
77-
extern __CPROVER_thread_local const char __func__[__CPROVER_constant_infinity_uint];
78-
79-
// this is GCC
80-
extern __CPROVER_thread_local const char __FUNCTION__[__CPROVER_constant_infinity_uint];
81-
extern __CPROVER_thread_local const char __PRETTY_FUNCTION__[__CPROVER_constant_infinity_uint];
82-
#endif
83-
84-
// float stuff
85-
int __CPROVER_fpclassify(int, int, int, int, int, ...);
86-
__CPROVER_bool __CPROVER_isfinite(double f);
87-
__CPROVER_bool __CPROVER_isinf(double f);
88-
__CPROVER_bool __CPROVER_isnormal(double f);
89-
__CPROVER_bool __CPROVER_sign(double f);
90-
__CPROVER_bool __CPROVER_isnanf(float f);
91-
__CPROVER_bool __CPROVER_isnand(double f);
92-
__CPROVER_bool __CPROVER_isnanld(long double f);
93-
__CPROVER_bool __CPROVER_isfinitef(float f);
94-
__CPROVER_bool __CPROVER_isfinited(double f);
95-
__CPROVER_bool __CPROVER_isfiniteld(long double f);
96-
__CPROVER_bool __CPROVER_isinff(float f);
97-
__CPROVER_bool __CPROVER_isinfd(double f);
98-
__CPROVER_bool __CPROVER_isinfld(long double f);
99-
__CPROVER_bool __CPROVER_isnormalf(float f);
100-
__CPROVER_bool __CPROVER_isnormald(double f);
101-
__CPROVER_bool __CPROVER_isnormalld(long double f);
102-
__CPROVER_bool __CPROVER_signf(float f);
103-
__CPROVER_bool __CPROVER_signd(double f);
104-
__CPROVER_bool __CPROVER_signld(long double f);
105-
double __CPROVER_inf(void);
106-
float __CPROVER_inff(void);
107-
long double __CPROVER_infl(void);
108-
//extern int __CPROVER_thread_local __CPROVER_rounding_mode;
109-
int __CPROVER_isgreaterd(double f, double g);
110-
111-
// absolute value
112-
int __CPROVER_abs(int);
113-
long int __CPROVER_labs(long int);
114-
long long int __CPROVER_llabs(long long int);
115-
double __CPROVER_fabs(double);
116-
long double __CPROVER_fabsl(long double);
117-
float __CPROVER_fabsf(float);
118-
119-
// modulo and remainder
120-
double __CPROVER_fmod(double, double);
121-
float __CPROVER_fmodf(float, float);
122-
long double __CPROVER_fmodl(long double, long double);
123-
double __CPROVER_remainder(double, double);
124-
float __CPROVER_remainderf(float, float);
125-
long double __CPROVER_remainderl(long double, long double);
126-
127-
// arrays
128-
//__CPROVER_bool __CPROVER_array_equal(const void *array1, const void *array2);
129-
void __CPROVER_array_copy(const void *dest, const void *src);
130-
void __CPROVER_array_set(const void *dest, ...);
131-
void __CPROVER_array_replace(const void *dest, const void *src);
132-
133-
#if 0
134-
// k-induction
135-
void __CPROVER_k_induction_hint(unsigned min, unsigned max,
136-
unsigned step, unsigned loop_free);
137-
138-
// manual specification of predicates
139-
void __CPROVER_predicate(__CPROVER_bool predicate);
140-
void __CPROVER_parameter_predicates();
141-
void __CPROVER_return_predicates();
142-
#endif
143-
144-
// pipes, write, read, close
14535
struct __CPROVER_pipet {
14636
_Bool widowed;
14737
char data[4];
14838
short next_avail;
14939
short next_unread;
15040
};
151-
#if 0
152-
extern struct __CPROVER_pipet __CPROVER_pipes[__CPROVER_constant_infinity_uint];
153-
// offset to make sure we don't collide with other fds
154-
extern const int __CPROVER_pipe_offset;
155-
extern unsigned __CPROVER_pipe_count;
156-
#endif
157-
158-
void __CPROVER_set_must(const void *, const char *);
159-
void __CPROVER_set_may(const void *, const char *);
160-
void __CPROVER_clear_must(const void *, const char *);
161-
void __CPROVER_clear_may(const void *, const char *);
162-
void __CPROVER_cleanup(const void *, void (*)(void *));
163-
__CPROVER_bool __CPROVER_get_must(const void *, const char *);
164-
__CPROVER_bool __CPROVER_get_may(const void *, const char *);
165-
166-
#define __CPROVER_danger_number_of_ops 1
167-
#define __CPROVER_danger_max_solution_size 1
168-
#define __CPROVER_danger_number_of_vars 1
169-
#define __CPROVER_danger_number_of_consts 1
17041

171-
// detect overflow
172-
__CPROVER_bool __CPROVER_overflow_minus();
173-
__CPROVER_bool __CPROVER_overflow_mult();
174-
__CPROVER_bool __CPROVER_overflow_plus();
175-
__CPROVER_bool __CPROVER_overflow_shl();
176-
__CPROVER_bool __CPROVER_overflow_unary_minus();
42+
#include "../cprover_builtin_headers.h"
17743

17844
#endif // CPROVER_ANSI_C_LIBRARY_CPROVER_H
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
..
12
ansi-c
23
ansi-c/library

0 commit comments

Comments
 (0)