Skip to content

Commit 0759b3c

Browse files
committed
Try working around the android bug by making sync symbols strong
1 parent 06db2de commit 0759b3c

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/arm_linux.rs

+35
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,30 @@ unsafe fn atomic_cmpxchg<T>(ptr: *mut T, oldval: u32, newval: u32) -> u32 {
9090

9191
macro_rules! atomic_rmw {
9292
($name:ident, $ty:ty, $op:expr, $fetch:expr) => {
93+
#[cfg(not(target_os = "android"))]
9394
intrinsics! {
9495
pub unsafe extern "C" fn $name(ptr: *mut $ty, val: $ty) -> $ty {
9596
atomic_rmw(ptr, |x| $op(x as $ty, val) as u32, |old, new| $fetch(old, new)) as $ty
9697
}
9798
}
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+
}
98117
};
99118

100119
(@old $name:ident, $ty:ty, $op:expr) => {
@@ -105,13 +124,29 @@ macro_rules! atomic_rmw {
105124
atomic_rmw!($name, $ty, $op, |_, new| new);
106125
};
107126
}
127+
108128
macro_rules! atomic_cmpxchg {
109129
($name:ident, $ty:ty) => {
130+
#[cfg(not(target_os = "android"))]
110131
intrinsics! {
111132
pub unsafe extern "C" fn $name(ptr: *mut $ty, oldval: $ty, newval: $ty) -> $ty {
112133
atomic_cmpxchg(ptr, oldval as u32, newval as u32) as $ty
113134
}
114135
}
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+
}
115150
};
116151
}
117152

0 commit comments

Comments
 (0)