Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1423 from redstar/solaristime
Browse files Browse the repository at this point in the history
Add clock definitions for Solaris.
  • Loading branch information
dnadlinger committed Nov 1, 2015
2 parents 65d7368 + 946e0f4 commit 758be31
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 3 deletions.
1 change: 1 addition & 0 deletions mak/COPY
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ COPY=\
$(IMPDIR)\core\sys\solaris\execinfo.d \
$(IMPDIR)\core\sys\solaris\libelf.d \
$(IMPDIR)\core\sys\solaris\link.d \
$(IMPDIR)\core\sys\solaris\time.d \
$(IMPDIR)\core\sys\solaris\sys\elf.d \
$(IMPDIR)\core\sys\solaris\sys\elf_386.d \
$(IMPDIR)\core\sys\solaris\sys\elf_amd64.d \
Expand Down
1 change: 1 addition & 0 deletions mak/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ MANIFEST=\
src\core\sys\solaris\execinfo.d \
src\core\sys\solaris\libelf.d \
src\core\sys\solaris\link.d \
src\core\sys\solaris\time.d \
\
src\core\sys\solaris\sys\elf.d \
src\core\sys\solaris\sys\elf_386.d \
Expand Down
5 changes: 4 additions & 1 deletion src/core/sys/posix/time.d
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,16 @@ else version( FreeBSD )
}
else version (Solaris)
{
enum CLOCK_PROCESS_CPUTIME_ID = 5; // <sys/time_impl.h>
enum CLOCK_THREAD_CPUTIME_ID = 2; // <sys/time_impl.h>

struct itimerspec
{
timespec it_interval;
timespec it_value;
}

enum CLOCK_REALTIME = 0; // <sys/time_impl.h>
enum CLOCK_REALTIME = 3; // <sys/time_impl.h>
enum TIMER_ABSOLUTE = 0x1;

alias int clockid_t;
Expand Down
18 changes: 18 additions & 0 deletions src/core/sys/solaris/time.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//Written in the D programming language

/++
D header file for Solaris's extensions to POSIX's time.h.
Copyright: Copyright 2014
License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: Kai Nacke
+/
module core.sys.solaris.time;

public import core.sys.posix.time;

version(Solaris):

enum CLOCK_VIRTUAL = 1;
enum CLOCK_HIGHRES = CLOCK_MONOTONIC;
enum CLOCK_PROF = CLOCK_THREAD_CPUTIME_ID;
26 changes: 24 additions & 2 deletions src/core/time.d
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ version(CoreDdoc) enum ClockType
precise = 3,

/++
$(BLUE Linux-Only)
$(BLUE Linux,Solaris-Only)
Uses $(D CLOCK_PROCESS_CPUTIME_ID).
+/
Expand Down Expand Up @@ -243,7 +243,7 @@ version(CoreDdoc) enum ClockType
second = 6,

/++
$(BLUE Linux-Only)
$(BLUE Linux,Solaris-Only)
Uses $(D CLOCK_THREAD_CPUTIME_ID).
+/
Expand Down Expand Up @@ -305,6 +305,15 @@ else version(FreeBSD) enum ClockType
uptimeCoarse = 9,
uptimePrecise = 10,
}
else version(Solaris) enum ClockType
{
normal = 0,
coarse = 2,
precise = 3,
processCPUTime = 4,
second = 6,
threadCPUTime = 7,
}
else
{
// It needs to be decided (and implemented in an appropriate version branch
Expand Down Expand Up @@ -351,6 +360,19 @@ version(Posix)
case second: assert(0);
}
}
else version(Solaris)
{
import core.sys.solaris.time;
with(ClockType) final switch(clockType)
{
case coarse: return CLOCK_MONOTONIC;
case normal: return CLOCK_MONOTONIC;
case precise: return CLOCK_MONOTONIC;
case processCPUTime: return CLOCK_PROCESS_CPUTIME_ID;
case threadCPUTime: return CLOCK_THREAD_CPUTIME_ID;
case second: assert(0);
}
}
else
// It needs to be decided (and implemented in an appropriate
// version branch here) which clock types new platforms are going
Expand Down
3 changes: 3 additions & 0 deletions win32.mak
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,9 @@ $(IMPDIR)\core\sys\solaris\libelf.d : src\core\sys\solaris\libelf.d
$(IMPDIR)\core\sys\solaris\link.d : src\core\sys\solaris\link.d
copy $** $@

$(IMPDIR)\core\sys\solaris\time.d : src\core\sys\solaris\time.d
copy $** $@

$(IMPDIR)\core\sys\solaris\sys\elf.d : src\core\sys\solaris\sys\elf.d
copy $** $@

Expand Down
3 changes: 3 additions & 0 deletions win64.mak
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,9 @@ $(IMPDIR)\core\sys\solaris\libelf.d : src\core\sys\solaris\libelf.d
$(IMPDIR)\core\sys\solaris\link.d : src\core\sys\solaris\link.d
copy $** $@

$(IMPDIR)\core\sys\solaris\time.d : src\core\sys\solaris\time.d
copy $** $@

$(IMPDIR)\core\sys\solaris\sys\elf.d : src\core\sys\solaris\sys\elf.d
copy $** $@

Expand Down

0 comments on commit 758be31

Please sign in to comment.