Skip to content
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

Add support for setjmp/longjmp on x86_64. #1216

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fn main() {
.header("fcntl.h")
.header("limits.h")
.header("locale.h")
.header("setjmp.h")
.header("stddef.h")
.header("stdint.h")
.header("stdio.h")
Expand Down Expand Up @@ -919,11 +920,23 @@ fn main() {
field == "ssi_arch"))
});

cfg.fn_cname(move |name, cname| {
if windows {
cname.unwrap_or(name).to_string()
} else {
name.to_string()
cfg.fn_cname(move |name, link_name_opt| {
match link_name_opt {
Some(link_name) => {
let mut use_link_name = true;
for c in link_name.chars() {
if !c.is_ascii_alphanumeric() && c != '_' {
use_link_name = false;
break;
}
}
if use_link_name {
link_name.to_string()
} else {
name.to_string()
}
},
None => name.to_string(),
}
});

Expand Down
21 changes: 21 additions & 0 deletions src/unix/notbsd/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ pub type Elf64_Sxword = i64;
pub type Elf32_Section = u16;
pub type Elf64_Section = u16;

cfg_if ! {
if #[cfg(target_arch = "x86_64")] {
pub type __jmp_buf = [i64; 8];
} else {
pub type __jmp_buf = [i32; 6];
}
}

pub type jmp_buf = [__jmp_buf_tag; 1];
pub type sigjmp_buf = [__jmp_buf_tag; 1];

pub enum fpos64_t {} // TODO: fill this out with a struct

s! {
Expand Down Expand Up @@ -655,6 +666,12 @@ s! {
pub updated: ::c_ulong,
pub ha: [::c_uchar; ::MAX_ADDR_LEN],
}

pub struct __jmp_buf_tag {
__jmpbuf: __jmp_buf,
__mask_was_saved: ::c_int,
__saved_mask: ::sigset_t,
}
}

pub const ABDAY_1: ::nl_item = 0x20000;
Expand Down Expand Up @@ -2259,6 +2276,10 @@ extern {
nobj: ::size_t,
stream: *mut ::FILE
) -> ::size_t;

pub fn setjmp(env: ::jmp_buf) -> ::c_int;
#[cfg_attr(target_env="gnu", link_name="__sigsetjmp")]
pub fn sigsetjmp(env: ::sigjmp_buf, savesigs: ::c_int) -> ::c_int;
}

cfg_if! {
Expand Down