From 8aa163da5ac7bf40d1a3b0612a46504dc56d16a2 Mon Sep 17 00:00:00 2001 From: darylm503 Date: Fri, 11 Nov 2011 00:32:31 +0000 Subject: 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 --- StdLib/LibC/LibC.inf | 1 - StdLib/LibC/Main/Main.c | 12 ++++-------- StdLib/LibC/Time/Time.c | 50 +++++++++++++++++++++-------------------------- StdLib/LibC/Time/Time.inf | 1 - 4 files changed, 26 insertions(+), 38 deletions(-) (limited to 'StdLib/LibC') 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 #include #include +#include #include -#include +#include 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 -- cgit v1.2.3