3
3
use crate :: float:: Float ;
4
4
use crate :: int:: MinInt ;
5
5
6
+ #[ cfg( target_arch = "avr" ) ]
7
+ type CmpResult = i8 ;
8
+
9
+ #[ cfg( not( target_arch = "avr" ) ) ]
10
+ type CmpResult = i32 ;
11
+
6
12
#[ derive( Clone , Copy ) ]
7
13
enum Result {
8
14
Less ,
@@ -12,7 +18,7 @@ enum Result {
12
18
}
13
19
14
20
impl Result {
15
- fn to_le_abi ( self ) -> i32 {
21
+ fn to_le_abi ( self ) -> CmpResult {
16
22
match self {
17
23
Result :: Less => -1 ,
18
24
Result :: Equal => 0 ,
@@ -21,7 +27,7 @@ impl Result {
21
27
}
22
28
}
23
29
24
- fn to_ge_abi ( self ) -> i32 {
30
+ fn to_ge_abi ( self ) -> CmpResult {
25
31
match self {
26
32
Result :: Less => -1 ,
27
33
Result :: Equal => 0 ,
@@ -99,120 +105,99 @@ fn unord<F: Float>(a: F, b: F) -> bool {
99
105
}
100
106
101
107
intrinsics ! {
102
- #[ avr_skip]
103
- pub extern "C" fn __lesf2( a: f32 , b: f32 ) -> i32 {
108
+ pub extern "C" fn __lesf2( a: f32 , b: f32 ) -> CmpResult {
104
109
cmp( a, b) . to_le_abi( )
105
110
}
106
111
107
- #[ avr_skip]
108
- pub extern "C" fn __gesf2( a: f32 , b: f32 ) -> i32 {
112
+ pub extern "C" fn __gesf2( a: f32 , b: f32 ) -> CmpResult {
109
113
cmp( a, b) . to_ge_abi( )
110
114
}
111
115
112
- #[ avr_skip]
113
116
#[ arm_aeabi_alias = __aeabi_fcmpun]
114
- pub extern "C" fn __unordsf2( a: f32 , b: f32 ) -> i32 {
115
- unord( a, b) as i32
117
+ pub extern "C" fn __unordsf2( a: f32 , b: f32 ) -> CmpResult {
118
+ unord( a, b) as CmpResult
116
119
}
117
120
118
- #[ avr_skip]
119
- pub extern "C" fn __eqsf2( a: f32 , b: f32 ) -> i32 {
121
+ pub extern "C" fn __eqsf2( a: f32 , b: f32 ) -> CmpResult {
120
122
cmp( a, b) . to_le_abi( )
121
123
}
122
124
123
- #[ avr_skip]
124
- pub extern "C" fn __ltsf2( a: f32 , b: f32 ) -> i32 {
125
+ pub extern "C" fn __ltsf2( a: f32 , b: f32 ) -> CmpResult {
125
126
cmp( a, b) . to_le_abi( )
126
127
}
127
128
128
- #[ avr_skip]
129
- pub extern "C" fn __nesf2( a: f32 , b: f32 ) -> i32 {
129
+ pub extern "C" fn __nesf2( a: f32 , b: f32 ) -> CmpResult {
130
130
cmp( a, b) . to_le_abi( )
131
131
}
132
132
133
- #[ avr_skip]
134
- pub extern "C" fn __gtsf2( a: f32 , b: f32 ) -> i32 {
133
+ pub extern "C" fn __gtsf2( a: f32 , b: f32 ) -> CmpResult {
135
134
cmp( a, b) . to_ge_abi( )
136
135
}
137
136
138
- #[ avr_skip]
139
- pub extern "C" fn __ledf2( a: f64 , b: f64 ) -> i32 {
137
+ pub extern "C" fn __ledf2( a: f64 , b: f64 ) -> CmpResult {
140
138
cmp( a, b) . to_le_abi( )
141
139
}
142
140
143
- #[ avr_skip]
144
- pub extern "C" fn __gedf2( a: f64 , b: f64 ) -> i32 {
141
+ pub extern "C" fn __gedf2( a: f64 , b: f64 ) -> CmpResult {
145
142
cmp( a, b) . to_ge_abi( )
146
143
}
147
144
148
- #[ avr_skip]
149
145
#[ arm_aeabi_alias = __aeabi_dcmpun]
150
- pub extern "C" fn __unorddf2( a: f64 , b: f64 ) -> i32 {
151
- unord( a, b) as i32
146
+ pub extern "C" fn __unorddf2( a: f64 , b: f64 ) -> CmpResult {
147
+ unord( a, b) as CmpResult
152
148
}
153
149
154
- #[ avr_skip]
155
- pub extern "C" fn __eqdf2( a: f64 , b: f64 ) -> i32 {
150
+ pub extern "C" fn __eqdf2( a: f64 , b: f64 ) -> CmpResult {
156
151
cmp( a, b) . to_le_abi( )
157
152
}
158
153
159
- #[ avr_skip]
160
- pub extern "C" fn __ltdf2( a: f64 , b: f64 ) -> i32 {
154
+ pub extern "C" fn __ltdf2( a: f64 , b: f64 ) -> CmpResult {
161
155
cmp( a, b) . to_le_abi( )
162
156
}
163
157
164
- #[ avr_skip]
165
- pub extern "C" fn __nedf2( a: f64 , b: f64 ) -> i32 {
158
+ pub extern "C" fn __nedf2( a: f64 , b: f64 ) -> CmpResult {
166
159
cmp( a, b) . to_le_abi( )
167
160
}
168
161
169
- #[ avr_skip]
170
- pub extern "C" fn __gtdf2( a: f64 , b: f64 ) -> i32 {
162
+ pub extern "C" fn __gtdf2( a: f64 , b: f64 ) -> CmpResult {
171
163
cmp( a, b) . to_ge_abi( )
172
164
}
173
165
}
174
166
175
167
#[ cfg( f128_enabled) ]
176
168
intrinsics ! {
177
- #[ avr_skip]
178
169
#[ ppc_alias = __lekf2]
179
- pub extern "C" fn __letf2( a: f128, b: f128) -> i32 {
170
+ pub extern "C" fn __letf2( a: f128, b: f128) -> CmpResult {
180
171
cmp( a, b) . to_le_abi( )
181
172
}
182
173
183
- #[ avr_skip]
184
174
#[ ppc_alias = __gekf2]
185
- pub extern "C" fn __getf2( a: f128, b: f128) -> i32 {
175
+ pub extern "C" fn __getf2( a: f128, b: f128) -> CmpResult {
186
176
cmp( a, b) . to_ge_abi( )
187
177
}
188
178
189
- #[ avr_skip]
190
179
#[ ppc_alias = __unordkf2]
191
- pub extern "C" fn __unordtf2( a: f128, b: f128) -> i32 {
192
- unord( a, b) as i32
180
+ pub extern "C" fn __unordtf2( a: f128, b: f128) -> CmpResult {
181
+ unord( a, b) as CmpResult
193
182
}
194
183
195
- #[ avr_skip]
196
184
#[ ppc_alias = __eqkf2]
197
- pub extern "C" fn __eqtf2( a: f128, b: f128) -> i32 {
185
+ pub extern "C" fn __eqtf2( a: f128, b: f128) -> CmpResult {
198
186
cmp( a, b) . to_le_abi( )
199
187
}
200
188
201
- #[ avr_skip]
202
189
#[ ppc_alias = __ltkf2]
203
- pub extern "C" fn __lttf2( a: f128, b: f128) -> i32 {
190
+ pub extern "C" fn __lttf2( a: f128, b: f128) -> CmpResult {
204
191
cmp( a, b) . to_le_abi( )
205
192
}
206
193
207
- #[ avr_skip]
208
194
#[ ppc_alias = __nekf2]
209
- pub extern "C" fn __netf2( a: f128, b: f128) -> i32 {
195
+ pub extern "C" fn __netf2( a: f128, b: f128) -> CmpResult {
210
196
cmp( a, b) . to_le_abi( )
211
197
}
212
198
213
- #[ avr_skip]
214
199
#[ ppc_alias = __gtkf2]
215
- pub extern "C" fn __gttf2( a: f128, b: f128) -> i32 {
200
+ pub extern "C" fn __gttf2( a: f128, b: f128) -> CmpResult {
216
201
cmp( a, b) . to_ge_abi( )
217
202
}
218
203
}
0 commit comments