public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Lin, Derek (HPS SW)" <derek.lin2@hpe.com>
To: derek.lin2@hpe.com, devel@edk2.groups.io
Cc: kitty.chen@hpe.com, jordan.l.justen@intel.com, afish@apple.com,
	ray.ni@intel.com
Subject: [PATCH] EmulatorPkg: Implement QueryPerformanceCounter()
Date: Wed, 18 Dec 2019 11:32:41 +0800	[thread overview]
Message-ID: <20191218033241.372320-1-derek.lin2@hpe.com> (raw)

Implement QueryPerformanceCounter() for Emulator on both Unix and Windows.

Signed-off-by: Derek Lin <derek.lin2@hpe.com>
Signed-off-by: Kitty Chen <kitty.chen@hpe.com>
---
 EmulatorPkg/Unix/Host/EmuThunk.c | 6 ++++--
 EmulatorPkg/Win/Host/WinThunk.c  | 7 ++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/EmulatorPkg/Unix/Host/EmuThunk.c b/EmulatorPkg/Unix/Host/EmuThunk.c
index 1e9dc99187..4fd7b3d093 100644
--- a/EmulatorPkg/Unix/Host/EmuThunk.c
+++ b/EmulatorPkg/Unix/Host/EmuThunk.c
@@ -274,8 +274,10 @@ QueryPerformanceCounter (
 
   return (Start * sTimebaseInfo.numer) / sTimebaseInfo.denom;
 #else
-  // Need to figure out what to do for Linux?
-  return 0;
+  int status;
+  struct timespec time;
+  status = clock_gettime(CLOCK_REALTIME, &time);
+  return time.tv_nsec;
 #endif
 }
 
diff --git a/EmulatorPkg/Win/Host/WinThunk.c b/EmulatorPkg/Win/Host/WinThunk.c
index a77be2a64b..a1f8870e27 100644
--- a/EmulatorPkg/Win/Host/WinThunk.c
+++ b/EmulatorPkg/Win/Host/WinThunk.c
@@ -447,7 +447,12 @@ SecQueryPerformanceCounter (
   VOID
   )
 {
-  return 0;
+  UINT64 PerformanceCount;
+
+  PerformanceCount = 0;
+  QueryPerformanceCounter ((LARGE_INTEGER *) &PerformanceCount);
+
+  return PerformanceCount;
 }
 
 
-- 
2.20.1.windows.1


                 reply	other threads:[~2019-12-18  3:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191218033241.372320-1-derek.lin2@hpe.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox