VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/os2/time-r0drv-os2.cpp@ 78365

Last change on this file since 78365 was 77120, checked in by vboxsync, 6 years ago

IPRT: Some license header cleanups.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.0 KB
Line 
1/* $Id: time-r0drv-os2.cpp 77120 2019-02-01 15:08:46Z vboxsync $ */
2/** @file
3 * IPRT - Time, Ring-0 Driver, OS/2.
4 */
5
6/*
7 * Contributed by knut st. osmundsen.
8 *
9 * Copyright (C) 2007-2019 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * The contents of this file may alternatively be used under the terms
20 * of the Common Development and Distribution License Version 1.0
21 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
22 * VirtualBox OSE distribution, in which case the provisions of the
23 * CDDL are applicable instead of those of the GPL.
24 *
25 * You may elect to license modified versions of this file under the
26 * terms and conditions of either the GPL or the CDDL or both.
27 *
28 * --------------------------------------------------------------------
29 *
30 * This code is based on:
31 *
32 * Copyright (c) 2007 knut st. osmundsen <[email protected]>
33 *
34 * Permission is hereby granted, free of charge, to any person
35 * obtaining a copy of this software and associated documentation
36 * files (the "Software"), to deal in the Software without
37 * restriction, including without limitation the rights to use,
38 * copy, modify, merge, publish, distribute, sublicense, and/or sell
39 * copies of the Software, and to permit persons to whom the
40 * Software is furnished to do so, subject to the following
41 * conditions:
42 *
43 * The above copyright notice and this permission notice shall be
44 * included in all copies or substantial portions of the Software.
45 *
46 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
47 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
48 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
49 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
50 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
51 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
52 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
53 * OTHER DEALINGS IN THE SOFTWARE.
54 */
55
56
57/*********************************************************************************************************************************
58* Header Files *
59*********************************************************************************************************************************/
60#include "the-os2-kernel.h"
61
62#include <iprt/time.h>
63
64
65RTDECL(uint64_t) RTTimeNanoTS(void)
66{
67 /** @remark OS/2 Ring-0: will wrap after 48 days. */
68 return g_pGIS->msecs * UINT64_C(1000000);
69}
70
71
72RTDECL(uint64_t) RTTimeMilliTS(void)
73{
74 /** @remark OS/2 Ring-0: will wrap after 48 days. */
75 return g_pGIS->msecs;
76}
77
78
79RTDECL(uint64_t) RTTimeSystemNanoTS(void)
80{
81 /** @remark OS/2 Ring-0: will wrap after 48 days. */
82 return g_pGIS->msecs * UINT64_C(1000000);
83}
84
85
86RTDECL(uint64_t) RTTimeSystemMilliTS(void)
87{
88 /** @remark OS/2 Ring-0: will wrap after 48 days. */
89 return g_pGIS->msecs;
90}
91
92
93RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
94{
95 /*
96 * Get the seconds since the unix epoch (local time) and current hundredths.
97 */
98 GINFOSEG volatile *pGIS = (GINFOSEG volatile *)g_pGIS;
99 UCHAR uchHundredths;
100 ULONG ulSeconds;
101 do
102 {
103 uchHundredths = pGIS->hundredths;
104 ulSeconds = pGIS->time;
105 } while ( uchHundredths == pGIS->hundredths
106 && ulSeconds == pGIS->time);
107
108 /*
109 * Combine the two and convert to UCT (later).
110 */
111 uint64_t u64 = ulSeconds * UINT64_C(1000000000) + (uint32_t)uchHundredths * 10000000;
112 /** @todo convert from local to UCT. */
113
114 /** @remark OS/2 Ring-0: Currently returns local time instead of UCT. */
115 return RTTimeSpecSetNano(pTime, u64);
116}
117
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette