Skip to content

Nim never used clock_gettime(CLOCK_REALTIME, t) for the realtime GC on linux #11853

Open
@ReneSac

Description

@ReneSac

Once upon a time I pointed it out in #nimrod irc channel and it was discussed, but I never formalized a bug report, so it seems like it was forgotten.

From what I understand, it has always been using the deprecated and less precise posix_gettimeofday() for all non-windows and non-macOS systems. See: https://github.com/nim-lang/Nim/blob/0ca71dd92cf2c53443e75487a787198a50266dcd/lib/system/timers.nim

It derives from a limitation in that Nim's defined()does not work for things defined in a C header (I would love to have a good option for that inside Nim, but that is beyond the scope of this bug), only for Nim symbols, and will naturally return false with no error in this case as posixRealtime isn't defined anywhere on Nim code base, thus the fallback option is always used.

Anyway, the non-system times.nim uses clock_gettime(CLOCK_REALTIME, t) behind just defined(posix) since #9793 and #10499, so that falback could just be removed? Alternatively, the most correct solution is perhaps to define posixRealtime in Nim with the correct value for the platform and implement the fallback for the non-system times.nim too.

I'm not sure if exotic targets like embedded linuxes may have a problem with that, but as I understand it would fail at compile time, so Nim could work to support it only when such a developer appear complaining.

And is this separated timers.nim still needed?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions