about summary refs log tree commit diff
path: root/src/libstd/os.rs
AgeCommit message (Collapse)AuthorLines
2014-05-07Test fixes and rebase conflictsAlex Crichton-3/+5
2014-05-07core: Inherit possible string functionalityAlex Crichton-1/+1
This moves as much allocation as possible from teh std::str module into core::str. This includes essentially all non-allocating functionality, mostly iterators and slicing and such. This primarily splits the Str trait into only having the as_slice() method, adding a new StrAllocating trait to std::str which contains the relevant new allocation methods. This is a breaking change if any of the methods of "trait Str" were overriden. The old functionality can be restored by implementing both the Str and StrAllocating traits. [breaking-change]
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-2/+2
2014-04-25Cleaned up os::consts. The module only exposes constants for the target OS ↵Michael Darakananda-172/+130
and arch. Constants for other OS's and arch's must be defined manually. [breaking-change]
2014-04-19auto merge of #13613 : alexcrichton/rust/fix-freebsd-compile, r=brsonbors-3/+2
Ah, the wonders of not being gated on FreeBSD...
2014-04-18Replace all ~"" with "".to_owned()Richo Healey-7/+7
2014-04-18std: Fix compiling on FreeBSDAlex Crichton-3/+2
Ah, the wonders of not being gated on FreeBSD...
2014-04-18Update the rest of the compiler with ~[T] changesAlex Crichton-25/+20
2014-04-18std: Make ~[T] no longer a growable vectorAlex Crichton-14/+11
This removes all resizability support for ~[T] vectors in preparation of DST. The only growable vector remaining is Vec<T>. In summary, the following methods from ~[T] and various functions were removed. Each method/function has an equivalent on the Vec type in std::vec unless otherwise stated. * slice::OwnedCloneableVector * slice::OwnedEqVector * slice::append * slice::append_one * slice::build (no replacement) * slice::bytes::push_bytes * slice::from_elem * slice::from_fn * slice::with_capacity * ~[T].capacity() * ~[T].clear() * ~[T].dedup() * ~[T].extend() * ~[T].grow() * ~[T].grow_fn() * ~[T].grow_set() * ~[T].insert() * ~[T].pop() * ~[T].push() * ~[T].push_all() * ~[T].push_all_move() * ~[T].remove() * ~[T].reserve() * ~[T].reserve_additional() * ~[T].reserve_exect() * ~[T].retain() * ~[T].set_len() * ~[T].shift() * ~[T].shrink_to_fit() * ~[T].swap_remove() * ~[T].truncate() * ~[T].unshift() * ~str.clear() * ~str.set_len() * ~str.truncate() Note that no other API changes were made. Existing apis that took or returned ~[T] continue to do so. [breaking-change]
2014-04-15std: Remove pub use globsBrian Anderson-11/+21
2014-04-04Fix fallout from std::libc separationCorey Richardson-2/+4
2014-04-01auto merge of #13115 : huonw/rust/rand-errors, r=alexcrichtonbors-11/+15
move errno -> IoError converter into std, bubble up OSRng errors Also adds a general errno -> `~str` converter to `std::os`, and makes the failure messages for the things using `OSRng` (e.g. (transitively) the task-local RNG, meaning hashmap initialisation failures aren't such a black box).
2014-04-01std: migrate the errno -> IoError converter from libnative.Huon Wilson-11/+15
This also adds a direct `errno` -> `~str` converter, rather than only being possible to get a string for the very last error.
2014-03-31std: Switch field privacy as necessaryAlex Crichton-5/+5
2014-03-28Convert most code to new inner attribute syntax.Brian Anderson-1/+1
Closes #2569
2014-03-25std: Touch various I/O documentation blocksAlex Crichton-8/+4
These are mostly touchups from the previous commit.
2014-03-25libstd: Document the following modules:Patrick Walton-3/+123
* native::io * std::char * std::fmt * std::fmt::parse * std::io * std::io::extensions * std::io::net::ip * std::io::net::udp * std::io::net::unix * std::io::pipe * std::num * std::num::f32 * std::num::f64 * std::num::strconv * std::os
2014-03-22std::os: Handle FormatMessage failureklutzy-3/+8
`FormatMessageW()` is called by `std::os::last_os_error()` to convert errno into string, but the function may fail on non-english locale. I don't know why it fails, but anyway it's better to return errno than to `fail!()` in the case. Fixes #13075 Fixes #13073
2014-03-20rename std::vec -> std::sliceDaniel Micay-10/+10
Closes #12702
2014-03-15Test fixes and rebase conflictsAlex Crichton-7/+4
This commit switches over the backtrace infrastructure from piggy-backing off the RUST_LOG environment variable to using the RUST_BACKTRACE environment variable (logging is now disabled in libstd).
2014-03-15log: Introduce liblog, the old std::loggingAlex Crichton-8/+2
This commit moves all logging out of the standard library into an external crate. This crate is the new crate which is responsible for all logging macros and logging implementation. A few reasons for this change are: * The crate map has always been a bit of a code smell among rust programs. It has difficulty being loaded on almost all platforms, and it's used almost exclusively for logging and only logging. Removing the crate map is one of the end goals of this movement. * The compiler has a fair bit of special support for logging. It has the __log_level() expression as well as generating a global word per module specifying the log level. This is unfairly favoring the built-in logging system, and is much better done purely in libraries instead of the compiler itself. * Initialization of logging is much easier to do if there is no reliance on a magical crate map being available to set module log levels. * If the logging library can be written outside of the standard library, there's no reason that it shouldn't be. It's likely that we're not going to build the highest quality logging library of all time, so third-party libraries should be able to provide just as high-quality logging systems as the default one provided in the rust distribution. With a migration such as this, the change does not come for free. There are some subtle changes in the behavior of liblog vs the previous logging macros: * The core change of this migration is that there is no longer a physical log-level per module. This concept is still emulated (it is quite useful), but there is now only a global log level, not a local one. This global log level is a reflection of the maximum of all log levels specified. The previously generated logging code looked like: if specified_level <= __module_log_level() { println!(...) } The newly generated code looks like: if specified_level <= ::log::LOG_LEVEL { if ::log::module_enabled(module_path!()) { println!(...) } } Notably, the first layer of checking is still intended to be "super fast" in that it's just a load of a global word and a compare. The second layer of checking is executed to determine if the current module does indeed have logging turned on. This means that if any module has a debug log level turned on, all modules with debug log levels get a little bit slower (they all do more expensive dynamic checks to determine if they're turned on or not). Semantically, this migration brings no change in this respect, but runtime-wise, this will have a perf impact on some code. * A `RUST_LOG=::help` directive will no longer print out a list of all modules that can be logged. This is because the crate map will no longer specify the log levels of all modules, so the list of modules is not known. Additionally, warnings can no longer be provided if a malformed logging directive was supplied. The new "hello world" for logging looks like: #[phase(syntax, link)] extern crate log; fn main() { debug!("Hello, world!"); }
2014-03-14extra: Put the nail in the coffin, delete libextraAlex Crichton-1/+0
This commit shreds all remnants of libextra from the compiler and standard distribution. Two modules, c_vec/tempfile, were moved into libstd after some cleanup, and the other modules were moved to separate crates as seen fit. Closes #8784 Closes #12413 Closes #12576
2014-03-12Remove remaining nolink usages.(fixes #12810)lpy-4/+0
2014-03-12rand: deprecate `rng`.Huon Wilson-1/+1
This should be called far less than it is because it does expensive OS interactions and seeding of the internal RNG, `task_rng` amortises this cost. The main problem is the name is so short and suggestive. The direct equivalent is `StdRng::new`, which does precisely the same thing. The deprecation will make migrating away from the function easier.
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-4/+4
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-22Warn about unnecessary parentheses upon assignmentEduard Bopp-2/+2
Closes #12366. Parentheses around assignment statements such as let mut a = (0); a = (1); a += (2); are not necessary and therefore an unnecessary_parens warning is raised when statements like this occur. The warning mechanism was refactored along the way to allow for code reuse between the routines for checking expressions and statements. Code had to be adopted throughout the compiler and standard libraries to comply with this modification of the lint.
2014-02-19Fix getting/setting huge env vars on windowsAlex Crichton-1/+13
On windows, the GetEnvironmentVariable function will return the necessary buffer size if the buffer provided was too small. This case previously fell through the checks inside of fill_utf16_buf_and_decode, tripping an assertion in the `slice` method. This adds an extra case for when the return value is >= the buffer size, in which case we assume the return value as the new buffer size and try again. Closes #12376
2014-02-19str: add a function for truncating a vector of u16 at NUL.Huon Wilson-3/+7
Many of the functions interacting with Windows APIs allocate a vector of 0's and do not retrieve a length directly from the API call, and so need to be sure to remove the unmodified junk at the end of the vector.
2014-02-18std: make str::from_utf16 return an Option.Huon Wilson-5/+10
The rest of the codebase is moving toward avoiding `fail!` so we do it here too!
2014-02-16std: Rename unstable::mutex::Mutex to StaticNativeMutex.Huon Wilson-2/+2
This better reflects its purpose and design.
2014-02-16std: add an RAII unlocker to Mutex.Huon Wilson-6/+2
This automatically unlocks its lock when it goes out of scope, and provides a safe(ish) method to call .wait.
2014-02-14Use str::from_utf8_lossy() for os::env() and friendsKevin Ballard-11/+60
Parse the environment by default with from_utf8_lossy. Also provide byte-vector equivalents (e.g. os::env_as_bytes()). Unfortunately, setenv() can't have a byte-vector equivalent because of Windows support, unless we want to define a setenv_bytes() that fails under Windows for non-UTF8 (or non-UTF16).
2014-02-14Use str::from_utf8_lossy() in os::args(), add os::args_as_bytes()Kevin Ballard-4/+27
os::args() was using str::raw::from_c_str(), which would assert if the C-string wasn't valid UTF-8. Switch to using from_utf8_lossy() instead, and add a separate function os::args_as_bytes() that returns the ~[u8] byte-vectors instead.
2014-02-08std::fmt: convert the formatting traits to a proper self.Huon Wilson-2/+2
Poly and String have polymorphic `impl`s and so require different method names.
2014-02-07Removed prelude::* from libstd files.chromatic-4/+18
This replaces the imports from the prelude with the re-exported symbols.
2014-02-03Fixing remaining warnings and errors throughoutAlex Crichton-0/+1
2014-02-03std: Fixing all documentationAlex Crichton-3/+3
* Stop referencing io_error * Start changing "Failure" sections to "Error" sections * Update all doc examples to work.
2014-02-03std: Fix tests with io_error usageAlex Crichton-3/+1
2014-02-03std: Remove io::io_errorAlex Crichton-10/+6
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-02-02std: rename fmt::Default to `Show`.Huon Wilson-1/+1
This is a better name with which to have a #[deriving] mode. Decision in: https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-01-28
2014-01-26Bring in the line-length policeAlex Crichton-51/+79
2014-01-24Fix zero-sized memory mappingCorey Richardson-2/+13
2014-01-24Use `mmap` to map in task stacks and guard pageCorey Richardson-22/+27
Also implement caching of stacks.
2014-01-24Add support for arbitrary flags to MemoryMap.Corey Richardson-7/+15
This also fixes up the documentation a bit, it was subtly incorrect.
2014-01-22Add std::os::self_exe_name()Ben Noordhuis-3/+21
2014-01-22Replace C types with Rust types in libstd, closes #7313Florian Hahn-32/+32
2014-01-21Remove unnecessary parentheses.Huon Wilson-5/+5
2014-01-07stdtest: Fix all leaked trait importsAlex Crichton-3/+1
2014-01-07Fix remaining cases of leaking importsAlex Crichton-3/+5
2013-12-24std: Stop reexporting the contents of 'mod consts'Alex Crichton-3/+1
This prevents usage of the win32 utf-16 helper functions from outside of libstd. Closes #9053