Why doesn't mktspec() use clock_gettime?

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 12 00:04:49 PST 2015


On 2015-01-12 02:19, Jonathan M Davis via Digitalmars-d wrote:

> It's probably because Mac OS X doesn't have clock_gettime, even though it's
> POSIX. std.datetime.Clock.currTime currently uses gettimeofday for getting
> the wall clock time on OS X (and clock_gettime on the other POSIX systems), which I'm not a fan of, but AFAIK, it works.
> However, I probably should try at some point to find a more precise wall
> clock function than gettimeofday for Mac OS X.

I don't know if this is what you're looking for but I found these two 
[1], [2]. I don't know if they're monotonic or not.

I also found this stackoverflow post [3] saying that mach_absolute_time 
and clock_get_time pauses when sleeping on iOS. Don't know if that's a 
problem or not. There seems to be a workaround in the post as well.

[1] 
https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/KernelProgramming/services/services.html

[2] 
http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/osfmk/man/clock_get_time.html

[3] 
http://stackoverflow.com/questions/12488481/getting-ios-system-uptime-that-doesnt-pause-when-asleep/12490414#12490414

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list