Fix usage of get_size
for gcc 12
This commit is contained in:
parent
9b1211db58
commit
7615e04f82
@ -68,7 +68,7 @@ fn atomic_extremum(
|
||||
src: RValue<'gcc>,
|
||||
order: AtomicOrdering,
|
||||
) -> RValue<'gcc> {
|
||||
let size = src.get_type().get_size();
|
||||
let size = get_maybe_pointer_size(src);
|
||||
|
||||
let func = self.current_func();
|
||||
|
||||
@ -138,7 +138,7 @@ fn compare_exchange(
|
||||
failure_order: AtomicOrdering,
|
||||
weak: bool,
|
||||
) -> RValue<'gcc> {
|
||||
let size = src.get_type().get_size();
|
||||
let size = get_maybe_pointer_size(src);
|
||||
let compare_exchange =
|
||||
self.context.get_builtin_function(&format!("__atomic_compare_exchange_{}", size));
|
||||
let order = self.context.new_rvalue_from_int(self.i32_type, order.to_gcc());
|
||||
@ -1586,7 +1586,7 @@ fn atomic_rmw(
|
||||
src: RValue<'gcc>,
|
||||
order: AtomicOrdering,
|
||||
) -> RValue<'gcc> {
|
||||
let size = src.get_type().get_size();
|
||||
let size = get_maybe_pointer_size(src);
|
||||
let name = match op {
|
||||
AtomicRmwBinOp::AtomicXchg => format!("__atomic_exchange_{}", size),
|
||||
AtomicRmwBinOp::AtomicAdd => format!("__atomic_fetch_add_{}", size),
|
||||
@ -2419,3 +2419,19 @@ fn to_gcc(self) -> i32 {
|
||||
ordering as i32
|
||||
}
|
||||
}
|
||||
|
||||
// Needed because gcc 12 `get_size()` doesn't work on pointers.
|
||||
#[cfg(feature = "master")]
|
||||
fn get_maybe_pointer_size(value: RValue<'_>) -> u32 {
|
||||
value.get_type().get_size()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "master"))]
|
||||
fn get_maybe_pointer_size(value: RValue<'_>) -> u32 {
|
||||
let type_ = value.get_type();
|
||||
if type_.get_pointee().is_some() {
|
||||
std::mem::size_of::<*const ()>() as _
|
||||
} else {
|
||||
type_.get_size()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user