Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix the microsecond-to-nanosecond conversion in rv_clock_gettime() #360

Merged
merged 1 commit into from
May 21, 2024

Conversation

alanjian85
Copy link
Collaborator

A microsecond is 1000 times bigger than a nanosecond (10-6 vs 10-9 seconds). This commit corrects the conversion of microseconds to nanoseconds in rv_clock_gettime() by multiplying tv_usec by 1000 instead of dividing it.

A microsecond is 1000 times bigger than a nanosecond (1e-6 vs 1e-9 seconds).
This commit corrects the conversion of microseconds to nanoseconds in
rv_clock_gettime() by multiplying tv_usec by 1000 instead of dividing it.
@jserv jserv requested a review from visitorckw February 26, 2024 04:21
@jserv
Copy link
Contributor

jserv commented Feb 26, 2024

The issue with time conversion for rv_clock_gettime has been resolved by @visitorckw, and it is expected that the fix would be included in newlib version 4.4. We need to verify that the prebuilt RISC-V toolchains, especially those maintained by SiFive, incorporate newlib-4.4 into their builds. Once confirmed, we will be able to mandate the proper approach for handling rv_clock_gettime.

@visitorckw
Copy link
Collaborator

@alanjian85 alanjian85 closed this Feb 29, 2024
@jserv
Copy link
Contributor

jserv commented Feb 29, 2024

Let's keep this pull request and wait for prebuilt GNU Toolchain for landing newlib fixes.

@jserv
Copy link
Contributor

jserv commented Apr 6, 2024

Let's keep this pull request and wait for prebuilt GNU Toolchain for landing newlib fixes.

Recent riscv-gnu-toolchain supports newlib 4.4.0, meaning that it is time to adopt this proposed change.

Once the prebuilt GNU Toolchain for RISC-V is ready for downloading, I will merge this pull request and rebuild all ELF files.

@jserv
Copy link
Contributor

jserv commented Apr 26, 2024

Recent riscv-gnu-toolchain supports newlib 4.4.0, meaning that it is time to adopt this proposed change.
Once the prebuilt GNU Toolchain for RISC-V is ready for downloading, I will merge this pull request and rebuild all ELF files.

The Nightly: April 12, 2024 build should include newlib v4.4.0 already.

@jserv jserv merged commit a8aa29e into sysprog21:master May 21, 2024
14 checks passed
@jserv
Copy link
Contributor

jserv commented May 21, 2024

Thank @alanjian85 for contributing!

vestata pushed a commit to vestata/rv32emu that referenced this pull request Jan 24, 2025
A microsecond is 1000 times bigger than a nanosecond (1e-6 vs 1e-9 seconds).
This commit corrects the conversion of microseconds to nanoseconds in
rv_clock_gettime() by multiplying tv_usec by 1000 instead of dividing it.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants