11/* FUNCTION: abs */
22
3+ #ifndef __CPROVER_LIMITS_H_INCLUDED
4+ # include <limits.h>
5+ # define __CPROVER_LIMITS_H_INCLUDED
6+ #endif
7+
38#undef abs
49
510int abs (int i )
611{
12+ // C99 Section 7.20.6.1:
13+ // "If the result cannot be represented, the behavior is undefined."
14+ __CPROVER_precondition (i != INT_MIN , "argument to abs must not be INT_MIN" );
715 return __CPROVER_abs (i );
816}
917
1018/* FUNCTION: labs */
1119
20+ #ifndef __CPROVER_LIMITS_H_INCLUDED
21+ # include <limits.h>
22+ # define __CPROVER_LIMITS_H_INCLUDED
23+ #endif
24+
1225#undef labs
1326
1427long int labs (long int i )
1528{
29+ // C99 Section 7.20.6.1:
30+ // "If the result cannot be represented, the behavior is undefined."
31+ __CPROVER_precondition (
32+ i != LONG_MIN , "argument to labs must not be LONG_MIN" );
1633 return __CPROVER_labs (i );
1734}
1835
1936/* FUNCTION: llabs */
2037
38+ #ifndef __CPROVER_LIMITS_H_INCLUDED
39+ # include <limits.h>
40+ # define __CPROVER_LIMITS_H_INCLUDED
41+ #endif
42+
2143#undef llabs
2244
2345long long int llabs (long long int i )
2446{
47+ // C99 Section 7.20.6.1:
48+ // "If the result cannot be represented, the behavior is undefined."
49+ __CPROVER_precondition (
50+ i != LLONG_MIN , "argument to llabs must not be LLONG_MIN" );
2551 return __CPROVER_llabs (i );
2652}
2753
@@ -32,12 +58,19 @@ long long int llabs(long long int i)
3258# define __CPROVER_INTTYPES_H_INCLUDED
3359#endif
3460
61+ #ifndef __CPROVER_LIMITS_H_INCLUDED
62+ # include <limits.h>
63+ # define __CPROVER_LIMITS_H_INCLUDED
64+ #endif
65+
3566#undef imaxabs
3667
3768intmax_t __CPROVER_imaxabs (intmax_t );
3869
3970intmax_t imaxabs (intmax_t i )
4071{
72+ __CPROVER_precondition (
73+ i != INTMAX_MIN , "argument to imaxabs must not be INTMAX_MIN" );
4174 return __CPROVER_imaxabs (i );
4275}
4376
0 commit comments