Skip to content

Instantly share code, notes, and snippets.

@staticfloat
Last active May 10, 2017 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save staticfloat/70651dfd50a9995492ac494d47065d26 to your computer and use it in GitHub Desktop.
Save staticfloat/70651dfd50a9995492ac494d47065d26 to your computer and use it in GitHub Desktop.
// acos_test.c
#include <stdio.h>
#include <openlibm.h>
// Fill the stack with 0x55, 0x55, 0x55...., which is a big double no matter where you start
void prepare_stack() {
volatile unsigned char stack[256];
for( unsigned int i=0; i<256; ++i )
stack[i] = 0x55;
}
int main(void) {
// Do this once so that we don't have to bother with the dl loading stuff
volatile double x = 0.8;
acos(x);
prepare_stack();
double y = acos(x);
printf("%.16f\n", y);
return 0;
}
[root@47a48e9c363b openlibm-1581174c85f7b645b15ba1ac1c3a98fb601f0fe7]# gcc -O1 -o acos_test -march=pentium4 -m32 -fno-gnu89-inline -fno-builtin -std=c99 -fPIC -I src -I include ./acos_test.c ./src/e_acos.c ./src/e_sqrt.c && ./acos_test
0.6435011087932843
[root@47a48e9c363b openlibm-1581174c85f7b645b15ba1ac1c3a98fb601f0fe7]# gcc -O1 -fpeephole2 -o acos_test -march=pentium4 -m32 -fno-gnu89-inline -fno-builtin -std=c99 -fPIC -I src -I include ./acos_test.c ./src/e_acos.c ./src/e_sqrt.c && ./acos_test
6066969536937485543883473977334376971721498622912628554206287716489800464666960761304196338155520.0000000000000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment