+++ /dev/null
-/** @file\r
- System-specific declarations and macros related to time.\r
-\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.\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
- Copyright (c) 1982, 1986, 1993\r
- The Regents of the University of California. All rights reserved.\r
-\r
- Redistribution and use in source and binary forms, with or without\r
- modification, are permitted provided that the following conditions\r
- are met:\r
- 1. Redistributions of source code must retain the above copyright\r
- notice, this list of conditions and the following disclaimer.\r
- 2. Redistributions in binary form must reproduce the above copyright\r
- notice, this list of conditions and the following disclaimer in the\r
- documentation and/or other materials provided with the distribution.\r
- 3. Neither the name of the University nor the names of its contributors\r
- may be used to endorse or promote products derived from this software\r
- without specific prior written permission.\r
-\r
- THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- SUCH DAMAGE.\r
-\r
- time.h 8.5 (Berkeley) 5/4/95\r
- NetBSD: time.h,v 1.56 2006/06/18 21:09:24 uwe Exp\r
- */\r
-#ifndef _SYS_TIME_H_\r
-#define _SYS_TIME_H_\r
-\r
-#include <Uefi.h>\r
-#include <sys/featuretest.h>\r
-#include <sys/types.h>\r
-\r
-/*\r
- * Traditional *nix structure returned by gettimeofday(2) system call,\r
- * and used in other calls.\r
- */\r
-struct timeval {\r
- LONG32 tv_sec; /* seconds */\r
- LONG32 tv_usec; /* and microseconds */\r
-};\r
-\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
- */\r
-struct timespec {\r
- time_t tv_sec; /* seconds */\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
-} while (/*CONSTCOND*/0)\r
-\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 = (tvp)->tv_usec + (uvp)->tv_usec; \\r
- if ((vvp)->tv_usec >= 1000000) { \\r
- (vvp)->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
- (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \\r
- if ((vvp)->tv_usec < 0) { \\r
- (vvp)->tv_sec--; \\r
- (vvp)->tv_usec += 1000000; \\r
- } \\r
- } while (/* CONSTCOND */ 0)\r
-\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 = (tsp)->tv_nsec + (usp)->tv_nsec; \\r
- if ((vsp)->tv_nsec >= 1000000000L) { \\r
- (vsp)->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
- (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \\r
- if ((vsp)->tv_nsec < 0) { \\r
- (vsp)->tv_sec--; \\r
- (vsp)->tv_nsec += 1000000000L; \\r
- } \\r
- } while (/* CONSTCOND */ 0)\r
-\r
-/*\r
- * Names of the interval timers, and structure\r
- * defining a timer setting.\r
- */\r
-#define ITIMER_REAL 0\r
-#define ITIMER_VIRTUAL 1\r
-#define ITIMER_PROF 2\r
-\r
-struct itimerval {\r
- struct timeval it_interval; /* timer interval */\r
- struct timeval it_value; /* current value */\r
-};\r
-\r
-/*\r
- * Structure defined by POSIX.1b to be like a itimerval, but with\r
- * timespecs. Used in the timer_*() system calls.\r
- */\r
-struct itimerspec {\r
- struct timespec it_interval;\r
- struct timespec it_value;\r
-};\r
-\r
-#define CLOCK_REALTIME 0\r
-#define CLOCK_VIRTUAL 1\r
-#define CLOCK_PROF 2\r
-#define CLOCK_MONOTONIC 3\r
-\r
-#define TIMER_RELTIME 0x0 /* relative timer */\r
-#define TIMER_ABSTIME 0x1 /* absolute timer */\r
-\r
-#if 0\r
- #if (_POSIX_C_SOURCE - 0) >= 200112L || \\r
- (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \\r
- (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)\r
- #include <sys/select.h>\r
- #endif\r
-#endif /* if 0 */\r
-\r
-#include <sys/EfiCdefs.h>\r
-#include <time.h>\r
-\r
-/* Functions useful for dealing with EFI */\r
-__BEGIN_DECLS\r
-\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
-#endif /* !_SYS_TIME_H_ */\r