about summary refs log tree commit diff
path: root/library/panic_unwind
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2024-09-14 20:24:40 -0700
committerJubilee Young <workingjubilee@gmail.com>2024-09-14 20:26:37 -0700
commitfef7373d13a50b09cf13f4f38ac27fd75b3d94d7 (patch)
tree521040601744cf8d087b05973fc2a108adee6046 /library/panic_unwind
parent0307e401c26699656ae08e3809e7d272f5c103f4 (diff)
downloadrust-fef7373d13a50b09cf13f4f38ac27fd75b3d94d7.tar.gz
rust-fef7373d13a50b09cf13f4f38ac27fd75b3d94d7.zip
library: Compute Rust exception class from its string repr
Diffstat (limited to 'library/panic_unwind')
-rw-r--r--library/panic_unwind/src/gcc.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/library/panic_unwind/src/gcc.rs b/library/panic_unwind/src/gcc.rs
index 589d3c1b4d2..d8c1dcaaefe 100644
--- a/library/panic_unwind/src/gcc.rs
+++ b/library/panic_unwind/src/gcc.rs
@@ -61,7 +61,7 @@ struct Exception {
 pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
     let exception = Box::new(Exception {
         _uwe: uw::_Unwind_Exception {
-            exception_class: rust_exception_class(),
+            exception_class: RUST_EXCEPTION_CLASS,
             exception_cleanup: Some(exception_cleanup),
             private: [core::ptr::null(); uw::unwinder_private_data_size],
         },
@@ -84,7 +84,7 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
 
 pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
     let exception = ptr as *mut uw::_Unwind_Exception;
-    if (*exception).exception_class != rust_exception_class() {
+    if (*exception).exception_class != RUST_EXCEPTION_CLASS {
         uw::_Unwind_DeleteException(exception);
         super::__rust_foreign_exception();
     }
@@ -107,7 +107,4 @@ pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
 
 // Rust's exception class identifier.  This is used by personality routines to
 // determine whether the exception was thrown by their own runtime.
-fn rust_exception_class() -> uw::_Unwind_Exception_Class {
-    // M O Z \0  R U S T -- vendor, language
-    0x4d4f5a_00_52555354
-}
+const RUST_EXCEPTION_CLASS: uw::_Unwind_Exception_Class = u64::from_be_bytes(*b"MOZ\0RUST");