auto merge of #14783 : alexcrichton/rust/rollup, r=alexcrichton
Closes #14611 (std: Remove the as_utf16_p functions) Closes #14694 (Num cleanup) Closes #14760 (Add --color to test binary options) Closes #14763 (std: Move dynamic_lib from std::unstable to std) Closes #14766 (Add test for issue #13446) Closes #14769 (collections: Add missing Default impls) Closes #14773 (General nits) Closes #14776 (rustdoc: Correctly classify enums/typedefs)
This commit is contained in:
commit
5bc2d03955
|
@ -292,6 +292,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
|
||||||
save_metrics: config.save_metrics.clone(),
|
save_metrics: config.save_metrics.clone(),
|
||||||
test_shard: config.test_shard.clone(),
|
test_shard: config.test_shard.clone(),
|
||||||
nocapture: false,
|
nocapture: false,
|
||||||
|
color: test::AutoColor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::io::process::{ProcessExit, Command, Process, ProcessOutput};
|
use std::io::process::{ProcessExit, Command, Process, ProcessOutput};
|
||||||
use std::unstable::dynamic_lib::DynamicLibrary;
|
use std::dynamic_lib::DynamicLibrary;
|
||||||
|
|
||||||
fn target_env(lib_path: &str, prog: &str) -> Vec<(String, String)> {
|
fn target_env(lib_path: &str, prog: &str) -> Vec<(String, String)> {
|
||||||
let prog = if cfg!(windows) {prog.slice_to(prog.len() - 4)} else {prog};
|
let prog = if cfg!(windows) {prog.slice_to(prog.len() - 4)} else {prog};
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use core::cmp;
|
use core::cmp;
|
||||||
|
use core::default::Default;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::iter::{Enumerate, Repeat, Map, Zip};
|
use core::iter::{Enumerate, Repeat, Map, Zip};
|
||||||
use core::ops;
|
use core::ops;
|
||||||
|
@ -698,6 +699,11 @@ pub struct BitvSet {
|
||||||
bitv: BigBitv
|
bitv: BigBitv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for BitvSet {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> BitvSet { BitvSet::new() }
|
||||||
|
}
|
||||||
|
|
||||||
impl BitvSet {
|
impl BitvSet {
|
||||||
/// Creates a new bit vector set with initially no contents
|
/// Creates a new bit vector set with initially no contents
|
||||||
pub fn new() -> BitvSet {
|
pub fn new() -> BitvSet {
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use alloc::owned::Box;
|
use alloc::owned::Box;
|
||||||
|
use core::default::Default;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::iter;
|
use core::iter;
|
||||||
use core::mem;
|
use core::mem;
|
||||||
|
@ -262,6 +263,11 @@ impl<T> Deque<T> for DList<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Default for DList<T> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> DList<T> { DList::new() }
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> DList<T> {
|
impl<T> DList<T> {
|
||||||
/// Create an empty DList
|
/// Create an empty DList
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
|
use core::default::Default;
|
||||||
use core::mem::{zeroed, replace, swap};
|
use core::mem::{zeroed, replace, swap};
|
||||||
use core::ptr;
|
use core::ptr;
|
||||||
|
|
||||||
|
@ -37,6 +38,11 @@ impl<T: Ord> Mutable for PriorityQueue<T> {
|
||||||
fn clear(&mut self) { self.data.truncate(0) }
|
fn clear(&mut self) { self.data.truncate(0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Ord> Default for PriorityQueue<T> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> PriorityQueue<T> { PriorityQueue::new() }
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: Ord> PriorityQueue<T> {
|
impl<T: Ord> PriorityQueue<T> {
|
||||||
/// An iterator visiting all values in underlying vector, in
|
/// An iterator visiting all values in underlying vector, in
|
||||||
/// arbitrary order.
|
/// arbitrary order.
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use core::cmp;
|
use core::cmp;
|
||||||
|
use core::default::Default;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::iter::RandomAccessIterator;
|
use core::iter::RandomAccessIterator;
|
||||||
|
|
||||||
|
@ -112,6 +113,11 @@ impl<T> Deque<T> for RingBuf<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Default for RingBuf<T> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> RingBuf<T> { RingBuf::new() }
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> RingBuf<T> {
|
impl<T> RingBuf<T> {
|
||||||
/// Create an empty RingBuf
|
/// Create an empty RingBuf
|
||||||
pub fn new() -> RingBuf<T> {
|
pub fn new() -> RingBuf<T> {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
|
use core::default::Default;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::iter::{Enumerate, FilterMap};
|
use core::iter::{Enumerate, FilterMap};
|
||||||
use core::mem::replace;
|
use core::mem::replace;
|
||||||
|
@ -114,6 +115,11 @@ impl<V> MutableMap<uint, V> for SmallIntMap<V> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<V> Default for SmallIntMap<V> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> SmallIntMap<V> { SmallIntMap::new() }
|
||||||
|
}
|
||||||
|
|
||||||
impl<V> SmallIntMap<V> {
|
impl<V> SmallIntMap<V> {
|
||||||
/// Create an empty SmallIntMap
|
/// Create an empty SmallIntMap
|
||||||
pub fn new() -> SmallIntMap<V> { SmallIntMap{v: vec!()} }
|
pub fn new() -> SmallIntMap<V> { SmallIntMap{v: vec!()} }
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use alloc::owned::Box;
|
use alloc::owned::Box;
|
||||||
|
use core::default::Default;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::fmt::Show;
|
use core::fmt::Show;
|
||||||
use core::iter::Peekable;
|
use core::iter::Peekable;
|
||||||
|
@ -135,6 +136,11 @@ impl<K: Ord, V> MutableMap<K, V> for TreeMap<K, V> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<K: Ord, V> Default for TreeMap<K,V> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> TreeMap<K, V> { TreeMap::new() }
|
||||||
|
}
|
||||||
|
|
||||||
impl<K: Ord, V> TreeMap<K, V> {
|
impl<K: Ord, V> TreeMap<K, V> {
|
||||||
/// Create an empty TreeMap
|
/// Create an empty TreeMap
|
||||||
pub fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
|
pub fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
|
||||||
|
@ -633,6 +639,11 @@ impl<T: Ord> MutableSet<T> for TreeSet<T> {
|
||||||
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
|
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Ord> Default for TreeSet<T> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> TreeSet<T> { TreeSet::new() }
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: Ord> TreeSet<T> {
|
impl<T: Ord> TreeSet<T> {
|
||||||
/// Create an empty TreeSet
|
/// Create an empty TreeSet
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use alloc::owned::Box;
|
use alloc::owned::Box;
|
||||||
|
use core::default::Default;
|
||||||
use core::mem::zeroed;
|
use core::mem::zeroed;
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use core::uint;
|
use core::uint;
|
||||||
|
@ -105,6 +106,11 @@ impl<T> MutableMap<uint, T> for TrieMap<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Default for TrieMap<T> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> TrieMap<T> { TrieMap::new() }
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> TrieMap<T> {
|
impl<T> TrieMap<T> {
|
||||||
/// Create an empty TrieMap
|
/// Create an empty TrieMap
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -332,6 +338,11 @@ impl MutableSet<uint> for TrieSet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for TrieSet {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> TrieSet { TrieSet::new() }
|
||||||
|
}
|
||||||
|
|
||||||
impl TrieSet {
|
impl TrieSet {
|
||||||
/// Create an empty TrieSet
|
/// Create an empty TrieSet
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -69,7 +69,6 @@ extern "system" {
|
||||||
pub mod compat {
|
pub mod compat {
|
||||||
use std::intrinsics::{atomic_store_relaxed, transmute};
|
use std::intrinsics::{atomic_store_relaxed, transmute};
|
||||||
use libc::types::os::arch::extra::{LPCWSTR, HMODULE, LPCSTR, LPVOID};
|
use libc::types::os::arch::extra::{LPCWSTR, HMODULE, LPCSTR, LPVOID};
|
||||||
use std::os::win32::as_utf16_p;
|
|
||||||
|
|
||||||
extern "system" {
|
extern "system" {
|
||||||
fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE;
|
fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE;
|
||||||
|
@ -80,12 +79,11 @@ pub mod compat {
|
||||||
// This way, calling a function in this compatibility layer (after it's loaded) shouldn't
|
// This way, calling a function in this compatibility layer (after it's loaded) shouldn't
|
||||||
// be any slower than a regular DLL call.
|
// be any slower than a regular DLL call.
|
||||||
unsafe fn store_func<T: Copy>(ptr: *mut T, module: &str, symbol: &str, fallback: T) {
|
unsafe fn store_func<T: Copy>(ptr: *mut T, module: &str, symbol: &str, fallback: T) {
|
||||||
as_utf16_p(module, |module| {
|
let module = module.to_utf16().append_one(0);
|
||||||
symbol.with_c_str(|symbol| {
|
symbol.with_c_str(|symbol| {
|
||||||
let handle = GetModuleHandleW(module);
|
let handle = GetModuleHandleW(module.as_ptr());
|
||||||
let func: Option<T> = transmute(GetProcAddress(handle, symbol));
|
let func: Option<T> = transmute(GetProcAddress(handle, symbol));
|
||||||
atomic_store_relaxed(ptr, func.unwrap_or(fallback))
|
atomic_store_relaxed(ptr, func.unwrap_or(fallback))
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,10 @@ use libc::{c_int, c_void};
|
||||||
use libc;
|
use libc;
|
||||||
use std::c_str::CString;
|
use std::c_str::CString;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os::win32::{as_utf16_p, fill_utf16_buf_and_decode};
|
use std::os::win32::fill_utf16_buf_and_decode;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::rt::rtio;
|
use std::rt::rtio;
|
||||||
use std::rt::rtio::IoResult;
|
use std::rt::rtio::{IoResult, IoError};
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
|
|
||||||
|
@ -253,6 +253,17 @@ impl Drop for Inner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn to_utf16(s: &CString) -> IoResult<Vec<u16>> {
|
||||||
|
match s.as_str() {
|
||||||
|
Some(s) => Ok(s.to_utf16().append_one(0)),
|
||||||
|
None => Err(IoError {
|
||||||
|
code: libc::ERROR_INVALID_NAME as uint,
|
||||||
|
extra: 0,
|
||||||
|
detail: Some("valid unicode input required".to_str()),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
|
pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
|
||||||
-> IoResult<FileDesc> {
|
-> IoResult<FileDesc> {
|
||||||
// Flags passed to open_osfhandle
|
// Flags passed to open_osfhandle
|
||||||
|
@ -299,15 +310,16 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
|
||||||
// Compat with unix, this allows opening directories (see libuv)
|
// Compat with unix, this allows opening directories (see libuv)
|
||||||
dwFlagsAndAttributes |= libc::FILE_FLAG_BACKUP_SEMANTICS;
|
dwFlagsAndAttributes |= libc::FILE_FLAG_BACKUP_SEMANTICS;
|
||||||
|
|
||||||
let handle = as_utf16_p(path.as_str().unwrap(), |buf| unsafe {
|
let path = try!(to_utf16(path));
|
||||||
libc::CreateFileW(buf,
|
let handle = unsafe {
|
||||||
|
libc::CreateFileW(path.as_ptr(),
|
||||||
dwDesiredAccess,
|
dwDesiredAccess,
|
||||||
dwShareMode,
|
dwShareMode,
|
||||||
ptr::mut_null(),
|
ptr::mut_null(),
|
||||||
dwCreationDisposition,
|
dwCreationDisposition,
|
||||||
dwFlagsAndAttributes,
|
dwFlagsAndAttributes,
|
||||||
ptr::mut_null())
|
ptr::mut_null())
|
||||||
});
|
};
|
||||||
if handle == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
if handle == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
||||||
Err(super::last_error())
|
Err(super::last_error())
|
||||||
} else {
|
} else {
|
||||||
|
@ -324,11 +336,10 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mkdir(p: &CString, _mode: uint) -> IoResult<()> {
|
pub fn mkdir(p: &CString, _mode: uint) -> IoResult<()> {
|
||||||
|
let p = try!(to_utf16(p));
|
||||||
super::mkerr_winbool(unsafe {
|
super::mkerr_winbool(unsafe {
|
||||||
// FIXME: turn mode into something useful? #2623
|
// FIXME: turn mode into something useful? #2623
|
||||||
as_utf16_p(p.as_str().unwrap(), |buf| {
|
libc::CreateDirectoryW(p.as_ptr(), ptr::mut_null())
|
||||||
libc::CreateDirectoryW(buf, ptr::mut_null())
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,9 +362,11 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
|
||||||
let star = Path::new(unsafe {
|
let star = Path::new(unsafe {
|
||||||
CString::new(p.with_ref(|p| p), false)
|
CString::new(p.with_ref(|p| p), false)
|
||||||
}).join("*");
|
}).join("*");
|
||||||
as_utf16_p(star.as_str().unwrap(), |path_ptr| unsafe {
|
let path = try!(to_utf16(&star.to_c_str()));
|
||||||
|
|
||||||
|
unsafe {
|
||||||
let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint);
|
let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint);
|
||||||
let find_handle = libc::FindFirstFileW(path_ptr, wfd_ptr as libc::HANDLE);
|
let find_handle = libc::FindFirstFileW(path.as_ptr(), wfd_ptr as libc::HANDLE);
|
||||||
if find_handle as libc::c_int != libc::INVALID_HANDLE_VALUE {
|
if find_handle as libc::c_int != libc::INVALID_HANDLE_VALUE {
|
||||||
let mut paths = vec!();
|
let mut paths = vec!();
|
||||||
let mut more_files = 1 as libc::c_int;
|
let mut more_files = 1 as libc::c_int;
|
||||||
|
@ -377,37 +390,35 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
|
||||||
} else {
|
} else {
|
||||||
Err(super::last_error())
|
Err(super::last_error())
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unlink(p: &CString) -> IoResult<()> {
|
pub fn unlink(p: &CString) -> IoResult<()> {
|
||||||
|
let p = try!(to_utf16(p));
|
||||||
super::mkerr_winbool(unsafe {
|
super::mkerr_winbool(unsafe {
|
||||||
as_utf16_p(p.as_str().unwrap(), |buf| {
|
libc::DeleteFileW(p.as_ptr())
|
||||||
libc::DeleteFileW(buf)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rename(old: &CString, new: &CString) -> IoResult<()> {
|
pub fn rename(old: &CString, new: &CString) -> IoResult<()> {
|
||||||
|
let old = try!(to_utf16(old));
|
||||||
|
let new = try!(to_utf16(new));
|
||||||
super::mkerr_winbool(unsafe {
|
super::mkerr_winbool(unsafe {
|
||||||
as_utf16_p(old.as_str().unwrap(), |old| {
|
libc::MoveFileExW(old.as_ptr(), new.as_ptr(),
|
||||||
as_utf16_p(new.as_str().unwrap(), |new| {
|
libc::MOVEFILE_REPLACE_EXISTING)
|
||||||
libc::MoveFileExW(old, new, libc::MOVEFILE_REPLACE_EXISTING)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn chmod(p: &CString, mode: uint) -> IoResult<()> {
|
pub fn chmod(p: &CString, mode: uint) -> IoResult<()> {
|
||||||
super::mkerr_libc(as_utf16_p(p.as_str().unwrap(), |p| unsafe {
|
let p = try!(to_utf16(p));
|
||||||
libc::wchmod(p, mode as libc::c_int)
|
super::mkerr_libc(unsafe {
|
||||||
}))
|
libc::wchmod(p.as_ptr(), mode as libc::c_int)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rmdir(p: &CString) -> IoResult<()> {
|
pub fn rmdir(p: &CString) -> IoResult<()> {
|
||||||
super::mkerr_libc(as_utf16_p(p.as_str().unwrap(), |p| unsafe {
|
let p = try!(to_utf16(p));
|
||||||
libc::wrmdir(p)
|
super::mkerr_libc(unsafe { libc::wrmdir(p.as_ptr()) })
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn chown(_p: &CString, _uid: int, _gid: int) -> IoResult<()> {
|
pub fn chown(_p: &CString, _uid: int, _gid: int) -> IoResult<()> {
|
||||||
|
@ -418,16 +429,15 @@ pub fn chown(_p: &CString, _uid: int, _gid: int) -> IoResult<()> {
|
||||||
pub fn readlink(p: &CString) -> IoResult<CString> {
|
pub fn readlink(p: &CString) -> IoResult<CString> {
|
||||||
// FIXME: I have a feeling that this reads intermediate symlinks as well.
|
// FIXME: I have a feeling that this reads intermediate symlinks as well.
|
||||||
use io::c::compat::kernel32::GetFinalPathNameByHandleW;
|
use io::c::compat::kernel32::GetFinalPathNameByHandleW;
|
||||||
|
let p = try!(to_utf16(p));
|
||||||
let handle = unsafe {
|
let handle = unsafe {
|
||||||
as_utf16_p(p.as_str().unwrap(), |p| {
|
libc::CreateFileW(p.as_ptr(),
|
||||||
libc::CreateFileW(p,
|
libc::GENERIC_READ,
|
||||||
libc::GENERIC_READ,
|
libc::FILE_SHARE_READ,
|
||||||
libc::FILE_SHARE_READ,
|
ptr::mut_null(),
|
||||||
ptr::mut_null(),
|
libc::OPEN_EXISTING,
|
||||||
libc::OPEN_EXISTING,
|
libc::FILE_ATTRIBUTE_NORMAL,
|
||||||
libc::FILE_ATTRIBUTE_NORMAL,
|
ptr::mut_null())
|
||||||
ptr::mut_null())
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
if handle as int == libc::INVALID_HANDLE_VALUE as int {
|
if handle as int == libc::INVALID_HANDLE_VALUE as int {
|
||||||
return Err(super::last_error())
|
return Err(super::last_error())
|
||||||
|
@ -453,19 +463,19 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
|
||||||
|
|
||||||
pub fn symlink(src: &CString, dst: &CString) -> IoResult<()> {
|
pub fn symlink(src: &CString, dst: &CString) -> IoResult<()> {
|
||||||
use io::c::compat::kernel32::CreateSymbolicLinkW;
|
use io::c::compat::kernel32::CreateSymbolicLinkW;
|
||||||
super::mkerr_winbool(as_utf16_p(src.as_str().unwrap(), |src| {
|
let src = try!(to_utf16(src));
|
||||||
as_utf16_p(dst.as_str().unwrap(), |dst| {
|
let dst = try!(to_utf16(dst));
|
||||||
unsafe { CreateSymbolicLinkW(dst, src, 0) }
|
super::mkerr_winbool(unsafe {
|
||||||
}) as libc::BOOL
|
CreateSymbolicLinkW(dst.as_ptr(), src.as_ptr(), 0) as libc::BOOL
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn link(src: &CString, dst: &CString) -> IoResult<()> {
|
pub fn link(src: &CString, dst: &CString) -> IoResult<()> {
|
||||||
super::mkerr_winbool(as_utf16_p(src.as_str().unwrap(), |src| {
|
let src = try!(to_utf16(src));
|
||||||
as_utf16_p(dst.as_str().unwrap(), |dst| {
|
let dst = try!(to_utf16(dst));
|
||||||
unsafe { libc::CreateHardLinkW(dst, src, ptr::mut_null()) }
|
super::mkerr_winbool(unsafe {
|
||||||
})
|
libc::CreateHardLinkW(dst.as_ptr(), src.as_ptr(), ptr::mut_null())
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mkstat(stat: &libc::stat) -> rtio::FileStat {
|
fn mkstat(stat: &libc::stat) -> rtio::FileStat {
|
||||||
|
@ -491,12 +501,11 @@ fn mkstat(stat: &libc::stat) -> rtio::FileStat {
|
||||||
|
|
||||||
pub fn stat(p: &CString) -> IoResult<rtio::FileStat> {
|
pub fn stat(p: &CString) -> IoResult<rtio::FileStat> {
|
||||||
let mut stat: libc::stat = unsafe { mem::zeroed() };
|
let mut stat: libc::stat = unsafe { mem::zeroed() };
|
||||||
as_utf16_p(p.as_str().unwrap(), |up| {
|
let p = try!(to_utf16(p));
|
||||||
match unsafe { libc::wstat(up, &mut stat) } {
|
match unsafe { libc::wstat(p.as_ptr(), &mut stat) } {
|
||||||
0 => Ok(mkstat(&stat)),
|
0 => Ok(mkstat(&stat)),
|
||||||
_ => Err(super::last_error()),
|
_ => Err(super::last_error()),
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lstat(_p: &CString) -> IoResult<rtio::FileStat> {
|
pub fn lstat(_p: &CString) -> IoResult<rtio::FileStat> {
|
||||||
|
@ -509,7 +518,8 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
|
||||||
actime: (atime / 1000) as libc::time64_t,
|
actime: (atime / 1000) as libc::time64_t,
|
||||||
modtime: (mtime / 1000) as libc::time64_t,
|
modtime: (mtime / 1000) as libc::time64_t,
|
||||||
};
|
};
|
||||||
super::mkerr_libc(as_utf16_p(p.as_str().unwrap(), |p| unsafe {
|
let p = try!(to_utf16(p));
|
||||||
libc::wutime(p, &buf)
|
super::mkerr_libc(unsafe {
|
||||||
}))
|
libc::wutime(p.as_ptr(), &buf)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ fn unimpl() -> IoError {
|
||||||
IoError {
|
IoError {
|
||||||
code: ERROR as uint,
|
code: ERROR as uint,
|
||||||
extra: 0,
|
extra: 0,
|
||||||
detail: None,
|
detail: Some("not yet supported by the `native` runtime, maybe try `green`.".to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,6 @@ use alloc::arc::Arc;
|
||||||
use libc;
|
use libc;
|
||||||
use std::c_str::CString;
|
use std::c_str::CString;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os::win32::as_utf16_p;
|
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::rt::rtio;
|
use std::rt::rtio;
|
||||||
|
@ -98,6 +97,7 @@ use std::rt::mutex;
|
||||||
|
|
||||||
use super::c;
|
use super::c;
|
||||||
use super::util;
|
use super::util;
|
||||||
|
use super::file::to_utf16;
|
||||||
|
|
||||||
struct Event(libc::HANDLE);
|
struct Event(libc::HANDLE);
|
||||||
|
|
||||||
|
@ -261,67 +261,66 @@ impl UnixStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn connect(addr: &CString, timeout: Option<u64>) -> IoResult<UnixStream> {
|
pub fn connect(addr: &CString, timeout: Option<u64>) -> IoResult<UnixStream> {
|
||||||
as_utf16_p(addr.as_str().unwrap(), |p| {
|
let addr = try!(to_utf16(addr));
|
||||||
let start = ::io::timer::now();
|
let start = ::io::timer::now();
|
||||||
loop {
|
loop {
|
||||||
match UnixStream::try_connect(p) {
|
match UnixStream::try_connect(addr.as_ptr()) {
|
||||||
Some(handle) => {
|
Some(handle) => {
|
||||||
let inner = Inner::new(handle);
|
let inner = Inner::new(handle);
|
||||||
let mut mode = libc::PIPE_TYPE_BYTE |
|
let mut mode = libc::PIPE_TYPE_BYTE |
|
||||||
libc::PIPE_READMODE_BYTE |
|
libc::PIPE_READMODE_BYTE |
|
||||||
libc::PIPE_WAIT;
|
libc::PIPE_WAIT;
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
libc::SetNamedPipeHandleState(inner.handle,
|
libc::SetNamedPipeHandleState(inner.handle,
|
||||||
&mut mode,
|
&mut mode,
|
||||||
ptr::mut_null(),
|
ptr::mut_null(),
|
||||||
ptr::mut_null())
|
ptr::mut_null())
|
||||||
};
|
};
|
||||||
return if ret == 0 {
|
return if ret == 0 {
|
||||||
Err(super::last_error())
|
Err(super::last_error())
|
||||||
} else {
|
} else {
|
||||||
Ok(UnixStream {
|
Ok(UnixStream {
|
||||||
inner: Arc::new(inner),
|
inner: Arc::new(inner),
|
||||||
read: None,
|
read: None,
|
||||||
write: None,
|
write: None,
|
||||||
read_deadline: 0,
|
read_deadline: 0,
|
||||||
write_deadline: 0,
|
write_deadline: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// On windows, if you fail to connect, you may need to call the
|
||||||
|
// `WaitNamedPipe` function, and this is indicated with an error
|
||||||
|
// code of ERROR_PIPE_BUSY.
|
||||||
|
let code = unsafe { libc::GetLastError() };
|
||||||
|
if code as int != libc::ERROR_PIPE_BUSY as int {
|
||||||
|
return Err(super::last_error())
|
||||||
|
}
|
||||||
|
|
||||||
|
match timeout {
|
||||||
|
Some(timeout) => {
|
||||||
|
let now = ::io::timer::now();
|
||||||
|
let timed_out = (now - start) >= timeout || unsafe {
|
||||||
|
let ms = (timeout - (now - start)) as libc::DWORD;
|
||||||
|
libc::WaitNamedPipeW(addr.as_ptr(), ms) == 0
|
||||||
|
};
|
||||||
|
if timed_out {
|
||||||
|
return Err(util::timeout("connect timed out"))
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// On windows, if you fail to connect, you may need to call the
|
// An example I found on microsoft's website used 20
|
||||||
// `WaitNamedPipe` function, and this is indicated with an error
|
// seconds, libuv uses 30 seconds, hence we make the
|
||||||
// code of ERROR_PIPE_BUSY.
|
// obvious choice of waiting for 25 seconds.
|
||||||
let code = unsafe { libc::GetLastError() };
|
None => {
|
||||||
if code as int != libc::ERROR_PIPE_BUSY as int {
|
if unsafe { libc::WaitNamedPipeW(addr.as_ptr(), 25000) } == 0 {
|
||||||
return Err(super::last_error())
|
return Err(super::last_error())
|
||||||
}
|
|
||||||
|
|
||||||
match timeout {
|
|
||||||
Some(timeout) => {
|
|
||||||
let now = ::io::timer::now();
|
|
||||||
let timed_out = (now - start) >= timeout || unsafe {
|
|
||||||
let ms = (timeout - (now - start)) as libc::DWORD;
|
|
||||||
libc::WaitNamedPipeW(p, ms) == 0
|
|
||||||
};
|
|
||||||
if timed_out {
|
|
||||||
return Err(util::timeout("connect timed out"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// An example I found on microsoft's website used 20
|
|
||||||
// seconds, libuv uses 30 seconds, hence we make the
|
|
||||||
// obvious choice of waiting for 25 seconds.
|
|
||||||
None => {
|
|
||||||
if unsafe { libc::WaitNamedPipeW(p, 25000) } == 0 {
|
|
||||||
return Err(super::last_error())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> libc::HANDLE { self.inner.handle }
|
fn handle(&self) -> libc::HANDLE { self.inner.handle }
|
||||||
|
@ -564,14 +563,13 @@ impl UnixListener {
|
||||||
// Although we technically don't need the pipe until much later, we
|
// Although we technically don't need the pipe until much later, we
|
||||||
// create the initial handle up front to test the validity of the name
|
// create the initial handle up front to test the validity of the name
|
||||||
// and such.
|
// and such.
|
||||||
as_utf16_p(addr.as_str().unwrap(), |p| {
|
let addr_v = try!(to_utf16(addr));
|
||||||
let ret = unsafe { pipe(p, true) };
|
let ret = unsafe { pipe(addr_v.as_ptr(), true) };
|
||||||
if ret == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
if ret == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
||||||
Err(super::last_error())
|
Err(super::last_error())
|
||||||
} else {
|
} else {
|
||||||
Ok(UnixListener { handle: ret, name: addr.clone() })
|
Ok(UnixListener { handle: ret, name: addr.clone() })
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn native_listen(self) -> IoResult<UnixAcceptor> {
|
pub fn native_listen(self) -> IoResult<UnixAcceptor> {
|
||||||
|
@ -639,6 +637,8 @@ impl UnixAcceptor {
|
||||||
// using the original server pipe.
|
// using the original server pipe.
|
||||||
let handle = self.listener.handle;
|
let handle = self.listener.handle;
|
||||||
|
|
||||||
|
let name = try!(to_utf16(&self.listener.name));
|
||||||
|
|
||||||
// Once we've got a "server handle", we need to wait for a client to
|
// Once we've got a "server handle", we need to wait for a client to
|
||||||
// connect. The ConnectNamedPipe function will block this thread until
|
// connect. The ConnectNamedPipe function will block this thread until
|
||||||
// someone on the other end connects. This function can "fail" if a
|
// someone on the other end connects. This function can "fail" if a
|
||||||
|
@ -678,9 +678,7 @@ impl UnixAcceptor {
|
||||||
// Now that we've got a connected client to our handle, we need to
|
// Now that we've got a connected client to our handle, we need to
|
||||||
// create a second server pipe. If this fails, we disconnect the
|
// create a second server pipe. If this fails, we disconnect the
|
||||||
// connected client and return an error (see comments above).
|
// connected client and return an error (see comments above).
|
||||||
let new_handle = as_utf16_p(self.listener.name.as_str().unwrap(), |p| {
|
let new_handle = unsafe { pipe(name.as_ptr(), false) };
|
||||||
unsafe { pipe(p, false) }
|
|
||||||
});
|
|
||||||
if new_handle == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
if new_handle == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
||||||
let ret = Err(super::last_error());
|
let ret = Err(super::last_error());
|
||||||
// If our disconnection fails, then there's not really a whole lot
|
// If our disconnection fails, then there's not really a whole lot
|
||||||
|
|
|
@ -296,16 +296,15 @@ fn spawn_process_os(cfg: ProcessConfig,
|
||||||
lpSecurityDescriptor: ptr::mut_null(),
|
lpSecurityDescriptor: ptr::mut_null(),
|
||||||
bInheritHandle: 1,
|
bInheritHandle: 1,
|
||||||
};
|
};
|
||||||
*slot = os::win32::as_utf16_p("NUL", |filename| {
|
let filename = "NUL".to_utf16().append_one(0);
|
||||||
libc::CreateFileW(filename,
|
*slot = libc::CreateFileW(filename.as_ptr(),
|
||||||
access,
|
access,
|
||||||
libc::FILE_SHARE_READ |
|
libc::FILE_SHARE_READ |
|
||||||
libc::FILE_SHARE_WRITE,
|
libc::FILE_SHARE_WRITE,
|
||||||
&mut sa,
|
&mut sa,
|
||||||
libc::OPEN_EXISTING,
|
libc::OPEN_EXISTING,
|
||||||
0,
|
0,
|
||||||
ptr::mut_null())
|
ptr::mut_null());
|
||||||
});
|
|
||||||
if *slot == INVALID_HANDLE_VALUE as libc::HANDLE {
|
if *slot == INVALID_HANDLE_VALUE as libc::HANDLE {
|
||||||
return Err(super::last_error())
|
return Err(super::last_error())
|
||||||
}
|
}
|
||||||
|
@ -338,18 +337,17 @@ fn spawn_process_os(cfg: ProcessConfig,
|
||||||
|
|
||||||
with_envp(cfg.env, |envp| {
|
with_envp(cfg.env, |envp| {
|
||||||
with_dirp(cfg.cwd, |dirp| {
|
with_dirp(cfg.cwd, |dirp| {
|
||||||
os::win32::as_mut_utf16_p(cmd_str.as_slice(), |cmdp| {
|
let mut cmd_str = cmd_str.to_utf16().append_one(0);
|
||||||
let created = CreateProcessW(ptr::null(),
|
let created = CreateProcessW(ptr::null(),
|
||||||
cmdp,
|
cmd_str.as_mut_ptr(),
|
||||||
ptr::mut_null(),
|
ptr::mut_null(),
|
||||||
ptr::mut_null(),
|
ptr::mut_null(),
|
||||||
TRUE,
|
TRUE,
|
||||||
flags, envp, dirp,
|
flags, envp, dirp,
|
||||||
&mut si, &mut pi);
|
&mut si, &mut pi);
|
||||||
if created == FALSE {
|
if created == FALSE {
|
||||||
create_err = Some(super::last_error());
|
create_err = Some(super::last_error());
|
||||||
}
|
}
|
||||||
})
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -740,7 +738,8 @@ fn with_dirp<T>(d: Option<&CString>, cb: |*u16| -> T) -> T {
|
||||||
Some(dir) => {
|
Some(dir) => {
|
||||||
let dir_str = dir.as_str()
|
let dir_str = dir.as_str()
|
||||||
.expect("expected workingdirectory to be utf-8 encoded");
|
.expect("expected workingdirectory to be utf-8 encoded");
|
||||||
os::win32::as_utf16_p(dir_str, cb)
|
let dir_str = dir_str.to_utf16().append_one(0);
|
||||||
|
cb(dir_str.as_ptr())
|
||||||
},
|
},
|
||||||
None => cb(ptr::null())
|
None => cb(ptr::null())
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,3 +321,8 @@ pub fn get_reachable_extern_fns(cstore: &cstore::CStore, cnum: ast::CrateNum)
|
||||||
let cdata = cstore.get_crate_data(cnum);
|
let cdata = cstore.get_crate_data(cnum);
|
||||||
decoder::get_reachable_extern_fns(&*cdata)
|
decoder::get_reachable_extern_fns(&*cdata)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_typedef(cstore: &cstore::CStore, did: ast::DefId) -> bool {
|
||||||
|
let cdata = cstore.get_crate_data(did.krate);
|
||||||
|
decoder::is_typedef(&*cdata, did.node)
|
||||||
|
}
|
||||||
|
|
|
@ -1339,3 +1339,11 @@ pub fn get_reachable_extern_fns(cdata: Cmd) -> Vec<ast::DefId> {
|
||||||
});
|
});
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_typedef(cdata: Cmd, id: ast::NodeId) -> bool {
|
||||||
|
let item_doc = lookup_item(id, cdata.data());
|
||||||
|
match item_family(item_doc) {
|
||||||
|
Type => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::io::fs;
|
use std::io::fs;
|
||||||
use std::unstable::dynamic_lib::DynamicLibrary;
|
use std::dynamic_lib::DynamicLibrary;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use myfs = util::fs;
|
use myfs = util::fs;
|
||||||
|
|
|
@ -16,7 +16,7 @@ use plugin::registry::Registry;
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::unstable::dynamic_lib::DynamicLibrary;
|
use std::dynamic_lib::DynamicLibrary;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::visit;
|
use syntax::visit;
|
||||||
|
|
|
@ -203,7 +203,7 @@ fn build_struct(tcx: &ty::ctxt, did: ast::DefId) -> clean::Struct {
|
||||||
fn build_type(tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEnum {
|
fn build_type(tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEnum {
|
||||||
let t = ty::lookup_item_type(tcx, did);
|
let t = ty::lookup_item_type(tcx, did);
|
||||||
match ty::get(t.ty).sty {
|
match ty::get(t.ty).sty {
|
||||||
ty::ty_enum(edid, _) => {
|
ty::ty_enum(edid, _) if !csearch::is_typedef(&tcx.sess.cstore, did) => {
|
||||||
return clean::EnumItem(clean::Enum {
|
return clean::EnumItem(clean::Enum {
|
||||||
generics: t.generics.clean(),
|
generics: t.generics.clean(),
|
||||||
variants_stripped: false,
|
variants_stripped: false,
|
||||||
|
|
|
@ -135,7 +135,6 @@ mod imp {
|
||||||
mod imp {
|
mod imp {
|
||||||
use libc;
|
use libc;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os::win32::as_utf16_p;
|
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
@ -162,8 +161,9 @@ mod imp {
|
||||||
|
|
||||||
impl Lock {
|
impl Lock {
|
||||||
pub fn new(p: &Path) -> Lock {
|
pub fn new(p: &Path) -> Lock {
|
||||||
let handle = as_utf16_p(p.as_str().unwrap(), |p| unsafe {
|
let p_16 = p.as_str().unwrap().to_utf16().append_one(0);
|
||||||
libc::CreateFileW(p,
|
let handle = unsafe {
|
||||||
|
libc::CreateFileW(p_16.as_ptr(),
|
||||||
libc::FILE_GENERIC_READ |
|
libc::FILE_GENERIC_READ |
|
||||||
libc::FILE_GENERIC_WRITE,
|
libc::FILE_GENERIC_WRITE,
|
||||||
libc::FILE_SHARE_READ |
|
libc::FILE_SHARE_READ |
|
||||||
|
@ -173,7 +173,7 @@ mod imp {
|
||||||
libc::CREATE_ALWAYS,
|
libc::CREATE_ALWAYS,
|
||||||
libc::FILE_ATTRIBUTE_NORMAL,
|
libc::FILE_ATTRIBUTE_NORMAL,
|
||||||
ptr::mut_null())
|
ptr::mut_null())
|
||||||
});
|
};
|
||||||
if handle as uint == libc::INVALID_HANDLE_VALUE as uint {
|
if handle as uint == libc::INVALID_HANDLE_VALUE as uint {
|
||||||
fail!("create file error: {}", os::last_os_error());
|
fail!("create file error: {}", os::last_os_error());
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
use clean;
|
use clean;
|
||||||
|
|
||||||
use dl = std::unstable::dynamic_lib;
|
use dl = std::dynamic_lib;
|
||||||
use serialize::json;
|
use serialize::json;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ use std::io::{Command, TempDir};
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use std::unstable::dynamic_lib::DynamicLibrary;
|
use std::dynamic_lib::DynamicLibrary;
|
||||||
|
|
||||||
use std::collections::{HashSet, HashMap};
|
use std::collections::{HashSet, HashMap};
|
||||||
use testing;
|
use testing;
|
||||||
|
|
|
@ -16,6 +16,9 @@ A simple wrapper over the platform's dynamic library facilities
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#![experimental]
|
||||||
|
#![allow(missing_doc)]
|
||||||
|
|
||||||
use clone::Clone;
|
use clone::Clone;
|
||||||
use c_str::ToCStr;
|
use c_str::ToCStr;
|
||||||
use iter::Iterator;
|
use iter::Iterator;
|
||||||
|
@ -272,21 +275,21 @@ pub mod dl {
|
||||||
|
|
||||||
#[cfg(target_os = "win32")]
|
#[cfg(target_os = "win32")]
|
||||||
pub mod dl {
|
pub mod dl {
|
||||||
|
use c_str::ToCStr;
|
||||||
use libc;
|
use libc;
|
||||||
use os;
|
use os;
|
||||||
use ptr;
|
use ptr;
|
||||||
use result::{Ok, Err, Result};
|
use result::{Ok, Err, Result};
|
||||||
use string::String;
|
use str::StrAllocating;
|
||||||
use str;
|
use str;
|
||||||
use c_str::ToCStr;
|
use string::String;
|
||||||
|
|
||||||
pub unsafe fn open_external<T: ToCStr>(filename: T) -> *u8 {
|
pub unsafe fn open_external<T: ToCStr>(filename: T) -> *u8 {
|
||||||
// Windows expects Unicode data
|
// Windows expects Unicode data
|
||||||
let filename_cstr = filename.to_c_str();
|
let filename_cstr = filename.to_c_str();
|
||||||
let filename_str = str::from_utf8(filename_cstr.as_bytes_no_nul()).unwrap();
|
let filename_str = str::from_utf8(filename_cstr.as_bytes_no_nul()).unwrap();
|
||||||
os::win32::as_utf16_p(filename_str, |raw_name| {
|
let filename_str = filename_str.to_utf16().append_one(0);
|
||||||
LoadLibraryW(raw_name as *libc::c_void) as *u8
|
LoadLibraryW(filename_str.as_ptr() as *libc::c_void) as *u8
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn open_internal() -> *u8 {
|
pub unsafe fn open_internal() -> *u8 {
|
|
@ -81,13 +81,18 @@ Some examples of obvious things you might want to do
|
||||||
|
|
||||||
* Make a simple TCP client connection and request
|
* Make a simple TCP client connection and request
|
||||||
|
|
||||||
```rust,should_fail
|
```rust
|
||||||
# #![allow(unused_must_use)]
|
# #![allow(unused_must_use)]
|
||||||
use std::io::net::tcp::TcpStream;
|
use std::io::net::tcp::TcpStream;
|
||||||
|
|
||||||
|
# // connection doesn't fail if a server is running on 8080
|
||||||
|
# // locally, we still want to be type checking this code, so lets
|
||||||
|
# // just stop it running (#11576)
|
||||||
|
# if false {
|
||||||
let mut socket = TcpStream::connect("127.0.0.1", 8080).unwrap();
|
let mut socket = TcpStream::connect("127.0.0.1", 8080).unwrap();
|
||||||
socket.write(bytes!("GET / HTTP/1.0\n\n"));
|
socket.write(bytes!("GET / HTTP/1.0\n\n"));
|
||||||
let response = socket.read_to_end();
|
let response = socket.read_to_end();
|
||||||
|
# }
|
||||||
```
|
```
|
||||||
|
|
||||||
* Make a simple TCP server
|
* Make a simple TCP server
|
||||||
|
|
|
@ -241,15 +241,12 @@ pub mod sync;
|
||||||
/* Runtime and platform support */
|
/* Runtime and platform support */
|
||||||
|
|
||||||
pub mod c_vec;
|
pub mod c_vec;
|
||||||
|
pub mod dynamic_lib;
|
||||||
pub mod os;
|
pub mod os;
|
||||||
pub mod io;
|
pub mod io;
|
||||||
pub mod path;
|
pub mod path;
|
||||||
pub mod fmt;
|
pub mod fmt;
|
||||||
|
|
||||||
// Private APIs
|
|
||||||
#[unstable]
|
|
||||||
pub mod unstable;
|
|
||||||
|
|
||||||
// FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable'
|
// FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable'
|
||||||
// but name resolution doesn't work without it being pub.
|
// but name resolution doesn't work without it being pub.
|
||||||
#[unstable]
|
#[unstable]
|
||||||
|
@ -279,3 +276,11 @@ mod std {
|
||||||
// The test runner requires std::slice::Vector, so re-export std::slice just for it.
|
// The test runner requires std::slice::Vector, so re-export std::slice just for it.
|
||||||
#[cfg(test)] pub use slice;
|
#[cfg(test)] pub use slice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated]
|
||||||
|
#[allow(missing_doc)]
|
||||||
|
#[doc(hiden)]
|
||||||
|
pub mod unstable {
|
||||||
|
#[deprecated = "use std::dynamic_lib"]
|
||||||
|
pub use dynamic_lib;
|
||||||
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ pub mod win32 {
|
||||||
use os::TMPBUF_SZ;
|
use os::TMPBUF_SZ;
|
||||||
use slice::{MutableVector, ImmutableVector};
|
use slice::{MutableVector, ImmutableVector};
|
||||||
use string::String;
|
use string::String;
|
||||||
use str::{StrSlice, StrAllocating};
|
use str::StrSlice;
|
||||||
use str;
|
use str;
|
||||||
use vec::Vec;
|
use vec::Vec;
|
||||||
|
|
||||||
|
@ -171,17 +171,6 @@ pub mod win32 {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_utf16_p<T>(s: &str, f: |*u16| -> T) -> T {
|
|
||||||
as_mut_utf16_p(s, |t| { f(t as *u16) })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_mut_utf16_p<T>(s: &str, f: |*mut u16| -> T) -> T {
|
|
||||||
let mut t = s.to_utf16();
|
|
||||||
// Null terminate before passing on.
|
|
||||||
t.push(0u16);
|
|
||||||
f(t.as_mut_ptr())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -356,11 +345,10 @@ pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> {
|
||||||
pub fn getenv(n: &str) -> Option<String> {
|
pub fn getenv(n: &str) -> Option<String> {
|
||||||
unsafe {
|
unsafe {
|
||||||
with_env_lock(|| {
|
with_env_lock(|| {
|
||||||
use os::win32::{as_utf16_p, fill_utf16_buf_and_decode};
|
use os::win32::{fill_utf16_buf_and_decode};
|
||||||
as_utf16_p(n, |u| {
|
let n = n.to_utf16().append_one(0);
|
||||||
fill_utf16_buf_and_decode(|buf, sz| {
|
fill_utf16_buf_and_decode(|buf, sz| {
|
||||||
libc::GetEnvironmentVariableW(u, buf, sz)
|
libc::GetEnvironmentVariableW(n.as_ptr(), buf, sz)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -398,14 +386,11 @@ pub fn setenv(n: &str, v: &str) {
|
||||||
/// Sets the environment variable `n` to the value `v` for the currently running
|
/// Sets the environment variable `n` to the value `v` for the currently running
|
||||||
/// process
|
/// process
|
||||||
pub fn setenv(n: &str, v: &str) {
|
pub fn setenv(n: &str, v: &str) {
|
||||||
|
let n = n.to_utf16().append_one(0);
|
||||||
|
let v = v.to_utf16().append_one(0);
|
||||||
unsafe {
|
unsafe {
|
||||||
with_env_lock(|| {
|
with_env_lock(|| {
|
||||||
use os::win32::as_utf16_p;
|
libc::SetEnvironmentVariableW(n.as_ptr(), v.as_ptr());
|
||||||
as_utf16_p(n, |nbuf| {
|
|
||||||
as_utf16_p(v, |vbuf| {
|
|
||||||
libc::SetEnvironmentVariableW(nbuf, vbuf);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,12 +413,10 @@ pub fn unsetenv(n: &str) {
|
||||||
}
|
}
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn _unsetenv(n: &str) {
|
fn _unsetenv(n: &str) {
|
||||||
|
let n = n.to_utf16().append_one(0);
|
||||||
unsafe {
|
unsafe {
|
||||||
with_env_lock(|| {
|
with_env_lock(|| {
|
||||||
use os::win32::as_utf16_p;
|
libc::SetEnvironmentVariableW(n.as_ptr(), ptr::null());
|
||||||
as_utf16_p(n, |nbuf| {
|
|
||||||
libc::SetEnvironmentVariableW(nbuf, ptr::null());
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -732,11 +715,12 @@ pub fn change_dir(p: &Path) -> bool {
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn chdir(p: &Path) -> bool {
|
fn chdir(p: &Path) -> bool {
|
||||||
|
let p = match p.as_str() {
|
||||||
|
Some(s) => s.to_utf16().append_one(0),
|
||||||
|
None => return false,
|
||||||
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
use os::win32::as_utf16_p;
|
libc::SetCurrentDirectoryW(p.as_ptr()) != (0 as libc::BOOL)
|
||||||
return as_utf16_p(p.as_str().unwrap(), |buf| {
|
|
||||||
libc::SetCurrentDirectoryW(buf) != (0 as libc::BOOL)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -614,7 +614,7 @@ mod imp {
|
||||||
use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
|
use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
|
||||||
use slice::ImmutableVector;
|
use slice::ImmutableVector;
|
||||||
use str::StrSlice;
|
use str::StrSlice;
|
||||||
use unstable::dynamic_lib::DynamicLibrary;
|
use dynamic_lib::DynamicLibrary;
|
||||||
|
|
||||||
#[allow(non_snake_case_functions)]
|
#[allow(non_snake_case_functions)]
|
||||||
extern "system" {
|
extern "system" {
|
||||||
|
|
|
@ -271,6 +271,12 @@ pub fn test_main_static_x(args: &[~str], tests: &[TestDescAndFn]) {
|
||||||
tests)
|
tests)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum ColorConfig {
|
||||||
|
AutoColor,
|
||||||
|
AlwaysColor,
|
||||||
|
NeverColor,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct TestOpts {
|
pub struct TestOpts {
|
||||||
pub filter: Option<Regex>,
|
pub filter: Option<Regex>,
|
||||||
pub run_ignored: bool,
|
pub run_ignored: bool,
|
||||||
|
@ -282,6 +288,7 @@ pub struct TestOpts {
|
||||||
pub test_shard: Option<(uint,uint)>,
|
pub test_shard: Option<(uint,uint)>,
|
||||||
pub logfile: Option<Path>,
|
pub logfile: Option<Path>,
|
||||||
pub nocapture: bool,
|
pub nocapture: bool,
|
||||||
|
pub color: ColorConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestOpts {
|
impl TestOpts {
|
||||||
|
@ -298,6 +305,7 @@ impl TestOpts {
|
||||||
test_shard: None,
|
test_shard: None,
|
||||||
logfile: None,
|
logfile: None,
|
||||||
nocapture: false,
|
nocapture: false,
|
||||||
|
color: AutoColor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,7 +332,11 @@ fn optgroups() -> Vec<getopts::OptGroup> {
|
||||||
getopts::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite",
|
getopts::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite",
|
||||||
"A.B"),
|
"A.B"),
|
||||||
getopts::optflag("", "nocapture", "don't capture stdout/stderr of each \
|
getopts::optflag("", "nocapture", "don't capture stdout/stderr of each \
|
||||||
task, allow printing directly"))
|
task, allow printing directly"),
|
||||||
|
getopts::optopt("", "color", "Configure coloring of output:
|
||||||
|
auto = colorize if stdout is a tty and tests are run on serially (default);
|
||||||
|
always = always colorize output;
|
||||||
|
never = never colorize output;", "auto|always|never"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(binary: &str) {
|
fn usage(binary: &str) {
|
||||||
|
@ -406,6 +418,16 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
|
||||||
nocapture = os::getenv("RUST_TEST_NOCAPTURE").is_some();
|
nocapture = os::getenv("RUST_TEST_NOCAPTURE").is_some();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let color = match matches.opt_str("color").as_ref().map(|s| s.as_slice()) {
|
||||||
|
Some("auto") | None => AutoColor,
|
||||||
|
Some("always") => AlwaysColor,
|
||||||
|
Some("never") => NeverColor,
|
||||||
|
|
||||||
|
Some(v) => return Some(Err(format!("argument for --color must be \
|
||||||
|
auto, always, or never (was {})",
|
||||||
|
v))),
|
||||||
|
};
|
||||||
|
|
||||||
let test_opts = TestOpts {
|
let test_opts = TestOpts {
|
||||||
filter: filter,
|
filter: filter,
|
||||||
run_ignored: run_ignored,
|
run_ignored: run_ignored,
|
||||||
|
@ -417,6 +439,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
|
||||||
test_shard: test_shard,
|
test_shard: test_shard,
|
||||||
logfile: logfile,
|
logfile: logfile,
|
||||||
nocapture: nocapture,
|
nocapture: nocapture,
|
||||||
|
color: color,
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(Ok(test_opts))
|
Some(Ok(test_opts))
|
||||||
|
@ -492,7 +515,7 @@ impl<T: Writer> ConsoleTestState<T> {
|
||||||
Ok(ConsoleTestState {
|
Ok(ConsoleTestState {
|
||||||
out: out,
|
out: out,
|
||||||
log_out: log_out,
|
log_out: log_out,
|
||||||
use_color: use_color(),
|
use_color: use_color(opts),
|
||||||
total: 0u,
|
total: 0u,
|
||||||
passed: 0u,
|
passed: 0u,
|
||||||
failed: 0u,
|
failed: 0u,
|
||||||
|
@ -867,8 +890,12 @@ fn should_sort_failures_before_printing_them() {
|
||||||
assert!(apos < bpos);
|
assert!(apos < bpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn use_color() -> bool {
|
fn use_color(opts: &TestOpts) -> bool {
|
||||||
get_concurrency() == 1 && io::stdout().get_ref().isatty()
|
match opts.color {
|
||||||
|
AutoColor => get_concurrency() == 1 && io::stdout().get_ref().isatty(),
|
||||||
|
AlwaysColor => true,
|
||||||
|
NeverColor => false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone)]
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::unstable::dynamic_lib::DynamicLibrary;
|
use std::dynamic_lib::DynamicLibrary;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn foo() { bar(); }
|
pub fn foo() { bar(); }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||||
// file at the top-level directory of this distribution and at
|
// file at the top-level directory of this distribution and at
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
//
|
//
|
||||||
|
@ -8,6 +8,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![doc(hidden)]
|
|
||||||
|
|
||||||
pub mod dynamic_lib;
|
// Used to cause ICE
|
||||||
|
|
||||||
|
static VEC: [u32, ..256] = vec!(); //~ ERROR mismatched types
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::unstable::dynamic_lib::DynamicLibrary;
|
use std::dynamic_lib::DynamicLibrary;
|
||||||
use std::os;
|
use std::os;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// aux-build:linkage-visibility.rs
|
// aux-build:linkage-visibility.rs
|
||||||
// ignore-android: FIXME(#10379)
|
// ignore-android: FIXME(#10379)
|
||||||
// ignore-win32: std::unstable::dynamic_lib does not work on win32 well
|
// ignore-win32: std::dynamic_lib does not work on win32 well
|
||||||
|
|
||||||
extern crate foo = "linkage-visibility";
|
extern crate foo = "linkage-visibility";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue