1. 08 5月, 2015 3 次提交
  2. 07 5月, 2015 1 次提交
  3. 06 5月, 2015 1 次提交
  4. 05 5月, 2015 1 次提交
  5. 01 5月, 2015 2 次提交
    • A
      std: Always check for EDEADLK in rwlocks on unix · 5c8ca26a
      Alex Crichton 提交于
      Apparently implementations are allowed to return EDEADLK instead of blocking
      forever, in which case this can lead to unsafety in the `RwLock` primitive
      exposed by the standard library. A debug-build of the standard library would
      have caught this error (due to the debug assert), but we don't ship debug
      builds right now.
      
      This commit adds explicit checks for the EDEADLK error code and triggers a panic
      to ensure the call does not succeed.
      
      Closes #25012
      5c8ca26a
    • A
      std: Favor cfg! over #[cfg] in unix rwlocks · 4288a08e
      Alex Crichton 提交于
      4288a08e
  6. 29 4月, 2015 1 次提交
  7. 28 4月, 2015 4 次提交
    • A
      std: Expand the area of std::fs · 93487000
      Alex Crichton 提交于
      This commit is an implementation of [RFC 1044][rfc] which adds additional
      surface area to the `std::fs` module. All new APIs are `#[unstable]` behind
      assorted feature names for each one.
      
      [rfc]: https://github.com/rust-lang/rfcs/pull/1044
      
      The new APIs added are:
      
      * `fs::canonicalize` - bindings to `realpath` on unix and
        `GetFinalPathNameByHandle` on windows.
      * `fs::symlink_metadata` - similar to `lstat` on unix
      * `fs::FileType` and accessor methods as `is_{file,dir,symlink}`
      * `fs::Metadata::file_type` - accessor for the raw file type
      * `fs::DirEntry::metadata` - acquisition of metadata which is free on Windows
        but requires a syscall on unix.
      * `fs::DirEntry::file_type` - access the file type which may not require a
        syscall on most platforms.
      * `fs::DirEntry::file_name` - access just the file name without leading
        components.
      * `fs::PathExt::symlink_metadata` - convenience method for the top-level
        function.
      * `fs::PathExt::canonicalize` - convenience method for the top-level
        function.
      * `fs::PathExt::read_link` - convenience method for the top-level
        function.
      * `fs::PathExt::read_dir` - convenience method for the top-level
        function.
      * `std::os::raw` - type definitions for raw OS/C types available on all
        platforms.
      * `std::os::$platform` - new modules have been added for all currently supported
        platforms (e.g. those more specific than just `unix`).
      * `std::os::$platform::raw` - platform-specific type definitions. These modules
        are populated with the bare essentials necessary for lowing I/O types into
        their raw representations, and currently largely consist of the `stat`
        definition for unix platforms.
      
      This commit also deprecates `Metadata::{modified, accessed}` in favor of
      inspecting the raw representations via the lowering methods of `Metadata`.
      93487000
    • A
      std: Don't assume thread::current() works on panic · d98ab4fa
      Alex Crichton 提交于
      Inspecting the current thread's info may not always work due to the TLS value
      having been destroyed (or is actively being destroyed). The code for printing
      a panic message assumed, however, that it could acquire the thread's name
      through this method.
      
      Instead this commit propagates the `Option` outwards to allow the
      `std::panicking` module to handle the case where the current thread isn't
      present.
      
      While it solves the immediate issue of #24313, there is still another underlying
      issue of panicking destructors in thread locals will abort the process.
      
      Closes #24313
      d98ab4fa
    • A
      std: Don't assume dlopen() works on yourself · 7dd62155
      Alex Crichton 提交于
      Statically linked executables do not succeed (aka MUSL-based executables).
      7dd62155
    • A
      std: Prepare for linking to musl · 6c048723
      Alex Crichton 提交于
      This commit modifies the standard library and its dependencies to link correctly
      when built against MUSL. This primarily ensures that the right libraries are
      linked against and when they're linked against they're linked against
      statically.
      6c048723
  8. 23 4月, 2015 2 次提交
    • A
      std: Add missing stability for symlink functions · a318b513
      Alex Crichton 提交于
      These functions were intended to be introduced as `#[stable]` as a stable API
      was deprecated in favor of them, but they just erroneously forgot the stability
      attributes.
      a318b513
    • A
      std: Audit std::thread implementations · 2e110099
      Alex Crichton 提交于
      Much of this code hasn't been updated in quite some time and this commit does a
      small audit of the functionality:
      
      * Implementation functions now centralize all functionality on a locally defined
        `Thread` type.
      * The `detach` method has been removed in favor of a `Drop` implementation. This
        notably fixes leaking thread handles on Windows.
      * The `Thread` structure is now appropriately annotated with `Send` and `Sync`
        automatically on Windows and in a custom fashion on Unix.
      * The unsafety of creating a thread has been pushed out to the right boundaries
        now.
      
      Closes #24442
      2e110099
  9. 22 4月, 2015 2 次提交
    • A
      std: Remove deprecated/unstable num functionality · eeb94886
      Alex Crichton 提交于
      This commit removes all the old casting/generic traits from `std::num` that are
      no longer in use by the standard library. This additionally removes the old
      `strconv` module which has not seen much use in quite a long time. All generic
      functionality has been supplanted with traits in the `num` crate and the
      `strconv` module is supplanted with the [rust-strconv crate][rust-strconv].
      
      [rust-strconv]: https://github.com/lifthrasiir/rust-strconv
      
      This is a breaking change due to the removal of these deprecated crates, and the
      alternative crates are listed above.
      
      [breaking-change]
      eeb94886
    • B
      Deprecate std::fs::soft_link in favor of platform-specific versions · 3cc84efc
      Brian Campbell 提交于
      On Windows, when you create a symbolic link you must specify whether it
      points to a directory or a file, even if it is created dangling, while
      on Unix, the same symbolic link could point to a directory, a file, or
      nothing at all.  Furthermore, on Windows special privilege is necessary
      to use a symbolic link, while on Unix, you can generally create a
      symbolic link in any directory you have write privileges to.
      
      This means that it is unlikely to be able to use symbolic links purely
      portably; anyone who uses them will need to think about the cross
      platform implications.  This means that using platform-specific APIs
      will make it easier to see where code will need to differ between the
      platforms, rather than trying to provide some kind of compatibility
      wrapper.
      
      Furthermore, `soft_link` has no precedence in any other API, so to avoid
      confusion, move back to the more standard `symlink` terminology.
      
      Create a `std::os::unix::symlink` for the Unix version that is
      destination type agnostic, as well as `std::os::windows::{symlink_file,
      symlink_dir}` for Windows.
      
      Because this is a stable API, leave a compatibility wrapper in
      `std::fs::soft_link`, which calls `symlink` on Unix and `symlink_file`
      on Windows, preserving the existing behavior of `soft_link`.
      3cc84efc
  10. 21 4月, 2015 2 次提交
    • T
      Remove unused files · 32e5f494
      Tamir Duberstein 提交于
      Looks like these were missed in bf4e77d4.
      32e5f494
    • C
      Implement Debug for File · 1131bc0a
      Chris Wong 提交于
      This patch adds a `Debug` impl for `std::fs::File`.
      
      On all platforms (Unix and Windows) it shows the file descriptor.
      
      On Linux, it displays the path and access mode as well.
      
      Ideally we should show the path/mode for all platforms, not just Linux,
      but this will do for now.
      
      cc #24570
      1131bc0a
  11. 15 4月, 2015 1 次提交
  12. 14 4月, 2015 1 次提交
  13. 10 4月, 2015 4 次提交
    • A
      std: Unconditionally close all file descriptors · eadc3bcd
      Alex Crichton 提交于
      The logic for only closing file descriptors >= 3 was inherited from quite some
      time ago and ends up meaning that some internal APIs are less consistent than
      they should be. By unconditionally closing everything entering a `FileDesc` we
      ensure that we're consistent in our behavior as well as robustly handling the
      stdio case.
      eadc3bcd
    • A
      std: Clean up process spawn impl on unix · 33a2191d
      Alex Crichton 提交于
      * De-indent quite a bit by removing usage of FnOnce closures
      * Clearly separate code for the parent/child after the fork
      * Use `fs2::{File, OpenOptions}` instead of calling `open` manually
      * Use RAII to close I/O objects wherever possible
      * Remove loop for closing all file descriptors, all our own ones are now
        `CLOEXEC` by default so they cannot be inherited
      33a2191d
    • A
      std: Set CLOEXEC for all fds opened on unix · d6c72306
      Alex Crichton 提交于
      This commit starts to set the CLOEXEC flag for all files and sockets opened by
      the standard library by default on all unix platforms. There are a few points of
      note in this commit:
      
      * The implementation is not 100% satisfactory in the face of threads. File
        descriptors only have the `F_CLOEXEC` flag set *after* they are opened,
        allowing for a fork/exec to happen in the middle and leak the descriptor.
        Some platforms do support atomically opening a descriptor while setting the
        `CLOEXEC` flag, and it is left as a future extension to bind these apis as it
        is unclear how to do so nicely at this time.
      
      * The implementation does not offer a method of opting into the old behavior of
        not setting `CLOEXEC`. This will possibly be added in the future through
        extensions on `OpenOptions`, for example.
      
      * This change does not yet audit any Windows APIs to see if the handles are
        inherited by default by accident.
      
      This is a breaking change for users who call `fork` or `exec` outside of the
      standard library itself and expect file descriptors to be inherted. All file
      descriptors created by the standard library will no longer be inherited.
      
      [breaking-change]
      d6c72306
    • A
      std: Make FromRawFd::from_raw_fd an unsafe method · 2705051e
      Alex Crichton 提交于
      As pointed out in [RFC issue 1043][rfc] it is quite useful to have the standard
      I/O types to provide the contract that they are the sole owner of the underlying
      object they represent. This guarantee enables writing safe interfaces like the
      `MemoryMap` API sketched out in that issue.
      
      [rfc]: https://github.com/rust-lang/rfcs/issues/1043
      
      As constructing objects from these raw handles may end up violating these
      ownership gurantees, the functions for construction are now marked unsafe.
      
      [breaking-change]
      Closes rust-lang/rfcs#1043
      2705051e
  14. 09 4月, 2015 2 次提交
    • A
      std: Stabilize io::Error::from_raw_os_error · 561fdec1
      Alex Crichton 提交于
      This commit stabilizes the old `io::Error::from_os_error` after being renamed to
      use the `raw_os_error` terminology instead. This function is often useful when
      writing bindings to OS functions but only actually converting to an I/O error at
      a later point.
      561fdec1
    • S
      Implement reentrant mutexes and make stdio use them · 45aa6c8d
      Simonas Kazlauskas 提交于
      write_fmt calls write for each formatted field. The default implementation of write_fmt is used,
      which will call write on not-yet-locked stdout (and write locking after), therefore making print!
      in multithreaded environment still interleave contents of two separate prints.
      
      This patch implements reentrant mutexes, changes stdio handles to use these mutexes and overrides
      write_fmt to lock the stdio handle for the whole duration of the call.
      45aa6c8d
  15. 05 4月, 2015 1 次提交
  16. 02 4月, 2015 1 次提交
  17. 01 4月, 2015 5 次提交
    • A
      Test fixes and rebase conflicts, round 3 · 72f59732
      Alex Crichton 提交于
      72f59732
    • A
      std: Stabilize last bits of io::Error · ac77392f
      Alex Crichton 提交于
      This commit stabilizes a few remaining bits of the `io::Error` type:
      
      * The `Error::new` method is now stable. The last `detail` parameter was removed
        and the second `desc` parameter was generalized to `E: Into<Box<Error>>` to
        allow creating an I/O error from any form of error. Currently there is no form
        of downcasting, but this will be added in time.
      
      * An implementation of `From<&str> for Box<Error>` was added to liballoc to
        allow construction of errors from raw strings.
      
      * The `Error::raw_os_error` method was stabilized as-is.
      
      * Trait impls for `Clone`, `Eq`, and `PartialEq` were removed from `Error` as it
        is not possible to use them with trait objects.
      
      This is a breaking change due to the modification of the `new` method as well as
      the removal of the trait implementations for the `Error` type.
      
      [breaking-change]
      ac77392f
    • A
      std: Clean out #[deprecated] APIs · d4a2c941
      Alex Crichton 提交于
      This commit cleans out a large amount of deprecated APIs from the standard
      library and some of the facade crates as well, updating all users in the
      compiler and in tests as it goes along.
      d4a2c941
    • A
      std: Add a process::exit function · 71982aa6
      Alex Crichton 提交于
      This commit is an implementation of [RFC #1011][rfc] which adds an `exit`
      function to the standard library for immediately terminating the current process
      with a specified exit code.
      
      [rfc]: https://github.com/rust-lang/rfcs/pull/1011
      71982aa6
    • A
      Stabilize `std::convert` and related code · 9fc51efe
      Aaron Turon 提交于
      * Marks `#[stable]` the contents of the `std::convert` module.
      
      * Added methods `PathBuf::as_path`, `OsString::as_os_str`,
        `String::as_str`, `Vec::{as_slice, as_mut_slice}`.
      
      * Deprecates `OsStr::from_str` in favor of a new, stable, and more
        general `OsStr::new`.
      
      * Adds unstable methods `OsString::from_bytes` and `OsStr::{to_bytes,
        to_cstring}` for ergonomic FFI usage.
      
      [breaking-change]
      9fc51efe
  18. 31 3月, 2015 1 次提交
    • A
      Stabilize std::num · 232424d9
      Aaron Turon 提交于
      This commit stabilizes the `std::num` module:
      
      * The `Int` and `Float` traits are deprecated in favor of (1) the
        newly-added inherent methods and (2) the generic traits available in
        rust-lang/num.
      
      * The `Zero` and `One` traits are reintroduced in `std::num`, which
        together with various other traits allow you to recover the most
        common forms of generic programming.
      
      * The `FromStrRadix` trait, and associated free function, is deprecated
        in favor of inherent implementations.
      
      * A wide range of methods and constants for both integers and floating
        point numbers are now `#[stable]`, having been adjusted for integer
        guidelines.
      
      * `is_positive` and `is_negative` are renamed to `is_sign_positive` and
        `is_sign_negative`, in order to address #22985
      
      * The `Wrapping` type is moved to `std::num` and stabilized;
        `WrappingOps` is deprecated in favor of inherent methods on the
        integer types, and direct implementation of operations on
        `Wrapping<X>` for each concrete integer type `X`.
      
      Closes #22985
      Closes #21069
      
      [breaking-change]
      232424d9
  19. 30 3月, 2015 1 次提交
  20. 28 3月, 2015 1 次提交
  21. 27 3月, 2015 3 次提交
    • A
      std: Stabilize parts of std::os::platform::io · 6370f297
      Alex Crichton 提交于
      This commit stabilizes the platform-specific `io` modules, specifically around
      the traits having to do with the raw representation of each object on each
      platform.
      
      Specifically, the following material was stabilized:
      
      * `AsRaw{Fd,Socket,Handle}`
      * `RawFd` (renamed from `Fd`)
      * `RawHandle` (renamed from `Handle`)
      * `RawSocket` (renamed from `Socket`)
      * `AsRaw{Fd,Socket,Handle}` implementations
      * `std::os::{unix, windows}::io`
      
      The following material was added as `#[unstable]`:
      
      * `FromRaw{Fd,Socket,Handle}`
      * Implementations for various primitives
      
      There are a number of future improvements that are possible to make to this
      module, but this should cover a good bit of functionality desired from these
      modules for now. Some specific future additions may include:
      
      * `IntoRawXXX` traits to consume the raw representation and cancel the
        auto-destructor.
      * `Fd`, `Socket`, and `Handle` abstractions that behave like Rust objects and
        have nice methods for various syscalls.
      
      At this time though, these are considered backwards-compatible extensions and
      will not be stabilized at this time.
      
      This commit is a breaking change due to the addition of `Raw` in from of the
      type aliases in each of the platform-specific modules.
      
      [breaking-change]
      6370f297
    • A
      Revise use of conversion traits · e7525cf6
      Aaron Turon 提交于
      This commit revises `path` and `os_str` to use blanket impls for `From`
      on reference types. This both cuts down on the number of required impls,
      and means that you can pass through e.g. `T: AsRef<OsStr>` to
      `PathBuf::from` without an intermediate call to `as_ref`.
      
      It also makes a FIXME note for later generalizing the blanket impls for
      `AsRef` and `AsMut` to use `Deref`/`DerefMut`, once it is possible to do
      so.
      e7525cf6
    • A
      Mass rename uint/int to usize/isize · 43bfaa4a
      Alex Crichton 提交于
      Now that support has been removed, all lingering use cases are renamed.
      43bfaa4a