-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fixes #31229 - fixes up BSD type mismatch errors and updates libc dependency. DEAD, see PR #31263 #31230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #31229 - fixes up BSD type mismatch errors and updates libc dependency. DEAD, see PR #31263 #31230
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,17 +134,42 @@ mod imp { | |
Handler { _data: MAIN_ALTSTACK }; | ||
} | ||
|
||
pub unsafe fn make_handler() -> Handler { | ||
let alt_stack = mmap(ptr::null_mut(), | ||
SIGSTKSZ, | ||
PROT_READ | PROT_WRITE, | ||
MAP_PRIVATE | MAP_ANON, | ||
-1, | ||
0); | ||
if alt_stack == MAP_FAILED { | ||
#[cfg(any(target_os = "linux", | ||
target_os = "macos", | ||
target_os = "bitrig", | ||
target_os = "netbsd", | ||
target_os = "openbsd"))] | ||
unsafe fn get_stack() -> *mut libc::c_void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these two blocks different? They look the same except for a cast at the very end? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they are the same except the cast at the end. we don't yet have conditional compilation for general statements and I couldn't think of any other way to make this compile. on dragonflybsd and freebsd, the stack.ss_sp field is a *mut i8 type and on the others it is a *mut libc::c_void. Doing a runtime cfg!() doesn't work because one branch always fails to compile due to the warn -> error compilation flags. I asked in #rust today if there was a better way to do this and nobody could think of a better way. @alexcrichton do you know of a better way to do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would have more sens to make The problem is on freebsd/dragonfly, It would be less confusing that casting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dhuseby you could also just insert |
||
let stack = mmap(ptr::null_mut(), | ||
SIGSTKSZ, | ||
PROT_READ | PROT_WRITE, | ||
MAP_PRIVATE | MAP_ANON, | ||
-1, | ||
0); | ||
if stack == MAP_FAILED { | ||
panic!("failed to allocate an alternative stack"); | ||
} | ||
stack | ||
} | ||
|
||
#[cfg(any(target_os = "dragonfly", | ||
target_os = "freebsd"))] | ||
unsafe fn get_stack() -> *mut i8 { | ||
let stack = mmap(ptr::null_mut(), | ||
SIGSTKSZ, | ||
PROT_READ | PROT_WRITE, | ||
MAP_PRIVATE | MAP_ANON, | ||
-1, | ||
0); | ||
if stack == MAP_FAILED { | ||
panic!("failed to allocate an alternative stack"); | ||
} | ||
stack as *mut i8 | ||
} | ||
|
||
|
||
pub unsafe fn make_handler() -> Handler { | ||
let alt_stack = get_stack(); | ||
let mut stack: libc::stack_t = mem::zeroed(); | ||
|
||
stack.ss_sp = alt_stack; | ||
|
@@ -153,7 +178,7 @@ mod imp { | |
|
||
sigaltstack(&stack, ptr::null_mut()); | ||
|
||
Handler { _data: alt_stack } | ||
Handler { _data: alt_stack as *mut libc::c_void } | ||
} | ||
|
||
pub unsafe fn drop_handler(handler: &mut Handler) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you unify this with the block above? after this change they're all the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unified now. thanks, i missed that.