about summary refs log tree commit diff
path: root/src/libnative
AgeCommit message (Collapse)AuthorLines
2014-06-06libs: Fix miscellaneous fallout of librustrtAlex Crichton-134/+114
2014-06-06native: Deal with the rtio changesAlex Crichton-318/+313
2014-06-06rtio: Remove usage of `Path`Alex Crichton-10/+10
The rtio interface is a thin low-level interface over the I/O subsystems, and the `Path` type is a little too high-level for this interface.
2014-06-05Fallout from the libcollections movementAlex Crichton-6/+9
2014-05-30windows: Allow snake_case errors for now.Kevin Butler-1/+3
2014-05-30lib{std,core,debug,rustuv,collections,native,regex}: Fix snake_case errors.Kevin Butler-1/+2
A number of functions/methods have been moved or renamed to align better with rust standard conventions. std::reflect::MovePtrAdaptor => MovePtrAdaptor::new debug::reflect::MovePtrAdaptor => MovePtrAdaptor::new std::repr::ReprVisitor => ReprVisitor::new debug::repr::ReprVisitor => ReprVisitor::new rustuv::homing::HomingIO.go_to_IO_home => go_to_io_home [breaking-change]
2014-05-29auto merge of #14487 : arielb1/rust/fix-13933, r=alexcrichtonbors-17/+23
Fix issue #13933 in a few files. A more complete fix would require core::raw::MutSlice.
2014-05-28auto merge of #14477 : alexcrichton/rust/issue-14456, r=brsonbors-52/+78
When spawning a process, stdio file descriptors can be configured to be ignored, which basically means that they'll be closed. Currently this is done by literally closing the file descriptors in the child, but this can have adverse side effects if the child process then opens a new file descriptor, assigning it to a stdio number. To work around the problems of the child, this commit alters the process spawning code to map stdio fds to /dev/null on unix (and a similar equivalent on windows) when they are specified as being ignored. This should allow spawned programs to have more expected behavior when opening new files. Closes #14456
2014-05-28Issue #13933: Remove transmute_mut from IOAriel Ben-Yehuda-17/+23
The IO libraries casted self to mut so they can pass it to seek(SEEK_CUR, 0). Fix this by introducing a private seek function that takes &self - of course one should be careful with it if he lacks an exclusive reference to self.
2014-05-28auto merge of #14455 : crabtw/rust/mips, r=alexcrichtonbors-12/+56
Because IPv4 address conversion doesn't consider big-endian target, I add functions to handle that. These function names may need to be changed, but I can't come up with a good one.
2014-05-27Move std::{reflect,repr,Poly} to a libdebug crateAlex Crichton-0/+1
This commit moves reflection (as well as the {:?} format modifier) to a new libdebug crate, all of which is marked experimental. This is a breaking change because it now requires the debug crate to be explicitly linked if the :? format qualifier is used. This means that any code using this feature will have to add `extern crate debug;` to the top of the crate. Any code relying on reflection will also need to do this. Closes #12019 [breaking-change]
2014-05-27native: Ignore stdio fds with /dev/nullAlex Crichton-52/+78
When spawning a process, stdio file descriptors can be configured to be ignored, which basically means that they'll be closed. Currently this is done by literally closing the file descriptors in the child, but this can have adverse side effects if the child process then opens a new file descriptor, assigning it to a stdio number. To work around the problems of the child, this commit alters the process spawning code to map stdio fds to /dev/null on unix (and a similar equivalent on windows) when they are specified as being ignored. This should allow spawned programs to have more expected behavior when opening new files. Closes #14456
2014-05-27std: Rename strbuf operations to stringRicho Healey-1/+1
[breaking-change]
2014-05-27std: Remove String's to_ownedRicho Healey-5/+5
2014-05-28fix MIPS targetJyun-Yan You-12/+56
2014-05-24core: rename strbuf::StrBuf to string::StringRicho Healey-6/+6
[breaking-change]
2014-05-23core: Finish stabilizing the `mem` module.Alex Crichton-5/+5
* All of the *_val functions have gone from #[unstable] to #[stable] * The overwrite and zeroed functions have gone from #[unstable] to #[stable] * The uninit function is now deprecated, replaced by its stable counterpart, uninitialized [breaking-change]
2014-05-22auto merge of #14357 : huonw/rust/spelling, r=pnkfelixbors-2/+2
The span on a inner doc-comment would point to the next token, e.g. the span for the `a` line points to the `b` line, and the span of `b` points to the `fn`. ```rust //! a //! b fn bar() {} ```
2014-05-22auto merge of #14348 : alexcrichton/rust/doc.rust-lang.org, r=huonwbors-1/+1
2014-05-22libcore: Remove all uses of `~str` from `libcore`.Patrick Walton-5/+7
[breaking-change]
2014-05-22libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`.Patrick Walton-2/+3
2014-05-22Spelling/doc formatting fixes.Huon Wilson-2/+2
2014-05-21Change static.rust-lang.org to doc.rust-lang.orgAlex Crichton-1/+1
The new documentation site has shorter urls, gzip'd content, and index.html redirecting functionality.
2014-05-21auto merge of #14301 : alexcrichton/rust/remove-unsafe-arc, r=brsonbors-53/+40
This type can be built with `Arc<Unsafe<T>>` now that liballoc exists.
2014-05-21std,green: Mark some queue types as NoShareAlex Crichton-11/+11
2014-05-20core: Stabilize the mem moduleAlex Crichton-21/+21
Excluding the functions inherited from the cast module last week (with marked stability levels), these functions received the following treatment. * size_of - this method has become #[stable] * nonzero_size_of/nonzero_size_of_val - these methods have been removed * min_align_of - this method is now #[stable] * pref_align_of - this method has been renamed without the `pref_` prefix, and it is the "default alignment" now. This decision is in line with what clang does (see url linked in comment on function). This function is now #[stable]. * init - renamed to zeroed and marked #[stable] * uninit - marked #[stable] * move_val_init - renamed to overwrite and marked #[stable] * {from,to}_{be,le}{16,32,64} - all functions marked #[stable] * swap/replace/drop - marked #[stable] * size_of_val/min_align_of_val/align_of_val - these functions are marked #[unstable], but will continue to exist in some form. Concerns have been raised about their `_val` prefix. [breaking-change]
2014-05-19native: Remove UnsafeArc in favor of just ArcAlex Crichton-43/+30
2014-05-15Make `from_bits` in `bitflags!` safe; add `from_bits_truncate`Aaron Turon-6/+2
Previously, the `from_bits` function in the `std::bitflags::bitflags` macro was marked as unsafe, as it did not check that the bits being converted actually corresponded to flags. This patch changes the function to check against the full set of possible flags and return an `Option` which is `None` if a non-flag bit is set. It also adds a `from_bits_truncate` function which simply zeros any bits not corresponding to a flag. This addresses the concern raised in https://github.com/mozilla/rust/pull/13897
2014-05-14Process::new etc should support non-utf8 commands/argsAaron Turon-99/+93
The existing APIs for spawning processes took strings for the command and arguments, but the underlying system may not impose utf8 encoding, so this is overly limiting. The assumption we actually want to make is just that the command and arguments are viewable as [u8] slices with no interior NULLs, i.e., as CStrings. The ToCStr trait is a handy bound for types that meet this requirement (such as &str and Path). However, since the commands and arguments are often a mixture of strings and paths, it would be inconvenient to take a slice with a single T: ToCStr bound. So this patch revamps the process creation API to instead use a builder-style interface, called `Command`, allowing arguments to be added one at a time with differing ToCStr implementations for each. The initial cut of the builder API has some drawbacks that can be addressed once issue #13851 (libstd as a facade) is closed. These are detailed as FIXMEs. Closes #11650. [breaking-change]
2014-05-13io: Implement process wait timeoutsAlex Crichton-222/+649
This implements set_timeout() for std::io::Process which will affect wait() operations on the process. This follows the same pattern as the rest of the timeouts emerging in std::io::net. The implementation was super easy for everything except libnative on unix (backwards from usual!), which required a good bit of signal handling. There's a doc comment explaining the strategy in libnative. Internally, this also required refactoring the "helper thread" implementation used by libnative to allow for an extra helper thread (not just the timer). This is a breaking change in terms of the io::Process API. It is now possible for wait() to fail, and subsequently wait_with_output(). These two functions now return IoResult<T> due to the fact that they can time out. Additionally, the wait_with_output() function has moved from taking `&mut self` to taking `self`. If a timeout occurs while waiting with output, the semantics are undesirable in almost all cases if attempting to re-wait on the process. Equivalent functionality can still be achieved by dealing with the output handles manually. [breaking-change] cc #13523
2014-05-13Test Unicode support of process spawningPhil Ruffwind-0/+4
Added a run-pass test to ensure that processes can be correctly spawned using non-ASCII arguments, working directory, and environment variables. It also tests Unicode support of os::env_as_bytes. An additional assertion was added to the test for make_command_line to verify it handles Unicode correctly.
2014-05-13Fix make_command_line to handle Unicode correctlyPhil Ruffwind-7/+8
Previously, make_command_line iterates over each u8 in the string and then appends them as chars, so any non-ASCII string will get horribly mangled by this function. This fix should allow Unicode arguments to work correctly in native::io::process::spawn.
2014-05-13Use CreateProcessW instead of CreateProcessAPhil Ruffwind-7/+10
Changed libnative to use CreateProcessW instead of CreateProcessA. In addition, the lpEnvironment parameter now uses Unicode. Added a helper function os::win32::as_mut_utf16_p, which does basically the same thing as os::win32::as_utf16_p except the pointer is mutable.
2014-05-12Add `stat` method to `std::io::fs::File` to stat without a Path.Yuri Kunde Schlesner-10/+25
The `FileStat` struct contained a `path` field, which was filled by the `stat` and `lstat` function. Since this field isn't in fact returned by the operating system (it was copied from the paths passed to the functions) it was removed, as in the `fstat` case we aren't working with a `Path`, but directly with a fd. If your code used the `path` field of `FileStat` you will now have to manually store the path passed to `stat` along with the returned struct. [breaking-change]
2014-05-12Add the patch number to version strings. Closes #13289Brian Anderson-1/+1
2014-05-12auto merge of #13932 : MrAlert/rust/win-compat, r=brsonbors-5/+101
This addresses #12842 by offering fallback implementations for functions that aren't available. In this case, as Windows XP simply doesn't support symbolic links at all, the fallbacks simply return an error code indicating that the function hasn't been implemented. This should allow programs written in Rust to run under XP while still offering full support for symbolic links under newer versions of Windows with the same binary, but due to LLVM using stderror_s(), which isn't available in msvcrt.dll in XP, rustc itself will not. The fallback implementation is as follows: Calling the function instead calls to a mutable function pointer. This in and of itself would not constitute a performance hit because DLL calls are implemented in a similar manner (see Import Address Table). The function pointer initially points to a thunk which tries to get the address of the associated function and write it back to the function pointer. If it fails to find the function, it instead writes the address to a fallback. As this operation is idempotent, reading and writing the pointer simply needs to be atomic. Subsequent calls to the function should be as fast as any other DLL call, as the pointer will then point directly to either the correct function or a fallback.
2014-05-11core: Remove the cast moduleAlex Crichton-27/+24
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-10rename `global_heap` -> `libc_heap`Daniel Micay-1/+1
This module only contains wrappers for malloc and realloc with out-of-memory checks.
2014-05-09Register new snapshotsAlex Crichton-1/+1
2014-05-08Handle fallout in libnativeKevin Ballard-6/+6
API Changes: - GetAddrInfoRequest::run() returns Result<Vec<..>, ..> - Process::spawn() returns Result(.., Vec<..>), ..>
2014-05-08Move slice::raw::from_buf_raw() to vec::raw::from_buf()Kevin Ballard-3/+3
Change from_buf_raw() to return a Vec<T> instead of a ~[T]. As such, it belongs in vec, in the newly-created vec::raw module.
2014-05-07Test fixes and rebase conflictsAlex Crichton-1/+1
2014-05-07native: Implement timeouts for windows pipesAlex Crichton-21/+69
This is the last remaining networkig object to implement timeouts for. This takes advantage of the CancelIo function and the already existing asynchronous I/O functionality of pipes.
2014-05-07native: Implement timeouts for unix networkingAlex Crichton-157/+493
This commit has an implementation of the previous commit's timeout interface for I/O objects on unix platforms. For implementation details, see the large comment at the end of libnative/io/net.rs which talks about the general strategy taken. Thankfully, all of these implementations can share code because they're performing all the same operations. This commit does not implement timeouts for named pipes on windows, only tcp/udp objects on windows (which are quite similar to their unix equivalents).
2014-05-07std: Add close_{read,write}() methods to I/OAlex Crichton-34/+181
Two new methods were added to TcpStream and UnixStream: fn close_read(&mut self) -> IoResult<()>; fn close_write(&mut self) -> IoResult<()>; These two methods map to shutdown()'s behavior (the system call on unix), closing the reading or writing half of a duplex stream. These methods are primarily added to allow waking up a pending read in another task. By closing the reading half of a connection, all pending readers will be woken up and will return with EndOfFile. The close_write() method was added for symmetry with close_read(), and I imagine that it will be quite useful at some point. Implementation-wise, librustuv got the short end of the stick this time. The native versions just delegate to the shutdown() syscall (easy). The uv versions can leverage uv_shutdown() for tcp/unix streams, but only for closing the writing half. Closing the reading half is done through some careful dancing to wake up a pending reader. As usual, windows likes to be different from unix. The windows implementation uses shutdown() for sockets, but shutdown() is not available for named pipes. Instead, CancelIoEx was used with same fancy synchronization to make sure everyone knows what's up. cc #11165
2014-05-07Move Windows compatibility layer to libnativeAlan Williams-2/+96
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-77/+106
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-06auto merge of #13897 : aturon/rust/issue-6085, r=bjzbors-5/+9
The `std::bitflags::bitflags!` macro did not provide support for adding attributes to the generates structure, due to limitations in the parser for macros. This patch works around the parser limitations by requiring a `flags` keyword in the `bitflags!` invocations: bitflags!( #[deriving(Hash)] #[doc="Three flags"] flags Flags: u32 { FlagA = 0x00000001, FlagB = 0x00000010, FlagC = 0x00000100 } ) The intent of `std::bitflags` is to allow building type-safe wrappers around C-style flags APIs. But in addition to construction these flags from the Rust side, we need a way to convert them from the C side. This patch adds a `from_bits` function, which is unsafe since the bits in question may not represent a valid combination of flags. Finally, this patch changes `std::io::FilePermissions` from an exposed `u32` representation to a typesafe representation (that only allows valid flag combinations) using the `std::bitflags`. Closes #6085.
2014-05-05Change std::io::FilePermission to a typesafe representationAaron Turon-5/+9
This patch changes `std::io::FilePermissions` from an exposed `u32` representation to a typesafe representation (that only allows valid flag combinations) using the `std::bitflags`, thus ensuring a greater degree of safety on the Rust side. Despite the change to the type, most code should continue to work as-is, sincde the new type provides bit operations in the style of C flags. To get at the underlying integer representation, use the `bits` method; to (unsafely) convert to `FilePermissions`, use `FilePermissions::from_bits`. Closes #6085. [breaking-change]
2014-05-05std: deprecate cast::transmute_mut.Huon Wilson-1/+2
Turning a `&T` into an `&mut T` carries a large risk of undefined behaviour, and needs to be done very very carefully. Providing a convenience function for exactly this task is a bad idea, just tempting people into doing the wrong thing. The right thing is to use types like `Cell`, `RefCell` or `Unsafe`. For memory safety, Rust has that guarantee that `&mut` pointers do not alias with any other pointer, that is, if you have a `&mut T` then that is the only usable pointer to that `T`. This allows Rust to assume that writes through a `&mut T` do not affect the values of any other `&` or `&mut` references. `&` pointers have no guarantees about aliasing or not, so it's entirely possible for the same pointer to be passed into both arguments of a function like fn foo(x: &int, y: &int) { ... } Converting either of `x` or `y` to a `&mut` pointer and modifying it would affect the other value: invalid behaviour. (Similarly, it's undefined behaviour to modify the value of an immutable local, like `let x = 1;`.) At a low-level, the *only* safe way to obtain an `&mut` out of a `&` is using the `Unsafe` type (there are higher level wrappers around it, like `Cell`, `RefCell`, `Mutex` etc.). The `Unsafe` type is registered with the compiler so that it can reason a little about these `&` to `&mut` casts, but it is still up to the user to ensure that the `&mut`s obtained out of an `Unsafe` never alias. (Note that *any* conversion from `&` to `&mut` can be invalid, including a plain `transmute`, or casting `&T` -> `*T` -> `*mut T` -> `&mut T`.) [breaking-change]