| |
| Posted by Jonathan M Davis in reply to Sergey | PermalinkReply |
|
Jonathan M Davis
Posted in reply to Sergey
| On Monday, August 21, 2023 2:54:02 PM MDT Sergey via Digitalmars-d-learn wrote:
> When I worked with one C code translation, I found that command
> clock_gettime, that available in POSIX systems is not implemented
> in MacOS.
> This SO thread
>
> https://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac -os-x
>
> suggested some workaround implementations, which using some mach headers like mach.h and mach_time.h
>
> But when I’ve checked dmd sources
>
> https://github.com/dlang/dmd/tree/master/druntime/src/core/sys/darwin/mach
>
> I didn’t find it. So currently I’ve used MonoTime as temporary solution (however I’m not sure if it is a proper alternative).
MonoTime is the system-agnostic D solution for getting the time from the system's monotonic clock, whereas Clock.currTime / Clock.currStdTime in std.datetime.systime is the system-agnostic D solution for getting the current wall clock time. Unless you're doing something really specific, you almost certainly should just be using those and not trying to call system-specific functions to get the time.
In the case of Darwin systems, core.time declares the appropriate C bindings for the mach stuff so that MonoTime can use them, but they really should be moved to the appropriate place in druntime for Darwin-specific bindings.
> How full is dmd specific implementation of Darwin and Mach
> headers?
> Any plans to improve it (in case it is not full right now)?
In general, system-specific bindings get added to druntime, because someone who needed them took the time to add them to the right place in druntime rather than there being an organized effort to add bindings to druntime.
- Jonathan M Davis
|