From 072a7cc091d727a81fda0c32ef4e8b2a58fc78d3 Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Fri, 20 Nov 2020 11:11:57 +0000 Subject: Haiku-specific patches for Rust 1.48.0 diff --git a/Cargo.lock b/Cargo.lock index 90fc560..20175d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4520,9 +4520,9 @@ checksum = "da73c8f77aebc0e40c300b93f0a5f1bece7a248a36eee287d4e095f35c7b7d6e" [[package]] name = "socket2" -version = "0.3.12" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +checksum = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" dependencies = [ "cfg-if", "libc", diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index 652219e..ea1d576 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -190,7 +190,7 @@ impl Thread { unsafe { let ret = libc::pthread_join(self.id, ptr::null_mut()); mem::forget(self); - assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret)); + debug_assert_eq!(ret, 0); } } diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs index 559c4dc..2c9a9c6 100644 --- a/library/std/src/sys/windows/c.rs +++ b/library/std/src/sys/windows/c.rs @@ -269,7 +269,6 @@ pub const FILE_END: DWORD = 2; pub const WAIT_OBJECT_0: DWORD = 0x00000000; pub const WAIT_TIMEOUT: DWORD = 258; -pub const WAIT_FAILED: DWORD = 0xFFFFFFFF; pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; diff --git a/library/std/src/sys/windows/thread.rs b/library/std/src/sys/windows/thread.rs index 38839ea..7bb8c95 100644 --- a/library/std/src/sys/windows/thread.rs +++ b/library/std/src/sys/windows/thread.rs @@ -70,10 +70,7 @@ impl Thread { } pub fn join(self) { - let rc = unsafe { c::WaitForSingleObject(self.handle.raw(), c::INFINITE) }; - if rc == c::WAIT_FAILED { - panic!("failed to join on thread: {}", io::Error::last_os_error()); - } + unsafe { c::WaitForSingleObject(self.handle.raw(), c::INFINITE); } } pub fn yield_now() { diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 087175b..215f910 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -1341,11 +1341,6 @@ impl JoinHandle { /// [`Err`]: crate::result::Result::Err /// [atomic memory orderings]: crate::sync::atomic /// - /// # Panics - /// - /// This function may panic on some platforms if a thread attempts to join - /// itself or otherwise may create a deadlock with joining threads. - /// /// # Examples /// /// ``` diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 6bba00e..37d6fab 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -378,6 +378,8 @@ fn configure_cmake( cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD"); } else if target.contains("windows") { cfg.define("CMAKE_SYSTEM_NAME", "Windows"); + } else if target.contains("haiku") { + cfg.define("CMAKE_SYSTEM_NAME", "Haiku"); } // When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in // that case like CMake we cannot easily determine system version either. diff --git a/src/llvm-project/llvm/lib/Support/CMakeLists.txt b/src/llvm-project/llvm/lib/Support/CMakeLists.txt index 17bef02..e36da10 100644 --- a/src/llvm-project/llvm/lib/Support/CMakeLists.txt +++ b/src/llvm-project/llvm/lib/Support/CMakeLists.txt @@ -36,6 +36,10 @@ elseif( CMAKE_HOST_UNIX ) if( FUCHSIA ) set(system_libs ${system_libs} zircon) endif() + if ( HAIKU ) + add_definitions(-D_BSD_SOURCE) + set(system_libs ${system_libs} bsd) + endif() endif( MSVC OR MINGW ) # Delay load shell32.dll if possible to speed up process startup. diff --git a/src/llvm-project/llvm/lib/Support/Unix/Program.inc b/src/llvm-project/llvm/lib/Support/Unix/Program.inc index 8f41fc0..950416d 100644 --- a/src/llvm-project/llvm/lib/Support/Unix/Program.inc +++ b/src/llvm-project/llvm/lib/Support/Unix/Program.inc @@ -448,8 +448,12 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait, if (ProcStat) { std::chrono::microseconds UserT = toDuration(Info.ru_utime); std::chrono::microseconds KernelT = toDuration(Info.ru_stime); +#ifndef __HAIKU__ uint64_t PeakMemory = static_cast(Info.ru_maxrss); *ProcStat = ProcessStatistics{UserT + KernelT, UserT, PeakMemory}; +#else + *ProcStat = ProcessStatistics{UserT + KernelT, UserT, 0}; +#endif } // Return the proper exit status. Detect error conditions -- 2.26.0