1 | /* $Id: time-r0drv-solaris.c 4179 2007-08-16 15:08:07Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * innotek Portable Runtime - Time, Ring-0 Driver, Solaris.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | /*******************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *******************************************************************************/
|
---|
22 | #include "the-solaris-kernel.h"
|
---|
23 | #define RTTIME_INCL_TIMESPEC
|
---|
24 |
|
---|
25 | #include <iprt/time.h>
|
---|
26 |
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Gets the current nanosecond timestamp.
|
---|
30 | *
|
---|
31 | * @returns nanosecond timestamp.
|
---|
32 | */
|
---|
33 | RTDECL(uint64_t) RTTimeNanoTS(void)
|
---|
34 | {
|
---|
35 | return gethrtime();
|
---|
36 | }
|
---|
37 |
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Gets the current millisecond timestamp.
|
---|
41 | *
|
---|
42 | * @returns millisecond timestamp.
|
---|
43 | */
|
---|
44 | RTDECL(uint64_t) RTTimeMilliTS(void)
|
---|
45 | {
|
---|
46 | return RTTimeNanoTS() / 1000;
|
---|
47 | }
|
---|
48 |
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Gets the current nanosecond timestamp.
|
---|
52 | *
|
---|
53 | * This differs from RTTimeNanoTS in that it will use system APIs and not do any
|
---|
54 | * resolution or performance optimizations.
|
---|
55 | *
|
---|
56 | * @returns nanosecond timestamp.
|
---|
57 | */
|
---|
58 | RTDECL(uint64_t) RTTimeSystemNanoTS(void)
|
---|
59 | {
|
---|
60 | return RTTimeNanoTS();
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Gets the current millisecond timestamp.
|
---|
66 | *
|
---|
67 | * This differs from RTTimeNanoTS in that it will use system APIs and not do any
|
---|
68 | * resolution or performance optimizations.
|
---|
69 | *
|
---|
70 | * @returns millisecond timestamp.
|
---|
71 | */
|
---|
72 | RTDECL(uint64_t) RTTimeSystemMilliTS(void)
|
---|
73 | {
|
---|
74 | return RTTimeMilliTS();
|
---|
75 | }
|
---|
76 |
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Gets the current system time.
|
---|
80 | *
|
---|
81 | * @returns pTime.
|
---|
82 | * @param pTime Where to store the time.
|
---|
83 | */
|
---|
84 | RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
|
---|
85 | {
|
---|
86 | /* timestruc_t is actually just a typedef struct timespec */
|
---|
87 | timestruc_t tv = tod_get();
|
---|
88 | return RTTimeSpecSetNano(pTime, (uint64_t)tv.tv_sec * 1000000000 + tv.tv_nsec);
|
---|
89 | }
|
---|