Skip to content

Add clock_gettime shim#975

Merged
bors merged 13 commits into
rust-lang:masterfrom
pvdrz:clock-shim
Oct 15, 2019
Merged

Add clock_gettime shim#975
bors merged 13 commits into
rust-lang:masterfrom
pvdrz:clock-shim

Conversation

@pvdrz

@pvdrz pvdrz commented Oct 2, 2019

Copy link
Copy Markdown
Contributor

r? @oli-obk

I think there is no way to do proper testing of this other than checking that miri does not crash when calling clock_gettime.

@pvdrz pvdrz force-pushed the clock-shim branch 2 times, most recently from 2ffc663 to 5259ebe Compare October 3, 2019 15:45
@bjorn3

bjorn3 commented Oct 3, 2019

Copy link
Copy Markdown
Member

Also I'm not sure what to do if the current time is lower than UNIX_EPOCH, which might happen if someone decides to mess with the clock before running miri.

You could calculate the opposite difference (UNIX_EPOCH-now) and then write a negative number, as clock_gettime returns a signed int.

@pvdrz

pvdrz commented Oct 3, 2019

Copy link
Copy Markdown
Contributor Author

Also I'm not sure what to do if the current time is lower than UNIX_EPOCH, which might happen if someone decides to mess with the clock before running miri.

You could calculate the opposite difference (UNIX_EPOCH-now) and then write a negative number, as clock_gettime returns a signed int.

That sounds like a good idea. I'll try to do that

@pvdrz

pvdrz commented Oct 3, 2019

Copy link
Copy Markdown
Contributor Author

Also CI is failing because the size of long and time_t is platform dependent. How should I handle that?

Edit: Solved by recovering the types from the target's libc

@bors

bors commented Oct 8, 2019

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #977) made this pull request unmergeable. Please resolve the merge conflicts.

@pvdrz pvdrz force-pushed the clock-shim branch 2 times, most recently from bbef7a0 to e00db1b Compare October 8, 2019 20:43
@pvdrz pvdrz mentioned this pull request Oct 10, 2019
Comment thread src/shims/env.rs
Comment thread src/shims/foreign_items.rs Outdated
Comment thread src/helpers.rs
Comment thread src/helpers.rs Outdated
Comment thread src/shims/time.rs
Comment thread tests/run-pass/clock.rs
@bors

bors commented Oct 11, 2019

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #983) made this pull request unmergeable. Please resolve the merge conflicts.

Comment thread src/helpers.rs Outdated
Comment thread src/shims/time.rs Outdated
Comment thread src/shims/time.rs Outdated
Comment thread src/helpers.rs Outdated
Comment thread src/helpers.rs Outdated
Comment thread src/shims/time.rs Outdated
Comment thread src/shims/time.rs Outdated
Comment thread src/shims/time.rs Outdated
Comment thread tests/run-pass/clock.rs
@RalfJung

Copy link
Copy Markdown
Member

Yeah this looks good, thanks a lot. :)

@bors r+

@bors

bors commented Oct 14, 2019

Copy link
Copy Markdown
Contributor

📌 Commit f9c7688 has been approved by RalfJung

bors added a commit that referenced this pull request Oct 14, 2019
Add clock_gettime shim

r? @oli-obk

I think there is no way to do proper testing of this other than checking that miri does not crash when calling `clock_gettime`.
@bors

bors commented Oct 14, 2019

Copy link
Copy Markdown
Contributor

⌛ Testing commit f9c7688 with merge 5d66fb4...

@RalfJung

Copy link
Copy Markdown
Member

That push aborted landing the PR I think.

@bors r+ retry

@bors

bors commented Oct 15, 2019

Copy link
Copy Markdown
Contributor

📌 Commit f9c7688 has been approved by RalfJung

@bors

bors commented Oct 15, 2019

Copy link
Copy Markdown
Contributor

⌛ Testing commit f9c7688 with merge d902a11...

bors added a commit that referenced this pull request Oct 15, 2019
Add clock_gettime shim

r? @oli-obk

I think there is no way to do proper testing of this other than checking that miri does not crash when calling `clock_gettime`.
@bors

bors commented Oct 15, 2019

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-travis, status-appveyor
Approved by: RalfJung
Pushing d902a11 to master...

@bors bors merged commit f9c7688 into rust-lang:master Oct 15, 2019
@pvdrz

pvdrz commented Oct 15, 2019

Copy link
Copy Markdown
Contributor Author

Thank you, I did a commit to the wrong branch by accident D:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants