1/*******************************************************************\
5Author: Daniel Kroening, kroening@kroening.com
7\*******************************************************************/
22 std::string
c2cpp(
const std::string &s)
26 result.reserve(s.size());
28 for(std::size_t i=0; i<s.size(); i++)
32 if(
ch==
'_' && std::string(s, i, 5)==
"_Bool")
34 result.append(
"bool");
47 out <<
"#line 1 \"<built-in-additions>\"" <<
'\n';
49 // __CPROVER namespace
50 out <<
"namespace __CPROVER { }" <<
'\n';
53 out <<
"typedef __typeof__(sizeof(int)) __CPROVER::size_t;" <<
'\n';
54 out <<
"typedef __CPROVER::size_t " CPROVER_PREFIX "size_t;" <<
'\n';
57 <<
" __CPROVER::ssize_t;" <<
'\n';
58 out <<
"typedef __CPROVER::ssize_t " CPROVER_PREFIX "ssize_t;" <<
'\n';
60 // new and delete are in the root namespace!
61 out <<
"void operator delete(void *);" <<
'\n';
62 out <<
"void *operator new(__CPROVER::size_t);" <<
'\n';
64 out <<
"extern \"C\" {" <<
'\n';
67 out <<
"const unsigned __CPROVER::constant_infinity_uint;" <<
'\n';
78 // auxiliaries for new/delete
79 out <<
"void *__new(__CPROVER::size_t);" <<
'\n';
80 out <<
"void *__new_array(__CPROVER::size_t, __CPROVER::size_t);" <<
'\n';
81 out <<
"void *__placement_new(__CPROVER::size_t, void *);" <<
'\n';
82 out <<
"void *__placement_new_array("
83 <<
"__CPROVER::size_t, __CPROVER::size_t, void *);" <<
'\n';
84 out <<
"void __delete(void *);" <<
'\n';
85 out <<
"void __delete_array(void *);" <<
'\n';
88 // TODO: should be thread_local
90 << std::to_string(
config.
ansi_c.rounding_mode) <<
';' <<
'\n';
92 // pipes, write, read, close
96 <<
" short next_avail;\n"
97 <<
" short next_unread;\n"
100 // This function needs to be declared, or otherwise can't be called
101 // by the entry-point construction.
104 // GCC junk stuff, also for CLANG and ARM
117 // https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
118 // For clang, __float128 is a keyword.
119 // For gcc, this is a typedef and not a keyword.
120 // C++ doesn't have _Float128.
126 // https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
127 // For clang, __float128 is a keyword.
128 // For gcc, this is a typedef and not a keyword.
129 // C++ doesn't have _Float128.
131 out <<
"typedef long double __float128;" <<
'\n';
135 // https://patchwork.ozlabs.org/patch/792295/
144 // clang doesn't do __float80
145 // Note that __float80 is a typedef, and not a keyword,
146 // and that C++ doesn't have _Float64x.
151 // On 64-bit systems, gcc has typedefs
152 // __int128_t und __uint128_t -- but not on 32 bit!
155 out <<
"typedef signed __int128 __int128_t;" <<
'\n';
156 out <<
"typedef unsigned __int128 __uint128_t;" <<
'\n';
163 out <<
"typedef struct __va_list {";
164 out <<
"void *__stack;";
165 out <<
"void *__gr_top;";
166 out <<
"void *__vr_top;";
167 out <<
"int __gr_offs;";
168 out <<
"int __vr_offs;";
169 out <<
" } __builtin_va_list;" <<
'\n';
173 out <<
"typedef void ** __builtin_va_list;" <<
'\n';
177 // this is Visual C/C++ only
180 out <<
"int __noop(...);" <<
'\n';
181 out <<
"int __assume(int);" <<
'\n';
192 // string symbols to identify the architecture we have compiled for
197 out <<
'}' <<
'\n';
// end extern "C"
202 // type_info infrastructure -- the standard wants this to be in the
203 // std:: namespace, but MS has it in the root namespace
204 out <<
"class type_info;" <<
'\n';
206 // this is the return type of __uuidof(...),
207 // in the root namespace
208 out <<
"struct _GUID;" <<
'\n';
210 // MS ATL-related stuff
211 out <<
"namespace ATL; " <<
'\n';
212 out <<
"void ATL::AtlThrowImpl(long);" <<
'\n';
213 out <<
"void __stdcall ATL::AtlThrowLastWin32();" <<
'\n';
irep_idt rounding_mode_identifier()
Return the identifier of the program symbol used to store the current rounding mode.
const char gcc_builtin_headers_types[]
const char cw_builtin_headers[]
const char arm_builtin_headers[]
void ansi_c_architecture_strings(std::string &code)
std::string c_type_as_string(const irep_idt &c_type)
signedbv_typet signed_size_type()
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
struct configt::ansi_ct ansi_c
std::string c2cpp(const std::string &s)
void cpp_internal_additions(std::ostream &out)
#define INITIALIZE_FUNCTION