File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -233,3 +233,61 @@ pub unsafe extern "aapcs" fn __aeabi_memclr4(dest: *mut u8, n: usize) {
233
233
pub unsafe extern "aapcs" fn __aeabi_memclr8 ( dest : * mut u8 , n : usize ) {
234
234
__aeabi_memset4 ( dest, n, 0 ) ;
235
235
}
236
+
237
+ #[ no_mangle]
238
+ #[ cfg( any( target_pointer_width = "16" , target_pointer_width = "32" , target_pointer_width = "64" ) ) ]
239
+ pub extern "C" fn __clzsi2 ( mut x : usize ) -> usize {
240
+ // TODO: const this? Requires const if
241
+ let mut y: usize ;
242
+ let mut n: usize = {
243
+ #[ cfg( target_pointer_width = "64" ) ]
244
+ {
245
+ 64
246
+ }
247
+ #[ cfg( target_pointer_width = "32" ) ]
248
+ {
249
+ 32
250
+ }
251
+ #[ cfg( target_pointer_width = "16" ) ]
252
+ {
253
+ 16
254
+ }
255
+ } ;
256
+ #[ cfg( target_pointer_width = "64" ) ]
257
+ {
258
+ y = x >> 32 ;
259
+ if y != 0 {
260
+ n -= 32 ;
261
+ x = y;
262
+ }
263
+ }
264
+ #[ cfg( any( target_pointer_width = "32" , target_pointer_width = "64" ) ) ]
265
+ {
266
+ y = x >> 16 ;
267
+ if y != 0 {
268
+ n -= 16 ;
269
+ x = y;
270
+ }
271
+ }
272
+ y = x >> 8 ;
273
+ if y != 0 {
274
+ n -= 8 ;
275
+ x = y;
276
+ }
277
+ y = x >> 4 ;
278
+ if y != 0 {
279
+ n -= 4 ;
280
+ x = y;
281
+ }
282
+ y = x >> 2 ;
283
+ if y != 0 {
284
+ n -= 2 ;
285
+ x = y;
286
+ }
287
+ y = x >> 1 ;
288
+ if y != 0 {
289
+ n - 2
290
+ } else {
291
+ n - x
292
+ }
293
+ }
You can’t perform that action at this time.
0 commit comments