Use global_asm for setjmp instead
This commit is contained in:
Generated
-3
@@ -367,9 +367,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "setjmp"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cbindgen 0.5.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef _BITS_SETJMP_H
|
||||
#define _BITS_SETJMP_H
|
||||
#ifndef _SETJMP_H
|
||||
#define _SETJMP_H
|
||||
|
||||
#ifdef __arch64__
|
||||
typedef unsigned long jmp_buf[22];
|
||||
@@ -2,7 +2,3 @@
|
||||
name = "setjmp"
|
||||
version = "0.1.0"
|
||||
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
|
||||
build = "build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = { path = "../../cbindgen" }
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
extern crate cbindgen;
|
||||
|
||||
use std::{env, fs, process::Command};
|
||||
|
||||
fn compile(file: &str, object: &str, output: &str) {
|
||||
let status = Command::new("gcc")
|
||||
.args(&["-c", file, "-o", object])
|
||||
.status()
|
||||
.expect("failed to run gcc to compile assembly");
|
||||
|
||||
if !status.success() {
|
||||
panic!("compilation error");
|
||||
}
|
||||
|
||||
let status = Command::new("ar")
|
||||
.args(&["rcs", output, object])
|
||||
.status()
|
||||
.expect("failed to run ar to convert object to a static library");
|
||||
|
||||
if !status.success() {
|
||||
panic!("error converting object to static library");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rustc-link-lib=static=setjmp");
|
||||
println!("cargo:rustc-link-lib=static=longjmp");
|
||||
|
||||
macro_rules! detect_arch {
|
||||
($($($token:tt);+),+) => {
|
||||
$(
|
||||
detect_arch!(inner $($token);+);
|
||||
)+
|
||||
};
|
||||
(inner $arch:expr) => {
|
||||
detect_arch!(inner $arch; ".s");
|
||||
};
|
||||
(inner $arch:expr; $ext:expr) => {
|
||||
#[cfg(target_arch = $arch)] {
|
||||
compile(concat!("impl/", $arch, "/setjmp", $ext), "impl/bin/setjmp.o", "impl/bin/libsetjmp.a");
|
||||
compile(concat!("impl/", $arch, "/longjmp", $ext), "impl/bin/longjmp.o", "impl/bin/liblongjmp.a");
|
||||
|
||||
let dir = env::current_dir().expect("failed to find current directory");
|
||||
println!("cargo:rustc-link-search=native={}/impl/bin", dir.display());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
detect_arch! {
|
||||
"aarch64",
|
||||
"arm",
|
||||
"i386",
|
||||
"m68k",
|
||||
"microblaze",
|
||||
"mips"; ".S",
|
||||
"mips64"; ".S",
|
||||
"mipsn32"; ".S",
|
||||
"or1k",
|
||||
"powerpc"; ".S",
|
||||
"powerpc64",
|
||||
"s390x",
|
||||
"sh"; ".S",
|
||||
"x32",
|
||||
"x86_64"
|
||||
}
|
||||
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
|
||||
fs::create_dir_all("../../target/include").expect("failed to create include directory");
|
||||
cbindgen::generate(crate_dir)
|
||||
.expect("failed to generate bindings")
|
||||
.write_to_file("../../target/include/setjmp.h");
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
include_guard = "_SETJMP_H"
|
||||
trailer = "#include <bits/setjmp.h>"
|
||||
language = "C"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
+29
-2
@@ -1,6 +1,33 @@
|
||||
//! setjmp implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/setjmp.h.html
|
||||
|
||||
#![no_std]
|
||||
#![feature(global_asm)]
|
||||
|
||||
// EMPTY FILE.
|
||||
// This project is here because of the build.rs file which will compile musl's existing code for setjmp.
|
||||
macro_rules! platform_specific {
|
||||
($($arch:expr,$ext:expr;)+) => {
|
||||
$(
|
||||
#[cfg(target_arch = $arch)]
|
||||
global_asm!(include_str!(concat!("impl/", $arch, "/setjmp.", $ext)));
|
||||
#[cfg(target_arch = $arch)]
|
||||
global_asm!(include_str!(concat!("impl/", $arch, "/longjmp.", $ext)));
|
||||
)+
|
||||
}
|
||||
}
|
||||
|
||||
platform_specific! {
|
||||
"aarch64","s";
|
||||
"arm","s";
|
||||
"i386","s";
|
||||
"m68k","s";
|
||||
"microblaze","s";
|
||||
"mips","S";
|
||||
"mips64","S";
|
||||
"mipsn32","S";
|
||||
"or1k","s";
|
||||
"powerpc","S";
|
||||
"powerpc64","s";
|
||||
"s390x","s";
|
||||
"sh","S";
|
||||
"x32","s";
|
||||
"x86_64","s";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user