diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2013-03-08 20:44:37 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2013-03-13 16:59:37 -0400 |
| commit | efc7f82bc44926c864c52caca8764816ab9150dd (patch) | |
| tree | c2d0cb8d8e8260c58e5b12d51218d935a83462d9 /src/libstd | |
| parent | 4d8ddff52a60d3785052f1e0a231cb95c98fdc24 (diff) | |
| download | rust-efc7f82bc44926c864c52caca8764816ab9150dd.tar.gz rust-efc7f82bc44926c864c52caca8764816ab9150dd.zip | |
Revamp foreign code not to consider the Rust modes. This requires
adjusting a few foreign functions that were declared with by-ref mode. This also allows us to remove by-val mode in the near future. With copy mode, though, we have to be careful because Rust will implicitly pass somethings by pointer but this may not be the C ABI rules. For example, rust will pass a struct Foo as a Foo*. So I added some code into the adapters to fix this (though the C ABI rules may put the pointer back, oh well). This patch also includes a lint mode for the use of by-ref mode in foreign functions as the semantics of this have changed.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/time.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libstd/time.rs b/src/libstd/time.rs index d6e19515ba6..d768eef9a8c 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -30,10 +30,10 @@ pub mod rustrt { pub unsafe fn rust_tzset(); // FIXME: The i64 values can be passed by-val when #2064 is fixed. - pub unsafe fn rust_gmtime(&&sec: i64, &&nsec: i32, &&result: Tm); - pub unsafe fn rust_localtime(&&sec: i64, &&nsec: i32, &&result: Tm); - pub unsafe fn rust_timegm(&&tm: Tm, sec: &mut i64); - pub unsafe fn rust_mktime(&&tm: Tm, sec: &mut i64); + pub unsafe fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm); + pub unsafe fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm); + pub unsafe fn rust_timegm(tm: &Tm, sec: &mut i64); + pub unsafe fn rust_mktime(tm: &Tm, sec: &mut i64); } } @@ -172,7 +172,7 @@ pub fn at_utc(clock: Timespec) -> Tm { unsafe { let mut Timespec { sec, nsec } = clock; let mut tm = empty_tm(); - rustrt::rust_gmtime(sec, nsec, tm); + rustrt::rust_gmtime(sec, nsec, &mut tm); tm } } @@ -187,7 +187,7 @@ pub fn at(clock: Timespec) -> Tm { unsafe { let mut Timespec { sec, nsec } = clock; let mut tm = empty_tm(); - rustrt::rust_localtime(sec, nsec, tm); + rustrt::rust_localtime(sec, nsec, &mut tm); tm } } @@ -217,9 +217,9 @@ pub impl Tm { unsafe { let mut sec = 0i64; if self.tm_gmtoff == 0_i32 { - rustrt::rust_timegm(*self, &mut sec); + rustrt::rust_timegm(self, &mut sec); } else { - rustrt::rust_mktime(*self, &mut sec); + rustrt::rust_mktime(self, &mut sec); } Timespec::new(sec, self.tm_nsec) } |
