]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #26682 - posix4e:netbsd, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 2 Jul 2015 18:50:46 +0000 (18:50 +0000)
committerbors <bors@rust-lang.org>
Thu, 2 Jul 2015 18:50:46 +0000 (18:50 +0000)
This is dependent on https://github.com/rust-lang/rust-installer/pull/38. Once it is merged we most likely need to update the commit.

43 files changed:
configure
mk/cfg/x86_64-unknown-netbsd.mk [new file with mode: 0644]
src/compiletest/util.rs
src/doc/reference.md
src/etc/snapshot.py
src/liblibc/lib.rs
src/librustc_back/arm.rs
src/librustc_back/mips.rs
src/librustc_back/mipsel.rs
src/librustc_back/target/mod.rs
src/librustc_back/target/netbsd_base.rs [new file with mode: 0644]
src/librustc_back/target/x86_64_unknown_netbsd.rs [new file with mode: 0644]
src/librustc_back/x86.rs
src/librustc_back/x86_64.rs
src/librustdoc/flock.rs
src/libstd/dynamic_lib.rs
src/libstd/env.rs
src/libstd/net/tcp.rs
src/libstd/net/udp.rs
src/libstd/os/mod.rs
src/libstd/os/netbsd/mod.rs [new file with mode: 0644]
src/libstd/os/netbsd/raw.rs [new file with mode: 0644]
src/libstd/rt/args.rs
src/libstd/rt/libunwind.rs
src/libstd/rtdeps.rs
src/libstd/sys/common/stack.rs
src/libstd/sys/unix/backtrace.rs
src/libstd/sys/unix/c.rs
src/libstd/sys/unix/mod.rs
src/libstd/sys/unix/os.rs
src/libstd/sys/unix/process.rs
src/libstd/sys/unix/stack_overflow.rs
src/libstd/sys/unix/sync.rs
src/libstd/sys/unix/thread.rs
src/libstd/sys/unix/thread_local.rs
src/libstd/sys/unix/time.rs
src/libstd/thread/scoped_tls.rs
src/libsyntax/abi.rs
src/test/parse-fail/issue-5806.rs
src/test/run-pass/intrinsic-alignment.rs
src/test/run-pass/rec-align-u64.rs
src/test/run-pass/tcp-stress.rs
src/test/run-pass/x86stdcall.rs

index 5d4a017b6fbfaa8f9624dd5f1c76dc7b975b7abb..1d3611f88f0a9bf77e400359c02676b85f1541e4 100755 (executable)
--- a/configure
+++ b/configure
@@ -405,6 +405,10 @@ case $CFG_OSTYPE in
         CFG_OSTYPE=unknown-openbsd
        ;;
 
+    NetBSD)
+           CFG_OSTYPE=unknown-netbsd
+           ;;
+
     Darwin)
         CFG_OSTYPE=apple-darwin
         ;;
diff --git a/mk/cfg/x86_64-unknown-netbsd.mk b/mk/cfg/x86_64-unknown-netbsd.mk
new file mode 100644 (file)
index 0000000..401b0fb
--- /dev/null
@@ -0,0 +1,22 @@
+# x86_64-unknown-netbsd configuration
+CC_x86_64-unknown-netbsd=$(CC)
+CXX_x86_64-unknown-netbsd=$(CXX)
+CPP_x86_64-unknown-netbsd=$(CPP)
+AR_x86_64-unknown-netbsd=$(AR)
+CFG_LIB_NAME_x86_64-unknown-netbsd=lib$(1).so
+CFG_STATIC_LIB_NAME_x86_64-unknown-netbsd=lib$(1).a
+CFG_LIB_GLOB_x86_64-unknown-netbsd=lib$(1)-*.so
+CFG_LIB_DSYM_GLOB_x86_64-unknown-netbsd=$(1)-*.dylib.dSYM
+CFG_JEMALLOC_CFLAGS_x86_64-unknown-netbsd := -I/usr/local/include $(CFLAGS)
+CFG_GCCISH_CFLAGS_x86_64-unknown-netbsd := -Wall -Werror -g -fPIC -I/usr/local/include $(CFLAGS)
+CFG_GCCISH_LINK_FLAGS_x86_64-unknown-netbsd := -shared -fPIC -g -pthread  -lrt
+CFG_GCCISH_DEF_FLAG_x86_64-unknown-netbsd := -Wl,--export-dynamic,--dynamic-list=
+CFG_LLC_FLAGS_x86_64-unknown-netbsd :=
+CFG_INSTALL_NAME_x86_64-unknown-netbsd =
+CFG_EXE_SUFFIX_x86_64-unknown-netbsd :=
+CFG_WINDOWSY_x86_64-unknown-netbsd :=
+CFG_UNIXY_x86_64-unknown-netbsd := 1
+CFG_LDPATH_x86_64-unknown-netbsd :=
+CFG_RUN_x86_64-unknown-netbsd=$(2)
+CFG_RUN_TARG_x86_64-unknown-netbsd=$(call CFG_RUN_x86_64-unknown-netbsd,,$(2))
+CFG_GNU_TRIPLE_x86_64-unknown-netbsd := x86_64-unknown-netbsd
index 184d62db45114682d21ffe8303424c89e7f5405e..13d6c029ff58458900dc57c34fc02fba75dab871 100644 (file)
@@ -21,6 +21,7 @@
     ("ios", "ios"),
     ("linux", "linux"),
     ("mingw32", "windows"),
+    ("netbsd", "netbsd"),
     ("openbsd", "openbsd"),
     ("win32", "windows"),
     ("windows", "windows"),
index 7e28651c6aafb1246283932cdb92e9ce83132595..650e1d5541ecf173ab20bcfd48549ace5221fff4 100644 (file)
@@ -2023,7 +2023,7 @@ The following configurations must be defined by the implementation:
   as a configuration itself, like `unix` or `windows`.
 * `target_os = "..."`. Operating system of the target, examples include
   `"windows"`, `"macos"`, `"ios"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"`,
-  `"bitrig"` or `"openbsd"`.
+  `"bitrig"` , `"openbsd"` or `"netbsd"`.
 * `target_pointer_width = "..."`. Target pointer width in bits. This is set
   to `"32"` for targets with 32-bit pointers, and likewise set to `"64"` for
   64-bit pointers.
index 0349ccf9b66408bf80833afe3d4b96d68dd6ceef..6d62a45c703a23561379d40467cb8337aa6efe40 100644 (file)
@@ -41,13 +41,14 @@ download_dir_base = "dl"
 download_unpack_base = os.path.join(download_dir_base, "unpack")
 
 snapshot_files = {
+        "bitrig": ["bin/rustc"],
+        "dragonfly": ["bin/rustc"],
+        "freebsd": ["bin/rustc"],
         "linux": ["bin/rustc"],
         "macos": ["bin/rustc"],
-        "winnt": ["bin/rustc.exe"],
-        "freebsd": ["bin/rustc"],
-        "dragonfly": ["bin/rustc"],
-        "bitrig": ["bin/rustc"],
+        "netbsd": ["bin/rustc"],
         "openbsd": ["bin/rustc"],
+        "winnt": ["bin/rustc.exe"],
         }
 
 winnt_runtime_deps_32 = ["libgcc_s_dw2-1.dll", "libstdc++-6.dll"]
@@ -103,6 +104,8 @@ def get_kernel(triple):
         return "dragonfly"
     if os_name == "bitrig":
         return "bitrig"
+    if os_name == "netbsd":
+        return "netbsd"
     if os_name == "openbsd":
         return "openbsd"
     return "linux"
index 6e01796ad82279b9f1f6305e4a04e65858700edc..f66811e561adf359d0e19ef75314a90fd6a156c3 100644 (file)
@@ -1322,7 +1322,7 @@ pub mod extra {
         }
     }
 
-    #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
+    #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os ="openbsd"))]
     pub mod os {
         pub mod common {
             pub mod posix01 {
@@ -1351,7 +1351,7 @@ pub mod posix01 {
                     pub __unused7: *mut c_void,
                 }
 
-                #[cfg(target_os = "openbsd")]
+                #[cfg(any(target_os = "netbsd", target_os="openbsd"))]
                 #[repr(C)]
                 #[derive(Copy, Clone)] pub struct glob_t {
                     pub gl_pathc:  c_int,
@@ -4323,7 +4323,7 @@ pub mod sysconf {
         }
     }
 
-    #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
+    #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))]
     pub mod os {
         pub mod c95 {
             use types::os::arch::c95::{c_int, c_uint};
@@ -5568,6 +5568,7 @@ pub mod mman {
               target_os = "freebsd",
               target_os = "dragonfly",
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd",
               target_os = "nacl"))]
     pub mod posix88 {
@@ -5584,6 +5585,7 @@ pub mod stat_ {
                           target_os = "freebsd",
                           target_os = "dragonfly",
                           target_os = "bitrig",
+                          target_os = "netbsd",
                           target_os = "openbsd",
                           target_os = "android",
                           target_os = "ios",
@@ -5602,6 +5604,7 @@ pub mod stat_ {
                           target_os = "freebsd",
                           target_os = "dragonfly",
                           target_os = "bitrig",
+                          target_os = "netbsd",
                           target_os = "openbsd",
                           target_os = "android",
                           target_os = "ios",
@@ -5889,6 +5892,7 @@ pub mod net {
               target_os = "freebsd",
               target_os = "dragonfly",
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd",
               target_os = "nacl"))]
     pub mod posix01 {
@@ -5901,6 +5905,7 @@ pub mod stat_ {
                           target_os = "freebsd",
                           target_os = "dragonfly",
                           target_os = "bitrig",
+                          target_os = "netbsd",
                           target_os = "openbsd",
                           target_os = "android",
                           target_os = "ios",
@@ -6019,16 +6024,17 @@ pub mod net {
     }
 
 
-    #[cfg(any(target_os = "windows",
-              target_os = "linux",
-              target_os = "android",
-              target_os = "macos",
+    #[cfg(any(target_os = "android",
+              target_os = "bitrig",
+              target_os = "dragonfly",
               target_os = "ios",
               target_os = "freebsd",
-              target_os = "dragonfly",
-              target_os = "bitrig",
+              target_os = "linux",
+              target_os = "macos",
+              target_os = "nacl",
+              target_os = "netbsd",
               target_os = "openbsd",
-              target_os = "nacl"))]
+              target_os = "windows"))]
     pub mod posix08 {
         pub mod unistd {
         }
@@ -6115,6 +6121,7 @@ pub fn sendto(socket: SOCKET, buf: *const c_void, len: c_int,
               target_os = "freebsd",
               target_os = "dragonfly",
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd"))]
     pub mod bsd44 {
         use types::common::c95::{c_void};
@@ -6192,6 +6199,7 @@ pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32)
     #[cfg(any(target_os = "freebsd",
               target_os = "dragonfly",
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd"))]
     pub mod extra {
     }
index 7325e4e7a2ece9aa4a15bee6e35c2820e4159a0c..9e288f6ddb2bfaa7b985831bba59939b47a03f31 100644 (file)
@@ -61,7 +61,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
                 -a:0:64-n32".to_string()
           }
 
-          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd => {
+          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd | abi::OsNetbsd => {
             "e-p:32:32:32\
                 -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
                 -f32:32:32-f64:64:64\
index b46150f75d084516102e96252fc7017489955254..e1edff817d6c1f27cf9e37285a5a4e4c1f58bb38 100644 (file)
@@ -56,7 +56,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
                 -a:0:64-n32".to_string()
           }
 
-          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd => {
+          abi::OsBitrig | abi::OsDragonfly | abi::OsFreebsd | abi::OsNetbsd | abi::OsOpenbsd => {
             "E-p:32:32:32\
                 -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
                 -f32:32:32-f64:64:64\
index c7fa7aa879ac272c440982fe5ece76fadd3a70c0..ca52a9e56ff52978b7ed9c68801219182fe98249 100644 (file)
@@ -56,7 +56,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
                 -a:0:64-n32".to_string()
           }
 
-          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd => {
+          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd | abi::OsNetbsd => {
             "e-p:32:32:32\
                 -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
                 -f32:32:32-f64:64:64\
index a42f861d19056d6d55d00ec613d243ede9a58693..bc5f306cd3568b8ad8a5521a5172eac59f9997fa 100644 (file)
@@ -58,6 +58,7 @@
 mod freebsd_base;
 mod linux_base;
 mod openbsd_base;
+mod netbsd_base;
 mod windows_base;
 mod windows_msvc_base;
 
@@ -368,6 +369,7 @@ macro_rules! load_specific {
 
             x86_64_unknown_bitrig,
             x86_64_unknown_openbsd,
+            x86_64_unknown_netbsd,
 
             x86_64_apple_darwin,
             i686_apple_darwin,
diff --git a/src/librustc_back/target/netbsd_base.rs b/src/librustc_back/target/netbsd_base.rs
new file mode 100644 (file)
index 0000000..0f2ab32
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use target::TargetOptions;
+use std::default::Default;
+
+pub fn opts() -> TargetOptions {
+    TargetOptions {
+        linker: "cc".to_string(),
+        dynamic_linking: true,
+        executables: true,
+        morestack: false,
+        linker_is_gnu: true,
+        has_rpath: true,
+        pre_link_args: vec!(
+            // GNU-style linkers will use this to omit linking to libraries
+            // which don't actually fulfill any relocations, but only for
+            // libraries which follow this flag.  Thus, use it before
+            // specifying libraries to link to.
+            "-Wl,--as-needed".to_string(),
+        ),
+        position_independent_executables: true,
+        .. Default::default()
+    }
+}
diff --git a/src/librustc_back/target/x86_64_unknown_netbsd.rs b/src/librustc_back/target/x86_64_unknown_netbsd.rs
new file mode 100644 (file)
index 0000000..3f5bd39
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use target::Target;
+
+pub fn target() -> Target {
+    let mut base = super::netbsd_base::opts();
+    base.pre_link_args.push("-m64".to_string());
+
+    Target {
+        data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
+                     f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
+                     s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
+        llvm_target: "x86_64-unknown-netbsd".to_string(),
+        target_endian: "little".to_string(),
+        target_pointer_width: "64".to_string(),
+        arch: "x86_64".to_string(),
+        target_os: "netbsd".to_string(),
+        target_env: "".to_string(),
+        options: base,
+    }
+}
index 1c6eacc355947850044b035fb5d6db4f8690a1c9..46e0a83ac033b681387cdc07c188c676cdefc3d8 100644 (file)
@@ -45,7 +45,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os)
             "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
           }
 
-          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd => {
+          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd | abi::OsNetbsd => {
             "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
           }
 
index d016bd12c698fdd5646cafbf4f5c7e298ba10c7a..abdcd56444213e121fbb7f023a6df1674716d554 100644 (file)
@@ -47,7 +47,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
                 s0:64:64-f80:128:128-n8:16:32:64-S128".to_string()
           }
 
-          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd => {
+          abi::OsBitrig | abi::OsDragonfly | abi::OsFreebsd | abi::OsNetbsd | abi::OsOpenbsd => {
             "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
                 f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
                 s0:64:64-f80:128:128-n8:16:32:64-S128".to_string()
index 760fa329fd9866808f68a7570a4bd2ba48b19c99..847e28d2bc510f7c8816174f05e67c4ba66505ff 100644 (file)
@@ -68,6 +68,7 @@ pub struct flock {
 
     #[cfg(any(target_os = "dragonfly",
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd"))]
     mod os {
         use libc;
index a17d121e60a2a834c4928480d6d2d9191ec6d962..3621d18daed818b27fe2ad08b5809804d7c09926 100644 (file)
@@ -160,6 +160,7 @@ fn test_loading_cosine() {
               target_os = "freebsd",
               target_os = "dragonfly",
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd"))]
     fn test_errors_do_not_crash() {
         // Open /dev/null as a library to get an error, and make sure
@@ -179,6 +180,7 @@ fn test_errors_do_not_crash() {
           target_os = "freebsd",
           target_os = "dragonfly",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 mod dl {
     use prelude::v1::*;
index 2e00e126e2378f8b7f9d385e4d184ad35b9d4411..7c2cd615303c0c19e2e30a6466d3e3e9ec9d44da 100644 (file)
@@ -633,6 +633,7 @@ pub mod consts {
     /// - freebsd
     /// - dragonfly
     /// - bitrig
+    /// - netbsd
     /// - openbsd
     /// - android
     /// - windows
@@ -759,6 +760,17 @@ mod os {
     pub const EXE_EXTENSION: &'static str = "";
 }
 
+#[cfg(target_os = "netbsd")]
+mod os {
+    pub const FAMILY: &'static str = "unix";
+    pub const OS: &'static str = "netbsd";
+    pub const DLL_PREFIX: &'static str = "lib";
+    pub const DLL_SUFFIX: &'static str = ".so";
+    pub const DLL_EXTENSION: &'static str = "so";
+    pub const EXE_SUFFIX: &'static str = "";
+    pub const EXE_EXTENSION: &'static str = "";
+}
+
 #[cfg(target_os = "openbsd")]
 mod os {
     pub const FAMILY: &'static str = "unix";
index 222059e4c0e6a164f6ebd0c26d021e6ee7a46429..085ba286dc3d94d626147e7ca993cabdd7d55c2f 100644 (file)
@@ -904,7 +904,7 @@ fn debug() {
 
     // FIXME: re-enabled bitrig/openbsd tests once their socket timeout code
     //        no longer has rounding errors.
-    #[cfg_attr(any(target_os = "bitrig", target_os = "openbsd"), ignore)]
+    #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)]
     #[test]
     fn timeouts() {
         let addr = next_test_ip4();
index c3cf9895205e47290f49cd08d355ca8988fc84d9..0545175d9aee90cb788002205bae53f7d190a4a2 100644 (file)
@@ -360,9 +360,9 @@ fn debug() {
         assert_eq!(format!("{:?}", udpsock), compare);
     }
 
-    // FIXME: re-enabled bitrig/openbsd tests once their socket timeout code
+    // FIXME: re-enabled bitrig/openbsd/netbsd tests once their socket timeout code
     //        no longer has rounding errors.
-    #[cfg_attr(any(target_os = "bitrig", target_os = "openbsd"), ignore)]
+    #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)]
     #[test]
     fn timeouts() {
         let addr = next_test_ip4();
index cc4b1c944e7861124462ef7c53e4239fe1c2b302..859cb900460c54bc7f8fc1449c54b5ed58fd5775 100644 (file)
@@ -24,6 +24,7 @@
 #[cfg(target_os = "linux")]     pub mod linux;
 #[cfg(target_os = "macos")]     pub mod macos;
 #[cfg(target_os = "nacl")]      pub mod nacl;
+#[cfg(target_os = "netbsd")]   pub mod netbsd;
 #[cfg(target_os = "openbsd")]   pub mod openbsd;
 
 pub mod raw;
diff --git a/src/libstd/os/netbsd/mod.rs b/src/libstd/os/netbsd/mod.rs
new file mode 100644 (file)
index 0000000..bdb003b
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! OpenBSD-specific definitions
+
+#![stable(feature = "raw_ext", since = "1.1.0")]
+
+pub mod raw;
+
+pub mod fs {
+    #![stable(feature = "raw_ext", since = "1.1.0")]
+    pub use sys::fs::MetadataExt;
+}
diff --git a/src/libstd/os/netbsd/raw.rs b/src/libstd/os/netbsd/raw.rs
new file mode 100644 (file)
index 0000000..f9898df
--- /dev/null
@@ -0,0 +1,71 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! NetBSD/OpenBSD-specific raw type definitions
+
+#![stable(feature = "raw_ext", since = "1.1.0")]
+
+use os::raw::c_long;
+use os::unix::raw::{uid_t, gid_t};
+
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = i32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
+#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
+
+#[repr(C)]
+#[stable(feature = "raw_ext", since = "1.1.0")]
+pub struct stat {
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_mode: mode_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_dev: dev_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_ino: ino_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_nlink: nlink_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_uid: uid_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_gid: gid_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_rdev: dev_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_atime: time_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_atime_nsec: c_long,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_mtime: time_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_mtime_nsec: c_long,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_ctime: time_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_ctime_nsec: c_long,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_size: off_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_blocks: blkcnt_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_blksize: blksize_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_flags: fflags_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_gen: u32,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_birthtime: time_t,
+    #[stable(feature = "raw_ext", since = "1.1.0")]
+    pub st_birthtime_nsec: c_long,
+}
index d23a124a6ecda21ddc572d19f8dc37aa7f9dd2e2..52697f00264beb4f3bd5232ead6109a8f8f7abfe 100644 (file)
@@ -44,6 +44,7 @@ pub fn clone() -> Option<Vec<Vec<u8>>> { imp::clone() }
           target_os = "freebsd",
           target_os = "dragonfly",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 mod imp {
     use prelude::v1::*;
index 8f75ae5ef5cc8441cd5b3e687a8465687e7928f1..d99b31c9f2b4318ded1c96f695b7bae2d088d7b9 100644 (file)
@@ -106,7 +106,7 @@ pub enum _Unwind_Context {}
 #[link(name = "unwind", kind = "static")]
 extern {}
 
-#[cfg(any(target_os = "android", target_os = "openbsd"))]
+#[cfg(any(target_os = "android", target_os = "netbsd", target_os = "openbsd"))]
 #[link(name = "gcc")]
 extern {}
 
index be674c83e221351903a0168741077c488cfbf946..a395dbf8995c648a02539fec1330804a8d806e5c 100644 (file)
@@ -39,6 +39,7 @@
 
 #[cfg(any(target_os = "dragonfly",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 #[link(name = "pthread")]
 extern {}
index 11982ebc572e5b3dc571d8a0726d7b5d5583ff8b..002e3b20c354222cff5c7f39eefa0b03ce906790 100644 (file)
@@ -202,6 +202,7 @@ unsafe fn target_record_sp_limit(limit: usize) {
               target_arch = "powerpc",
               all(target_arch = "arm", target_os = "ios"),
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd"))]
     unsafe fn target_record_sp_limit(_: usize) {
     }
@@ -299,6 +300,7 @@ unsafe fn target_get_sp_limit() -> usize {
               target_arch = "powerpc",
               all(target_arch = "arm", target_os = "ios"),
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd"))]
     #[inline(always)]
     unsafe fn target_get_sp_limit() -> usize {
index b23a3eee1a1738e03e69f9706901a3d5e82b21fa..a5d1595cfeb1f89da2d7e8c8cb0da2b84bc21e74 100644 (file)
@@ -363,6 +363,7 @@ unsafe fn init_state() -> *mut backtrace_state {
         let selfname = if cfg!(target_os = "freebsd") ||
                           cfg!(target_os = "dragonfly") ||
                           cfg!(target_os = "bitrig") ||
+                          cfg!(target_os = "netbsd") ||
                           cfg!(target_os = "openbsd") {
             env::current_exe().ok()
         } else {
index 99a6731c57d95317d597a8ddf4ac2c02f8ff03d8..eeecf7f50f79a52fa522e7a8a173a0a0dfda76fa 100644 (file)
@@ -34,6 +34,7 @@
           target_os = "freebsd",
           target_os = "dragonfly",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 pub const FIOCLEX: libc::c_ulong = 0x20006601;
 
@@ -60,6 +61,7 @@
           target_os = "dragonfly"))]
 pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 71;
 #[cfg(any(target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 101;
 #[cfg(target_os = "android")]
@@ -82,6 +84,7 @@ pub struct passwd {
           target_os = "freebsd",
           target_os = "dragonfly",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 pub struct passwd {
     pub pw_name: *mut libc::c_char,
@@ -321,6 +324,7 @@ pub struct sigaltstack {
           target_os = "freebsd",
           target_os = "dragonfly",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 mod signal_os {
     use libc;
@@ -348,7 +352,7 @@ mod signal_os {
     pub struct sigset_t {
         bits: [u32; 4],
     }
-    #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
+    #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))]
     pub type sigset_t = libc::c_uint;
 
     // This structure has more fields, but we're not all that interested in
@@ -365,7 +369,7 @@ pub struct siginfo {
         pub _status: libc::c_int,
         pub si_addr: *mut libc::c_void
     }
-    #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
+    #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))]
     #[repr(C)]
     pub struct siginfo {
         pub si_signo: libc::c_int,
@@ -375,7 +379,7 @@ pub struct siginfo {
     }
 
     #[cfg(any(target_os = "macos", target_os = "ios",
-              target_os = "bitrig", target_os = "openbsd"))]
+              target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))]
     #[repr(C)]
     pub struct sigaction {
         pub sa_sigaction: sighandler_t,
index c1a4e8cee9ed4079fdbac145417ef76c7b520351..6fd20b940bb52f14c9c4b53cda1bf2ebf3f8e6f9 100644 (file)
@@ -26,6 +26,7 @@
 #[cfg(target_os = "linux")]     pub use os::linux as platform;
 #[cfg(target_os = "macos")]     pub use os::macos as platform;
 #[cfg(target_os = "nacl")]      pub use os::nacl as platform;
+#[cfg(target_os = "netbsd")]    pub use os::netbsd as platform;
 #[cfg(target_os = "openbsd")]   pub use os::openbsd as platform;
 
 pub mod backtrace;
index 5178d7b8fb1a0ac962ddb058a68fb0b31ff65a20..334dd6b5f18c1ef56b7c35967a3a6c9949c730e8 100644 (file)
@@ -51,23 +51,13 @@ unsafe fn errno_location() -> *const c_int {
         __error()
     }
 
-    #[cfg(target_os = "bitrig")]
-    fn errno_location() -> *const c_int {
-        extern {
-            fn __errno() -> *const c_int;
-        }
-        unsafe {
-            __errno()
-        }
-    }
-
     #[cfg(target_os = "dragonfly")]
     unsafe fn errno_location() -> *const c_int {
         extern { fn __dfly_error() -> *const c_int; }
         __dfly_error()
     }
 
-    #[cfg(target_os = "openbsd")]
+    #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))]
     unsafe fn errno_location() -> *const c_int {
         extern { fn __errno() -> *const c_int; }
         __errno()
@@ -214,7 +204,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
     ::fs::read_link("/proc/curproc/file")
 }
 
-#[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
+#[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))]
 pub fn current_exe() -> io::Result<PathBuf> {
     use sync::StaticMutex;
     static LOCK: StaticMutex = StaticMutex::new();
@@ -356,6 +346,7 @@ pub fn args() -> Args {
           target_os = "freebsd",
           target_os = "dragonfly",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 pub fn args() -> Args {
     use rt;
index 695d0ddfaaf61f455cbb4faa23d3b276d91418c6..cc78dd4e5ef1233f4ac58a8d1a14e96c8b361f7a 100644 (file)
@@ -423,6 +423,7 @@ pub fn WTERMSIG(status: i32) -> i32 { status & 0x7f }
               target_os = "freebsd",
               target_os = "dragonfly",
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd"))]
     mod imp {
         pub fn WIFEXITED(status: i32) -> bool { (status & 0x7f) == 0 }
index 52494a17b9d24f314a44b4504d15fc1e8aa5ce4b..62689c39255e37f8c5d4054fbdf3099e48c28b46 100644 (file)
@@ -35,6 +35,7 @@ fn drop(&mut self) {
 #[cfg(any(target_os = "linux",
           target_os = "macos",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 mod imp {
     use sys_common::stack;
@@ -149,6 +150,7 @@ pub unsafe fn drop_handler(handler: &mut Handler) {
 #[cfg(not(any(target_os = "linux",
               target_os = "macos",
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd")))]
 mod imp {
     use libc;
index 41e1e206a423a7c43a0869c6ec642a5aedf9d1e9..9c8a1f4ca40ecc7e230da8aecb88f80365af639b 100644 (file)
@@ -55,6 +55,7 @@ pub fn gettimeofday(tp: *mut libc::timeval,
 #[cfg(any(target_os = "freebsd",
           target_os = "dragonfly",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 mod os {
     use libc;
index bb0e12e8df89944afeca8653820c5e4c661c9905..17804c8d81ffbbd2744e9a5edfac82a86258094e 100644 (file)
@@ -105,6 +105,7 @@ fn prctl(option: libc::c_int, arg2: libc::c_ulong,
     #[cfg(any(target_os = "freebsd",
               target_os = "dragonfly",
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd"))]
     pub fn set_name(name: &str) {
         extern {
@@ -162,6 +163,7 @@ fn drop(&mut self) {
 #[cfg(all(not(target_os = "linux"),
           not(target_os = "macos"),
           not(target_os = "bitrig"),
+          not(target_os = "netbsd"),
           not(target_os = "openbsd")))]
 pub mod guard {
     pub unsafe fn current() -> usize { 0 }
@@ -173,6 +175,7 @@ pub unsafe fn init() {}
 #[cfg(any(target_os = "linux",
           target_os = "macos",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 #[allow(unused_imports)]
 pub mod guard {
@@ -193,6 +196,7 @@ pub mod guard {
 
     #[cfg(any(target_os = "macos",
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd"))]
     unsafe fn get_stack_start() -> *mut libc::c_void {
         current() as *mut libc::c_void
@@ -258,7 +262,7 @@ pub unsafe fn current() -> usize {
          pthread_get_stacksize_np(pthread_self())) as usize
     }
 
-    #[cfg(any(target_os = "openbsd", target_os = "bitrig"))]
+    #[cfg(any(target_os = "openbsd", target_os = "netbsd", target_os = "bitrig"))]
     pub unsafe fn current() -> usize {
         #[repr(C)]
         struct stack_t {
index 3afe84b25804c3c5d11836da16d80052984b7ec0..7238adfcc566de983f2e9542f613367f2b449ef7 100644 (file)
@@ -46,6 +46,7 @@ pub unsafe fn destroy(key: Key) {
 #[cfg(any(target_os = "freebsd",
           target_os = "dragonfly",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 type pthread_key_t = ::libc::c_int;
 
@@ -54,6 +55,7 @@ pub unsafe fn destroy(key: Key) {
               target_os = "freebsd",
               target_os = "dragonfly",
               target_os = "bitrig",
+              target_os = "netbsd",
               target_os = "openbsd")))]
 type pthread_key_t = ::libc::c_uint;
 
index 6b84baeca7dc9d6a2d0f298c253f53d196de2a62..db0d0f150613953e5100878c7930ae1468656e73 100644 (file)
@@ -80,6 +80,7 @@ pub struct SteadyTime {
     // OpenBSD provide it via libc
     #[cfg(not(any(target_os = "android",
                   target_os = "bitrig",
+                  target_os = "netbsd",
                   target_os = "openbsd",
                   target_env = "musl")))]
     #[link(name = "rt")]
index 679902ec7abdb0fdaad47b0deb44b4de3e7c1a13..c2fad0aa89c9376aa8ef77012161169ac18c6caa 100644 (file)
@@ -104,6 +104,7 @@ macro_rules! __scoped_thread_local_inner {
         #[cfg_attr(not(any(windows,
                            target_os = "android",
                            target_os = "ios",
+                           target_os = "netbsd",
                            target_os = "openbsd",
                            target_arch = "aarch64")),
                    thread_local)]
@@ -215,6 +216,7 @@ pub fn is_set(&'static self) -> bool {
 #[cfg(not(any(windows,
               target_os = "android",
               target_os = "ios",
+              target_os = "netbsd",
               target_os = "openbsd",
               target_arch = "aarch64",
               no_elf_tls)))]
@@ -238,6 +240,7 @@ pub unsafe fn get(&self) -> *mut T { self.inner.get() }
 #[cfg(any(windows,
           target_os = "android",
           target_os = "ios",
+          target_os = "netbsd",
           target_os = "openbsd",
           target_arch = "aarch64",
           no_elf_tls))]
index 27e331893e5d7fcd642113988baf2123092ef15a..50c86a80b4ab5e27ae66031489a3b177766d3c6b 100644 (file)
@@ -25,6 +25,7 @@ pub enum Os {
     OsiOS,
     OsDragonfly,
     OsBitrig,
+    OsNetbsd,
     OsOpenbsd,
 }
 
@@ -138,6 +139,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             OsFreebsd => "freebsd".fmt(f),
             OsDragonfly => "dragonfly".fmt(f),
             OsBitrig => "bitrig".fmt(f),
+            OsNetbsd => "netbsd".fmt(f),
             OsOpenbsd => "openbsd".fmt(f),
         }
     }
index f54423139049e89534e4272a08548b5c284732f4..f6606a58ecaf190d58f809febd95ba10d6b77f85 100644 (file)
@@ -11,6 +11,7 @@
 // ignore-windows
 // ignore-freebsd
 // ignore-openbsd
+// ignore-netbsd
 // ignore-bitrig
 
 // compile-flags: -Z parse-only
index fa97ef8fcd39434983863aab8b715e1821bca4b1..ef69946d7aa2ad27c943bd0db86744bab4088819 100644 (file)
@@ -22,6 +22,7 @@ mod rusti {
           target_os = "macos",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 mod m {
     #[main]
index bae95bcb50f50d2beee9c0422df10a11fc1c1748..fc032aa3ff0cdfd45fa9642c7727d8e8e8b40b09 100644 (file)
@@ -40,6 +40,7 @@ struct Outer {
           target_os = "macos",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "netbsd",
           target_os = "openbsd"))]
 mod m {
     #[cfg(target_arch = "x86")]
index c47b95bec2b52daaad2ccb4ce63fd519f76f2302..dca65f03f690af16f126e1c746e80e64d39f26a9 100644 (file)
@@ -9,8 +9,9 @@
 // except according to those terms.
 
 // ignore-android needs extra network permissions
-// ignore-openbsd system ulimit (Too many open files)
 // ignore-bitrig system ulimit (Too many open files)
+// ignore-netbsd system ulimit (Too many open files)
+// ignore-openbsd system ulimit (Too many open files)
 
 use std::io::prelude::*;
 use std::net::{TcpListener, TcpStream};
index b0bfb5c29c18c9b48ad736d0a2a07fc72bd746bc..62cbb76c3095099038983347f51e7c0b203281a9 100644 (file)
@@ -35,6 +35,7 @@ pub fn main() {
           target_os = "freebsd",
           target_os = "dragonfly",
           target_os = "bitrig",
+          target_os = "netbsd",
           target_os = "openbsd",
           target_os = "android"))]
 pub fn main() { }