VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/time/timesupref.cpp@ 54202

Last change on this file since 54202 was 54202, checked in by vboxsync, 10 years ago

IPRT,TM: Implemented GIP TSC delta processing in the RTTimeNanoTS code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.5 KB
Line 
1/* $Id: timesupref.cpp 54202 2015-02-13 17:13:44Z vboxsync $ */
2/** @file
3 * IPRT - Time using SUPLib, the C Implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2015 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#if !defined(IN_GUEST) && !defined(RT_NO_GIP)
28
29/*******************************************************************************
30* Header Files *
31*******************************************************************************/
32#include <iprt/time.h>
33#include "internal/iprt.h"
34
35#include <iprt/asm.h>
36#include <iprt/asm-math.h>
37#include <iprt/asm-amd64-x86.h>
38#include <VBox/sup.h>
39#include "internal/time.h"
40
41
42#define GIP_MODE_SYNC_NO_DELTA 1
43#define GIP_MODE_SYNC_WITH_DELTA 2
44#define GIP_MODE_ASYNC 3
45#define GIP_MODE_INVARIANT_NO_DELTA 4
46#define GIP_MODE_INVARIANT_WITH_DELTA 5
47#define IS_GIP_MODE_WITH_DELTA(a_enmMode) \
48 ((a_enmMode) == GIP_MODE_SYNC_WITH_DELTA || (a_enmMode) == GIP_MODE_INVARIANT_WITH_DELTA)
49
50
51/*
52 * Use the CPUID instruction for some kind of serialization.
53 */
54#define GIP_MODE GIP_MODE_SYNC_NO_DELTA
55#undef USE_LFENCE
56#define NEED_TRANSACTION_ID
57#define rtTimeNanoTSInternalRef RTTimeNanoTSLegacySyncNoDelta
58#include "timesupref.h"
59RT_EXPORT_SYMBOL(RTTimeNanoTSLegacySyncNoDelta);
60
61#undef GIP_MODE
62#define GIP_MODE GIP_MODE_SYNC_NO_DELTA
63#undef rtTimeNanoTSInternalRef
64#define rtTimeNanoTSInternalRef RTTimeNanoTSLegacySyncWithDelta
65#include "timesupref.h"
66RT_EXPORT_SYMBOL(RTTimeNanoTSLegacySyncWithDelta);
67
68#undef GIP_MODE
69#define GIP_MODE GIP_MODE_ASYNC
70#ifdef IN_RC
71# undef NEED_TRANSACTION_ID
72#endif
73#undef rtTimeNanoTSInternalRef
74#define rtTimeNanoTSInternalRef RTTimeNanoTSLegacyAsync
75#include "timesupref.h"
76RT_EXPORT_SYMBOL(RTTimeNanoTSLegacyAsync);
77
78#undef GIP_MODE
79#define GIP_MODE GIP_MODE_INVARIANT_NO_DELTA
80#undef NEED_TRANSACTION_ID
81#define NEED_TRANSACTION_ID
82#undef rtTimeNanoTSInternalRef
83#define rtTimeNanoTSInternalRef RTTimeNanoTSLegacyInvariantNoDelta
84#include "timesupref.h"
85RT_EXPORT_SYMBOL(RTTimeNanoTSLegacyInvariantNoDelta);
86
87#undef GIP_MODE
88#define GIP_MODE GIP_MODE_INVARIANT_WITH_DELTA
89#undef rtTimeNanoTSInternalRef
90#define rtTimeNanoTSInternalRef RTTimeNanoTSLegacyInvariantWithDelta
91#include "timesupref.h"
92RT_EXPORT_SYMBOL(RTTimeNanoTSLegacyInvariantWithDelta);
93
94
95/*
96 * Use LFENCE for load serialization.
97 */
98#undef GIP_MODE
99#define GIP_MODE GIP_MODE_SYNC_NO_DELTA
100#define USE_LFENCE
101#undef NEED_TRANSACTION_ID
102#define NEED_TRANSACTION_ID
103#undef rtTimeNanoTSInternalRef
104#define rtTimeNanoTSInternalRef RTTimeNanoTSLFenceSyncNoDelta
105#include "timesupref.h"
106RT_EXPORT_SYMBOL(RTTimeNanoTSLFenceSyncNoDelta);
107
108#undef GIP_MODE
109#define GIP_MODE GIP_MODE_SYNC_WITH_DELTA
110#undef rtTimeNanoTSInternalRef
111#define rtTimeNanoTSInternalRef RTTimeNanoTSLFenceSyncWithDelta
112#include "timesupref.h"
113RT_EXPORT_SYMBOL(RTTimeNanoTSLFenceSyncWithDelta);
114
115#undef GIP_MODE
116#define GIP_MODE GIP_MODE_ASYNC
117#ifdef IN_RC
118# undef NEED_TRANSACTION_ID
119#endif
120#undef rtTimeNanoTSInternalRef
121#define rtTimeNanoTSInternalRef RTTimeNanoTSLFenceAsync
122#include "timesupref.h"
123RT_EXPORT_SYMBOL(RTTimeNanoTSLFenceAsync);
124
125#undef GIP_MODE
126#define GIP_MODE GIP_MODE_INVARIANT_NO_DELTA
127#undef NEED_TRANSACTION_ID
128#define NEED_TRANSACTION_ID
129#undef rtTimeNanoTSInternalRef
130#define rtTimeNanoTSInternalRef RTTimeNanoTSLFenceInvariantNoDelta
131#include "timesupref.h"
132RT_EXPORT_SYMBOL(RTTimeNanoTSLFenceInvariantNoDelta);
133
134#undef GIP_MODE
135#define GIP_MODE GIP_MODE_INVARIANT_WITH_DELTA
136#undef rtTimeNanoTSInternalRef
137#define rtTimeNanoTSInternalRef RTTimeNanoTSLFenceInvariantWithDelta
138#include "timesupref.h"
139RT_EXPORT_SYMBOL(RTTimeNanoTSLFenceInvariantWithDelta);
140
141
142#endif /* !IN_GUEST && !RT_NO_GIP */
143
Note: See TracBrowser for help on using the repository browser.

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