Skip to content

Commit 4b4d467

Browse files
committed
fix BorrowDatum implementations on big endian
1 parent a7b95b4 commit 4b4d467

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pgrx/src/datum/borrow.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,18 @@ macro_rules! impl_borrow_fixed_len {
9595
};
9696

9797
unsafe fn point_from(ptr: ptr::NonNull<u8>) -> ptr::NonNull<Self> {
98-
ptr.cast()
98+
#[cfg(target_endian = "big")]
99+
unsafe {
100+
if mem::size_of::<Self>() <= mem::size_of::<Datum>() {
101+
ptr.add(mem::size_of::<Datum>() - mem::size_of::<Self>()).cast()
102+
} else {
103+
ptr.cast()
104+
}
105+
}
106+
#[cfg(target_endian = "little")]
107+
{
108+
ptr.cast()
109+
}
99110
}
100111
}
101112
)*

0 commit comments

Comments
 (0)