about summary refs log tree commit diff
path: root/src/libnative
AgeCommit message (Collapse)AuthorLines
2014-03-23Snapshot cleanupAlex Crichton-1/+1
2014-03-23Register new snapshotsFlavio Percoco-1/+0
2014-03-22native: Fix a possible deadlock in spawnAlex Crichton-107/+105
The OSX bots have been deadlocking recently in the rustdoc tests. I have only been able to rarely reproduce the deadlock on my local setup. When reproduced, it looks like the child process is spinning on the malloc mutex, which I presume is locked with no other threads to unlock it. I'm not convinced that this is what's happening, because OSX should protect against this with pthread_atfork by default. Regardless, running as little code as possible in the child after fork() is normally a good idea anyway, so this commit moves all allocation to the parent process to run before the child executes. After running 6k iterations of rustdoc tests, this deadlocked twice before, and after 20k iterations afterwards, it never deadlocked. I draw the conclusion that this is either sweeping the bug under the rug, or it did indeed fix the underlying problem.
2014-03-21rustc: Switch defaults from libgreen to libnativeAlex Crichton-1/+17
The compiler will no longer inject libgreen as the default runtime for rust programs, this commit switches it over to libnative by default. Now that libnative has baked for some time, it is ready enough to start getting more serious usage as the default runtime for rustc generated binaries. We've found that there isn't really a correct decision in choosing a 1:1 or M:N runtime as a default for all applications, but it seems that a larger number of programs today would work more reasonable with a native default rather than a green default. With this commit come a number of bugfixes: * The main native task is now named "<main>" * The main native task has the stack bounds set up properly * #[no_uv] was renamed to #[no_start] * The core-run-destroy test was rewritten for both libnative and libgreen and one of the tests was modified to be more robust. * The process-detach test was locked to libgreen because it uses signal handling
2014-03-20Register new snapshotsAlex Crichton-0/+1
2014-03-20Removing imports of std::vec_ng::VecAlex Crichton-2/+0
It's now in the prelude.
2014-03-20rename std::vec_ng -> std::vecDaniel Micay-1/+1
Closes #12771
2014-03-20rename std::vec -> std::sliceDaniel Micay-9/+8
Closes #12702
2014-03-15Test fixes and rebase conflictsAlex Crichton-1/+1
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-16/+5
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-13auto merge of #12861 : huonw/rust/lint-owned-vecs, r=thestingerbors-0/+1
lint: add lint for use of a `~[T]`. This is useless at the moment (since pretty much every crate uses `~[]`), but should help avoid regressions once completely removed from a crate.
2014-03-13auto merge of #12855 : alexcrichton/rust/shutdown, r=brsonbors-0/+5
This is something that is plausibly useful, and is provided by libuv. This is not currently surfaced as part of the `TcpStream` type, but it may possibly appear in the future. For now only the raw functionality is provided through the Rtio objects.
2014-03-14lint: add lint for use of a `~[T]`.Huon Wilson-0/+1
This is useless at the moment (since pretty much every crate uses `~[]`), but should help avoid regressions once completely removed from a crate.
2014-03-13io: Bind to shutdown() for TCP streamsAlex Crichton-0/+5
This is something that is plausibly useful, and is provided by libuv. This is not currently surfaced as part of the `TcpStream` type, but it may possibly appear in the future. For now only the raw functionality is provided through the Rtio objects.
2014-03-13std: Rename Chan/Port types and constructorAlex Crichton-106/+103
* Chan<T> => Sender<T> * Port<T> => Receiver<T> * Chan::new() => channel() * constructor returns (Sender, Receiver) instead of (Receiver, Sender) * local variables named `port` renamed to `rx` * local variables named `chan` renamed to `tx` Closes #11765
2014-03-12Remove remaining nolink usages.(fixes #12810)lpy-1/+0
2014-03-05std: Move libnative task count bookkeeping to stdAlex Crichton-52/+3
When using tasks in Rust, the expectation is that the runtime does not exit before all tasks have exited. This is enforced in libgreen through the `SchedPool` type, and it is enforced in libnative through a `bookkeeping` module and a global count/mutex pair. Unfortunately, this means that a process which originates with libgreen will not wait for spawned native tasks. In order to fix this problem, the bookkeeping module was moved from libnative to libstd so the runtime itself can wait for native tasks to exit. Green tasks do not manage themselves through this bookkeeping module, but native tasks will continue to manage themselves through this module. Closes #12684
2014-03-05native: Fix usage of a deallocated mutexAlex Crichton-16/+14
When the timer_helper thread exited, it would attempt to re-acquire the global task count mutex, but the mutex had previously been deallocated, leading to undefined behavior of the mutex, and in some cases deadlock. Another mutex is used to coordinate shutting down the timer helper thread. Closes #12699
2014-03-05native: Move from usleep() to nanosleep()Alex Crichton-6/+20
Using nanosleep() allows us to gracefully recover from EINTR because on error it fills in the second parameter with the remaining time to sleep. Closes #12689
2014-03-05native: Stop using readdir()Alex Crichton-5/+11
This function is not threadsafe, and is deprecated in favor of the threadsafe readdir_r variant. Closes #12692
2014-03-04auto merge of #12667 : Kimundi/rust/any_improv, r=cmrbors-0/+1
- Added `TraitObject` representation to `std::raw`. - Added doc to `std::raw`. - Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()` methods as they are uneccessary now after the removal of headers on owned boxes. This reduces the number of virtual calls needed from 2 to 1. - Made the `..Ext` implementations work directly with the repr of a trait object. - Removed `Any`-related traits from the prelude. - Added bench. Bench before/after: ~~~ 7 ns/iter (+/- 0) 4 ns/iter (+/- 0) ~~~
2014-03-04Cleaned up `std::any`Marvin Löbel-0/+1
- Added `TraitObject` representation to `std::raw`. - Added doc to `std::raw`. - Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()` methods as they are uneccessary now after the removal of headers on owned boxes. This reduces the number of virtual calls needed. - Made the `..Ext` implementations work directly with the repr of a trait object. - Removed `Any`-related traits from the prelude. - Added bench for `Any`
2014-03-04doc: use the newer faviconAdrien Tétar-1/+1
2014-02-28auto merge of #12616 : alexcrichton/rust/size, r=huonwbors-2/+2
I've been playing around with code size when linking to libstd recently, and these were some findings I found that really helped code size. I started out by eliminating all I/O implementations from libnative and instead just return an unimplemented error. In doing so, a `fn main() {}` executable was ~378K before this patch, and about 170K after the patch. These size wins are all pretty minor, but they all seemed pretty reasonable to me. With native I/O not stubbed out, this takes the size of an LTO executable from 675K to 400K.
2014-02-28std: Avoid using "{:?}" in format stringsAlex Crichton-2/+2
This removes all usage of Poly in format strings from libstd. This doesn't prevent more future strings from coming in, but it at least removes the ones for now.
2014-03-01Publicise types/add #[allow(visible_private_types)] to a variety of places.Huon Wilson-0/+2
There's a lot of these types in the compiler libraries, and a few of the older or private stdlib ones. Some types are obviously meant to be public, others not so much.
2014-02-27native: Recognize EISDIRAlex Crichton-0/+8
This recognizes the EISDIR error code on both windows and unix platforms to provide a more descriptive error condition.
2014-02-27rustc: Use libnative for the compilerAlex Crichton-0/+1
The compiler itself doesn't necessarily need any features of green threading such as spawning tasks and lots of I/O, so libnative is slightly more appropriate for rustc to use itself. This should also help the rusti bot which is currently incompatible with libuv.
2014-02-27native: Improve windows file handlingAlex Crichton-1018/+1125
This commit splits the file implementation into file_unix and file_win32. The two implementations have diverged to the point that they share almost 0 code at this point, so it's easier to maintain as separate files. The other major change accompanied with this commit is that file::open is no longer based on libc's open function on windows, but rather windows's CreateFile function. This fixes dealing with binary files on windows (test added in previous commit). This also changes the read/write functions to use ReadFile and WriteFile instead of libc's read/write. Closes #12406
2014-02-24auto merge of #12445 : huonw/rust/less-unsafe, r=alexcrichtonbors-10/+10
Commits for details. Highlights: - `flate` returns `CVec<u8>` to save reallocating a whole new `&[u8]` - a lot of `transmute`s removed outright or replaced with `as` (etc.)
2014-02-23Roll std::run into std::io::processAlex Crichton-36/+65
The std::run module is a relic from a standard library long since past, and there's not much use to having two modules to execute processes with where one is slightly more convenient. This commit merges the two modules, moving lots of functionality from std::run into std::io::process and then deleting std::run. New things you can find in std::io::process are: * Process::new() now only takes prog/args * Process::configure() takes a ProcessConfig * Process::status() is the same as run::process_status * Process::output() is the same as run::process_output * I/O for spawned tasks is now defaulted to captured in pipes instead of ignored * Process::kill() was added (plus an associated green/native implementation) * Process::wait_with_output() is the same as the old finish_with_output() * destroy() is now signal_exit() * force_destroy() is now signal_kill() Closes #2625 Closes #10016
2014-02-24native: be more const correct with the FFI calls.Huon Wilson-8/+8
These calls are mutating their argument and so it's bad behaviour to be pretending that the values are immutable to rustc.
2014-02-24green,native,rustuv: Replace many pointer `transmute`'s with `as` or ↵Huon Wilson-2/+2
referencing. These can all be written in a more controlled manner than with the transmute hammer, leading to (hopefully) safer code.
2014-02-23auto merge of #12311 : brson/rust/unstable, r=alexcrichtonbors-3/+3
With the stability attributes we can put public-but unstable modules next to others, so this moves `intrinsics` and `raw` out of the `unstable` module (and marks both as `#[experimental]`).
2014-02-23std: Move unstable::stack to rt::stackBrian Anderson-1/+1
2014-02-23std: Move intrinsics to std::intrinsics.Brian Anderson-2/+2
Issue #1457
2014-02-23Move std::{trie, hashmap} to libcollectionsAlex Crichton-17/+36
These two containers are indeed collections, so their place is in libcollections, not in libstd. There will always be a hash map as part of the standard distribution of Rust, but by moving it out of the standard library it makes libstd that much more portable to more platforms and environments. This conveniently also removes the stuttering of 'std::hashmap::HashMap', although 'collections::HashMap' is only one character shorter.
2014-02-21Changed NonCamelCaseTypes lint to warn by defaultmr.Shu-4/+15
Added allow(non_camel_case_types) to librustc where necesary Tried to fix problems with non_camel_case_types outside rustc fixed failing tests Docs updated Moved #[allow(non_camel_case_types)] a level higher. markdown.rs reverted Fixed timer that was failing tests Fixed another timer
2014-02-20Mass rename if_ok! to try!Alex Crichton-8/+8
This "bubble up an error" macro was originally named if_ok! in order to get it landed, but after the fact it was discovered that this name is not exactly desirable. The name `if_ok!` isn't immediately clear that is has much to do with error handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In general, the agreed opinion about `if_ok!` is that is came in as subpar. The name `try!` is more invocative of error handling, it's shorter by 2 letters, and it looks fitting in almost all circumstances. One concern about the word `try!` is that it's too invocative of exceptions, but the belief is that this will be overcome with documentation and examples. Close #12037
2014-02-19librustc: Remove unique vector patterns from the language.Patrick Walton-19/+17
Preparatory work for removing unique vectors from the language, which is itself preparatory work for dynamically sized types.
2014-02-18auto merge of #12317 : huonw/rust/utf16, r=alexcrichtonbors-1/+3
Iterators! Use them (in `is_utf16`), create them (in `utf16_items`). Handle errors gracefully (`from_utf16_lossy`) and `from_utf16` returning `Option<~str>` instead of failing. Add a pile of tests.
2014-02-19str: add a function for truncating a vector of u16 at NUL.Huon Wilson-1/+2
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-17auto merge of #12103 : alexcrichton/rust/unix, r=brsonbors-4/+794
There's a few parts to this PR * Implement unix pipes in libnative for unix platforms (thanks @Geal!) * Implement named pipes in libnative for windows (terrible, terrible code) * Remove `#[cfg(unix)]` from `mod unix` in `std::io::net`. This is a terrible name for what it is, but that's the topic of #12093. The windows implementation was significantly more complicated than I thought it would be, but it seems to be passing all the tests. now. Closes #11201
2014-02-17auto merge of #12232 : kballard/rust/taskbuilder-is-a-builder, r=alexcrichtonbors-1/+0
Delete all the documentation from std::task that references linked failure. Tweak TaskBuilder to be more builder-like. `.name()` is now `.named()` and `.add_wrapper()` is now `.with_wrapper()`. Remove `.watched()` and `.unwatched()` as they didn't actually do anything. Closes #6399.
2014-02-18std: make str::from_utf16 return an Option.Huon Wilson-1/+2
The rest of the codebase is moving toward avoiding `fail!` so we do it here too!
2014-02-16Implement named pipes for windows, touch up unixAlex Crichton-237/+666
* Implementation of pipe_win32 filled out for libnative * Reorganize pipes to be clone-able * Fix a few file descriptor leaks on error * Factor out some common code into shared functions * Make use of the if_ok!() macro for less indentation Closes #11201
2014-02-16Move unix pipes implementation to pipe_unix.rsAlex Crichton-307/+312
The windows named pipes implementation will have almost nothing to do with unix pipes, so I think it's best if they live in separate files.
2014-02-16Implement Unix domain sockets in libnativeGeoffroy Couprie-2/+358
2014-02-16Allow configuration of uid/gid/detach on processesAlex Crichton-21/+74
This just copies the libuv implementation for libnative which seems reasonable enough (uid/gid fail on windows). Closes #12082
2014-02-16Clean up std::task docs, make TaskBuilder a real builderKevin Ballard-1/+0
Delete all the documentation from std::task that references linked failure. Tweak TaskBuilder to be more builder-like. .name() is now .named() and .add_wrapper() is now .with_wrapper(). Remove .watched() and .unwatched() as they didn't actually do anything.