Skip to content

Commit a0744d7

Browse files
committed
C library: model __builtin_powi{,f,l}
These GCC built-ins are modelled by implementing pow{,f,l} specialised to integral exponents (where multiple failure cases cannot occur).
1 parent 9c7bccc commit a0744d7

File tree

7 files changed

+418
-0
lines changed

7 files changed

+418
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <assert.h>
2+
#include <math.h>
3+
4+
double __builtin_powi(double, int);
5+
6+
int main()
7+
{
8+
double four = __builtin_powi(2.0, 2);
9+
assert(four > 3.999 && four < 4.345);
10+
return 0;
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--float-overflow-check --nan-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <assert.h>
2+
#include <math.h>
3+
4+
float __builtin_powif(float, int);
5+
6+
int main()
7+
{
8+
float four = __builtin_powif(2.0f, 2);
9+
assert(four > 3.999f && four < 4.345f);
10+
return 0;
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--float-overflow-check --nan-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <assert.h>
2+
#include <math.h>
3+
4+
long double __builtin_powil(long double, int);
5+
6+
int main()
7+
{
8+
long double four = __builtin_powil(2.0l, 2);
9+
assert(four > 3.999l && four < 4.345l);
10+
return 0;
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--float-overflow-check --nan-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)