1
/* Test to see if floating point state is being properly maintained
2
for each thread. Different threads doing floating point operations
3
simultaneously should not interfere with one another. This
4
includes operations that might change some FPU flags, such as
5
rounding modes, at least implicitly. */
15
void *log_loop (void *x) {
19
for (i = 0; i < limit; i++) {
29
if (memcmp (&d2, &d1, 8)) {
30
pthread_exit(&float_failed);
34
pthread_exit(&float_passed);
37
void *trig_loop (void *x) {
41
for (i = 0; i < limit; i++) {
53
if (memcmp (&d2, &d1, 8)) {
54
pthread_exit(&float_failed);
58
pthread_exit(&float_passed);
69
pthread_attr_init(&attr);
70
pthread_attr_setfloatstate(&attr, PTHREAD_NOFLOAT);
72
while(limit < 100000) {
73
pthread_create (&thread[0], &attr, trig_loop, 0);
74
pthread_create (&thread[1], &attr, log_loop, 0);
75
pthread_join(thread[0], (void **) &x);
76
pthread_join(thread[1], (void **) &y);
77
if ((*x == float_failed) || (*y == float_failed)) {
83
if ((*x == float_passed) && (*y == float_passed)) {
84
printf("test_preemption_float INDETERMINATE\n");
87
pthread_create (&thread[0], NULL, trig_loop, 0);
88
pthread_create (&thread[1], NULL, log_loop, 0);
89
pthread_join(thread[0], (void **) &x);
90
pthread_join(thread[1], (void **) &y);
92
if ((*x == float_failed) || (*y == float_failed)) {
93
printf("test_preemption_float FAILED\n");
96
printf("test_preemption_float PASSED\n");