<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/src/libstd/sys/windows/sync.rs, branch try</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=try</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=try'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2015-06-28T02:45:24+00:00</updated>
<entry>
<title>std: Fix Windows XP compatibility</title>
<updated>2015-06-28T02:45:24+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2015-06-26T16:30:35+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=10b103af48368c5df644fa61dc417a36083922c8'/>
<id>urn:sha1:10b103af48368c5df644fa61dc417a36083922c8</id>
<content type='text'>
This commit enables executables linked against the standard library to run on
Windows XP. There are two main components of this commit:

* APIs not available on XP are shimmed to have a fallback implementation and use
  runtime detection to determine if they are available.
* Mutexes on Windows were reimplemented to use critical sections on XP where
  rwlocks are not available.

The APIs which are not available on XP are:

* SetFileInformationByHandle - this is just used by `File::truncate` and that
  function just returns an error now.
* SetThreadStackGuarantee - this is used by the stack overflow support on
  windows, but if this isn't available then it's just ignored (it seems
  non-critical).
* All condition variable APIs are missing - the shims added for these apis
  simply always panic for now. We may eventually provide a fallback
  implementation, but for now the standard library does not rely on condition
  variables for normal use.
* RWLocks, like condition variables, are missing entirely. The same story for
  condition variables is taken here. These APIs are all now panicking stubs as
  the standard library doesn't rely on RWLocks for normal use.

Currently, as an optimization, we use SRWLOCKs for the standard `sync::Mutex`
implementation on Windows, which is indeed required for normal operation of the
standard library. To allow the standard library to run on XP, this commit
reimplements mutexes on Windows to use SRWLOCK instances *if available* and
otherwise a CriticalSection is used (with some checking for recursive
locking).

With all these changes put together, a 32-bit MSVC-built executable can run on
Windows XP and print "hello world"

Closes #12842
Closes #19992
Closes #24776
</content>
</entry>
<entry>
<title>Implement reentrant mutexes and make stdio use them</title>
<updated>2015-04-08T16:42:16+00:00</updated>
<author>
<name>Simonas Kazlauskas</name>
<email>git@kazlauskas.me</email>
</author>
<published>2015-04-03T21:46:54+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=45aa6c8d1bc2f7863c92da6643de4642bb2d83bf'/>
<id>urn:sha1:45aa6c8d1bc2f7863c92da6643de4642bb2d83bf</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>std: Add a new `env` module</title>
<updated>2015-02-01T19:08:15+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2015-01-27T20:20:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=70ed3a48dfa301c5bb56de3e0a7c25214539b83c'/>
<id>urn:sha1:70ed3a48dfa301c5bb56de3e0a7c25214539b83c</id>
<content type='text'>
This is an implementation of [RFC 578][rfc] which adds a new `std::env` module
to replace most of the functionality in the current `std::os` module. More
details can be found in the RFC itself, but as a summary the following methods
have all been deprecated:

[rfc]: https://github.com/rust-lang/rfcs/pull/578

* `os::args_as_bytes`   =&gt; `env::args`
* `os::args`            =&gt; `env::args`
* `os::consts`          =&gt; `env::consts`
* `os::dll_filename`    =&gt; no replacement, use `env::consts` directly
* `os::page_size`       =&gt; `env::page_size`
* `os::make_absolute`   =&gt; use `env::current_dir` + `join` instead
* `os::getcwd`          =&gt; `env::current_dir`
* `os::change_dir`      =&gt; `env::set_current_dir`
* `os::homedir`         =&gt; `env::home_dir`
* `os::tmpdir`          =&gt; `env::temp_dir`
* `os::join_paths`      =&gt; `env::join_paths`
* `os::split_paths`     =&gt; `env::split_paths`
* `os::self_exe_name`   =&gt; `env::current_exe`
* `os::self_exe_path`   =&gt; use `env::current_exe` + `pop`
* `os::set_exit_status` =&gt; `env::set_exit_status`
* `os::get_exit_status` =&gt; `env::get_exit_status`
* `os::env`             =&gt; `env::vars`
* `os::env_as_bytes`    =&gt; `env::vars`
* `os::getenv`          =&gt; `env::var` or `env::var_string`
* `os::getenv_as_bytes` =&gt; `env::var`
* `os::setenv`          =&gt; `env::set_var`
* `os::unsetenv`        =&gt; `env::remove_var`

Many function signatures have also been tweaked for various purposes, but the
main changes were:

* `Vec`-returning APIs now all return iterators instead
* All APIs are now centered around `OsString` instead of `Vec&lt;u8&gt;` or `String`.
  There is currently on convenience API, `env::var_string`, which can be used to
  get the value of an environment variable as a unicode `String`.

All old APIs are `#[deprecated]` in-place and will remain for some time to allow
for migrations. The semantics of the APIs have been tweaked slightly with regard
to dealing with invalid unicode (panic instead of replacement).

The new `std::env` module is all contained within the `env` feature, so crates
must add the following to access the new APIs:

    #![feature(env)]

[breaking-change]
</content>
</entry>
<entry>
<title>Change Mutex to use SRWLock on Windows.</title>
<updated>2015-01-13T02:35:39+00:00</updated>
<author>
<name>Peter Atashian</name>
<email>retep998@gmail.com</email>
</author>
<published>2015-01-12T22:50:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ee1ca88213133a58f0a9d234f03babbebeb7c5d8'/>
<id>urn:sha1:ee1ca88213133a58f0a9d234f03babbebeb7c5d8</id>
<content type='text'>
Signed-off-by: Peter Atashian &lt;retep998@gmail.com&gt;
</content>
</entry>
<entry>
<title>std: Rewrite the `sync` module</title>
<updated>2014-12-05T08:53:22+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2014-11-24T19:16:40+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=71d4e77db8ad4b6d821da7e5d5300134ac95974e'/>
<id>urn:sha1:71d4e77db8ad4b6d821da7e5d5300134ac95974e</id>
<content type='text'>
This commit is a reimplementation of `std::sync` to be based on the
system-provided primitives wherever possible. The previous implementation was
fundamentally built on top of channels, and as part of the runtime reform it has
become clear that this is not the level of abstraction that the standard level
should be providing. This rewrite aims to provide as thin of a shim as possible
on top of the system primitives in order to make them safe.

The overall interface of the `std::sync` module has in general not changed, but
there are a few important distinctions, highlighted below:

* The condition variable type, `Condvar`, has been separated out of a `Mutex`.
  A condition variable is now an entirely separate type. This separation
  benefits users who only use one mutex, and provides a clearer distinction of
  who's responsible for managing condition variables (the application).

* All of `Condvar`, `Mutex`, and `RWLock` are now directly built on top of
  system primitives rather than using a custom implementation. The `Once`,
  `Barrier`, and `Semaphore` types are still built upon these abstractions of
  the system primitives.

* The `Condvar`, `Mutex`, and `RWLock` types all have a new static type and
  constant initializer corresponding to them. These are provided primarily for C
  FFI interoperation, but are often useful to otherwise simply have a global
  lock. The types, however, will leak memory unless `destroy()` is called on
  them, which is clearly documented.

* The `Condvar` implementation for an `RWLock` write lock has been removed. This
  may be added back in the future with a userspace implementation, but this
  commit is focused on exposing the system primitives first.

* The fundamental architecture of this design is to provide two separate layers.
  The first layer is that exposed by `sys_common` which is a cross-platform
  bare-metal abstraction of the system synchronization primitives. No attempt is
  made at making this layer safe, and it is quite unsafe to use! It is currently
  not exported as part of the API of the standard library, but the stabilization
  of the `sys` module will ensure that these will be exposed in time. The
  purpose of this layer is to provide the core cross-platform abstractions if
  necessary to implementors.

  The second layer is the layer provided by `std::sync` which is intended to be
  the thinnest possible layer on top of `sys_common` which is entirely safe to
  use. There are a few concerns which need to be addressed when making these
  system primitives safe:

    * Once used, the OS primitives can never be **moved**. This means that they
      essentially need to have a stable address. The static primitives use
      `&amp;'static self` to enforce this, and the non-static primitives all use a
      `Box` to provide this guarantee.

    * Poisoning is leveraged to ensure that invalid data is not accessible from
      other tasks after one has panicked.

  In addition to these overall blanket safety limitations, each primitive has a
  few restrictions of its own:

    * Mutexes and rwlocks can only be unlocked from the same thread that they
      were locked by. This is achieved through RAII lock guards which cannot be
      sent across threads.

    * Mutexes and rwlocks can only be unlocked if they were previously locked.
      This is achieved by not exposing an unlocking method.

    * A condition variable can only be waited on with a locked mutex. This is
      achieved by requiring a `MutexGuard` in the `wait()` method.

    * A condition variable cannot be used concurrently with more than one mutex.
      This is guaranteed by dynamically binding a condition variable to
      precisely one mutex for its entire lifecycle. This restriction may be able
      to be relaxed in the future (a mutex is unbound when no threads are
      waiting on the condvar), but for now it is sufficient to guarantee safety.

* Condvars now support timeouts for their blocking operations. The
  implementation for these operations is provided by the system.

Due to the modification of the `Condvar` API, removal of the `std::sync::mutex`
API, and reimplementation, this is a breaking change. Most code should be fairly
easy to port using the examples in the documentation of these primitives.

[breaking-change]

Closes #17094
Closes #18003
</content>
</entry>
</feed>
