Fix FreeBSD
This commit is contained in:
parent
751b42e653
commit
a1b948e34a
|
@ -0,0 +1,30 @@
|
|||
# A vagrant configuration file for running tests on BSD-like machines
|
||||
#
|
||||
# Note that this was originally intended to later be used to run tests on
|
||||
# Travis, but it didn't work out. Regardless this has stuck around! You can run
|
||||
# tests in FreeBSD via:
|
||||
#
|
||||
# git clone https://github.com/alexcrichton/libc --branch autotest
|
||||
# cd libc/ci
|
||||
# vagrant up freebsd
|
||||
# vagrant ssh freebsd
|
||||
# ...
|
||||
# cd /vagrant/libc-test
|
||||
# cargo run
|
||||
#
|
||||
# And "that's it"! You look up instructions on Vagrant's website for how to
|
||||
# install vagrant.
|
||||
|
||||
Vagrant.configure(2) do |config|
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
config.vm.define :freebsd do |bsd|
|
||||
bsd.vm.box = "arkadi/freebsd-10.1-amd64"
|
||||
bsd.vm.provision :shell, inline: 'yes | sudo pkg install rust cargo'
|
||||
bsd.vm.provider "virtualbox" do |vb|
|
||||
vb.memory = "2048"
|
||||
end
|
||||
end
|
||||
config.vm.synced_folder "..", "/vagrant"
|
||||
end
|
|
@ -20,6 +20,23 @@ install() {
|
|||
sudo apt-get install $@
|
||||
}
|
||||
|
||||
# NOTE: this is not actually run on travis right now, this was added to in
|
||||
# theory run FreeBSD vagrant images on Travis, but it ended up not working, so
|
||||
# this may not be working when you read this.
|
||||
install_vagrant() {
|
||||
echo 'deb http://download.virtualbox.org/virtualbox/debian trusty contrib' | \
|
||||
sudo tee -a /etc/apt/sources.list
|
||||
vbox=virtualbox-5.0_5.0.4-102546~Ubuntu~trusty_amd64.deb
|
||||
curl https://www.virtualbox.org/download/oracle_vbox.asc | sudo apt-key add -
|
||||
install virtualbox-5.0 linux-headers-3.16.0-31-generic nfs-kernel-server
|
||||
|
||||
# After we've got virtualbox, install vagrant itself. Note that the version in
|
||||
# the default ubuntu repos is too old to run the images we have, so install
|
||||
# the one from the vagrant website's download link
|
||||
curl -LO https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.4_x86_64.deb
|
||||
sudo dpkg -i vagrant_1.7.4_x86_64.deb
|
||||
}
|
||||
|
||||
if [ "$TARGET" = "arm-linux-androideabi" ]; then
|
||||
# Pull a pre-built docker image for testing android, then run tests entirely
|
||||
# within that image.
|
||||
|
@ -51,6 +68,12 @@ elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then
|
|||
install emdebian-archive-keyring
|
||||
install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes
|
||||
export CC=mips-linux-gnu-gcc
|
||||
elif [ "$TARGET" = "x86_64-unknown-freebsd" ]; then
|
||||
install_vagrant
|
||||
cd ci
|
||||
vagrant up freebsd
|
||||
exec vagrant ssh freebsd -c \
|
||||
'cd /vagrant && CARGO_TARGET_DIR=/tmp sh ci/run.sh x86_64-unknown-freebsd'
|
||||
else
|
||||
# Download the rustlib folder from the relevant portion of main distribution's
|
||||
# tarballs.
|
||||
|
|
|
@ -12,6 +12,8 @@ fn main() {
|
|||
let android = target.contains("android");
|
||||
let darwin = target.contains("apple-darwin");
|
||||
let musl = target.contains("musl");
|
||||
let freebsd = target.contains("freebsd");
|
||||
let bsdlike = freebsd || darwin;
|
||||
let mut cfg = ctest::TestGenerator::new();
|
||||
|
||||
// Pull in extra goodies on linux/mingw
|
||||
|
@ -39,14 +41,6 @@ fn main() {
|
|||
.header("time.h")
|
||||
.header("wchar.h");
|
||||
|
||||
if darwin {
|
||||
cfg.header("mach-o/dyld.h");
|
||||
cfg.header("mach/mach_time.h");
|
||||
} else if linux || android {
|
||||
cfg.header("netpacket/packet.h");
|
||||
cfg.header("net/ethernet.h");
|
||||
}
|
||||
|
||||
if windows {
|
||||
cfg.header("winsock2.h"); // must be before windows.h
|
||||
|
||||
|
@ -84,31 +78,38 @@ fn main() {
|
|||
cfg.header("utime.h");
|
||||
cfg.header("pwd.h");
|
||||
cfg.header("grp.h");
|
||||
|
||||
if android {
|
||||
cfg.header("arpa/inet.h");
|
||||
} else {
|
||||
cfg.header("glob.h");
|
||||
cfg.header("ifaddrs.h");
|
||||
|
||||
if !musl {
|
||||
cfg.header("execinfo.h");
|
||||
cfg.header("sys/sysctl.h");
|
||||
}
|
||||
}
|
||||
|
||||
if darwin {
|
||||
cfg.header("malloc/malloc.h");
|
||||
cfg.header("crt_externs.h");
|
||||
} else {
|
||||
cfg.header("malloc.h");
|
||||
}
|
||||
|
||||
}
|
||||
if target.contains("linux") {
|
||||
|
||||
if android {
|
||||
cfg.header("arpa/inet.h");
|
||||
} else if !windows {
|
||||
cfg.header("glob.h");
|
||||
cfg.header("ifaddrs.h");
|
||||
|
||||
if !musl {
|
||||
cfg.header("execinfo.h");
|
||||
cfg.header("sys/sysctl.h");
|
||||
}
|
||||
}
|
||||
|
||||
if darwin {
|
||||
cfg.header("mach-o/dyld.h");
|
||||
cfg.header("mach/mach_time.h");
|
||||
cfg.header("malloc/malloc.h");
|
||||
cfg.header("crt_externs.h");
|
||||
}
|
||||
|
||||
if linux || android {
|
||||
cfg.header("netpacket/packet.h");
|
||||
cfg.header("net/ethernet.h");
|
||||
cfg.header("malloc.h");
|
||||
cfg.header("sys/prctl.h");
|
||||
}
|
||||
|
||||
if freebsd {
|
||||
cfg.header("pthread_np.h");
|
||||
}
|
||||
|
||||
cfg.type_name(move |ty, is_struct| {
|
||||
match ty {
|
||||
// Just pass all these through, no need for a "struct" prefix
|
||||
|
@ -120,7 +121,7 @@ fn main() {
|
|||
"ssize_t" if windows => "SSIZE_T".to_string(),
|
||||
|
||||
// OSX calls this something else
|
||||
"sighandler_t" if darwin => "sig_t".to_string(),
|
||||
"sighandler_t" if bsdlike => "sig_t".to_string(),
|
||||
|
||||
t if t.ends_with("_t") => t.to_string(),
|
||||
|
||||
|
@ -216,7 +217,7 @@ fn main() {
|
|||
"strerror_r" if linux => true, // actually xpg-something-or-other
|
||||
|
||||
// typed 2nd arg on linux and android
|
||||
"gettimeofday" if linux || android => true,
|
||||
"gettimeofday" if linux || android || freebsd => true,
|
||||
|
||||
"dlerror" if android => true, // const-ness is added
|
||||
|
||||
|
|
|
@ -158,6 +158,12 @@ s! {
|
|||
pub sa_mask: sigset_t,
|
||||
pub sa_flags: ::c_int,
|
||||
}
|
||||
|
||||
pub struct stack_t {
|
||||
pub ss_sp: *mut ::c_void,
|
||||
pub ss_size: ::size_t,
|
||||
pub ss_flags: ::c_int,
|
||||
}
|
||||
}
|
||||
|
||||
pub const EXIT_FAILURE: c_int = 1;
|
||||
|
@ -638,7 +644,6 @@ pub const _SC_TRACE_SYS_MAX: c_int = 129;
|
|||
pub const _SC_TRACE_USER_EVENT_MAX: c_int = 130;
|
||||
pub const _SC_PASS_MAX: c_int = 131;
|
||||
|
||||
|
||||
pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
|
||||
pub const _PTHREAD_MUTEX_SIG_init: ::c_long = 0x32AAABA7;
|
||||
pub const _PTHREAD_COND_SIG_init: ::c_long = 0x3CB0B1BB;
|
||||
|
@ -656,6 +661,8 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
|
|||
__opaque: [0; __PTHREAD_RWLOCK_SIZE__],
|
||||
};
|
||||
|
||||
pub const SIGSTKSZ: ::size_t = 131072;
|
||||
|
||||
extern {
|
||||
pub fn _NSGetExecutablePath(buf: *mut ::c_char,
|
||||
bufsize: *mut ::uint32_t) -> ::c_int;
|
||||
|
@ -686,6 +693,8 @@ extern {
|
|||
pub fn pthread_get_stackaddr_np(thread: pthread_t) -> *mut ::c_void;
|
||||
pub fn pthread_get_stacksize_np(thread: pthread_t) -> ::size_t;
|
||||
pub fn __error() -> *mut ::c_int;
|
||||
pub fn backtrace(buf: *mut *mut ::c_void,
|
||||
sz: ::c_int) -> ::c_int;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -2,5 +2,5 @@ pub const PTHREAD_STACK_MIN: ::size_t = 2048;
|
|||
pub const KERN_PROC_PATHNAME: ::c_int = 12;
|
||||
|
||||
extern {
|
||||
pub fn __error() -> *const ::c_int;
|
||||
pub fn __error() -> *mut ::c_int;
|
||||
}
|
||||
|
|
|
@ -64,13 +64,14 @@ s! {
|
|||
}
|
||||
|
||||
pub struct siginfo_t {
|
||||
pub _signo: ::c_int,
|
||||
pub _errno: ::c_int,
|
||||
pub _code: ::c_int,
|
||||
pub _pid: ::pid_t,
|
||||
pub _uid: ::uid_t,
|
||||
pub _status: ::c_int,
|
||||
pub si_addr: *mut ::c_void
|
||||
pub si_signo: ::c_int,
|
||||
pub si_errno: ::c_int,
|
||||
pub si_code: ::c_int,
|
||||
pub si_pid: ::pid_t,
|
||||
pub si_uid: ::uid_t,
|
||||
pub si_status: ::c_int,
|
||||
pub si_addr: *mut ::c_void,
|
||||
_pad: [c_int; 12],
|
||||
}
|
||||
|
||||
pub struct sigaction {
|
||||
|
@ -78,6 +79,12 @@ s! {
|
|||
pub sa_flags: ::c_int,
|
||||
pub sa_mask: sigset_t,
|
||||
}
|
||||
|
||||
pub struct stack_t {
|
||||
pub ss_sp: *mut ::c_char,
|
||||
pub ss_size: ::size_t,
|
||||
pub ss_flags: ::c_int,
|
||||
}
|
||||
}
|
||||
|
||||
pub const EXIT_FAILURE: ::c_int = 1;
|
||||
|
@ -491,6 +498,8 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _;
|
|||
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _;
|
||||
pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
|
||||
|
||||
pub const SIGSTKSZ: ::size_t = 34816;
|
||||
|
||||
extern {
|
||||
pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int)
|
||||
-> c_int;
|
||||
|
@ -511,6 +520,8 @@ extern {
|
|||
-> c_int;
|
||||
pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
|
||||
pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char);
|
||||
pub fn backtrace(buf: *mut *mut ::c_void,
|
||||
sz: ::size_t) -> ::size_t;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -39,12 +39,9 @@ s! {
|
|||
pub pw_dir: *mut ::c_char,
|
||||
pub pw_shell: *mut ::c_char,
|
||||
pub pw_expire: ::time_t,
|
||||
}
|
||||
|
||||
pub struct stack_t {
|
||||
pub ss_sp: *mut ::c_void,
|
||||
pub ss_size: ::size_t,
|
||||
pub ss_flags: ::c_int,
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub pw_fields: ::c_int,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +50,6 @@ pub const FIOCLEX: c_ulong = 0x20006601;
|
|||
pub const SA_ONSTACK: ::c_int = 0x0001;
|
||||
pub const SA_SIGINFO: ::c_int = 0x0040;
|
||||
|
||||
pub const SIGSTKSZ: ::size_t = 131072;
|
||||
pub const SIGBUS: ::c_int = 10;
|
||||
pub const SIG_SETMASK: ::c_int = 3;
|
||||
|
||||
|
|
|
@ -17,6 +17,12 @@ pub type pthread_key_t = ::c_int;
|
|||
pub sa_flags: libc::c_int,
|
||||
}
|
||||
|
||||
|
||||
pub struct stack_t {
|
||||
pub ss_sp: *mut ::c_void,
|
||||
pub ss_size: ::size_t,
|
||||
pub ss_flags: ::c_int,
|
||||
}
|
||||
#[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os ="openbsd"))]
|
||||
pub mod os {
|
||||
pub mod common {
|
||||
|
@ -736,6 +742,7 @@ pub type pthread_key_t = ::c_int;
|
|||
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut();
|
||||
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut();
|
||||
pub const PTHREAD_MUTEX_RECURSIVE: libc::c_int = 2;
|
||||
pub const SIGSTKSZ: ::size_t = 131072;
|
||||
extern {
|
||||
pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int)
|
||||
-> c_int;
|
||||
|
@ -760,4 +767,6 @@ extern {
|
|||
pub fn pthread_stackseg_np(thread: pthread_t,
|
||||
sinfo: *mut stack_t) -> ::c_uint;
|
||||
pub fn __errno() -> *const ::c_int;
|
||||
pub fn backtrace(buf: *mut *mut ::c_void,
|
||||
sz: ::size_t) -> ::size_t;
|
||||
}
|
||||
|
|
|
@ -493,9 +493,6 @@ extern {
|
|||
buf: *mut ::c_char,
|
||||
buflen: ::size_t,
|
||||
result: *mut *mut passwd) -> ::c_int;
|
||||
#[cfg(not(target_env = "musl"))]
|
||||
pub fn backtrace(buf: *mut *mut ::c_void,
|
||||
sz: ::c_int) -> ::c_int;
|
||||
pub fn posix_memalign(memptr: *mut *mut ::c_void,
|
||||
align: ::size_t,
|
||||
size: ::size_t) -> ::c_int;
|
||||
|
|
|
@ -318,6 +318,9 @@ extern {
|
|||
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
|
||||
pub fn setgroups(ngroups: ::size_t,
|
||||
ptr: *const ::gid_t) -> ::c_int;
|
||||
#[cfg(not(target_env = "musl"))]
|
||||
pub fn backtrace(buf: *mut *mut ::c_void,
|
||||
sz: ::c_int) -> ::c_int;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
Loading…
Reference in New Issue