CBMC
float.c
Go to the documentation of this file.
1 /* FUNCTION: _controlfp */
2 
3 #ifdef _WIN32
4 #include <float.h>
5 
6 __CPROVER_thread_local unsigned __CPROVER_fpu_control_word;
7 
8 unsigned int _controlfp(
9  unsigned int new_value,
10  unsigned int mask)
11 {
12  __CPROVER_fpu_control_word=
13  (__CPROVER_fpu_control_word&~mask)|new_value;
14 
15  if((mask&_MCW_RC)!=0)
16  __CPROVER_rounding_mode=(new_value&_MCW_RC)>>8;
17 
18  return __CPROVER_fpu_control_word;
19 }
20 
21 #endif
22 
23 /* FUNCTION: _status87 */
24 
25 #ifdef _WIN32
26 
27 __CPROVER_thread_local unsigned __CPROVER_fpu_control_word;
28 
29 unsigned int _status87(void)
30 {
31  return __CPROVER_fpu_control_word;
32 }
33 
34 #endif
35 
36 /* FUNCTION: _statusfp */
37 
38 #ifdef _WIN32
39 
40 __CPROVER_thread_local unsigned __CPROVER_fpu_control_word;
41 
42 unsigned int _statusfp(void)
43 {
44  return __CPROVER_fpu_control_word;
45 }
46 
47 #endif
48 
49 /* FUNCTION: _statusfp2 */
50 
51 #ifdef _WIN32
52 
53 __CPROVER_thread_local unsigned __CPROVER_fpu_control_word;
54 
55 void _statusfp2(unsigned int *px86, unsigned int *pSSE2)
56 {
57  unsigned SSE2_status;
58  *px86=__CPROVER_fpu_control_word;
59  *pSSE2=SSE2_status; // nondet
60 }
61 
62 #endif
63 
64 /* FUNCTION: _isnan */
65 
66 int _isnan(double x)
67 {
68  return __CPROVER_isnand(x);
69 }
70 
71 /* FUNCTION: __builtin_flt_rounds */
72 
73 extern int __CPROVER_rounding_mode;
74 
76 {
77  // This is a clang builtin for FLT_ROUNDS
78  // The magic numbers are C99 and different from the
79  // x86 encoding that CPROVER uses.
80  return __CPROVER_rounding_mode==0?1: // to nearest
81  __CPROVER_rounding_mode==1?3: // downward
82  __CPROVER_rounding_mode==2?2: // upward
83  __CPROVER_rounding_mode==3?0: // to zero
84  -1;
85 }
86 
87 /* FUNCTION: __flt_rounds */
88 
89 int __builtin_flt_rounds(void);
90 
91 int __flt_rounds(void)
92 {
93  // Spotted on FreeBSD
94  return __builtin_flt_rounds();
95 }
__CPROVER_bool __CPROVER_isnand(double f)
int _isnan(double x)
Definition: float.c:66
int __builtin_flt_rounds(void)
Definition: float.c:75
int __flt_rounds(void)
Definition: float.c:91
int __CPROVER_rounding_mode