Subversion Repositories HelenOS

Rev

Rev 3874 | Rev 4343 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3874 Rev 3918
Line 42... Line 42...
42
#define ATTEMPTS    100
42
#define ATTEMPTS  100
43
 
43
 
44
#define E_10e8  271828182
44
#define E_10e8   271828182
45
#define PI_10e8 314159265
45
#define PI_10e8  314159265
46
 
46
 
47
 
-
 
48
#ifdef KERN_ia32_ARCH_H_
-
 
49
static inline double sqrt(double x)
-
 
50
{
-
 
51
    double v;
-
 
52
   
-
 
53
    asm (
-
 
54
        "fsqrt\n"
-
 
55
        : "=t" (v)
-
 
56
        : "0" (x)
-
 
57
    );
-
 
58
   
-
 
59
    return v;
-
 
60
}
-
 
61
#endif
-
 
62
 
-
 
63
#ifdef KERN_amd64_ARCH_H_
-
 
64
static inline double sqrt(double x)
47
static inline double sqrt(double x)
65
{
48
{
66
    double v;
49
    double v;
67
   
50
   
68
    asm (
51
    asm (
Line 71... Line 54...
71
        : "0" (x)
54
        : "0" (x)
72
    );
55
    );
73
   
56
   
74
    return v;
57
    return v;
75
}
58
}
76
#endif
-
 
77
 
-
 
78
#ifdef KERN_ia64_ARCH_H_
-
 
79
 
-
 
80
#undef PI_10e8  
-
 
81
#define PI_10e8 3141592
-
 
82
 
-
 
83
static inline long double sqrt(long double a)
-
 
84
{  
-
 
85
    long double x = 1;
-
 
86
    long double lx = 0;
-
 
87
 
-
 
88
    if (a < 0.00000000000000001)
-
 
89
        return 0;
-
 
90
       
-
 
91
    while(x != lx) {
-
 
92
        lx = x;
-
 
93
        x = (x + (a / x)) / 2;
-
 
94
    }
-
 
95
   
-
 
96
    return x;
-
 
97
}
-
 
98
#endif
-
 
99
 
-
 
100
 
59
 
101
static atomic_t threads_ok;
60
static atomic_t threads_ok;
102
static atomic_t threads_fault;
61
static atomic_t threads_fault;
103
static waitq_t can_start;
62
static waitq_t can_start;
104
static bool sh_quiet;
63
static bool sh_quiet;
Line 154... Line 113...
154
            ad = sqrt(ab * ab / 4 + cd * cd);
113
            ad = sqrt(ab * ab / 4 + cd * cd);
155
            lpi = pi;
114
            lpi = pi;
156
            pi = 2 * n * ad;
115
            pi = 2 * n * ad;
157
        }
116
        }
158
 
117
       
159
#ifdef KERN_ia64_ARCH_H_
-
 
160
        if ((int) (1000000 * pi) != PI_10e8) {
-
 
161
            if (!sh_quiet)
-
 
162
                printf("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (1000000 * pi), (unative_t) (PI_10e8 / 100));
-
 
163
            atomic_inc(&threads_fault);
-
 
164
            break;
-
 
165
        }
-
 
166
#else
-
 
167
        if ((int) (100000000 * pi) != PI_10e8) {
118
        if ((int) (100000000 * pi) != PI_10e8) {
168
            if (!sh_quiet)
119
            if (!sh_quiet)
169
                printf("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
120
                printf("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
170
            atomic_inc(&threads_fault);
121
            atomic_inc(&threads_fault);
171
            break;
122
            break;
172
        }
123
        }
173
#endif
-
 
174
    }
124
    }
175
    atomic_inc(&threads_ok);
125
    atomic_inc(&threads_ok);
176
}
126
}
177
 
127
 
178
char * test_fpu1(bool quiet)
128
char * test_fpu1(bool quiet)