diff options
| author | bors <bors@rust-lang.org> | 2017-09-15 04:22:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-09-15 04:22:45 +0000 |
| commit | d86a7f7a78e96bd28468e165c2b223b3b6ecc11d (patch) | |
| tree | 78839e9a358a6781af8c1dd0a21b3f9503382b3a /src/libstd/sys | |
| parent | 2d288a5ae5e2e72b1c40611db80f94bbec75639b (diff) | |
| parent | 68e0f28304249a4f2db6b177b3be156ba4774a92 (diff) | |
| download | rust-d86a7f7a78e96bd28468e165c2b223b3b6ecc11d.tar.gz rust-d86a7f7a78e96bd28468e165c2b223b3b6ecc11d.zip | |
Auto merge of #44585 - frewsxcv:rollup, r=frewsxcv
Rollup of 23 pull requests - Successful merges: #44131, #44254, #44368, #44374, #44378, #44388, #44430, #44450, #44453, #44472, #44476, #44477, #44485, #44497, #44521, #44534, #44536, #44541, #44552, #44559, #44563, #44569, #44572 - Failed merges:
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/windows/c.rs | 11 | ||||
| -rw-r--r-- | src/libstd/sys/windows/thread.rs | 13 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index 7dfcc996e18..9535ddfe5ca 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -32,6 +32,7 @@ pub type DWORD = c_ulong; pub type HANDLE = LPVOID; pub type HINSTANCE = HANDLE; pub type HMODULE = HINSTANCE; +pub type HRESULT = LONG; pub type BOOL = c_int; pub type BYTE = u8; pub type BOOLEAN = BYTE; @@ -197,6 +198,8 @@ pub const ERROR_OPERATION_ABORTED: DWORD = 995; pub const ERROR_IO_PENDING: DWORD = 997; pub const ERROR_TIMEOUT: DWORD = 0x5B4; +pub const E_NOTIMPL: HRESULT = 0x80004001u32 as HRESULT; + pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE; pub const FACILITY_NT_BIT: DWORD = 0x1000_0000; @@ -1163,8 +1166,8 @@ extern "system" { timeout: *const timeval) -> c_int; } -// Functions that aren't available on Windows XP, but we still use them and just -// provide some form of a fallback implementation. +// Functions that aren't available on every version of Windows that we support, +// but we still use them and just provide some form of a fallback implementation. compat_fn! { kernel32: @@ -1182,6 +1185,10 @@ compat_fn! { pub fn SetThreadStackGuarantee(_size: *mut c_ulong) -> BOOL { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0 } + pub fn SetThreadDescription(hThread: HANDLE, + lpThreadDescription: LPCWSTR) -> HRESULT { + SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); E_NOTIMPL + } pub fn SetFileInformationByHandle(_hFile: HANDLE, _FileInformationClass: FILE_INFO_BY_HANDLE_CLASS, _lpFileInformation: LPVOID, diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs index 6aea9d1fb56..c47baaa2434 100644 --- a/src/libstd/sys/windows/thread.rs +++ b/src/libstd/sys/windows/thread.rs @@ -19,6 +19,8 @@ use sys::handle::Handle; use sys_common::thread::*; use time::Duration; +use super::to_u16s; + pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024; pub struct Thread { @@ -55,11 +57,12 @@ impl Thread { } } - pub fn set_name(_name: &CStr) { - // Windows threads are nameless - // The names in MSVC debugger are obtained using a "magic" exception, - // which requires a use of MS C++ extensions. - // See https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx + pub fn set_name(name: &CStr) { + if let Ok(utf8) = name.to_str() { + if let Ok(utf16) = to_u16s(utf8) { + unsafe { c::SetThreadDescription(c::GetCurrentThread(), utf16.as_ptr()); }; + }; + }; } pub fn join(self) { |
