]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make it a more effective test.
authorJulian Seward <jseward@acm.org>
Thu, 6 Jan 2005 15:46:22 +0000 (15:46 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 6 Jan 2005 15:46:22 +0000 (15:46 +0000)
git-svn-id: svn://svn.valgrind.org/vex/trunk@696

VEX/test/frstor.c

index d64c0565a6db38933318684383a50570fb16b572..006e19ee3cfe278b7a1733e74332b69d4fd3bc06 100644 (file)
@@ -2,6 +2,15 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+void do_fsave_interesting_stuff ( void* p )
+{
+   asm __volatile__("fninit");
+   asm __volatile__("fldpi");
+   asm __volatile__("fld1");
+   asm __volatile__("fldln2");
+   asm __volatile__("fsave (%0)" : : "r" (p) : "memory" );
+}
+
 void do_fsave ( void* p )
 {
    asm __volatile__("fsave (%0)" : : "r" (p) : "memory" );
@@ -54,23 +63,20 @@ void show_fpustate ( unsigned char* buf, int hide64to80 )
 
 int main ( int argc, char** argv )
 {
-   int i;
-   unsigned short* buf = malloc(54*sizeof(short));
+   unsigned short* buf1 = malloc(54*sizeof(short));
+   unsigned short* buf2 = malloc(54*sizeof(short));
    int xx = argc > 1;
    printf("Re-run with any arg to suppress least-significant\n"
           "   16 bits of FP numbers\n");
 
-   for (i = 0; i < 54; i++)
-      buf[i] = i;
-   buf[0] = 0x037f;
-
-   for (i = 0; i < 8; i++)
-      *(long double *)(&buf[14+5 *i]) = 20.0 + 0.1234 * i;
-
-   do_frstor(buf);
-   do_fsave(buf);
+   /* Create an initial image. */
+   do_fsave_interesting_stuff(buf1);
+   show_fpustate( (unsigned char*)buf1, xx );
 
-   show_fpustate( (unsigned char*)buf, xx );
+   /* Reload it into buf2. */
+   do_frstor(buf1);
+   do_fsave(buf2);
+   show_fpustate( (unsigned char*)buf2, xx );
 
    return 0;
 }