File tree 3 files changed +38
-1
lines changed
3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ macro_rules! sdivmod {
9
9
$( $attr: tt) ,* // attributes
10
10
) => {
11
11
intrinsics! {
12
+ #[ avr_skip]
12
13
$(
13
14
#[ $attr]
14
15
) *
@@ -50,6 +51,7 @@ macro_rules! sdiv {
50
51
$( $attr: tt) ,* // attributes
51
52
) => {
52
53
intrinsics! {
54
+ #[ avr_skip]
53
55
$(
54
56
#[ $attr]
55
57
) *
@@ -85,6 +87,7 @@ macro_rules! smod {
85
87
$( $attr: tt) ,* // attributes
86
88
) => {
87
89
intrinsics! {
90
+ #[ avr_skip]
88
91
$(
89
92
#[ $attr]
90
93
) *
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ intrinsics! {
18
18
u32_div_rem( n, d) . 1
19
19
}
20
20
21
+ #[ avr_skip]
21
22
#[ maybe_use_optimized_c_shim]
22
23
/// Returns `n / d` and sets `*rem = n % d`
23
24
pub extern "C" fn __udivmodsi4( n: u32 , d: u32 , rem: Option <& mut u32 >) -> u32 {
@@ -28,18 +29,21 @@ intrinsics! {
28
29
quo_rem. 0
29
30
}
30
31
32
+ #[ avr_skip]
31
33
#[ maybe_use_optimized_c_shim]
32
34
/// Returns `n / d`
33
35
pub extern "C" fn __udivdi3( n: u64 , d: u64 ) -> u64 {
34
36
u64_div_rem( n, d) . 0
35
37
}
36
38
39
+ #[ avr_skip]
37
40
#[ maybe_use_optimized_c_shim]
38
41
/// Returns `n % d`
39
42
pub extern "C" fn __umoddi3( n: u64 , d: u64 ) -> u64 {
40
43
u64_div_rem( n, d) . 1
41
44
}
42
45
46
+ #[ avr_skip]
43
47
#[ maybe_use_optimized_c_shim]
44
48
/// Returns `n / d` and sets `*rem = n % d`
45
49
pub extern "C" fn __udivmoddi4( n: u64 , d: u64 , rem: Option <& mut u64 >) -> u64 {
@@ -77,6 +81,7 @@ intrinsics! {
77
81
}
78
82
}
79
83
84
+ #[ avr_skip]
80
85
#[ win64_128bit_abi_hack]
81
86
/// Returns `n / d` and sets `*rem = n % d`
82
87
pub extern "C" fn __udivmodti4( n: u128 , d: u128 , rem: Option <& mut u128 >) -> u128 {
Original file line number Diff line number Diff line change @@ -111,7 +111,6 @@ macro_rules! intrinsics {
111
111
112
112
$( $rest: tt) *
113
113
) => (
114
-
115
114
#[ cfg( $name = "optimized-c" ) ]
116
115
pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
117
116
extern $abi {
@@ -333,6 +332,36 @@ macro_rules! intrinsics {
333
332
intrinsics!( $( $rest) * ) ;
334
333
) ;
335
334
335
+ // For division and modulo, AVR uses a custom calling convention¹ that does
336
+ // not match our definitions here. Ideally we would just use hand-written
337
+ // naked functions, but that's quite a lot of code to port² - so for the
338
+ // time being we are just ignoring the problematic functions, letting
339
+ // avr-gcc (which is required to compile to AVR anyway) link them from
340
+ // libgcc.
341
+ //
342
+ // ¹ https://gcc.gnu.org/wiki/avr-gcc (see "Exceptions to the Calling
343
+ // Convention")
344
+ // ² https://github.com/gcc-mirror/gcc/blob/31048012db98f5ec9c2ba537bfd850374bdd771f/libgcc/config/avr/lib1funcs.S
345
+ (
346
+ #[ avr_skip]
347
+ $( #[ $( $attr: tt) * ] ) *
348
+ pub extern $abi: tt fn $name: ident( $( $argname: ident: $ty: ty) ,* ) $( -> $ret: ty) ? {
349
+ $( $body: tt) *
350
+ }
351
+
352
+ $( $rest: tt) *
353
+ ) => (
354
+ #[ cfg( not( target_arch = "avr" ) ) ]
355
+ intrinsics! {
356
+ $( #[ $( $attr) * ] ) *
357
+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
358
+ $( $body) *
359
+ }
360
+ }
361
+
362
+ intrinsics!( $( $rest) * ) ;
363
+ ) ;
364
+
336
365
// This is the final catch-all rule. At this point we generate an
337
366
// intrinsic with a conditional `#[no_mangle]` directive to avoid
338
367
// interfering with duplicate symbols and whatnot during testing.
You can’t perform that action at this time.
0 commit comments