@@ -90,11 +90,30 @@ unsafe fn atomic_cmpxchg<T>(ptr: *mut T, oldval: u32, newval: u32) -> u32 {
90
90
91
91
macro_rules! atomic_rmw {
92
92
( $name: ident, $ty: ty, $op: expr, $fetch: expr) => {
93
+ #[ cfg( not( target_os = "android" ) ) ]
93
94
intrinsics! {
94
95
pub unsafe extern "C" fn $name( ptr: * mut $ty, val: $ty) -> $ty {
95
96
atomic_rmw( ptr, |x| $op( x as $ty, val) as u32 , |old, new| $fetch( old, new) ) as $ty
96
97
}
97
98
}
99
+
100
+ #[ cfg( target_os = "android" ) ]
101
+ #[ cfg( not( feature = "mangled-names" ) ) ]
102
+ mod $name {
103
+ #[ no_mangle]
104
+ unsafe extern "C" fn $name( ptr: * mut $ty, val: $ty) -> $ty {
105
+ super :: $name( ptr, val)
106
+ }
107
+ }
108
+
109
+ #[ cfg( target_os = "android" ) ]
110
+ pub unsafe extern "C" fn $name( ptr: * mut $ty, val: $ty) -> $ty {
111
+ atomic_rmw(
112
+ ptr,
113
+ |x| $op( x as $ty, val) as u32 ,
114
+ |old, new| $fetch( old, new) ,
115
+ ) as $ty
116
+ }
98
117
} ;
99
118
100
119
( @old $name: ident, $ty: ty, $op: expr) => {
@@ -105,13 +124,29 @@ macro_rules! atomic_rmw {
105
124
atomic_rmw!( $name, $ty, $op, |_, new| new) ;
106
125
} ;
107
126
}
127
+
108
128
macro_rules! atomic_cmpxchg {
109
129
( $name: ident, $ty: ty) => {
130
+ #[ cfg( not( target_os = "android" ) ) ]
110
131
intrinsics! {
111
132
pub unsafe extern "C" fn $name( ptr: * mut $ty, oldval: $ty, newval: $ty) -> $ty {
112
133
atomic_cmpxchg( ptr, oldval as u32 , newval as u32 ) as $ty
113
134
}
114
135
}
136
+
137
+ #[ cfg( target_os = "android" ) ]
138
+ #[ cfg( not( feature = "mangled-names" ) ) ]
139
+ mod $name {
140
+ #[ no_mangle]
141
+ unsafe extern "C" fn $name( ptr: * mut $ty, oldval: $ty, newval: $ty) -> $ty {
142
+ super :: $name( ptr, oldval, newval)
143
+ }
144
+ }
145
+
146
+ #[ cfg( target_os = "android" ) ]
147
+ pub unsafe extern "C" fn $name( ptr: * mut $ty, oldval: $ty, newval: $ty) -> $ty {
148
+ atomic_cmpxchg( ptr, oldval as u32 , newval as u32 ) as $ty
149
+ }
115
150
} ;
116
151
}
117
152
0 commit comments