--- a/Cargo.lock
+++ b/Cargo.lock
@@ -283,17 +283,17 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "chrono"
version = "0.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clang-sys"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -324,17 +324,17 @@ dependencies = [
"cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cookie"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-foundation"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -909,17 +909,17 @@ version = "0.10.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ident_case"
@@ -1338,17 +1338,17 @@ version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "msdos_time"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "net2"
version = "0.2.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
@@ -1958,17 +1958,17 @@ dependencies = [
"rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.19.0",
"servo_arc 0.1.1",
"smallbitvec 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"style_derive 0.0.1",
"style_traits 0.0.1",
- "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"uluru 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2103,23 +2103,22 @@ dependencies = [
[[package]]
name = "thread_profiler"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "time"
-version = "0.1.38"
+version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tokio-core"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2307,17 +2306,17 @@ dependencies = [
name = "webdriver"
version = "0.35.1"
dependencies = [
"cookie 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "webidl"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2347,17 +2346,17 @@ dependencies = [
"log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
"plane-split 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.57.2",
]
[[package]]
name = "webrender_api"
version = "0.57.2"
dependencies = [
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2366,17 +2365,17 @@ dependencies = [
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.58 (git+https://github.com/servo/serde?branch=deserialize_from_enums7)",
- "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "webrender_bindings"
version = "0.1.0"
dependencies = [
"app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2505,17 +2504,17 @@ dependencies = [
name = "zip"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bzip2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"msdos_time 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"podio 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum Inflector 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1b33cd9b653730fc539c53c7b3c672d2f47108fa20c6df571fa5817178f5a14c"
"checksum adler32 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6cbd0b9af8587c72beadc9f72d35b9fbb070982c9e6203e46e93f10df25f8f45"
"checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29069a9b483f7780aebb55dafb360c6225eefdc1f98c8d336a65148fd10c37b1"
@@ -2711,17 +2710,17 @@ dependencies = [
"checksum synstructure 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "010366096045d8250555904c58da03377289e7f4b2ce7a5b1027e2b532f41000"
"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6"
"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1"
"checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209"
"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83"
"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963"
"checksum thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf947d192a9be60ef5131cc7a4648886ba89d712f16700ebbf80c8a69d05d48f"
-"checksum time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d788d3aa77bc0ef3e9621256885555368b47bd495c13dd2e7413c89f845520"
+"checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b"
"checksum tokio-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "febd81b3e2ef615c6c8077347b33f3f3deec3d708ecd08194c9707b7a1eccfc9"
"checksum tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ab83e7adb5677e42e405fa4ceff75659d93c4d7d7dd22f52fcec59ee9f02af"
"checksum tokio-uds 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "65ae5d255ce739e8537221ed2942e0445f4b3b813daebac1c0050ddaaa3587f9"
"checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e"
"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"
"checksum uluru 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "519130f0ea964ba540a9d8af1373738c2226f1d465eda07e61db29feb5479db9"
--- a/third_party/rust/time/.cargo-checksum.json
+++ b/third_party/rust/time/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{".travis.yml":"9555a092ed1f87de52b07a90c614a30c6fa8f307eb4b05229253d06df363ce7a","Cargo.toml":"e51328f4f8dd0d9b1f039121c70de3e8bb4cf29975a64036af64c95bfeaa9e72","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"2c17f942c4a797f6f491c6d40570f904f35047531884ded3244438832b3d6f0a","appveyor.yml":"da991211b72fa6f231af7adb84c9fb72f5a9131d1c0a3d47b8ceffe5a82c8542","benches/precise_time_ns.rs":"f331c85489a05ea3bb83df9d57131a6e651ce852ca881417f328c4e8f53503c6","src/display.rs":"b79a81b4f068e44934ad3398ba0259120cc30cf0855ac5108c4569e320fd7f1d","src/duration.rs":"032f2ced8ea4dddaf6ed111f345e99217bad17edb7ed9fc4c511e405c8e02b87","src/lib.rs":"d01631b2340e30673e4c809678a5bdd3f8c18debb25ada21805a990254cb7caf","src/parse.rs":"717ae5735dfdaaba513f2a54a179e73bb2a48f8d4fb8787740d4662d6ff3389c","src/sys.rs":"0ca713b16747d046e4ce117828148bea66f23f4d461ad17045a24c7895d62be7"},"package":"d5d788d3aa77bc0ef3e9621256885555368b47bd495c13dd2e7413c89f845520"}
\ No newline at end of file
+{"files":{".travis.yml":"f820708f76fe75456b05c99b9ee4e9e720e0dd6189da11f3df3d8094111fdf31","Cargo.toml":"3c15858858af40a4cfa78a73cea88ba2e4ff31a59e7c7d2fef17d2282c9aa6e7","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"2c17f942c4a797f6f491c6d40570f904f35047531884ded3244438832b3d6f0a","appveyor.yml":"da991211b72fa6f231af7adb84c9fb72f5a9131d1c0a3d47b8ceffe5a82c8542","benches/precise_time_ns.rs":"06206c16764c6cef71da645ddb1aa7476dff7697e38d0742b3c907be9f00dadf","src/display.rs":"b79a81b4f068e44934ad3398ba0259120cc30cf0855ac5108c4569e320fd7f1d","src/duration.rs":"c227f6809f837996d24145843ba4972650d0fca7e2af7bbb0ebc0dbcec3358d9","src/lib.rs":"a07a09d4955fc92b85eb854e136a2732b94feff1c9be97fcf49accde6e704ee7","src/parse.rs":"717ae5735dfdaaba513f2a54a179e73bb2a48f8d4fb8787740d4662d6ff3389c","src/sys.rs":"14e3f57e7cf63167eda2f2fead3e01e59eb4cf71a5b15ae7563e962a43dbc659"},"package":"d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b"}
\ No newline at end of file
--- a/third_party/rust/time/.travis.yml
+++ b/third_party/rust/time/.travis.yml
@@ -1,27 +1,31 @@
language: rust
-rust:
- - stable
- - beta
- - nightly
sudo: false
-before_script:
- - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
+
+matrix:
+ include:
+ - rust: 1.21.0
+ - rust: stable
+ - os: osx
+ - rust: beta
+ - rust: nightly
+
+ - rust: nightly
+ before_script:
+ - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
+ script:
+ - cargo doc --no-deps --all-features
+ after_success:
+ - travis-cargo --only nightly doc-upload
+
script:
- - cargo build --verbose
- - cargo test --verbose
- - cargo test --verbose --features rustc-serialize
- - cargo doc --no-deps
-after_success:
- - travis-cargo --only nightly doc-upload
+ - cargo build
+ - cargo test
+ - cargo test --features rustc-serialize
+
env:
global:
secure: "NlXnNaUBf2MgV2gPJyIQU+JM814e29itvvb8o5BvN4YB60rseu16yLbzKpO4FzuOFBc/Uc+1veDcKyzZYsdV6FIwQk4jfdUkNZ3i56InVCzXcaaHCe78cpg/IxK+/48fGy/EIJkWYdtQsoVCGunaf5NdF360Lzb6G/B1vheC34E="
-
-
notifications:
email:
on_success: never
-os:
- - linux
- - osx
--- a/third_party/rust/time/Cargo.toml
+++ b/third_party/rust/time/Cargo.toml
@@ -1,29 +1,43 @@
-[package]
-
-name = "time"
-version = "0.1.38"
-authors = ["The Rust Project Developers"]
-license = "MIT/Apache-2.0"
-homepage = "https://github.com/rust-lang/time"
-repository = "https://github.com/rust-lang/time"
-documentation = "https://doc.rust-lang.org/time"
-description = """
-Utilities for working with time-related functions in Rust.
-"""
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g. crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
-[dependencies]
-libc = "0.2.1"
-rustc-serialize = { version = "0.3", optional = true }
-
-[target.'cfg(target_os = "redox")'.dependencies]
-redox_syscall = "0.1"
+[package]
+name = "time"
+version = "0.1.40"
+authors = ["The Rust Project Developers"]
+description = "Utilities for working with time-related functions in Rust.\n"
+homepage = "https://github.com/rust-lang/time"
+documentation = "https://doc.rust-lang.org/time"
+license = "MIT/Apache-2.0"
+repository = "https://github.com/rust-lang/time"
+[dependencies.libc]
+version = "0.2.1"
-[target.'cfg(windows)'.dependencies]
-winapi = "0.2.0"
-kernel32-sys = "0.2.0"
+[dependencies.rustc-serialize]
+version = "0.3"
+optional = true
+[dev-dependencies.log]
+version = "0.4"
-[dev-dependencies]
-log = "0.3"
+[dev-dependencies.winapi]
+version = "0.3.0"
+features = ["std", "processthreadsapi", "winbase"]
+[target."cfg(target_os = \"redox\")".dependencies.redox_syscall]
+version = "0.1"
+[target."cfg(windows)".dependencies.winapi]
+version = "0.3.0"
+features = ["std", "minwinbase", "minwindef", "ntdef", "profileapi", "sysinfoapi", "timezoneapi"]
+[badges.appveyor]
+repository = "alexcrichton/time"
-[target.'cfg(windows)'.dev-dependencies]
-advapi32-sys = "0.1.2"
+[badges.travis-ci]
+repository = "rust-lang-deprecated/time"
--- a/third_party/rust/time/benches/precise_time_ns.rs
+++ b/third_party/rust/time/benches/precise_time_ns.rs
@@ -2,10 +2,13 @@
extern crate test;
extern crate time;
use test::Bencher;
#[bench]
fn bench_precise_time_ns(b: &mut Bencher) {
- b.iter(|| time::precise_time_ns())
+ b.iter(|| {
+ time::precise_time_ns();
+ time::precise_time_ns();
+ });
}
--- a/third_party/rust/time/src/duration.rs
+++ b/third_party/rust/time/src/duration.rs
@@ -188,25 +188,25 @@ impl Duration {
// A proper Duration will not overflow, because MIN and MAX are defined
// such that the range is exactly i64 milliseconds.
let secs_part = self.num_seconds() * MILLIS_PER_SEC;
let nanos_part = self.nanos_mod_sec() / NANOS_PER_MILLI;
secs_part + nanos_part as i64
}
/// Returns the total number of whole microseconds in the duration,
- /// or `None` on overflow (exceeding 2^63 microseconds in either direction).
+ /// or `None` on overflow (exceeding 2<sup>63</sup> microseconds in either direction).
pub fn num_microseconds(&self) -> Option<i64> {
let secs_part = try_opt!(self.num_seconds().checked_mul(MICROS_PER_SEC));
let nanos_part = self.nanos_mod_sec() / NANOS_PER_MICRO;
secs_part.checked_add(nanos_part as i64)
}
/// Returns the total number of whole nanoseconds in the duration,
- /// or `None` on overflow (exceeding 2^63 nanoseconds in either direction).
+ /// or `None` on overflow (exceeding 2<sup>63</sup> nanoseconds in either direction).
pub fn num_nanoseconds(&self) -> Option<i64> {
let secs_part = try_opt!(self.num_seconds().checked_mul(NANOS_PER_SEC as i64));
let nanos_part = self.nanos_mod_sec();
secs_part.checked_add(nanos_part as i64)
}
/// Add two durations, returning `None` if overflow occurred.
pub fn checked_add(&self, rhs: &Duration) -> Option<Duration> {
--- a/third_party/rust/time/src/lib.rs
+++ b/third_party/rust/time/src/lib.rs
@@ -21,34 +21,32 @@
//! ```
//!
//! And this in your crate root:
//!
//! ```rust
//! extern crate time;
//! ```
//!
-//! This crate uses the same syntax for format strings as the [strftime()]
-//! (http://man7.org/linux/man-pages/man3/strftime.3.html) function from the C
-//! standard library.
+//! This crate uses the same syntax for format strings as the
+//! [`strftime()`](http://man7.org/linux/man-pages/man3/strftime.3.html)
+//! function from the C standard library.
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/time/")]
#![allow(trivial_numeric_casts)]
#![cfg_attr(test, deny(warnings))]
#[cfg(target_os = "redox")] extern crate syscall;
#[cfg(unix)] extern crate libc;
-#[cfg(windows)] extern crate kernel32;
#[cfg(windows)] extern crate winapi;
#[cfg(feature = "rustc-serialize")] extern crate rustc_serialize;
#[cfg(test)] #[macro_use] extern crate log;
-#[cfg(all(windows, test))] extern crate advapi32;
use std::cmp::Ordering;
use std::error::Error;
use std::fmt;
use std::ops::{Add, Sub};
pub use duration::{Duration, OutOfRangeError};
@@ -153,16 +151,17 @@ pub fn get_time() -> Timespec {
Timespec::new(sec, nsec)
}
/**
* Returns the current value of a high-resolution performance counter
* in nanoseconds since an unspecified epoch.
*/
+#[inline]
pub fn precise_time_ns() -> u64 {
sys::get_precise_ns()
}
/**
* Returns the current value of a high-resolution performance counter
* in seconds since an unspecified epoch.
@@ -327,17 +326,17 @@ pub struct Tm {
/// This value is positive if Daylight Saving Time is in effect, zero if
/// Daylight Saving Time is not in effect, and negative if this information
/// is not available.
pub tm_isdst: i32,
/// Identifies the time zone that was used to compute this broken-down time
/// value, including any adjustment for Daylight Saving Time. This is the
/// number of seconds east of UTC. For example, for U.S. Pacific Daylight
- /// Time, the value is -7*60*60 = -25200.
+ /// Time, the value is `-7*60*60 = -25200`.
pub tm_utcoff: i32,
/// Nanoseconds after the second - [0, 10<sup>9</sup> - 1]
pub tm_nsec: i32,
}
impl Add<Duration> for Tm {
type Output = Tm;
--- a/third_party/rust/time/src/sys.rs
+++ b/third_party/rust/time/src/sys.rs
@@ -1,23 +1,20 @@
#![allow(bad_style)]
pub use self::inner::*;
-#[cfg(target_os = "redox")]
-mod inner {
- use std::fmt;
- use std::cmp::Ordering;
- use std::ops::{Add, Sub};
- use syscall;
-
- use Duration;
+#[cfg(any(
+ all(target_arch = "wasm32", not(target_os = "emscripten")),
+ target_os = "redox",
+))]
+mod common {
use Tm;
- fn time_to_tm(ts: i64, tm: &mut Tm) {
+ pub fn time_to_tm(ts: i64, tm: &mut Tm) {
let leapyear = |year| -> bool {
year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
};
static _ytab: [[i64; 12]; 2] = [
[ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ],
[ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
];
@@ -51,30 +48,106 @@ mod inner {
dayno -= _ytab[if leapyear(year) { 1 } else { 0 }][mon];
mon += 1;
}
tm.tm_mon = mon as i32;
tm.tm_mday = dayno as i32 + 1;
tm.tm_isdst = 0;
}
- fn tm_to_time(tm: &Tm) -> i64 {
+ pub fn tm_to_time(tm: &Tm) -> i64 {
let mut y = tm.tm_year as i64 + 1900;
let mut m = tm.tm_mon as i64 + 1;
if m <= 2 {
y -= 1;
m += 12;
}
let d = tm.tm_mday as i64;
let h = tm.tm_hour as i64;
let mi = tm.tm_min as i64;
let s = tm.tm_sec as i64;
(365*y + y/4 - y/100 + y/400 + 3*(m+1)/5 + 30*m + d - 719561)
* 86400 + 3600 * h + 60 * mi + s
}
+}
+
+#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
+mod inner {
+ use std::ops::{Add, Sub};
+ use Tm;
+ use Duration;
+ use super::common::{time_to_tm, tm_to_time};
+
+ #[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
+ pub struct SteadyTime;
+
+ pub fn time_to_utc_tm(sec: i64, tm: &mut Tm) {
+ time_to_tm(sec, tm);
+ }
+
+ pub fn time_to_local_tm(sec: i64, tm: &mut Tm) {
+ // FIXME: Add timezone logic
+ time_to_tm(sec, tm);
+ }
+
+ pub fn utc_tm_to_time(tm: &Tm) -> i64 {
+ tm_to_time(tm)
+ }
+
+ pub fn local_tm_to_time(tm: &Tm) -> i64 {
+ // FIXME: Add timezone logic
+ tm_to_time(tm)
+ }
+
+ pub fn get_time() -> (i64, i32) {
+ unimplemented!()
+ }
+
+ pub fn get_precise_ns() -> u64 {
+ unimplemented!()
+ }
+
+ impl SteadyTime {
+ pub fn now() -> SteadyTime {
+ unimplemented!()
+ }
+ }
+
+ impl Sub for SteadyTime {
+ type Output = Duration;
+ fn sub(self, _other: SteadyTime) -> Duration {
+ unimplemented!()
+ }
+ }
+
+ impl Sub<Duration> for SteadyTime {
+ type Output = SteadyTime;
+ fn sub(self, _other: Duration) -> SteadyTime {
+ unimplemented!()
+ }
+ }
+
+ impl Add<Duration> for SteadyTime {
+ type Output = SteadyTime;
+ fn add(self, _other: Duration) -> SteadyTime {
+ unimplemented!()
+ }
+ }
+}
+
+#[cfg(target_os = "redox")]
+mod inner {
+ use std::fmt;
+ use std::cmp::Ordering;
+ use std::ops::{Add, Sub};
+ use syscall;
+ use super::common::{time_to_tm, tm_to_time};
+
+ use Duration;
+ use Tm;
pub fn time_to_utc_tm(sec: i64, tm: &mut Tm) {
time_to_tm(sec, tm);
}
pub fn time_to_local_tm(sec: i64, tm: &mut Tm) {
// FIXME: Add timezone logic
time_to_tm(sec, tm);
@@ -235,18 +308,18 @@ mod inner {
rust_tm.tm_mon = tm.tm_mon;
rust_tm.tm_year = tm.tm_year;
rust_tm.tm_wday = tm.tm_wday;
rust_tm.tm_yday = tm.tm_yday;
rust_tm.tm_isdst = tm.tm_isdst;
rust_tm.tm_utcoff = utcoff;
}
- #[cfg(target_os = "nacl")]
- unsafe fn timegm(tm: *const libc::tm) -> time_t {
+ #[cfg(any(target_os = "nacl", target_os = "solaris"))]
+ unsafe fn timegm(tm: *mut libc::tm) -> time_t {
use std::env::{set_var, var_os, remove_var};
extern {
fn tzset();
}
let ret;
let current_tz = var_os("TZ");
@@ -300,17 +373,17 @@ mod inner {
let gmtoff = out.tm_gmtoff;
tm_to_rust_tm(&out, gmtoff as i32, tm);
}
}
pub fn utc_tm_to_time(rust_tm: &Tm) -> i64 {
#[cfg(all(target_os = "android", target_pointer_width = "32"))]
use libc::timegm64 as timegm;
- #[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
+ #[cfg(not(any(all(target_os = "android", target_pointer_width = "32"), target_os = "nacl", target_os = "solaris")))]
use libc::timegm;
let mut tm = unsafe { mem::zeroed() };
rust_tm_to_tm(rust_tm, &mut tm);
unsafe { timegm(&mut tm) as i64 }
}
pub fn local_tm_to_time(rust_tm: &Tm) -> i64 {
@@ -343,16 +416,17 @@ mod inner {
pub fn get_time() -> (i64, i32) {
use std::ptr;
let mut tv = timeval { tv_sec: 0, tv_usec: 0 };
unsafe { libc::gettimeofday(&mut tv, ptr::null_mut()); }
(tv.tv_sec as i64, tv.tv_usec * 1000)
}
+ #[inline]
pub fn get_precise_ns() -> u64 {
unsafe {
let time = libc::mach_absolute_time();
let info = info();
time * info.numer as u64 / info.denom as u64
}
}
@@ -485,24 +559,30 @@ mod inner {
}
impl Add<Duration> for SteadyTime {
type Output = SteadyTime;
fn add(mut self, other: Duration) -> SteadyTime {
let seconds = other.num_seconds();
let nanoseconds = other - Duration::seconds(seconds);
let nanoseconds = nanoseconds.num_nanoseconds().unwrap();
+
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ type nsec = i64;
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ type nsec = libc::c_long;
+
self.t.tv_sec += seconds as libc::time_t;
- self.t.tv_nsec += nanoseconds as libc::c_long;
- if self.t.tv_nsec >= ::NSEC_PER_SEC as libc::c_long {
- self.t.tv_nsec -= ::NSEC_PER_SEC as libc::c_long;
+ self.t.tv_nsec += nanoseconds as nsec;
+ if self.t.tv_nsec >= ::NSEC_PER_SEC as nsec {
+ self.t.tv_nsec -= ::NSEC_PER_SEC as nsec;
self.t.tv_sec += 1;
} else if self.t.tv_nsec < 0 {
self.t.tv_sec -= 1;
- self.t.tv_nsec += ::NSEC_PER_SEC as libc::c_long;
+ self.t.tv_nsec += ::NSEC_PER_SEC as nsec;
}
self
}
}
impl PartialOrd for SteadyTime {
fn partial_cmp(&self, other: &SteadyTime) -> Option<Ordering> {
Some(self.cmp(other))
@@ -534,31 +614,51 @@ mod inner {
#[allow(non_snake_case)]
mod inner {
use std::io;
use std::mem;
use std::sync::{Once, ONCE_INIT};
use std::ops::{Add, Sub};
use {Tm, Duration};
- use kernel32::*;
- use winapi::*;
+ use winapi::um::winnt::*;
+ use winapi::shared::minwindef::*;
+ use winapi::um::minwinbase::SYSTEMTIME;
+ use winapi::um::profileapi::*;
+ use winapi::um::timezoneapi::*;
+ use winapi::um::sysinfoapi::GetSystemTimeAsFileTime;
- fn frequency() -> LARGE_INTEGER {
- static mut FREQUENCY: LARGE_INTEGER = 0;
+ fn frequency() -> i64 {
+ static mut FREQUENCY: i64 = 0;
static ONCE: Once = ONCE_INIT;
unsafe {
ONCE.call_once(|| {
- QueryPerformanceFrequency(&mut FREQUENCY);
+ let mut l = i64_to_large_integer(0);
+ QueryPerformanceFrequency(&mut l);
+ FREQUENCY = large_integer_to_i64(l);
});
FREQUENCY
}
}
+ fn i64_to_large_integer(i: i64) -> LARGE_INTEGER {
+ unsafe {
+ let mut large_integer: LARGE_INTEGER = mem::zeroed();
+ *large_integer.QuadPart_mut() = i;
+ large_integer
+ }
+ }
+
+ fn large_integer_to_i64(l: LARGE_INTEGER) -> i64 {
+ unsafe {
+ *l.QuadPart()
+ }
+ }
+
const HECTONANOSECS_IN_SEC: i64 = 10_000_000;
const HECTONANOSEC_TO_UNIX_EPOCH: i64 = 11_644_473_600 * HECTONANOSECS_IN_SEC;
fn time_to_file_time(sec: i64) -> FILETIME {
let t = (((sec * HECTONANOSECS_IN_SEC) + HECTONANOSEC_TO_UNIX_EPOCH)) as u64;
FILETIME {
dwLowDateTime: t as DWORD,
dwHighDateTime: (t >> 32) as DWORD
@@ -692,58 +792,58 @@ mod inner {
unsafe {
let mut ft = mem::zeroed();
GetSystemTimeAsFileTime(&mut ft);
(file_time_to_unix_seconds(&ft), file_time_to_nsec(&ft))
}
}
pub fn get_precise_ns() -> u64 {
- let mut ticks = 0;
+ let mut ticks = i64_to_large_integer(0);
unsafe {
assert!(QueryPerformanceCounter(&mut ticks) == 1);
}
- mul_div_i64(ticks as i64, 1000000000, frequency() as i64) as u64
+ mul_div_i64(large_integer_to_i64(ticks), 1000000000, frequency()) as u64
}
- #[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug)]
+ #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub struct SteadyTime {
- t: LARGE_INTEGER,
+ t: i64,
}
impl SteadyTime {
pub fn now() -> SteadyTime {
- let mut t = SteadyTime { t: 0 };
- unsafe { QueryPerformanceCounter(&mut t.t); }
- t
+ let mut l = i64_to_large_integer(0);
+ unsafe { QueryPerformanceCounter(&mut l); }
+ SteadyTime { t : large_integer_to_i64(l) }
}
}
impl Sub for SteadyTime {
type Output = Duration;
fn sub(self, other: SteadyTime) -> Duration {
let diff = self.t as i64 - other.t as i64;
Duration::nanoseconds(mul_div_i64(diff, 1000000000,
- frequency() as i64))
+ frequency()))
}
}
impl Sub<Duration> for SteadyTime {
type Output = SteadyTime;
fn sub(self, other: Duration) -> SteadyTime {
self + -other
}
}
impl Add<Duration> for SteadyTime {
type Output = SteadyTime;
fn add(mut self, other: Duration) -> SteadyTime {
- self.t += (other.num_microseconds().unwrap() * frequency() as i64 /
- 1_000_000) as LARGE_INTEGER;
+ self.t += (other.num_microseconds().unwrap() * frequency() /
+ 1_000_000) as i64;
self
}
}
#[cfg(test)]
pub struct TzReset {
old: TIME_ZONE_INFORMATION,
}
@@ -799,20 +899,29 @@ mod inner {
}
// Ensures that this process has the necessary privileges to set a new time
// zone, and this is all transcribed from:
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724944%28v=vs.85%29.aspx
#[cfg(test)]
fn acquire_privileges() {
use std::sync::{ONCE_INIT, Once};
- use advapi32::*;
+ use winapi::um::processthreadsapi::*;
+ use winapi::um::winbase::LookupPrivilegeValueA;
const SE_PRIVILEGE_ENABLED: DWORD = 2;
static INIT: Once = ONCE_INIT;
+ // TODO: FIXME
+ extern "system" {
+ fn AdjustTokenPrivileges(
+ TokenHandle: HANDLE, DisableAllPrivileges: BOOL, NewState: PTOKEN_PRIVILEGES,
+ BufferLength: DWORD, PreviousState: PTOKEN_PRIVILEGES, ReturnLength: PDWORD,
+ ) -> BOOL;
+ }
+
#[repr(C)]
struct TKP {
tkp: TOKEN_PRIVILEGES,
laa: LUID_AND_ATTRIBUTES,
}
INIT.call_once(|| unsafe {
let mut hToken = 0 as *mut _;