druntime
druntime copied to clipboard
Solaris time unittest fix: unimplemented clock types checking added.
The only two clock types currently implemented on Solaris and illumos.
Is the definition of ClockType for Solaris wrong then? Should it be changed instead and the Solaris comments above it?
https://github.com/tethyslab/druntime/blob/6f61dee0a15e8c1e898c28cc6cbf7dd4c4182682/src/core/time.d#L308
Is the definition of ClockType for Solaris wrong then?
Not quite. In Solaris kernel present declaration of these Clock types:
#define __CLOCK_REALTIME0 0 /* obsolete; same as CLOCK_REALTIME */
#define CLOCK_VIRTUAL 1 /* thread's user-level CPU clock */
#define CLOCK_THREAD_CPUTIME_ID 2 /* thread's user+system CPU clock */
#define CLOCK_REALTIME 3 /* wall clock */
#define CLOCK_MONOTONIC 4 /* high resolution monotonic clock */
#define CLOCK_PROCESS_CPUTIME_ID 5 /* process's user+system CPU clock */
#define CLOCK_HIGHRES CLOCK_MONOTONIC /* alternate name */
#define CLOCK_PROF CLOCK_THREAD_CPUTIME_ID /* alternate name */
But implemented only two types:
/* CLOCK_REALTIME and CLOCK_HIGHRES (CLOCK_MONOTONIC) are the only two
* clock backends currently implemented on illumos. Functions in the kernel
* that use the CLOCK_BACKEND macro will return an error for any clock type
* that does not exist in the clock_backend array. These functions are
* clock_settime, clock_gettime, clock_getres and timer_create.
*
* For reference, the kernel's clock_backend array looks like this:
*
* clock_backend[CLOCK_MAX] (6 entries)
* 0 __CLOCK_REALTIME0 valid ptr. (obs. same as CLOCK_REALTIME)
* 1 CLOCK_VIRTUAL NULL
* 2 CLOCK_THREAD_CPUTIME_ID NULL
* 3 CLOCK_REALTIME valid ptr.
* 4 CLOCK_MONOTONIC (CLOCK_HIGHRES) valid ptr.
* 5 CLOCK_PROCESS_CPUTIME_ID NULL
*/
So druntime definition of ClockType can save the same as in Solaris for the future. Or keep in druntime definition of ClockType only implemented types and add them in the future if necessary.
So is this a general Solaris shortcoming or just true for illumos, the OpenSolaris fork?
I don't know for latest Oracle Solaris 11, but for Solaris 10 and Illumos this is true. I tested it on Illumos.