druntime icon indicating copy to clipboard operation
druntime copied to clipboard

Solaris time unittest fix: unimplemented clock types checking added.

Open nykytenko opened this issue 9 years ago • 4 comments

The only two clock types currently implemented on Solaris and illumos.

nykytenko avatar Jun 23 '16 17:06 nykytenko

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

smolt avatar Jun 24 '16 04:06 smolt

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.

nykytenko avatar Jun 24 '16 18:06 nykytenko

So is this a general Solaris shortcoming or just true for illumos, the OpenSolaris fork?

kinke avatar Jul 02 '16 09:07 kinke

I don't know for latest Oracle Solaris 11, but for Solaris 10 and Illumos this is true. I tested it on Illumos.

nykytenko avatar Jul 04 '16 10:07 nykytenko