/** @file\r
System-specific declarations and macros related to time.\r
\r
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials are licensed and made available under\r
the terms and conditions of the BSD License that accompanies this distribution.\r
The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php.\r
+ http://opensource.org/licenses/bsd-license.\r
\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
/*\r
* Structure defined by POSIX.1b to be like a timeval.\r
* This works within EFI since the times really are time_t.\r
- * Note that this is not exactly POSIX compliant since tv_nsec\r
- * is a UINT32 instead of the compliant long.\r
*/\r
struct timespec {\r
time_t tv_sec; /* seconds */\r
- UINT32 tv_nsec; /* and nanoseconds */\r
+ LONG32 tv_nsec; /* and nanoseconds */\r
};\r
\r
#define TIMEVAL_TO_TIMESPEC(tv, ts) do { \\r
(ts)->tv_sec = (tv)->tv_sec; \\r
(ts)->tv_nsec = (tv)->tv_usec * 1000; \\r
} while (/*CONSTCOND*/0)\r
+\r
#define TIMESPEC_TO_TIMEVAL(tv, ts) do { \\r
(tv)->tv_sec = (ts)->tv_sec; \\r
(tv)->tv_usec = (ts)->tv_nsec / 1000; \\r
/* Operations on timevals. */\r
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0\r
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)\r
+\r
#define timercmp(tvp, uvp, cmp) \\r
(((tvp)->tv_sec == (uvp)->tv_sec) ? \\r
((tvp)->tv_usec cmp (uvp)->tv_usec) : \\r
((tvp)->tv_sec cmp (uvp)->tv_sec))\r
+\r
#define timeradd(tvp, uvp, vvp) \\r
do { \\r
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \\r
(vvp)->tv_usec -= 1000000; \\r
} \\r
} while (/* CONSTCOND */ 0)\r
+\r
#define timersub(tvp, uvp, vvp) \\r
do { \\r
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \\r
/* Operations on timespecs. */\r
#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0\r
#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec)\r
+\r
#define timespeccmp(tsp, usp, cmp) \\r
(((tsp)->tv_sec == (usp)->tv_sec) ? \\r
((tsp)->tv_nsec cmp (usp)->tv_nsec) : \\r
((tsp)->tv_sec cmp (usp)->tv_sec))\r
+\r
#define timespecadd(tsp, usp, vsp) \\r
do { \\r
(vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \\r
(vsp)->tv_nsec -= 1000000000L; \\r
} \\r
} while (/* CONSTCOND */ 0)\r
+\r
#define timespecsub(tsp, usp, vsp) \\r
do { \\r
(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \\r
/* Convert an EFI_TIME structure into a time_t value. */\r
time_t Efi2Time( EFI_TIME *EfiBDtime);\r
\r
+/* Convert a time_t value into an EFI_TIME structure.\r
+ It is the caller's responsibility to free the returned structure.\r
+*/\r
+EFI_TIME * Time2Efi(time_t OTime);\r
+\r
/* Convert an EFI_TIME structure into a C Standard tm structure. */\r
void Efi2Tm( EFI_TIME *EfiBDtime, struct tm *NewTime);\r
+void Tm2Efi( struct tm *BdTime, EFI_TIME *ETime);\r
+\r
+/* BSD compatibility functions */\r
+int gettimeofday (struct timeval *tp, void *ignore);\r
+/* POSIX compatibility functions */\r
+int getitimer (int which, struct itimerval *value);\r
+int setitimer (int which, const struct itimerval *value, struct itimerval *ovalue);\r
\r
__END_DECLS\r
\r