]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Time/Time.c
StdLib: Eliminate TimerLib dependencies.
[mirror_edk2.git] / StdLib / LibC / Time / Time.c
index 5cb93477526778a7ee395963fef841e7f75f5c0e..0296a5dc93910871cd3d10e2382fbed2168016e7 100644 (file)
@@ -82,7 +82,6 @@ static void
 localsub(const time_t * const timep, const long   offset, struct tm * const tmp);\r
 \r
 clock_t\r
-EFIAPI\r
 __getCPS(void)\r
 {\r
   return gMD->ClocksPerSecond;\r
@@ -181,39 +180,9 @@ timesub(
 \r
 /* ###############  Time Manipulation Functions  ########################## */\r
 \r
-/** The clock function determines the processor time used.\r
-\r
-    @return   The clock function returns the implementation\92s best\r
-              approximation to the processor time used by the program since the\r
-              beginning of an implementation-defined era related only to the\r
-              program invocation.  To determine the time in seconds, the value\r
-              returned by the clock function should be divided by the value of\r
-              the macro CLOCKS_PER_SEC.  If the processor time used is not\r
-              available or its value cannot be represented, the function\r
-              returns the value (clock_t)(-1).\r
-\r
-              On IA32 or X64 platforms, the value returned is the number of\r
-              CPU TimeStamp Counter ticks since the appliation started.\r
-**/\r
-clock_t\r
-EFIAPI\r
-clock(void)\r
-{\r
-#ifndef NT32dvm\r
-  clock_t   temp;\r
-\r
-  temp = (clock_t)GetPerformanceCounter();\r
-\r
-  return temp - gMD->AppStartTime;\r
-#else\r
-  return (clock_t)-1;\r
-#endif  /* NT32dvm */\r
-}\r
-\r
 /**\r
 **/\r
 double\r
-EFIAPI\r
 difftime(time_t time1, time_t time0)\r
 {\r
   return (double)(time1 - time0);\r
@@ -429,7 +398,7 @@ time2sub(
   return t;\r
 }\r
 \r
-static time_t\r
+time_t\r
 time2(struct tm * const tmp, void (* const funcp)(const time_t*, long, struct tm*),\r
       const long offset, int * const okayp)\r
 {\r
@@ -542,7 +511,6 @@ time1(
               represented, the function returns the value (time_t)(-1).\r
 **/\r
 time_t\r
-EFIAPI\r
 mktime(struct tm *timeptr)\r
 {\r
   /* From NetBSD */\r
@@ -558,14 +526,13 @@ mktime(struct tm *timeptr)
 /** The time function determines the current calendar time.  The encoding of\r
     the value is unspecified.\r
 \r
-    @return   The time function returns the implementation\92s best approximation\r
+    @return   The time function returns the implementation's best approximation\r
               to the current calendar time.  The value (time_t)(-1) is returned\r
               if the calendar time is not available.  If timer is not a null\r
               pointer, the return value is also assigned to the object it\r
               points to.\r
 **/\r
 time_t\r
-EFIAPI\r
 time(time_t *timer)\r
 {\r
   time_t      CalTime;\r
@@ -596,6 +563,28 @@ time(time_t *timer)
   return CalTime;   // Return calendar time in microseconds\r
 }\r
 \r
+/** The clock function determines the processor time used.\r
+\r
+    @return   The clock function returns the implementation's best\r
+              approximation to the processor time used by the program since the\r
+              beginning of an implementation-defined era related only to the\r
+              program invocation.  To determine the time in seconds, the value\r
+              returned by the clock function should be divided by the value of\r
+              the macro CLOCKS_PER_SEC.  If the processor time used is not\r
+              available or its value cannot be represented, the function\r
+              returns the value (clock_t)(-1).\r
+**/\r
+clock_t\r
+clock(void)\r
+{\r
+  clock_t   retval;\r
+  time_t    temp;\r
+\r
+  temp = time(NULL);\r
+  retval = ((clock_t)((UINT32)temp)) - gMD->AppStartTime;\r
+  return retval;\r
+}\r
+\r
 /* #################  Time Conversion Functions  ########################## */\r
 /*\r
     Except for the strftime function, these functions each return a pointer to\r
@@ -633,7 +622,6 @@ time(time_t *timer)
     @return   The asctime function returns a pointer to the string.\r
 **/\r
 char *\r
-EFIAPI\r
 asctime(const struct tm *timeptr)\r
 {\r
   register const char * wn;\r
@@ -663,7 +651,6 @@ asctime(const struct tm *timeptr)
 /**\r
 **/\r
 char *\r
-EFIAPI\r
 ctime(const time_t *timer)\r
 {\r
   return asctime(localtime(timer));\r
@@ -672,7 +659,7 @@ ctime(const time_t *timer)
 /*\r
 ** gmtsub is to gmtime as localsub is to localtime.\r
 */\r
-static void\r
+void\r
 gmtsub(\r
   const time_t * const  timep,\r
   const long            offset,\r
@@ -718,7 +705,6 @@ gmtsub(
 /**\r
 **/\r
 struct tm *\r
-EFIAPI\r
 gmtime(const time_t *timer)\r
 {\r
   gmtsub(timer, 0L, &gMD->BDTime);\r
@@ -771,7 +757,6 @@ localsub(const time_t * const timep, const long   offset, struct tm * const tmp)
 /**\r
 **/\r
 struct tm *\r
-EFIAPI\r
 localtime(const time_t *timer)\r
 {\r
   tzset();\r