summary refs log tree commit diff
path: root/src/libstd/os.rs
AgeCommit message (Collapse)AuthorLines
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
2013-12-24std: Move management of the exit code to std::osAlex Crichton-5/+15
Previously this functionality was located in std::rt::util, but there's no real reason for it to be located in there.
2013-12-19std::str: replace .as_imm_buf with .as_ptr.Huon Wilson-6/+4
2013-12-19std::vec: remove .as_muf_buf, replaced by .as_mut_ptr & .len.Huon Wilson-49/+36
2013-12-19std::vec: remove .as_imm_buf, replaced by .as_ptr & .len.Huon Wilson-1/+1
There's no need for the restrictions of a closure with the above methods.
2013-12-15std::vec: convert to(_mut)_ptr to as_... methods on &[] and &mut [].Huon Wilson-2/+2
2013-12-15Move std::{str,vec}::raw::set_len to an unsafe method on Owned{Vector,Str}.Huon Wilson-2/+2
2013-12-10librustpkg: Make `io::ignore_io_error()` use RAII; remove a few morePatrick Walton-1/+3
cells.
2013-12-08Remove dead codesKiet Tran-10/+2
2013-12-04Revert "libstd: Change `Path::new` to `Path::init`."Kevin Ballard-17/+17
This reverts commit c54427ddfbbab41a39d14f2b1dc4f080cbc2d41b. Leave the #[ignores] in that were added to rustpkg tests. Conflicts: src/librustc/driver/driver.rs src/librustc/metadata/creader.rs
2013-11-29libstd: Change `Path::new` to `Path::init`.Patrick Walton-17/+17
2013-11-28Register new snapshotsAlex Crichton-1/+1
2013-11-26libstd: Remove all non-`proc` uses of `do` from libstdPatrick Walton-67/+61
2013-11-26Removed unneccessary `_iter` suffixes from various APIsMarvin Löbel-1/+1
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-3/+3