* elf64-ppc.c (add_symbol_adjust): Correct mismatched function
[binutils.git] / libiberty / copysign.c
blobd288be239eb45b2cf4def41075a4329d9e036fcc
1 #include <ansidecl.h>
3 #ifdef __IEEE_BIG_ENDIAN
5 typedef union
7 double value;
8 struct
10 unsigned int sign : 1;
11 unsigned int exponent: 11;
12 unsigned int fraction0:4;
13 unsigned int fraction1:16;
14 unsigned int fraction2:16;
15 unsigned int fraction3:16;
17 } number;
18 struct
20 unsigned int sign : 1;
21 unsigned int exponent: 11;
22 unsigned int quiet:1;
23 unsigned int function0:3;
24 unsigned int function1:16;
25 unsigned int function2:16;
26 unsigned int function3:16;
27 } nan;
28 struct
30 unsigned long msw;
31 unsigned long lsw;
32 } parts;
33 long aslong[2];
34 } __ieee_double_shape_type;
36 #endif
38 #ifdef __IEEE_LITTLE_ENDIAN
40 typedef union
42 double value;
43 struct
45 #ifdef __SMALL_BITFIELDS
46 unsigned int fraction3:16;
47 unsigned int fraction2:16;
48 unsigned int fraction1:16;
49 unsigned int fraction0: 4;
50 #else
51 unsigned int fraction1:32;
52 unsigned int fraction0:20;
53 #endif
54 unsigned int exponent :11;
55 unsigned int sign : 1;
56 } number;
57 struct
59 #ifdef __SMALL_BITFIELDS
60 unsigned int function3:16;
61 unsigned int function2:16;
62 unsigned int function1:16;
63 unsigned int function0:3;
64 #else
65 unsigned int function1:32;
66 unsigned int function0:19;
67 #endif
68 unsigned int quiet:1;
69 unsigned int exponent: 11;
70 unsigned int sign : 1;
71 } nan;
72 struct
74 unsigned long lsw;
75 unsigned long msw;
76 } parts;
78 long aslong[2];
80 } __ieee_double_shape_type;
82 #endif
84 #ifdef __IEEE_BIG_ENDIAN
85 typedef union
87 float value;
88 struct
90 unsigned int sign : 1;
91 unsigned int exponent: 8;
92 unsigned int fraction0: 7;
93 unsigned int fraction1: 16;
94 } number;
95 struct
97 unsigned int sign:1;
98 unsigned int exponent:8;
99 unsigned int quiet:1;
100 unsigned int function0:6;
101 unsigned int function1:16;
102 } nan;
103 long p1;
105 } __ieee_float_shape_type;
106 #endif
108 #ifdef __IEEE_LITTLE_ENDIAN
109 typedef union
111 float value;
112 struct
114 unsigned int fraction0: 7;
115 unsigned int fraction1: 16;
116 unsigned int exponent: 8;
117 unsigned int sign : 1;
118 } number;
119 struct
121 unsigned int function1:16;
122 unsigned int function0:6;
123 unsigned int quiet:1;
124 unsigned int exponent:8;
125 unsigned int sign:1;
126 } nan;
127 long p1;
129 } __ieee_float_shape_type;
130 #endif
132 #if defined(__IEEE_BIG_ENDIAN) || defined(__IEEE_LITTLE_ENDIAN)
134 double
135 copysign (x, y)
136 double x, y;
138 __ieee_double_shape_type a,b;
139 b.value = y;
140 a.value = x;
141 a.number.sign =b.number.sign;
142 return a.value;
145 #else
147 double
148 copysign (x, y)
149 double x, y;
151 if ((x < 0 && y > 0) || (x > 0 && y < 0))
152 return -x;
153 return x;
156 #endif