diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2021-10-08 13:29:03 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2021-10-08 13:29:03 +0200 |
| commit | d2c83774d333a94bde537e049d05a98c954857ee (patch) | |
| tree | 30189238038d62f494361245b3fd48688922b154 /library/std/src/sys/unix/stack_overflow.rs | |
| parent | bf9e6e5598fb714a2b2ba971f8a7404a877d7568 (diff) | |
| download | rust-d2c83774d333a94bde537e049d05a98c954857ee.tar.gz rust-d2c83774d333a94bde537e049d05a98c954857ee.zip | |
Let stack_overflow::imp::cleanup call drop_handler directly
instead of through the Drop impl for Handler
Diffstat (limited to 'library/std/src/sys/unix/stack_overflow.rs')
| -rw-r--r-- | library/std/src/sys/unix/stack_overflow.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/library/std/src/sys/unix/stack_overflow.rs b/library/std/src/sys/unix/stack_overflow.rs index e8747e39bcb..fa3791566b7 100644 --- a/library/std/src/sys/unix/stack_overflow.rs +++ b/library/std/src/sys/unix/stack_overflow.rs @@ -6,7 +6,7 @@ pub use self::imp::cleanup; pub use self::imp::init; pub struct Handler { - _data: *mut libc::c_void, + data: *mut libc::c_void, } impl Handler { @@ -15,14 +15,14 @@ impl Handler { } fn null() -> Handler { - Handler { _data: crate::ptr::null_mut() } + Handler { data: crate::ptr::null_mut() } } } impl Drop for Handler { fn drop(&mut self) { unsafe { - drop_handler(self); + drop_handler(self.data); } } } @@ -134,12 +134,12 @@ mod imp { } let handler = make_handler(); - MAIN_ALTSTACK.store(handler._data, Ordering::Relaxed); + MAIN_ALTSTACK.store(handler.data, Ordering::Relaxed); mem::forget(handler); } pub unsafe fn cleanup() { - Handler { _data: MAIN_ALTSTACK.load(Ordering::Relaxed) }; + drop_handler(MAIN_ALTSTACK.load(Ordering::Relaxed)); } unsafe fn get_stackp() -> *mut libc::c_void { @@ -175,14 +175,14 @@ mod imp { if stack.ss_flags & SS_DISABLE != 0 { stack = get_stack(); sigaltstack(&stack, ptr::null_mut()); - Handler { _data: stack.ss_sp as *mut libc::c_void } + Handler { data: stack.ss_sp as *mut libc::c_void } } else { Handler::null() } } - pub unsafe fn drop_handler(handler: &mut Handler) { - if !handler._data.is_null() { + pub unsafe fn drop_handler(data: *mut libc::c_void) { + if !data.is_null() { let stack = libc::stack_t { ss_sp: ptr::null_mut(), ss_flags: SS_DISABLE, @@ -195,7 +195,7 @@ mod imp { sigaltstack(&stack, ptr::null_mut()); // We know from `get_stackp` that the alternate stack we installed is part of a mapping // that started one page earlier, so walk back a page and unmap from there. - munmap(handler._data.sub(page_size()), SIGSTKSZ + page_size()); + munmap(data.sub(page_size()), SIGSTKSZ + page_size()); } } } @@ -219,5 +219,5 @@ mod imp { super::Handler::null() } - pub unsafe fn drop_handler(_handler: &mut super::Handler) {} + pub unsafe fn drop_handler(_data: *mut libc::c_void) {} } |
