annotate test/float_gcc.c @ 775:a2a7b2835fa3

ia32 regression test
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 18 Nov 2010 21:25:30 +0900
parents c2c709727221
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
617
efc99e397413 test for inf()
kono
parents:
diff changeset
1 #include <math.h>
efc99e397413 test for inf()
kono
parents:
diff changeset
2
efc99e397413 test for inf()
kono
parents:
diff changeset
3 extern int printf(const char *,...);
efc99e397413 test for inf()
kono
parents:
diff changeset
4
efc99e397413 test for inf()
kono
parents:
diff changeset
5
efc99e397413 test for inf()
kono
parents:
diff changeset
6 #if 0
efc99e397413 test for inf()
kono
parents:
diff changeset
7 static __inline__ int __inline_signbitf( float __x ) {
efc99e397413 test for inf()
kono
parents:
diff changeset
8 union{ float __f; unsigned int __u;
efc99e397413 test for inf()
kono
parents:
diff changeset
9 }
efc99e397413 test for inf()
kono
parents:
diff changeset
10 __u = {__x};
efc99e397413 test for inf()
kono
parents:
diff changeset
11 return (int)(__u.__u >> 31);
efc99e397413 test for inf()
kono
parents:
diff changeset
12 }
efc99e397413 test for inf()
kono
parents:
diff changeset
13
efc99e397413 test for inf()
kono
parents:
diff changeset
14 static __inline__ int __inline_isnormalf( float __x ) {
efc99e397413 test for inf()
kono
parents:
diff changeset
15 float fabsf = __builtin_fabsf(__x);
efc99e397413 test for inf()
kono
parents:
diff changeset
16 if( __x != __x ) return 0;
efc99e397413 test for inf()
kono
parents:
diff changeset
17 return fabsf < __builtin_inff() && fabsf >= __FLT_MIN__;
efc99e397413 test for inf()
kono
parents:
diff changeset
18 }
efc99e397413 test for inf()
kono
parents:
diff changeset
19
efc99e397413 test for inf()
kono
parents:
diff changeset
20 extern double scalb ( double, double ) __asm("_scalb$UNIX2003" );
efc99e397413 test for inf()
kono
parents:
diff changeset
21 #endif
efc99e397413 test for inf()
kono
parents:
diff changeset
22
efc99e397413 test for inf()
kono
parents:
diff changeset
23
efc99e397413 test for inf()
kono
parents:
diff changeset
24 double fabs0(double a)
efc99e397413 test for inf()
kono
parents:
diff changeset
25 {
efc99e397413 test for inf()
kono
parents:
diff changeset
26 return __builtin_fabs(a);
efc99e397413 test for inf()
kono
parents:
diff changeset
27 }
efc99e397413 test for inf()
kono
parents:
diff changeset
28
efc99e397413 test for inf()
kono
parents:
diff changeset
29 float fabsf0(float a)
efc99e397413 test for inf()
kono
parents:
diff changeset
30 {
efc99e397413 test for inf()
kono
parents:
diff changeset
31 return __builtin_fabsf(a);
efc99e397413 test for inf()
kono
parents:
diff changeset
32 }
efc99e397413 test for inf()
kono
parents:
diff changeset
33
efc99e397413 test for inf()
kono
parents:
diff changeset
34
efc99e397413 test for inf()
kono
parents:
diff changeset
35
efc99e397413 test for inf()
kono
parents:
diff changeset
36 int main()
efc99e397413 test for inf()
kono
parents:
diff changeset
37 {
efc99e397413 test for inf()
kono
parents:
diff changeset
38 float a = 0.3;
efc99e397413 test for inf()
kono
parents:
diff changeset
39 double d = 0.3;
efc99e397413 test for inf()
kono
parents:
diff changeset
40 float f ;
efc99e397413 test for inf()
kono
parents:
diff changeset
41 double dd ;
efc99e397413 test for inf()
kono
parents:
diff changeset
42 int i,j;
efc99e397413 test for inf()
kono
parents:
diff changeset
43 i = __inline_signbitf(a);
efc99e397413 test for inf()
kono
parents:
diff changeset
44 j = __inline_isnormalf(a);
efc99e397413 test for inf()
kono
parents:
diff changeset
45 d = scalb( d, d );
efc99e397413 test for inf()
kono
parents:
diff changeset
46
efc99e397413 test for inf()
kono
parents:
diff changeset
47 dd = __builtin_inf();
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
48 printf("#0047:inf %g\n",dd);
617
efc99e397413 test for inf()
kono
parents:
diff changeset
49 f = __builtin_inff();
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
50 printf("#0049:inff %g\n",f);
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
51 // printf("#0050:scalb %g\n",d);
617
efc99e397413 test for inf()
kono
parents:
diff changeset
52
efc99e397413 test for inf()
kono
parents:
diff changeset
53 d = -0.3;
efc99e397413 test for inf()
kono
parents:
diff changeset
54
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
55 printf("#0054:%d %d %g\n",i,j,d);
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
56 printf("#0055:%g %g\n",fabs0(d),fabsf0(d));
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
57 printf("#0056:%g %g\n",fabs0(-d),fabsf0(-d));
617
efc99e397413 test for inf()
kono
parents:
diff changeset
58 }