summaryrefslogtreecommitdiffstats
path: root/third_party/rust/objc/src/message/apple/arm.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /third_party/rust/objc/src/message/apple/arm.rs
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/objc/src/message/apple/arm.rs')
-rw-r--r--third_party/rust/objc/src/message/apple/arm.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/third_party/rust/objc/src/message/apple/arm.rs b/third_party/rust/objc/src/message/apple/arm.rs
new file mode 100644
index 0000000000..d26defc0de
--- /dev/null
+++ b/third_party/rust/objc/src/message/apple/arm.rs
@@ -0,0 +1,40 @@
+use std::any::{Any, TypeId};
+use std::mem;
+
+use runtime::Imp;
+
+extern {
+ fn objc_msgSend();
+ fn objc_msgSend_stret();
+
+ fn objc_msgSendSuper();
+ fn objc_msgSendSuper_stret();
+}
+
+pub fn msg_send_fn<R: Any>() -> Imp {
+ // Double-word sized fundamental data types don't use stret,
+ // but any composite type larger than 4 bytes does.
+ // <http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf>
+
+ let type_id = TypeId::of::<R>();
+ if mem::size_of::<R>() <= 4 ||
+ type_id == TypeId::of::<i64>() ||
+ type_id == TypeId::of::<u64>() ||
+ type_id == TypeId::of::<f64>() {
+ objc_msgSend
+ } else {
+ objc_msgSend_stret
+ }
+}
+
+pub fn msg_send_super_fn<R: Any>() -> Imp {
+ let type_id = TypeId::of::<R>();
+ if mem::size_of::<R>() <= 4 ||
+ type_id == TypeId::of::<i64>() ||
+ type_id == TypeId::of::<u64>() ||
+ type_id == TypeId::of::<f64>() {
+ objc_msgSendSuper
+ } else {
+ objc_msgSendSuper_stret
+ }
+}