Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Solaris time unittest fix: unimplemented clock types checking added. #78

Open
wants to merge 1 commit into
base: ldc
Choose a base branch
from
Open

Solaris time unittest fix: unimplemented clock types checking added. #78

wants to merge 1 commit into from

Conversation

nykytenko
Copy link

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

@smolt
Copy link
Member

smolt commented Jun 24, 2016

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

@nykytenko
Copy link
Author

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.

@kinke
Copy link
Member

kinke commented Jul 2, 2016

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

@nykytenko
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants