]> git.lizzy.rs Git - rust.git/commitdiff
bitrig integration
authorDave Huseby <dhuseby@mozilla.com>
Sat, 17 Jan 2015 07:51:04 +0000 (23:51 -0800)
committerDave Huseby <dhuseby@mozilla.com>
Wed, 11 Feb 2015 22:49:06 +0000 (14:49 -0800)
50 files changed:
configure
mk/cfg/x86_64-unknown-bitrig.mk [new file with mode: 0644]
mk/platform.mk
src/compiletest/util.rs
src/doc/reference.md
src/etc/local_stage0.sh
src/etc/mklldeps.py
src/etc/snapshot.py
src/libbacktrace/configure
src/libbacktrace/ltmain.sh
src/liblibc/lib.rs
src/librustc_back/arm.rs
src/librustc_back/mips.rs
src/librustc_back/mipsel.rs
src/librustc_back/rpath.rs
src/librustc_back/target/bitrig_base.rs [new file with mode: 0644]
src/librustc_back/target/mod.rs
src/librustc_back/target/x86_64_unknown_bitrig.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/os.rs
src/libstd/rt/args.rs
src/libstd/rt/libunwind.rs
src/libstd/rtdeps.rs
src/libstd/sys/common/net.rs
src/libstd/sys/common/stack.rs
src/libstd/sys/unix/backtrace.rs
src/libstd/sys/unix/c.rs
src/libstd/sys/unix/fs.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/sys/unix/tty.rs
src/libsyntax/abi.rs
src/rt/arch/x86_64/morestack.S
src/rt/rust_builtin.c
src/test/run-pass/dupe-first-attr.rc
src/test/run-pass/intrinsic-alignment.rs
src/test/run-pass/lang-item-public.rs
src/test/run-pass/out-of-stack-new-thread-no-split.rs
src/test/run-pass/out-of-stack-no-split.rs
src/test/run-pass/rec-align-u64.rs
src/test/run-pass/x86stdcall.rs

index e6b8d23544829ca6d277375067b09ec5409c860c..03d4fdac496c0ec5c7f2860b7983c44f8cba4d7d 100755 (executable)
--- a/configure
+++ b/configure
@@ -374,8 +374,12 @@ case $CFG_OSTYPE in
         CFG_OSTYPE=unknown-dragonfly
         ;;
 
+    Bitrig)
+        CFG_OSTYPE=unknown-bitrig
+        ;;
+
     OpenBSD)
-       CFG_OSTYPE=unknown-openbsd
+        CFG_OSTYPE=unknown-openbsd
        ;;
 
     Darwin)
@@ -747,6 +751,13 @@ then
     CFG_ENABLE_CLANG=1
 fi
 
+# Force bitrig to build with clang; gcc doesn't like us there
+if [ $CFG_OSTYPE = unknown-bitrig ]
+then
+    step_msg "on Bitrig, forcing use of clang"
+    CFG_ENABLE_CLANG=1
+fi
+
 if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
 then
     err "either clang or gcc is required"
@@ -1106,11 +1117,12 @@ then
     msg "git: submodule status"
     "${CFG_GIT}" submodule status --recursive
 
-    msg "git: submodule clobber"
-    "${CFG_GIT}" submodule foreach --recursive git clean -dxf
-    need_ok "git failed"
-    "${CFG_GIT}" submodule foreach --recursive git checkout .
-    need_ok "git failed"
+    # don't clobber so that our patches won't get removed
+    #msg "git: submodule clobber"
+    #"${CFG_GIT}" submodule foreach --recursive git clean -dxf
+    #need_ok "git failed"
+    #"${CFG_GIT}" submodule foreach --recursive git checkout .
+    #need_ok "git failed"
 
     cd ${CFG_BUILD_DIR}
 fi
diff --git a/mk/cfg/x86_64-unknown-bitrig.mk b/mk/cfg/x86_64-unknown-bitrig.mk
new file mode 100644 (file)
index 0000000..ad34988
--- /dev/null
@@ -0,0 +1,26 @@
+# x86_64-unknown-bitrig-elf configuration
+CC_x86_64-unknown-bitrig=$(CC)
+CXX_x86_64-unknown-bitrig=$(CXX)
+CPP_x86_64-unknown-bitrig=$(CPP)
+AR_x86_64-unknown-bitrig=$(AR)
+CFG_LIB_NAME_x86_64-unknown-bitrig=lib$(1).so
+CFG_STATIC_LIB_NAME_x86_64-unknown-bitrig=lib$(1).a
+CFG_LIB_GLOB_x86_64-unknown-bitrig=lib$(1)-*.so
+CFG_LIB_DSYM_GLOB_x86_64-unknown-bitrig=$(1)-*.dylib.dSYM
+CFG_JEMALLOC_CFLAGS_x86_64-unknown-bitrig := -m64 -I/usr/include $(CFLAGS)
+CFG_GCCISH_CFLAGS_x86_64-unknown-bitrig := -Wall -Werror -fPIC -m64 -I/usr/include $(CFLAGS)
+CFG_GCCISH_LINK_FLAGS_x86_64-unknown-bitrig := -shared -pic -pthread -m64 $(LDFLAGS)
+CFG_GCCISH_DEF_FLAG_x86_64-unknown-bitrig := -Wl,--export-dynamic,--dynamic-list=
+CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-bitrig := -Wl,-pic -Wl,-whole-archive
+CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-bitrig := -Wl,-no-whole-archive
+CFG_DEF_SUFFIX_x86_64-unknown-bitrig := .bsd.def
+CFG_LLC_FLAGS_x86_64-unknown-bitrig :=
+CFG_INSTALL_NAME_x86_64-unknown-bitrig =
+CFG_EXE_SUFFIX_x86_64-unknown-bitrig :=
+CFG_WINDOWSY_x86_64-unknown-bitrig :=
+CFG_UNIXY_x86_64-unknown-bitrig := 1
+CFG_PATH_MUNGE_x86_64-unknown-bitrig :=
+CFG_LDPATH_x86_64-unknown-bitrig :=
+CFG_RUN_x86_64-unknown-bitrig=$(2)
+CFG_RUN_TARG_x86_64-unknown-bitrig=$(call CFG_RUN_x86_64-unknown-bitrig,,$(2))
+CFG_GNU_TRIPLE_x86_64-unknown-bitrig := x86_64-unknown-bitrig
index 78c1057c2fe524ca28a19e6d9164c0f1d08ab771..3b172e87bda79c1795ca239081db712d1b632f58 100644 (file)
@@ -144,14 +144,14 @@ FIND_COMPILER = $(word 1,$(1:ccache=))
 define CFG_MAKE_TOOLCHAIN
   # Prepend the tools with their prefix if cross compiling
   ifneq ($(CFG_BUILD),$(1))
-       CC_$(1)=$(CROSS_PREFIX_$(1))$(CC_$(1))
-       CXX_$(1)=$(CROSS_PREFIX_$(1))$(CXX_$(1))
-       CPP_$(1)=$(CROSS_PREFIX_$(1))$(CPP_$(1))
-       AR_$(1)=$(CROSS_PREFIX_$(1))$(AR_$(1))
-       RUSTC_CROSS_FLAGS_$(1)=-C linker=$$(call FIND_COMPILER,$$(CC_$(1))) \
-           -C ar=$$(call FIND_COMPILER,$$(AR_$(1))) $(RUSTC_CROSS_FLAGS_$(1))
-
-       RUSTC_FLAGS_$(1)=$$(RUSTC_CROSS_FLAGS_$(1)) $(RUSTC_FLAGS_$(1))
+  CC_$(1)=$(CROSS_PREFIX_$(1))$(CC_$(1))
+  CXX_$(1)=$(CROSS_PREFIX_$(1))$(CXX_$(1))
+  CPP_$(1)=$(CROSS_PREFIX_$(1))$(CPP_$(1))
+  AR_$(1)=$(CROSS_PREFIX_$(1))$(AR_$(1))
+  RUSTC_CROSS_FLAGS_$(1)=-C linker=$$(call FIND_COMPILER,$$(CC_$(1))) \
+      -C ar=$$(call FIND_COMPILER,$$(AR_$(1))) $(RUSTC_CROSS_FLAGS_$(1))
+
+  RUSTC_FLAGS_$(1)=$$(RUSTC_CROSS_FLAGS_$(1)) $(RUSTC_FLAGS_$(1))
   endif
 
   CFG_COMPILE_C_$(1) = $$(CC_$(1)) \
@@ -179,11 +179,19 @@ define CFG_MAKE_TOOLCHAIN
 
   ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel powerpc),)
 
+  # On Bitrig, we need the relocation model to be PIC for everthing
+  ifeq (,$(filter $(OSTYPE_$(1)),bitrig))
+    LLVM_MC_RELOCATION_MODEL="pic"
+  else
+    LLVM_MC_RELOCATION_MODEL="default"
+  endif
+
   # We're using llvm-mc as our assembler because it supports
   # .cfi pseudo-ops on mac
   CFG_ASSEMBLE_$(1)=$$(CPP_$(1)) -E $$(CFG_DEPEND_FLAGS) $$(2) | \
                     $$(LLVM_MC_$$(CFG_BUILD)) \
                     -assemble \
+                    -relocation-model=$$(LLVM_MC_RELOCATION_MODEL) \
                     -filetype=obj \
                     -triple=$(1) \
                     -o=$$(1)
@@ -192,7 +200,7 @@ define CFG_MAKE_TOOLCHAIN
   # For the ARM, AARCH64, MIPS and POWER crosses, use the toolchain assembler
   # FIXME: We should be able to use the LLVM assembler
   CFG_ASSEMBLE_$(1)=$$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
-                   $$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)
+        $$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)
 
   endif
 
index 078eb7bba20a45924d5841f1a7d07c84c7640892..ee011e3b3b9b0d43557db4545c54f74c3f10ac02 100644 (file)
@@ -23,6 +23,7 @@
     ("linux", "linux"),
     ("freebsd", "freebsd"),
     ("dragonfly", "dragonfly"),
+    ("bitrig", "bitrig"),
     ("openbsd", "openbsd"),
 ];
 
index 9c51f6bad6feea3e1caefbf8bd2135a0ec629399..79e84842f6c585be5fbfd4d51a81086fac4d404d 100644 (file)
@@ -2192,8 +2192,8 @@ The following configurations must be defined by the implementation:
   `"unix"` or `"windows"`. The value of this configuration option is defined
   as a configuration itself, like `unix` or `windows`.
 * `target_os = "..."`. Operating system of the target, examples include
-  `"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"` or
-  `"openbsd"`.
+  `"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"`,
+  `"bitrig"` or `"openbsd"`.
 * `target_word_size = "..."`. Target word size in bits. This is set to `"32"`
   for targets with 32-bit pointers, and likewise set to `"64"` for 64-bit
   pointers.
index b506aff94e7209372ba7197874cef1109fec0a21..ca59b1c7d34a2faeb8f967d73a55355aea9c2a00 100755 (executable)
@@ -18,7 +18,7 @@ LIB_PREFIX=lib
 
 OS=`uname -s`
 case $OS in
-    ("Linux"|"FreeBSD"|"DragonFly"|"OpenBSD")
+    ("Linux"|"FreeBSD"|"DragonFly"|"Bitrig"|"OpenBSD")
     BIN_SUF=
     LIB_SUF=.so
     ;;
index a4234159cb81c9ee624df8b7e4b10aab01aa0788..e5e8c9f11bd82691e823583bfc140d4c46d1664c 100644 (file)
@@ -57,7 +57,16 @@ else:
 args.extend(components)
 out = run(args)
 for lib in out.strip().replace("\n", ' ').split(' '):
-    lib = lib.strip()[2:] # chop of the leading '-l'
+    if len(lib) == 0:
+        continue
+    # in some cases we get extra spaces in between libs so ignore those
+    if len(lib) == 1 and lib == ' ':
+        continue
+    # not all libs strictly follow -lfoo, on Bitrig, there is -pthread
+    if lib[0:2] == '-l':
+        lib = lib.strip()[2:]
+    elif lib[0] == '-':
+        lib = lib.strip()[1:]
     f.write("#[link(name = \"" + lib + "\"")
     # LLVM libraries are all static libraries
     if 'LLVM' in lib:
index 264af5f9854cc81c5ec73306167840aab1187807..0349ccf9b66408bf80833afe3d4b96d68dd6ceef 100644 (file)
@@ -46,13 +46,13 @@ snapshot_files = {
         "winnt": ["bin/rustc.exe"],
         "freebsd": ["bin/rustc"],
         "dragonfly": ["bin/rustc"],
+        "bitrig": ["bin/rustc"],
         "openbsd": ["bin/rustc"],
         }
 
 winnt_runtime_deps_32 = ["libgcc_s_dw2-1.dll", "libstdc++-6.dll"]
 winnt_runtime_deps_64 = ["libgcc_s_seh-1.dll", "libstdc++-6.dll"]
 
-
 def parse_line(n, line):
     global snapshotfile
 
@@ -101,6 +101,8 @@ def get_kernel(triple):
         return "freebsd"
     if os_name == "dragonfly":
         return "dragonfly"
+    if os_name == "bitrig":
+        return "bitrig"
     if os_name == "openbsd":
         return "openbsd"
     return "linux"
index 14a9fd4f452793a1a5ffb1607fc8f00fc3a9aa40..694b5d23c490e5e4736aab26321f33c22ce3826d 100755 (executable)
@@ -5650,7 +5650,7 @@ else
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly* | bitrig*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -9332,7 +9332,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | dragonfly* | openbsd*)
+    freebsd* | dragonfly* | bitrig* | openbsd*)
       archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec='-R$libdir'
       hardcode_direct=yes
index 9503ec85d709d8f7fdad222ef3c4d8d85fdc6cd1..eaef55a59332a88c6bcb008a56214d48518c6546 100644 (file)
@@ -4741,7 +4741,7 @@ func_mode_link ()
            # These systems don't actually have a C library (as such)
            test "X$arg" = "X-lc" && continue
            ;;
-         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
            # Do not include libc due to us having libc/libc_r.
            test "X$arg" = "X-lc" && continue
            ;;
index 94e4012c5ee13f14a8c1fd9b51d18c193b854850..342e532fc91fd3c74c7b034bccb5589eddd90aba 100644 (file)
           target_os = "android",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 pub use consts::os::posix01::{CLOCK_REALTIME, CLOCK_MONOTONIC};
 
 #[cfg(any(target_os = "linux", target_os = "android"))]
 pub use consts::os::extra::{AF_PACKET};
 
-#[cfg(all(unix, not(any(target_os = "freebsd", target_os = "openbsd"))))]
+#[cfg(all(unix, not(any(target_os = "freebsd", target_os = "bitrig", target_os = "openbsd"))))]
 pub use consts::os::extra::{MAP_STACK};
 
 #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
@@ -1322,7 +1323,7 @@ pub mod extra {
         }
     }
 
-    #[cfg(target_os = "openbsd")]
+    #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
     pub mod os {
         pub mod common {
             pub mod posix01 {
@@ -1333,6 +1334,24 @@ pub mod posix01 {
 
                 pub type pthread_t = uintptr_t;
 
+                #[cfg(target_os = "bitrig")]
+                #[repr(C)]
+                #[derive(Copy)] pub struct glob_t {
+                    pub gl_pathc:  c_int,
+                    pub gl_matchc: c_int,
+                    pub gl_offs:   c_int,
+                    pub gl_flags:  c_int,
+                    pub gl_pathv:  *mut *mut c_char,
+                    pub __unused1: *mut c_void,
+                    pub __unused2: *mut c_void,
+                    pub __unused3: *mut c_void,
+                    pub __unused4: *mut c_void,
+                    pub __unused5: *mut c_void,
+                    pub __unused6: *mut c_void,
+                    pub __unused7: *mut c_void,
+                }
+
+                #[cfg(target_os = "openbsd")]
                 #[repr(C)]
                 #[derive(Copy)] pub struct glob_t {
                     pub gl_pathc:  c_int,
@@ -1451,7 +1470,6 @@ pub mod bsd44 {
                     pub ifa_dstaddr: *mut sockaddr,
                     pub ifa_data: *mut c_void
                 }
-
             }
         }
 
@@ -1485,25 +1503,27 @@ pub mod c99 {
                 pub type uintmax_t = u64;
             }
             pub mod posix88 {
+                use types::os::arch::c95::{c_long};
                 pub type off_t = i64;
-                pub type dev_t = u32;
+                pub type dev_t = i32;
                 pub type ino_t = u64;
                 pub type pid_t = i32;
                 pub type uid_t = u32;
                 pub type gid_t = u32;
                 pub type useconds_t = u32;
                 pub type mode_t = u32;
-                pub type ssize_t = i64;
+                pub type ssize_t = c_long;
             }
             pub mod posix01 {
                 use types::common::c95::{c_void};
                 use types::common::c99::{uint32_t, uint64_t};
-                use types::os::arch::c95::{c_long, time_t};
+                use types::os::arch::c95::{time_t};
                 use types::os::arch::posix88::{dev_t, gid_t};
                 use types::os::arch::posix88::{mode_t, off_t};
                 use types::os::arch::posix88::{uid_t};
+                use types::os::common::posix01::{timespec};
 
-                pub type nlink_t = u32;
+                pub type nlink_t = uint32_t;
                 pub type blksize_t = uint32_t;
                 pub type ino_t = uint64_t;
                 pub type blkcnt_t = i64;
@@ -1518,19 +1538,15 @@ pub mod posix01 {
                     pub st_uid: uid_t,
                     pub st_gid: gid_t,
                     pub st_rdev: dev_t,
-                    pub st_atime: time_t,
-                    pub st_atime_nsec: c_long,
-                    pub st_mtime: time_t,
-                    pub st_mtime_nsec: c_long,
-                    pub st_ctime: time_t,
-                    pub st_ctime_nsec: c_long,
+                    pub st_atim: timespec,
+                    pub st_mtim: timespec,
+                    pub st_ctim: timespec,
                     pub st_size: off_t,
                     pub st_blocks: blkcnt_t,
                     pub st_blksize: blksize_t,
                     pub st_flags: fflags_t,
                     pub st_gen: uint32_t,
-                    pub st_birthtime: time_t,
-                    pub st_birthtime_nsec: c_long,
+                    pub __st_birthtim: timespec,
                 }
                 #[repr(C)]
                 #[derive(Copy)] pub struct utimbuf {
@@ -3887,7 +3903,386 @@ pub mod sysconf {
         }
     }
 
-    #[cfg(target_os = "openbsd")]
+    #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
+    pub mod os {
+        pub mod c95 {
+            use types::os::arch::c95::{c_int, c_uint};
+
+            pub const EXIT_FAILURE : c_int = 1;
+            pub const EXIT_SUCCESS : c_int = 0;
+            pub const RAND_MAX : c_int = 2147483647;
+            pub const EOF : c_int = -1;
+            pub const SEEK_SET : c_int = 0;
+            pub const SEEK_CUR : c_int = 1;
+            pub const SEEK_END : c_int = 2;
+            pub const _IOFBF : c_int = 0;
+            pub const _IONBF : c_int = 2;
+            pub const _IOLBF : c_int = 1;
+            pub const BUFSIZ : c_uint = 1024_u32;
+            pub const FOPEN_MAX : c_uint = 20_u32;
+            pub const FILENAME_MAX : c_uint = 1024_u32;
+            pub const L_tmpnam : c_uint = 1024_u32;
+            pub const TMP_MAX : c_uint = 308915776_u32;
+        }
+        pub mod c99 {
+        }
+        pub mod posix88 {
+            use types::common::c95::c_void;
+            use types::os::arch::c95::c_int;
+            use types::os::arch::posix88::mode_t;
+
+            pub const O_RDONLY : c_int = 0;
+            pub const O_WRONLY : c_int = 1;
+            pub const O_RDWR : c_int = 2;
+            pub const O_APPEND : c_int = 8;
+            pub const O_CREAT : c_int = 512;
+            pub const O_EXCL : c_int = 2048;
+            pub const O_TRUNC : c_int = 1024;
+            pub const S_IFIFO : mode_t = 4096;
+            pub const S_IFCHR : mode_t = 8192;
+            pub const S_IFBLK : mode_t = 24576;
+            pub const S_IFDIR : mode_t = 16384;
+            pub const S_IFREG : mode_t = 32768;
+            pub const S_IFLNK : mode_t = 40960;
+            pub const S_IFMT : mode_t = 61440;
+            pub const S_IEXEC : mode_t = 64;
+            pub const S_IWRITE : mode_t = 128;
+            pub const S_IREAD : mode_t = 256;
+            pub const S_IRWXU : mode_t = 448;
+            pub const S_IXUSR : mode_t = 64;
+            pub const S_IWUSR : mode_t = 128;
+            pub const S_IRUSR : mode_t = 256;
+            pub const F_OK : c_int = 0;
+            pub const R_OK : c_int = 4;
+            pub const W_OK : c_int = 2;
+            pub const X_OK : c_int = 1;
+            pub const STDIN_FILENO : c_int = 0;
+            pub const STDOUT_FILENO : c_int = 1;
+            pub const STDERR_FILENO : c_int = 2;
+            pub const F_LOCK : c_int = 1;
+            pub const F_TEST : c_int = 3;
+            pub const F_TLOCK : c_int = 2;
+            pub const F_ULOCK : c_int = 0;
+            pub const SIGHUP : c_int = 1;
+            pub const SIGINT : c_int = 2;
+            pub const SIGQUIT : c_int = 3;
+            pub const SIGILL : c_int = 4;
+            pub const SIGABRT : c_int = 6;
+            pub const SIGFPE : c_int = 8;
+            pub const SIGKILL : c_int = 9;
+            pub const SIGSEGV : c_int = 11;
+            pub const SIGPIPE : c_int = 13;
+            pub const SIGALRM : c_int = 14;
+            pub const SIGTERM : c_int = 15;
+
+            pub const PROT_NONE : c_int = 0;
+            pub const PROT_READ : c_int = 1;
+            pub const PROT_WRITE : c_int = 2;
+            pub const PROT_EXEC : c_int = 4;
+
+            pub const MAP_FILE : c_int = 0x0000;
+            pub const MAP_SHARED : c_int = 0x0001;
+            pub const MAP_PRIVATE : c_int = 0x0002;
+            pub const MAP_FIXED : c_int = 0x0010;
+            pub const MAP_ANON : c_int = 0x1000;
+
+            pub const MAP_FAILED : *mut c_void = -1 as *mut c_void;
+
+            pub const MCL_CURRENT : c_int = 0x0001;
+            pub const MCL_FUTURE : c_int = 0x0002;
+
+            pub const MS_ASYNC : c_int = 0x0001;
+            pub const MS_SYNC : c_int = 0x0002;
+            pub const MS_INVALIDATE : c_int = 0x0004;
+
+            pub const EPERM : c_int = 1;
+            pub const ENOENT : c_int = 2;
+            pub const ESRCH : c_int = 3;
+            pub const EINTR : c_int = 4;
+            pub const EIO : c_int = 5;
+            pub const ENXIO : c_int = 6;
+            pub const E2BIG : c_int = 7;
+            pub const ENOEXEC : c_int = 8;
+            pub const EBADF : c_int = 9;
+            pub const ECHILD : c_int = 10;
+            pub const EDEADLK : c_int = 11;
+            pub const ENOMEM : c_int = 12;
+            pub const EACCES : c_int = 13;
+            pub const EFAULT : c_int = 14;
+            pub const ENOTBLK : c_int = 15;
+            pub const EBUSY : c_int = 16;
+            pub const EEXIST : c_int = 17;
+            pub const EXDEV : c_int = 18;
+            pub const ENODEV : c_int = 19;
+            pub const ENOTDIR : c_int = 20;
+            pub const EISDIR : c_int = 21;
+            pub const EINVAL : c_int = 22;
+            pub const ENFILE : c_int = 23;
+            pub const EMFILE : c_int = 24;
+            pub const ENOTTY : c_int = 25;
+            pub const ETXTBSY : c_int = 26;
+            pub const EFBIG : c_int = 27;
+            pub const ENOSPC : c_int = 28;
+            pub const ESPIPE : c_int = 29;
+            pub const EROFS : c_int = 30;
+            pub const EMLINK : c_int = 31;
+            pub const EPIPE : c_int = 32;
+            pub const EDOM : c_int = 33;
+            pub const ERANGE : c_int = 34;
+            pub const EAGAIN : c_int = 35;
+            pub const EWOULDBLOCK : c_int = 35;
+            pub const EINPROGRESS : c_int = 36;
+            pub const EALREADY : c_int = 37;
+            pub const ENOTSOCK : c_int = 38;
+            pub const EDESTADDRREQ : c_int = 39;
+            pub const EMSGSIZE : c_int = 40;
+            pub const EPROTOTYPE : c_int = 41;
+            pub const ENOPROTOOPT : c_int = 42;
+            pub const EPROTONOSUPPORT : c_int = 43;
+            pub const ESOCKTNOSUPPORT : c_int = 44;
+            pub const EOPNOTSUPP : c_int = 45;
+            pub const EPFNOSUPPORT : c_int = 46;
+            pub const EAFNOSUPPORT : c_int = 47;
+            pub const EADDRINUSE : c_int = 48;
+            pub const EADDRNOTAVAIL : c_int = 49;
+            pub const ENETDOWN : c_int = 50;
+            pub const ENETUNREACH : c_int = 51;
+            pub const ENETRESET : c_int = 52;
+            pub const ECONNABORTED : c_int = 53;
+            pub const ECONNRESET : c_int = 54;
+            pub const ENOBUFS : c_int = 55;
+            pub const EISCONN : c_int = 56;
+            pub const ENOTCONN : c_int = 57;
+            pub const ESHUTDOWN : c_int = 58;
+            pub const ETOOMANYREFS : c_int = 59;
+            pub const ETIMEDOUT : c_int = 60;
+            pub const ECONNREFUSED : c_int = 61;
+            pub const ELOOP : c_int = 62;
+            pub const ENAMETOOLONG : c_int = 63;
+            pub const EHOSTDOWN : c_int = 64;
+            pub const EHOSTUNREACH : c_int = 65;
+            pub const ENOTEMPTY : c_int = 66;
+            pub const EPROCLIM : c_int = 67;
+            pub const EUSERS : c_int = 68;
+            pub const EDQUOT : c_int = 69;
+            pub const ESTALE : c_int = 70;
+            pub const EREMOTE : c_int = 71;
+            pub const EBADRPC : c_int = 72;
+            pub const ERPCMISMATCH : c_int = 73;
+            pub const EPROGUNAVAIL : c_int = 74;
+            pub const EPROGMISMATCH : c_int = 75;
+            pub const EPROCUNAVAIL : c_int = 76;
+            pub const ENOLCK : c_int = 77;
+            pub const ENOSYS : c_int = 78;
+            pub const EFTYPE : c_int = 79;
+            pub const EAUTH : c_int = 80;
+            pub const ENEEDAUTH : c_int = 81;
+            pub const EIPSEC : c_int = 82;
+            pub const ENOATTR : c_int = 83;
+            pub const EILSEQ : c_int = 84;
+            pub const ENOMEDIUM : c_int = 85;
+            pub const EMEDIUMTYPE : c_int = 86;
+            pub const EOVERFLOW : c_int = 87;
+            pub const ECANCELED : c_int = 88;
+            pub const EIDRM : c_int = 89;
+            pub const ENOMSG : c_int = 90;
+            pub const ENOTSUP : c_int = 91;
+            pub const ELAST : c_int = 91; // must be equal to largest errno
+        }
+        pub mod posix01 {
+            use types::os::arch::c95::{c_int, size_t};
+
+            pub const F_DUPFD : c_int = 0;
+            pub const F_GETFD : c_int = 1;
+            pub const F_SETFD : c_int = 2;
+            pub const F_GETFL : c_int = 3;
+            pub const F_SETFL : c_int = 4;
+            pub const F_GETOWN : c_int = 5;
+            pub const F_SETOWN : c_int = 6;
+            pub const F_GETLK : c_int = 7;
+            pub const F_SETLK : c_int = 8;
+            pub const F_SETLKW : c_int = 9;
+            pub const F_DUPFD_CLOEXEC : c_int = 10;
+
+            pub const SIGTRAP : c_int = 5;
+            pub const SIGPIPE: c_int = 13;
+            pub const SIG_IGN: size_t = 1;
+
+            pub const GLOB_APPEND   : c_int = 0x0001;
+            pub const GLOB_DOOFFS   : c_int = 0x0002;
+            pub const GLOB_ERR      : c_int = 0x0004;
+            pub const GLOB_MARK     : c_int = 0x0008;
+            pub const GLOB_NOCHECK  : c_int = 0x0010;
+            pub const GLOB_NOSORT   : c_int = 0x0020;
+            pub const GLOB_NOESCAPE : c_int = 0x1000;
+
+            pub const GLOB_NOSPACE  : c_int = -1;
+            pub const GLOB_ABORTED  : c_int = -2;
+            pub const GLOB_NOMATCH  : c_int = -3;
+            pub const GLOB_NOSYS : c_int = -4;
+
+            pub const POSIX_MADV_NORMAL : c_int = 0;
+            pub const POSIX_MADV_RANDOM : c_int = 1;
+            pub const POSIX_MADV_SEQUENTIAL : c_int = 2;
+            pub const POSIX_MADV_WILLNEED : c_int = 3;
+            pub const POSIX_MADV_DONTNEED : c_int = 4;
+
+            pub const _SC_IOV_MAX : c_int = 51;
+            pub const _SC_GETGR_R_SIZE_MAX : c_int = 100;
+            pub const _SC_GETPW_R_SIZE_MAX : c_int = 101;
+            pub const _SC_LOGIN_NAME_MAX : c_int = 102;
+            pub const _SC_MQ_PRIO_MAX : c_int = 59;
+            pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77;
+            pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78;
+            pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 80;
+            pub const _SC_THREAD_KEYS_MAX : c_int = 81;
+            pub const _SC_THREAD_PRIO_INHERIT : c_int = 82;
+            pub const _SC_THREAD_PRIO_PROTECT : c_int = 83;
+            pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 84;
+            pub const _SC_THREAD_PROCESS_SHARED : c_int = 85;
+            pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 103;
+            pub const _SC_THREAD_STACK_MIN : c_int = 89;
+            pub const _SC_THREAD_THREADS_MAX : c_int = 90;
+            pub const _SC_THREADS : c_int = 91;
+            pub const _SC_TTY_NAME_MAX : c_int = 107;
+            pub const _SC_ATEXIT_MAX : c_int = 146;
+            pub const _SC_XOPEN_CRYPT : c_int = 117;
+            pub const _SC_XOPEN_ENH_I18N : c_int = 118;
+            pub const _SC_XOPEN_LEGACY : c_int = 119;
+            pub const _SC_XOPEN_REALTIME : c_int = 120;
+            pub const _SC_XOPEN_REALTIME_THREADS : c_int = 121;
+            pub const _SC_XOPEN_SHM : c_int = 30;
+            pub const _SC_XOPEN_UNIX : c_int = 123;
+            pub const _SC_XOPEN_VERSION : c_int = 125;
+
+            pub const PTHREAD_CREATE_JOINABLE : c_int = 0;
+            pub const PTHREAD_CREATE_DETACHED : c_int = 1;
+            pub const PTHREAD_STACK_MIN : size_t = 2048;
+
+            pub const CLOCK_REALTIME : c_int = 0;
+            pub const CLOCK_MONOTONIC : c_int = 3;
+        }
+        pub mod posix08 {
+        }
+        pub mod bsd44 {
+            use types::os::arch::c95::c_int;
+
+            pub const MADV_NORMAL : c_int = 0;
+            pub const MADV_RANDOM : c_int = 1;
+            pub const MADV_SEQUENTIAL : c_int = 2;
+            pub const MADV_WILLNEED : c_int = 3;
+            pub const MADV_DONTNEED : c_int = 4;
+            pub const MADV_FREE : c_int = 6;
+
+            pub const AF_UNIX: c_int = 1;
+            pub const AF_INET: c_int = 2;
+            pub const AF_INET6: c_int = 24;
+            pub const SOCK_STREAM: c_int = 1;
+            pub const SOCK_DGRAM: c_int = 2;
+            pub const SOCK_RAW: c_int = 3;
+            pub const IPPROTO_TCP: c_int = 6;
+            pub const IPPROTO_IP: c_int = 0;
+            pub const IPPROTO_IPV6: c_int = 41;
+            pub const IP_MULTICAST_TTL: c_int = 10;
+            pub const IP_MULTICAST_LOOP: c_int = 11;
+            pub const IP_TTL: c_int = 4;
+            pub const IP_HDRINCL: c_int = 2;
+            pub const IP_ADD_MEMBERSHIP: c_int = 12;
+            pub const IP_DROP_MEMBERSHIP: c_int = 13;
+            pub const IPV6_ADD_MEMBERSHIP: c_int = 12; // don't exist
+            pub const IPV6_DROP_MEMBERSHIP: c_int = 13; // don't exist
+
+            pub const TCP_NODELAY: c_int = 0x01;
+            pub const SOL_SOCKET: c_int = 0xffff;
+            pub const SO_KEEPALIVE: c_int = 0x0008;
+            pub const SO_BROADCAST: c_int = 0x0020;
+            pub const SO_REUSEADDR: c_int = 0x0004;
+            pub const SO_ERROR: c_int = 0x1007;
+
+            pub const IFF_LOOPBACK: c_int = 0x8;
+
+            pub const SHUT_RD: c_int = 0;
+            pub const SHUT_WR: c_int = 1;
+            pub const SHUT_RDWR: c_int = 2;
+        }
+        pub mod extra {
+            use types::os::arch::c95::c_int;
+
+            pub const O_DSYNC : c_int = 128; // same as SYNC
+            pub const O_SYNC : c_int = 128;
+            pub const O_NONBLOCK : c_int = 4;
+            pub const CTL_KERN : c_int = 1;
+            pub const KERN_PROC : c_int = 66;
+
+            pub const MAP_COPY : c_int = 0x0002;
+            pub const MAP_RENAME : c_int = 0x0000;
+            pub const MAP_NORESERVE : c_int = 0x0000;
+            pub const MAP_NOEXTEND : c_int = 0x0000;
+            pub const MAP_HASSEMAPHORE : c_int = 0x0000;
+
+            pub const IPPROTO_RAW : c_int = 255;
+
+            pub const PATH_MAX: c_int = 1024;
+        }
+        pub mod sysconf {
+            use types::os::arch::c95::c_int;
+
+            pub const _SC_ARG_MAX : c_int = 1;
+            pub const _SC_CHILD_MAX : c_int = 2;
+            pub const _SC_CLK_TCK : c_int = 3;
+            pub const _SC_NGROUPS_MAX : c_int = 4;
+            pub const _SC_OPEN_MAX : c_int = 5;
+            pub const _SC_JOB_CONTROL : c_int = 6;
+            pub const _SC_SAVED_IDS : c_int = 7;
+            pub const _SC_VERSION : c_int = 8;
+            pub const _SC_BC_BASE_MAX : c_int = 9;
+            pub const _SC_BC_DIM_MAX : c_int = 10;
+            pub const _SC_BC_SCALE_MAX : c_int = 11;
+            pub const _SC_BC_STRING_MAX : c_int = 12;
+            pub const _SC_COLL_WEIGHTS_MAX : c_int = 13;
+            pub const _SC_EXPR_NEST_MAX : c_int = 14;
+            pub const _SC_LINE_MAX : c_int = 15;
+            pub const _SC_RE_DUP_MAX : c_int = 16;
+            pub const _SC_2_VERSION : c_int = 17;
+            pub const _SC_2_C_BIND : c_int = 18;
+            pub const _SC_2_C_DEV : c_int = 19;
+            pub const _SC_2_CHAR_TERM : c_int = 20;
+            pub const _SC_2_FORT_DEV : c_int = 21;
+            pub const _SC_2_FORT_RUN : c_int = 22;
+            pub const _SC_2_LOCALEDEF : c_int = 23;
+            pub const _SC_2_SW_DEV : c_int = 24;
+            pub const _SC_2_UPE : c_int = 25;
+            pub const _SC_STREAM_MAX : c_int = 26;
+            pub const _SC_TZNAME_MAX : c_int = 27;
+            pub const _SC_PAGESIZE : c_int = 28;
+            pub const _SC_FSYNC : c_int = 29;
+            pub const _SC_SEM_NSEMS_MAX : c_int = 31;
+            pub const _SC_SEM_VALUE_MAX : c_int = 32;
+            pub const _SC_AIO_LISTIO_MAX : c_int = 42;
+            pub const _SC_AIO_MAX : c_int = 43;
+            pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
+            pub const _SC_ASYNCHRONOUS_IO : c_int = 45;
+            pub const _SC_DELAYTIMER_MAX : c_int = 50;
+            pub const _SC_MAPPED_FILES : c_int = 53;
+            pub const _SC_MEMLOCK : c_int = 54;
+            pub const _SC_MEMLOCK_RANGE : c_int = 55;
+            pub const _SC_MEMORY_PROTECTION : c_int = 56;
+            pub const _SC_MESSAGE_PASSING : c_int = 57;
+            pub const _SC_MQ_OPEN_MAX : c_int = 58;
+            pub const _SC_PRIORITIZED_IO : c_int = 60;
+            pub const _SC_PRIORITY_SCHEDULING : c_int = 61;
+            pub const _SC_REALTIME_SIGNALS : c_int = 64;
+            pub const _SC_RTSIG_MAX : c_int = 66;
+            pub const _SC_SEMAPHORES : c_int = 67;
+            pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 68;
+            pub const _SC_SIGQUEUE_MAX : c_int = 70;
+            pub const _SC_SYNCHRONIZED_IO : c_int = 75;
+            pub const _SC_TIMER_MAX : c_int = 93;
+            pub const _SC_TIMERS : c_int = 94;
+        }
+    }
+
+    #[cfg(any(target_os = "macos", target_os = "ios"))]
     pub mod os {
         pub mod c95 {
             use types::os::arch::c95::{c_int, c_uint};
@@ -5000,6 +5395,7 @@ pub mod mman {
               target_os = "ios",
               target_os = "freebsd",
               target_os = "dragonfly",
+              target_os = "bitrig",
               target_os = "openbsd"))]
     pub mod posix88 {
         pub mod stat_ {
@@ -5014,6 +5410,7 @@ pub mod stat_ {
                 #[cfg(any(target_os = "linux",
                           target_os = "freebsd",
                           target_os = "dragonfly",
+                          target_os = "bitrig",
                           target_os = "openbsd",
                           target_os = "android",
                           target_os = "ios"))]
@@ -5029,6 +5426,7 @@ pub mod stat_ {
                 #[cfg(any(target_os = "linux",
                           target_os = "freebsd",
                           target_os = "dragonfly",
+                          target_os = "bitrig",
                           target_os = "openbsd",
                           target_os = "android",
                           target_os = "ios"))]
@@ -5223,6 +5621,7 @@ pub mod net {
               target_os = "ios",
               target_os = "freebsd",
               target_os = "dragonfly",
+              target_os = "bitrig",
               target_os = "openbsd"))]
     pub mod posix01 {
         pub mod stat_ {
@@ -5233,6 +5632,7 @@ pub mod stat_ {
                 #[cfg(any(target_os = "linux",
                           target_os = "freebsd",
                           target_os = "dragonfly",
+                          target_os = "bitrig",
                           target_os = "openbsd",
                           target_os = "android",
                           target_os = "ios"))]
@@ -5342,6 +5742,7 @@ pub mod net {
               target_os = "ios",
               target_os = "freebsd",
               target_os = "dragonfly",
+              target_os = "bitrig",
               target_os = "openbsd"))]
     pub mod posix08 {
         pub mod unistd {
@@ -5429,6 +5830,7 @@ pub fn sendto(socket: SOCKET, buf: *const c_void, len: c_int,
               target_os = "ios",
               target_os = "freebsd",
               target_os = "dragonfly",
+              target_os = "bitrig",
               target_os = "openbsd"))]
     pub mod bsd44 {
         use types::common::c95::{c_void};
@@ -5458,10 +5860,11 @@ pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int)
                            -> c_int;
             pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar)
                            -> c_int;
+            pub fn realpath(pathname: *const c_char, resolved: *mut c_char)
+                            -> *mut c_char;
         }
     }
 
-
     #[cfg(any(target_os = "linux", target_os = "android"))]
     pub mod bsd44 {
         use types::common::c95::{c_void};
@@ -5494,6 +5897,7 @@ pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32)
 
     #[cfg(any(target_os = "freebsd",
               target_os = "dragonfly",
+              target_os = "bitrig",
               target_os = "openbsd"))]
     pub mod extra {
     }
index a4417b49f1c41e771fd65a0e18dbc692183597dd..7325e4e7a2ece9aa4a15bee6e35c2820e4159a0c 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::OsOpenbsd => {
+          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | 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 cb44fe117f54645d7740dd287e0355f2b3fb40d1..b46150f75d084516102e96252fc7017489955254 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::OsOpenbsd => {
+          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | 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 7ee357fb1eaf35d7a28c8e4ea5c1559872535119..c7fa7aa879ac272c440982fe5ece76fadd3a70c0 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::OsOpenbsd => {
+          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | 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 36bbd4b987297d020e5fe867d36b604bfbf9211f..d772ae70256f065e7280681584a533d9d43dcf5d 100644 (file)
@@ -215,6 +215,7 @@ fn test_rpath_relative() {
     #[test]
     #[cfg(any(target_os = "freebsd",
               target_os = "dragonfly",
+              target_os = "bitrig",
               target_os = "openbsd"))]
     fn test_rpath_relative() {
         let config = &mut RPathConfig {
diff --git a/src/librustc_back/target/bitrig_base.rs b/src/librustc_back/target/bitrig_base.rs
new file mode 100644 (file)
index 0000000..6e5a48c
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright 2014 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,
+        position_independent_executables: true,
+        pre_link_args: vec!(
+        ),
+
+        .. Default::default()
+    }
+}
index afb5c948f188542b20cb63c72c03b15d38d9be0e..e576a9a717e69f32817dcc02fa49d0d5282ed2e0 100644 (file)
@@ -56,6 +56,7 @@
 mod apple_ios_base;
 mod freebsd_base;
 mod dragonfly_base;
+mod bitrig_base;
 mod openbsd_base;
 
 mod armv7_apple_ios;
@@ -80,6 +81,7 @@
 mod x86_64_pc_windows_gnu;
 mod x86_64_unknown_freebsd;
 mod x86_64_unknown_dragonfly;
+mod x86_64_unknown_bitrig;
 mod x86_64_unknown_linux_gnu;
 mod x86_64_unknown_openbsd;
 
@@ -355,6 +357,7 @@ macro_rules! load_specific {
             i686_unknown_dragonfly,
             x86_64_unknown_dragonfly,
 
+            x86_64_unknown_bitrig,
             x86_64_unknown_openbsd,
 
             x86_64_apple_darwin,
diff --git a/src/librustc_back/target/x86_64_unknown_bitrig.rs b/src/librustc_back/target/x86_64_unknown_bitrig.rs
new file mode 100644 (file)
index 0000000..7b7877c
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright 2014 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::bitrig_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-a0:0:64-\
+                     s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
+        llvm_target: "x86_64-unknown-bitrig".to_string(),
+        target_endian: "little".to_string(),
+        target_pointer_width: "64".to_string(),
+        arch: "x86_64".to_string(),
+        target_os: "bitrig".to_string(),
+        options: base,
+    }
+}
index 9d1b7347d0651039a799e10bccfd7e3a1113fd21..0569de6ded0a4a307fe3f44316701459f93e261a 100644 (file)
@@ -45,10 +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 => {
-            "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
-          }
-          abi::OsDragonfly => {
+          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig => {
             "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
           }
           abi::OsOpenbsd => {
index 2f13bb3158119ad6e8a8f1661bd36b2014f431f7..12d717eb13086a51b20626035a1f9bc01a6f70ee 100644 (file)
@@ -47,12 +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 => {
-            "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()
-          }
-          abi::OsDragonfly => {
+          abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig => {
             "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 a7cf5eb89187f2a99ac4b6133e33fea74d710062..099be92374d3a9cfabb75740c44a531f61460763 100644 (file)
@@ -64,7 +64,9 @@ pub struct flock {
         pub const F_SETLKW: libc::c_int = 13;
     }
 
-    #[cfg(any(target_os = "dragonfly", target_os = "openbsd"))]
+    #[cfg(any(target_os = "dragonfly", 
+              target_os = "bitrig",
+              target_os = "openbsd"))]
     mod os {
         use libc;
 
index bee9a0d00337b4fa2f9a9130bd5c525ada3cec88..bf47543863bd7595fc6af7417ee8eedf6de3eb1d 100644 (file)
@@ -165,6 +165,7 @@ fn test_loading_cosine() {
               target_os = "macos",
               target_os = "freebsd",
               target_os = "dragonfly",
+              target_os = "bitrig",
               target_os = "openbsd"))]
     fn test_errors_do_not_crash() {
         // Open /dev/null as a library to get an error, and make sure
@@ -183,6 +184,7 @@ fn test_errors_do_not_crash() {
           target_os = "ios",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 mod dl {
     use prelude::v1::*;
index e73797bc66c7f377324b8bb1e6e9fca25d808e7b..16539cf06b9e5958874ec1eb76514f9c6602534d 100644 (file)
@@ -562,6 +562,38 @@ pub mod consts {
     pub const EXE_EXTENSION: &'static str = "";
 }
 
+/// Constants associated with the current target
+#[cfg(target_os = "bitrig")]
+pub mod consts {
+    pub use super::arch_consts::ARCH;
+
+    pub const FAMILY: &'static str = "unix";
+
+    /// A string describing the specific operating system in use: in this
+    /// case, `bitrig`.
+    pub const OS: &'static str = "bitrig";
+
+    /// Specifies the filename prefix used for shared libraries on this
+    /// platform: in this case, `lib`.
+    pub const DLL_PREFIX: &'static str = "lib";
+
+    /// Specifies the filename suffix used for shared libraries on this
+    /// platform: in this case, `.so`.
+    pub const DLL_SUFFIX: &'static str = ".so";
+
+    /// Specifies the file extension used for shared libraries on this
+    /// platform that goes after the dot: in this case, `so`.
+    pub const DLL_EXTENSION: &'static str = "so";
+
+    /// Specifies the filename suffix used for executable binaries on this
+    /// platform: in this case, the empty string.
+    pub const EXE_SUFFIX: &'static str = "";
+
+    /// Specifies the file extension, if any, used for executable binaries
+    /// on this platform: in this case, the empty string.
+    pub const EXE_EXTENSION: &'static str = "";
+}
+
 /// Constants associated with the current target
 #[cfg(target_os = "openbsd")]
 pub mod consts {
@@ -570,7 +602,7 @@ pub mod consts {
     pub const FAMILY: &'static str = "unix";
 
     /// A string describing the specific operating system in use: in this
-    /// case, `dragonfly`.
+    /// case, `openbsd`.
     pub const OS: &'static str = "openbsd";
 
     /// Specifies the filename prefix used for shared libraries on this
index 526b5edd4cbde8bf5fb1497ff9af81db7c35c9cd..8a6b31e77dab65b74923b07595186e90f786159a 100644 (file)
@@ -639,6 +639,7 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> {
           target_os = "android",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 fn real_args_as_bytes() -> Vec<Vec<u8>> {
     use rt;
@@ -1287,6 +1288,39 @@ pub mod consts {
     pub const EXE_EXTENSION: &'static str = "";
 }
 
+#[cfg(target_os = "bitrig")]
+#[deprecated(since = "1.0.0", reason = "renamed to env::consts")]
+#[unstable(feature = "os")]
+pub mod consts {
+    pub use os::arch_consts::ARCH;
+
+    pub const FAMILY: &'static str = "unix";
+
+    /// A string describing the specific operating system in use: in this
+    /// case, `bitrig`.
+    pub const SYSNAME: &'static str = "bitrig";
+
+    /// Specifies the filename prefix used for shared libraries on this
+    /// platform: in this case, `lib`.
+    pub const DLL_PREFIX: &'static str = "lib";
+
+    /// Specifies the filename suffix used for shared libraries on this
+    /// platform: in this case, `.so`.
+    pub const DLL_SUFFIX: &'static str = ".so";
+
+    /// Specifies the file extension used for shared libraries on this
+    /// platform that goes after the dot: in this case, `so`.
+    pub const DLL_EXTENSION: &'static str = "so";
+
+    /// Specifies the filename suffix used for executable binaries on this
+    /// platform: in this case, the empty string.
+    pub const EXE_SUFFIX: &'static str = "";
+
+    /// Specifies the file extension, if any, used for executable binaries
+    /// on this platform: in this case, the empty string.
+    pub const EXE_EXTENSION: &'static str = "";
+}
+
 #[cfg(target_os = "openbsd")]
 #[deprecated(since = "1.0.0", reason = "renamed to env::consts")]
 #[unstable(feature = "os")]
index c2f5133eaf3fe5547a3fd450274d0948d127cee4..0300ea62453b92814af49d1c6976de1adc14768f 100644 (file)
@@ -43,6 +43,7 @@ pub fn clone() -> Option<Vec<Vec<u8>>> { imp::clone() }
           target_os = "android",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 mod imp {
     use prelude::v1::*;
index 43e3a43f56d3632ce38017ebf3df9511aed42709..3063d9d942a28c3c3a8edd3b23ec2f1c431dadf4 100644 (file)
@@ -109,6 +109,10 @@ pub enum _Unwind_Context {}
 #[link(name = "gcc_pic")]
 extern {}
 
+#[cfg(target_os = "bitrig")]
+#[link(name = "c++abi")]
+extern {}
+
 extern "C" {
     // iOS on armv7 uses SjLj exceptions and requires to link
     // against corresponding routine (..._SjLj_...)
index 1392bc815c4f9d68d31a93aa47ae87e3a72af478..a2f5e8680fd90c1d2129d697cf724aa56289ff51 100644 (file)
@@ -39,7 +39,9 @@
 #[link(name = "pthread")]
 extern {}
 
-#[cfg(any(target_os = "dragonfly", target_os = "openbsd"))]
+#[cfg(any(target_os = "dragonfly", 
+          target_os = "bitrig",
+          target_os = "openbsd"))]
 #[link(name = "pthread")]
 extern {}
 
index 7325e0a5ac8ddfaeb3726aeca06be0c723b5d987..aa0883e097e95307fc6f8e6762e5d61ecae52bbb 100644 (file)
@@ -689,7 +689,8 @@ fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> {
         setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPALIVE,
                    seconds as libc::c_int)
     }
-    #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+    #[cfg(any(target_os = "freebsd",
+              target_os = "dragonfly"))]
     fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> {
         setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
                    seconds as libc::c_int)
index 8dd2f154fa8e3028fd5c0cd31cbc71060cca6b93..bc4ea662318aaea4385b79acfcfd158129cca1de 100644 (file)
@@ -189,11 +189,18 @@ unsafe fn target_record_sp_limit(_: uint) {
     unsafe fn target_record_sp_limit(limit: uint) {
         asm!("movq $0, %fs:24" :: "r"(limit) :: "volatile")
     }
-    #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)]
+    #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))]
+    #[inline(always)]
     unsafe fn target_record_sp_limit(limit: uint) {
         asm!("movq $0, %fs:32" :: "r"(limit) :: "volatile")
     }
 
+    #[cfg(target_os = "bitrig")]
+    #[inline(always)]
+    unsafe fn target_record_sp_limit(_: uint) {
+        // segmented stacks are disabled
+    }
+
     // x86
     #[cfg(all(target_arch = "x86",
               any(target_os = "macos", target_os = "ios")))]
@@ -276,12 +283,18 @@ unsafe fn target_get_sp_limit() -> uint {
         asm!("movq %fs:24, $0" : "=r"(limit) ::: "volatile");
         return limit;
     }
-    #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)]
+    #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))]
+    #[inline(always)]
     unsafe fn target_get_sp_limit() -> uint {
         let limit;
         asm!("movq %fs:32, $0" : "=r"(limit) ::: "volatile");
         return limit;
     }
+    #[cfg(target_os = "bitrig")]
+    #[inline(always)]
+    unsafe fn target_get_sp_limit() -> uint {
+      return 2048;
+    }
 
 
     // x86
index 5e512e9261b1dfe475ec84ecad7adcb36c608c44..258e70584528a14dd3522662ddae38d80b8c949d 100644 (file)
@@ -319,6 +319,7 @@ unsafe fn init_state() -> *mut backtrace_state {
         if !STATE.is_null() { return STATE }
         let selfname = if cfg!(target_os = "freebsd") ||
                           cfg!(target_os = "dragonfly") ||
+                          cfg!(target_os = "bitrig") ||
                           cfg!(target_os = "openbsd") {
             env::current_exe().ok()
         } else {
index cf05733cc18af07040bf705984be954777e43ae9..06e5333239e140c3626be990b3118c0e899fa391 100644 (file)
@@ -24,6 +24,7 @@
           target_os = "ios",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 pub const FIONBIO: libc::c_ulong = 0x8004667e;
 #[cfg(any(all(target_os = "linux",
@@ -43,6 +44,7 @@
           target_os = "ios",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 pub const FIOCLEX: libc::c_ulong = 0x20006601;
 #[cfg(any(all(target_os = "linux",
@@ -62,6 +64,7 @@
           target_os = "ios",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 pub const MSG_DONTWAIT: libc::c_int = 0x80;
 #[cfg(any(target_os = "linux", target_os = "android"))]
@@ -75,7 +78,8 @@
           target_os = "freebsd",
           target_os = "dragonfly"))]
 pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 71;
-#[cfg(target_os = "openbsd")]
+#[cfg(any(target_os = "bitrig",
+          target_os = "openbsd"))]
 pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 101;
 #[cfg(target_os = "android")]
 pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 0x0048;
@@ -96,6 +100,7 @@ pub struct passwd {
 #[cfg(any(target_os = "macos",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 pub struct passwd {
     pub pw_name: *mut libc::c_char,
@@ -176,6 +181,7 @@ pub fn fd_set(set: &mut fd_set, fd: i32) {
 #[cfg(any(target_os = "android",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd",
           target_os = "linux"))]
 mod select {
@@ -344,3 +350,41 @@ pub struct sigaction {
         pub sa_mask: sigset_t,
     }
 }
+
+#[cfg(target_os = "bitrig")]
+mod signal {
+    use libc;
+
+    pub const SA_ONSTACK: libc::c_int = 0x0001;
+    pub const SA_RESTART: libc::c_int = 0x0002;
+    pub const SA_RESETHAND: libc::c_int = 0x0004;
+    pub const SA_NOCLDSTOP: libc::c_int = 0x0008;
+    pub const SA_NODEFER: libc::c_int = 0x0010;
+    pub const SA_NOCLDWAIT: libc::c_int = 0x0020;
+    pub const SA_SIGINFO: libc::c_int = 0x0040;
+    pub const SIGCHLD: libc::c_int = 20;
+
+    pub type sigset_t = libc::c_uint;
+
+    // This structure has more fields, but we're not all that interested in
+    // them.
+    #[repr(C)]
+    pub struct siginfo {
+        pub si_signo: libc::c_int,
+        pub si_code: libc::c_int,
+        pub si_errno: libc::c_int,
+        // FIXME: Bitrig has a crazy union here in the siginfo, I think this
+        // layout will still work tho.  The status might be off by the size of
+        // a clock_t by my reading, but we can fix this later.
+        pub pid: libc::pid_t,
+        pub uid: libc::uid_t,
+        pub status: libc::c_int,
+    }
+
+    #[repr(C)]
+    pub struct sigaction {
+        pub sa_handler: extern fn(libc::c_int),
+        pub sa_mask: sigset_t,
+        pub sa_flags: libc::c_int,
+    }
+}
index 66ae018cb36af96fb75b3105d2296ace9df33c76..9bde7ed9d7e493a0576fb82e520408ef0cb131f1 100644 (file)
@@ -291,6 +291,33 @@ fn mkstat(stat: &libc::stat) -> FileStat {
     // FileStat times are in milliseconds
     fn mktime(secs: u64, nsecs: u64) -> u64 { secs * 1000 + nsecs / 1000000 }
 
+    #[cfg(target_os = "bitrig")]
+    fn ctime(stat: &libc::stat) -> u64 { 
+      mktime(stat.st_ctim.tv_sec as u64, stat.st_ctim.tv_nsec as u64)
+    }
+    #[cfg(not(target_os = "bitrig"))]
+    fn ctime(stat: &libc::stat) -> u64 { 
+      mktime(stat.st_ctime as u64, stat.st_ctime_nsec as u64) 
+    }
+
+    #[cfg(target_os = "bitrig")]
+    fn atime(stat: &libc::stat) -> u64 { 
+      mktime(stat.st_atim.tv_sec as u64, stat.st_atim.tv_nsec as u64)
+    }
+    #[cfg(not(target_os = "bitrig"))]
+    fn atime(stat: &libc::stat) -> u64 { 
+      mktime(stat.st_atime as u64, stat.st_atime_nsec as u64)
+    }
+
+    #[cfg(target_os = "bitrig")]
+    fn mtime(stat: &libc::stat) -> u64 { 
+      mktime(stat.st_mtim.tv_sec as u64, stat.st_mtim.tv_nsec as u64)
+    }
+    #[cfg(not(target_os = "bitrig"))]
+    fn mtime(stat: &libc::stat) -> u64 { 
+      mktime(stat.st_mtime as u64, stat.st_mtime_nsec as u64)
+    }
+
     #[cfg(not(any(target_os = "linux", target_os = "android")))]
     fn flags(stat: &libc::stat) -> u64 { stat.st_flags as u64 }
     #[cfg(any(target_os = "linux", target_os = "android"))]
@@ -312,9 +339,9 @@ fn gen(_stat: &libc::stat) -> u64 { 0 }
             _ => old_io::FileType::Unknown,
         },
         perm: FilePermission::from_bits_truncate(stat.st_mode as u32),
-        created: mktime(stat.st_ctime as u64, stat.st_ctime_nsec as u64),
-        modified: mktime(stat.st_mtime as u64, stat.st_mtime_nsec as u64),
-        accessed: mktime(stat.st_atime as u64, stat.st_atime_nsec as u64),
+        created: ctime(stat),
+        modified: mtime(stat),
+        accessed: atime(stat),
         unstable: UnstableFileStat {
             device: stat.st_dev as u64,
             inode: stat.st_ino as u64,
index b191eda583c9b82d4a57a3ea6da3f35d7d7b9fb0..67098ac4689f732e8fd1c9e3ef469cc919c58d23 100644 (file)
@@ -40,6 +40,16 @@ 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; }
@@ -192,10 +202,9 @@ pub fn current_exe() -> IoResult<Path> {
     fs::readlink(&Path::new("/proc/curproc/file"))
 }
 
-#[cfg(target_os = "openbsd")]
+#[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
 pub fn current_exe() -> IoResult<Path> {
     use sync::{StaticMutex, MUTEX_INIT};
-
     static LOCK: StaticMutex = MUTEX_INIT;
 
     extern {
@@ -330,6 +339,7 @@ pub fn args() -> Args {
           target_os = "android",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 pub fn args() -> Args {
     use rt;
index 52a8ac9c338e0d4a58ba1a7f32a4b37af2bbea92..4438d5d1b1fafafefaac3bc49c9dcd315de84d5b 100644 (file)
@@ -593,6 +593,7 @@ pub fn WTERMSIG(status: i32) -> i32 { status & 0x7f }
               target_os = "ios",
               target_os = "freebsd",
               target_os = "dragonfly",
+              target_os = "bitrig",
               target_os = "openbsd"))]
     mod imp {
         pub fn WIFEXITED(status: i32) -> bool { (status & 0x7f) == 0 }
index 3512fa36eb3b7fc07e61b56a0103fc1c02ca4ba4..efcb92e482660ef9115aa74a62aba45d64d86b61 100644 (file)
@@ -34,6 +34,7 @@ fn drop(&mut self) {
 
 #[cfg(any(target_os = "linux",
           target_os = "macos",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 mod imp {
     use core::prelude::*;
@@ -205,7 +206,9 @@ pub struct sigaltstack {
 
     }
 
-    #[cfg(any(target_os = "macos", target_os = "openbsd"))]
+    #[cfg(any(target_os = "macos", 
+              target_os = "bitrig",
+              target_os = "openbsd"))]
     mod signal {
         use libc;
         use super::sighandler_t;
@@ -219,6 +222,9 @@ mod signal {
         #[cfg(target_os = "openbsd")]
         pub const SIGSTKSZ: libc::size_t = 40960;
 
+        #[cfg(target_os = "bitrig")]
+        pub const SIGSTKSZ: libc::size_t = 40960;
+
         pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
 
         pub type sigset_t = u32;
@@ -237,14 +243,14 @@ pub struct siginfo {
             pub si_addr: *mut libc::c_void
         }
 
-        #[cfg(target_os = "openbsd")]
+        #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
         #[repr(C)]
         pub struct siginfo {
             pub si_signo: libc::c_int,
             pub si_code: libc::c_int,
             pub si_errno: libc::c_int,
-            // union
-            pub si_addr: *mut libc::c_void,
+            //union
+            pub si_addr: *mut libc::c_void
         }
 
         #[repr(C)]
@@ -277,6 +283,7 @@ pub fn sigaltstack(ss: *const sigaltstack,
 
 #[cfg(not(any(target_os = "linux",
               target_os = "macos",
+              target_os = "bitrig",
               target_os = "openbsd")))]
 mod imp {
     use libc;
index bc93513af63d4609f2593ba42ef213608c23dbe6..c7d704922cb7fbdb0ac8e5c5267683e635d1b23b 100644 (file)
@@ -46,6 +46,7 @@ pub fn gettimeofday(tp: *mut libc::timeval,
 
 #[cfg(any(target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 mod os {
     use libc;
index 6f030ee91fe2d6db045ca5daec23dc3dc8240c8c..2a9531fa5283f090dfd90a5c79a8dbd7c1c7243d 100644 (file)
@@ -33,6 +33,7 @@
 
 #[cfg(all(not(target_os = "linux"),
           not(target_os = "macos"),
+          not(target_os = "bitrig"),
           not(target_os = "openbsd")))]
 pub mod guard {
     pub unsafe fn current() -> uint {
@@ -50,11 +51,13 @@ pub unsafe fn init() {
 
 #[cfg(any(target_os = "linux",
           target_os = "macos",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 pub mod guard {
     use super::*;
     #[cfg(any(target_os = "linux",
               target_os = "android",
+              target_os = "bitrig",
               target_os = "openbsd"))]
     use mem;
     #[cfg(any(target_os = "linux", target_os = "android"))]
@@ -71,7 +74,9 @@ pub mod guard {
     static mut PAGE_SIZE: uint = 0;
     static mut GUARD_PAGE: uint = 0;
 
-    #[cfg(any(target_os = "macos", target_os = "openbsd"))]
+    #[cfg(any(target_os = "macos", 
+              target_os = "bitrig",
+              target_os = "openbsd"))]
     unsafe fn get_stack_start() -> *mut libc::c_void {
         current() as *mut libc::c_void
     }
@@ -189,6 +194,22 @@ pub unsafe fn current() -> uint {
 
         stackaddr as uint + guardsize as uint
     }
+
+    #[cfg(target_os = "bitrig")]
+    pub unsafe fn current() -> uint {
+      let mut current_stack: stack_t = mem::zeroed();
+      if pthread_stackseg_np(pthread_self(), &mut current_stack) != 0 {
+        panic!("failed to get current stack: pthread_stackseg_np")
+      }
+
+      if pthread_main_np() == 1 {
+        // main thread
+        current_stack.ss_sp as uint - current_stack.ss_size as uint + 3 * PAGE_SIZE as uint
+      } else {
+        // new thread
+        current_stack.ss_sp as uint - current_stack.ss_size as uint
+      }
+    }
 }
 
 pub unsafe fn create(stack: uint, p: Thunk) -> rust_thread {
@@ -250,6 +271,7 @@ pub unsafe fn set_name(name: &str) {
 
 #[cfg(any(target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 pub unsafe fn set_name(name: &str) {
     // pthread_set_name_np() since almost forever on all BSDs
@@ -332,6 +354,15 @@ pub fn pthread_attr_getstack(attr: *const libc::pthread_attr_t,
     fn pthread_setname_np(name: *const libc::c_char) -> libc::c_int;
 }
 
+#[cfg(target_os = "bitrig")]
+extern {
+    pub fn pthread_self() -> libc::pthread_t;
+    pub fn pthread_stackseg_np(thread: libc::pthread_t,
+                              sinfo: *mut stack_t) -> libc::c_uint;
+    pub fn pthread_main_np() -> libc::c_uint;
+    fn pthread_set_name_np(tid: libc::pthread_t, name: *const libc::c_char);
+}
+
 #[cfg(target_os = "openbsd")]
 extern {
         pub fn pthread_stackseg_np(thread: libc::pthread_t,
@@ -339,7 +370,7 @@ pub fn pthread_stackseg_np(thread: libc::pthread_t,
         pub fn pthread_main_np() -> libc::c_uint;
 }
 
-#[cfg(target_os = "openbsd")]
+#[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
 #[repr(C)]
 pub struct stack_t {
     pub ss_sp: *mut libc::c_void,
index 62d9a33c83d7af78d0280a0118e950844b59c99b..9b7079ee10833de308a6cb70ba250e59f5a8d959 100644 (file)
@@ -43,6 +43,7 @@ pub unsafe fn destroy(key: Key) {
 
 #[cfg(any(target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 type pthread_key_t = ::libc::c_int;
 
@@ -50,6 +51,7 @@ pub unsafe fn destroy(key: Key) {
               target_os = "ios",
               target_os = "freebsd",
               target_os = "dragonfly",
+              target_os = "bitrig",
               target_os = "openbsd")))]
 type pthread_key_t = ::libc::c_uint;
 
index bddf7b075df96ab365f534484bde9e6cff17e373..7016a700dd82ff94f62fd71cfb71a1e67af8630a 100644 (file)
@@ -80,8 +80,11 @@ pub struct SteadyTime {
     }
 
     // Apparently android provides this in some other library?
+    // Bitrig's RT extensions are in the C library, not a separate librt
     // OpenBSD provide it via libc
-    #[cfg(not(any(target_os = "android", target_os = "openbsd")))]
+    #[cfg(not(any(target_os = "android", 
+                  target_os = "bitrig",
+                  target_os = "openbsd")))]
     #[link(name = "rt")]
     extern {}
 
index 3a79047445cdd8d10a5a70b6c9df8d36e60649f7..8e60bbf4cbd00a5e655fb1e6d477bb0fc239a788 100644 (file)
@@ -22,6 +22,7 @@ pub struct TTY {
 
 #[cfg(any(target_os = "macos",
           target_os = "freebsd",
+          target_os = "bitrig",
           target_os = "openbsd"))]
 const TIOCGWINSZ: c_ulong = 0x40087468;
 
@@ -55,6 +56,7 @@ pub fn set_raw(&mut self, _raw: bool) -> IoResult<()> {
               target_os = "android",
               target_os = "macos",
               target_os = "freebsd",
+              target_os = "bitrig",
               target_os = "openbsd"))]
     pub fn get_winsize(&mut self) -> IoResult<(int, int)> {
         unsafe {
index de3fa1135b161382d5cb13eb363c026cd72c6aae..2cf157bd245227f3710a0243b14c4b52919a0d4c 100644 (file)
@@ -24,6 +24,7 @@ pub enum Os {
     OsFreebsd,
     OsiOS,
     OsDragonfly,
+    OsBitrig,
     OsOpenbsd,
 }
 
@@ -136,6 +137,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             OsAndroid => "android".fmt(f),
             OsFreebsd => "freebsd".fmt(f),
             OsDragonfly => "dragonfly".fmt(f),
+            OsBitrig => "bitrig".fmt(f),
             OsOpenbsd => "openbsd".fmt(f),
         }
     }
index c82da57c12847af48603e9bbc1660d0a57a4e36f..cf2b9b9f717c57ff13ff997c99a33e467cd26dd6 100644 (file)
 
 #if defined(__APPLE__)
 #define EXHAUSTED               _rust_stack_exhausted
-#elif defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#elif defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__Bitrig__)
 #define EXHAUSTED               rust_stack_exhausted@PLT
 #else
 #define EXHAUSTED               rust_stack_exhausted
 #endif
 
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__Bitrig__)
        .hidden MORESTACK
 #else
 #if defined(__APPLE__)
index b756602ead4f43286408ad769742f79e4fc32934..5fe5e55a92487642496f8ad4971b73666243441a 100644 (file)
@@ -47,8 +47,8 @@ extern char **environ;
 #endif
 #endif
 
-#if defined(__FreeBSD__) || defined(__linux__) || defined(__ANDROID__) \
-  || defined(__DragonFly__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__linux__) || defined(__ANDROID__) || \
+    defined(__DragonFly__) || defined(__Bitrig__) || defined(__OpenBSD__)
 extern char **environ;
 #endif
 
@@ -200,7 +200,282 @@ rust_unset_sigprocmask() {
 int *__dfly_error(void) { return __error(); }
 #endif
 
-#if defined(__OpenBSD__)
+#if defined(__Bitrig__)
+#include <stdio.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <limits.h>
+
+int rust_get_path(void *p, size_t* sz)
+{
+  int mib[4];
+  char *eq = NULL;
+  char *key = NULL;
+  char *val = NULL;
+  char **menv = NULL;
+  size_t maxlen, len;
+  int nenv = 0;
+  int i;
+
+  if ((p == NULL) && (sz == NULL))
+    return -1;
+
+  /* get the argv array */
+  mib[0] = CTL_KERN;
+  mib[1] = KERN_PROC_ARGS;
+  mib[2] = getpid();
+  mib[3] = KERN_PROC_ENV;
+
+  /* get the number of bytes needed to get the env */
+  maxlen = 0;
+  if (sysctl(mib, 4, NULL, &maxlen, NULL, 0) == -1)
+    return -1;
+
+  /* allocate the buffer */
+  if ((menv = calloc(maxlen, sizeof(char))) == NULL)
+    return -1;
+
+  /* get the env array */
+  if (sysctl(mib, 4, menv, &maxlen, NULL, 0) == -1)
+  {
+    free(menv);
+    return -1;
+  }
+
+  mib[3] = KERN_PROC_NENV;
+  len = sizeof(int);
+  /* get the length of env array */
+  if (sysctl(mib, 4, &nenv, &len, NULL, 0) == -1)
+  {
+    free(menv);
+    return -1;
+  }
+
+  /* find _ key and resolve the value */
+  for (i = 0; i < nenv; i++)
+  {
+    if ((eq = strstr(menv[i], "=")) == NULL)
+      continue;
+
+    key = menv[i];
+    val = eq + 1;
+    *eq = '\0';
+
+    if (strncmp(key, "PATH", maxlen) != 0)
+      continue;
+
+    if (p == NULL)
+    {
+      /* return the length of the value + NUL */
+      *sz = strnlen(val, maxlen) + 1;
+      free(menv);
+      return 0;
+    }
+    else
+    {
+      /* copy *sz bytes to the output buffer */
+      memcpy(p, val, *sz);
+      free(menv);
+      return 0;
+    }
+  }
+
+  free(menv);
+  return -1;
+}
+
+int rust_get_path_array(void * p, size_t * sz)
+{
+  char *path, *str;
+  char **buf;
+  int i, num;
+  size_t len;
+
+  if ((p == NULL) && (sz == NULL))
+    return -1;
+
+  /* get the length of the PATH value */
+  if (rust_get_path(NULL, &len) == -1)
+    return -1;
+
+  if (len == 0)
+    return -1;
+
+  /* allocate the buffer */
+  if ((path = calloc(len, sizeof(char))) == NULL)
+    return -1;
+
+  /* get the PATH value */
+  if (rust_get_path(path, &len) == -1)
+  {
+    free(path);
+    return -1;
+  }
+
+  /* count the number of parts in the PATH */
+  num = 1;
+  for(str = path; *str != '\0'; str++)
+  {
+    if (*str == ':')
+      num++;
+  }
+
+  /* calculate the size of the buffer for the 2D array */
+  len = (num * sizeof(char*) + 1) + strlen(path) + 1;
+
+  if (p == NULL)
+  {
+    free(path);
+    *sz = len;
+    return 0;
+  }
+
+  /* make sure we have enough buffer space */
+  if (*sz < len)
+  {
+    free(path);
+    return -1;
+  }
+
+  /* zero out the buffer */
+  buf = (char**)p;
+  memset(buf, 0, *sz);
+
+  /* copy the data into the right place */
+  str = p + ((num+1) * sizeof(char*));
+  memcpy(str, path, strlen(path));
+
+  /* parse the path into it's parts */
+  for (i = 0; i < num && (buf[i] = strsep(&str, ":")) != NULL; i++) {;}
+  buf[num] = NULL;
+
+  free(path);
+  return 0;
+}
+
+int rust_get_argv_zero(void* p, size_t* sz)
+{
+  int mib[4];
+  char **argv = NULL;
+  size_t len;
+
+  if ((p == NULL) && (sz == NULL))
+    return -1;
+
+  /* get the argv array */
+  mib[0] = CTL_KERN;
+  mib[1] = KERN_PROC_ARGS;
+  mib[2] = getpid();
+  mib[3] = KERN_PROC_ARGV;
+
+  /* request KERN_PROC_ARGV size */
+  len = 0;
+  if (sysctl(mib, 4, NULL, &len, NULL, 0) == -1)
+    return -1;
+
+  /* allocate buffer to receive the values */
+  if ((argv = malloc(len)) == NULL)
+    return -1;
+
+  /* get the argv array */
+  if (sysctl(mib, 4, argv, &len, NULL, 0) == -1)
+  {
+    free(argv);
+    return -1;
+  }
+
+  /* get length of argv[0] */
+  len = strnlen(argv[0], len) + 1;
+
+  if (p == NULL)
+  {
+    *sz = len;
+    free(argv);
+    return 0;
+  }
+
+  if (*sz < len)
+  {
+    free(argv);
+    return -1;
+  }
+
+  memset(p, 0, len);
+  memcpy(p, argv[0], len);
+  free(argv);
+  return 0;
+}
+
+const char * rust_load_self()
+{
+  static char *self = NULL;
+  char *argv0;
+  char **paths;
+  size_t sz;
+  int i;
+  char buf[2*PATH_MAX], exe[2*PATH_MAX];
+
+  if (self != NULL)
+    return self;
+
+  if (rust_get_argv_zero(NULL, &sz) == -1)
+    return NULL;
+  if ((argv0 = calloc(sz, sizeof(char))) == NULL)
+    return NULL;
+  if (rust_get_argv_zero(argv0, &sz) == -1)
+  {
+    free(argv0);
+    return NULL;
+  }
+
+  /* if argv0 is a relative or absolute path, resolve it with realpath */
+  if ((*argv0 == '.') || (*argv0 == '/') || (strstr(argv0, "/") != NULL))
+  {
+    self = realpath(argv0, NULL);
+    free(argv0);
+    return self;
+  }
+
+  /* get the path array */
+  if (rust_get_path_array(NULL, &sz) == -1)
+  {
+    free(argv0);
+    return NULL;
+  }
+  if ((paths = calloc(sz, sizeof(char))) == NULL)
+  {
+    free(argv0);
+    return NULL;
+  }
+  if (rust_get_path_array(paths, &sz) == -1)
+  {
+    free(argv0);
+    free(paths);
+    return NULL;
+  }
+
+  for(i = 0; paths[i] != NULL; i++)
+  {
+    snprintf(buf, 2*PATH_MAX, "%s/%s", paths[i], argv0);
+    if (realpath(buf, exe) == NULL)
+      continue;
+
+    if (access(exe, F_OK | X_OK) == -1)
+      continue;
+
+    self = strdup(exe);
+    free(argv0);
+    free(paths);
+    return self;
+  }
+
+  free(argv0);
+  free(paths);
+  return NULL;
+}
+
+#elif defined(__OpenBSD__)
+
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <limits.h>
@@ -248,6 +523,7 @@ const char * rust_current_exe() {
 
     return (self);
 }
+
 #endif
 
 //
index 30d6b934fa277a06b83e8bd7792bf218f741df18..eb66423f1c7a7f0543678616f498aefae01f156d 100644 (file)
@@ -26,6 +26,9 @@ mod hello;
 #[cfg(target_os = "dragonfly")]
 mod hello;
 
+#[cfg(target_os = "bitrig")]
+mod hello;
+
 #[cfg(target_os = "android")]
 mod hello;
 
index 07f021e48d7e7a40de3a0a99def9651e913519c1..1a3e48576902b982ce8242199402e481f6a9d1fc 100644 (file)
@@ -42,6 +42,18 @@ pub fn main() {
     }
 }
 
+#[cfg(target_os = "bitrig")]
+mod m {
+    #[main]
+    #[cfg(target_arch = "x86_64")]
+    pub fn main() {
+        unsafe {
+            assert_eq!(::rusti::pref_align_of::<u64>(), 8u);
+            assert_eq!(::rusti::min_align_of::<u64>(), 8u);
+        }
+    }
+}
+
 #[cfg(target_os = "windows")]
 mod m {
     #[main]
index 350ec68a7d1495347ffe02ba11595b627cdb5ef9..9c0da173f7fd3d3bd88390e65a3947f719d88782 100644 (file)
@@ -37,7 +37,7 @@
 #[link(name = "c")]
 extern {}
 
-#[cfg(target_os = "openbsd")]
+#[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
 #[link(name = "c")]
 extern {}
 
index ca9ee469e38976ec8e49f729de97a428fb17db33..a37f4a28c68adc22f549e9283aaf00884807c3a7 100644 (file)
@@ -12,6 +12,7 @@
 //ignore-freebsd
 //ignore-ios
 //ignore-dragonfly
+//ignore-bitrig
 
 #![feature(asm)]
 
index fba86d74816790438fe07d986d7ccf82c49f5ee4..082a69b0296f535701be08188459d9359c8e9e1c 100644 (file)
@@ -13,6 +13,7 @@
 //ignore-freebsd
 //ignore-ios
 //ignore-dragonfly
+//ignore-bitrig
 
 #![feature(asm)]
 
index 5330490e54f55394221394d2308a91d9c88218af..5df495e69fc6164f350489a324f885f3432a88b7 100644 (file)
@@ -55,6 +55,15 @@ pub fn size() -> uint { 16u }
     }
 }
 
+#[cfg(target_os = "bitrig")]
+mod m {
+    #[cfg(target_arch = "x86_64")]
+    pub mod m {
+        pub fn align() -> uint { 8u }
+        pub fn size() -> uint { 16u }
+    }
+}
+
 #[cfg(target_os = "windows")]
 mod m {
     #[cfg(target_arch = "x86")]
index 75a8f6019b89895c1f83ffe5ed0a99fcd915209e..7e21c3507b3220a485567c777fa39a8eb7717a23 100644 (file)
@@ -34,6 +34,7 @@ pub fn main() {
           target_os = "linux",
           target_os = "freebsd",
           target_os = "dragonfly",
+          target_os = "bitrig",
           target_os = "openbsd",
           target_os = "android"))]
 pub fn main() { }