summaryrefslogtreecommitdiff
path: root/StdLib/LibC
diff options
context:
space:
mode:
authordarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-11 00:32:31 +0000
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-11 00:32:31 +0000
commit8aa163da5ac7bf40d1a3b0612a46504dc56d16a2 (patch)
tree35d16404b59494864d7d04da2c2f0ba9b2889a8b /StdLib/LibC
parent4b3d663f7b2f0db316f20c0ee86c7270c1338852 (diff)
downloadedk2-8aa163da5ac7bf40d1a3b0612a46504dc56d16a2.tar.gz
StdLib: Eliminate TimerLib dependencies.
Implement the clock() function using the EFI time-of-day clock instead of a TimerLib instance. Signed-off-by: darylm503 Reviewed-by: jljusten Reviewed-by: geekboy15a git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12683 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib/LibC')
-rw-r--r--StdLib/LibC/LibC.inf1
-rw-r--r--StdLib/LibC/Main/Main.c12
-rw-r--r--StdLib/LibC/Time/Time.c50
-rw-r--r--StdLib/LibC/Time/Time.inf1
4 files changed, 26 insertions, 38 deletions
diff --git a/StdLib/LibC/LibC.inf b/StdLib/LibC/LibC.inf
index 451b9b0e6..23647cb42 100644
--- a/StdLib/LibC/LibC.inf
+++ b/StdLib/LibC/LibC.inf
@@ -100,7 +100,6 @@
BaseLib
BaseMemoryLib
MemoryAllocationLib
- TimerLib
LibStdLib
LibStdio
LibString
diff --git a/StdLib/LibC/Main/Main.c b/StdLib/LibC/Main/Main.c
index 3a5cca5b2..59a72bd63 100644
--- a/StdLib/LibC/Main/Main.c
+++ b/StdLib/LibC/Main/Main.c
@@ -27,8 +27,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <MainData.h>
-#include <sys/EfiSysCall.h>
+#include <unistd.h>
extern int main( int, char**);
extern int __sse2_available;
@@ -149,13 +150,8 @@ ShellAppMain (
errno = 0;
EFIerrno = 0;
-#ifdef NT32dvm
- gMD->ClocksPerSecond = 1; // For NT32 only
- gMD->AppStartTime = 1; // For NT32 only
-#else
- gMD->ClocksPerSecond = (clock_t)GetPerformanceCounterProperties( NULL, NULL);
- gMD->AppStartTime = (clock_t)GetPerformanceCounter();
-#endif /* NT32 dvm */
+ gMD->ClocksPerSecond = 1;
+ gMD->AppStartTime = (clock_t)((UINT32)time(NULL));
// Initialize file descriptors
mfd = gMD->fdarray;
diff --git a/StdLib/LibC/Time/Time.c b/StdLib/LibC/Time/Time.c
index e3eccb593..0296a5dc9 100644
--- a/StdLib/LibC/Time/Time.c
+++ b/StdLib/LibC/Time/Time.c
@@ -180,34 +180,6 @@ timesub(
/* ############### Time Manipulation Functions ########################## */
-/** The clock function determines the processor time used.
-
- @return The clock function returns the implementation's best
- approximation to the processor time used by the program since the
- beginning of an implementation-defined era related only to the
- program invocation. To determine the time in seconds, the value
- returned by the clock function should be divided by the value of
- the macro CLOCKS_PER_SEC. If the processor time used is not
- available or its value cannot be represented, the function
- returns the value (clock_t)(-1).
-
- On IA32 or X64 platforms, the value returned is the number of
- CPU TimeStamp Counter ticks since the appliation started.
-**/
-clock_t
-clock(void)
-{
-#ifndef NT32dvm
- clock_t temp;
-
- temp = (clock_t)GetPerformanceCounter();
-
- return temp - gMD->AppStartTime;
-#else
- return (clock_t)-1;
-#endif /* NT32dvm */
-}
-
/**
**/
double
@@ -591,6 +563,28 @@ time(time_t *timer)
return CalTime; // Return calendar time in microseconds
}
+/** The clock function determines the processor time used.
+
+ @return The clock function returns the implementation's best
+ approximation to the processor time used by the program since the
+ beginning of an implementation-defined era related only to the
+ program invocation. To determine the time in seconds, the value
+ returned by the clock function should be divided by the value of
+ the macro CLOCKS_PER_SEC. If the processor time used is not
+ available or its value cannot be represented, the function
+ returns the value (clock_t)(-1).
+**/
+clock_t
+clock(void)
+{
+ clock_t retval;
+ time_t temp;
+
+ temp = time(NULL);
+ retval = ((clock_t)((UINT32)temp)) - gMD->AppStartTime;
+ return retval;
+}
+
/* ################# Time Conversion Functions ########################## */
/*
Except for the strftime function, these functions each return a pointer to
diff --git a/StdLib/LibC/Time/Time.inf b/StdLib/LibC/Time/Time.inf
index 3ad226951..84a47048e 100644
--- a/StdLib/LibC/Time/Time.inf
+++ b/StdLib/LibC/Time/Time.inf
@@ -43,7 +43,6 @@
[LibraryClasses]
UefiLib
- TimerLib
BaseLib
UefiRuntimeServicesTableLib