diff --git a/libc-test/build.rs b/libc-test/build.rs index 7606800afb9cd..02d2a4b62b0eb 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -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") @@ -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(), } }); diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 8669a06ca5954..24723e0a1667e 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -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! { @@ -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; @@ -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! {