1/* time.h -- An implementation of the standard Unix <sys/time.h> file. 2 Written by Geoffrey Noer <noer@cygnus.com> 3 Public domain; no rights reserved. */ 4 5#ifndef _SYS_TIME_H_ 6#define _SYS_TIME_H_ 7 8#include <_ansi.h> 9#include <sys/types.h> 10 11#ifdef __cplusplus 12extern "C" { 13#endif 14 15#ifndef _WINSOCK_H 16#define _TIMEVAL_DEFINED 17struct timeval { 18 time_t tv_sec; 19 suseconds_t tv_usec; 20}; 21 22struct timezone { 23 int tz_minuteswest; 24 int tz_dsttime; 25}; 26 27#ifdef __CYGWIN__ 28#include <cygwin/sys_time.h> 29#endif /* __CYGWIN__ */ 30 31#endif /* _WINSOCK_H */ 32 33#define ITIMER_REAL 0 34#define ITIMER_VIRTUAL 1 35#define ITIMER_PROF 2 36 37struct itimerval { 38 struct timeval it_interval; 39 struct timeval it_value; 40}; 41 42/* BSD time macros used by RTEMS code */ 43#if defined (__rtems__) || defined (__CYGWIN__) 44 45/* Convenience macros for operations on timevals. 46 NOTE: `timercmp' does not work for >= or <=. */ 47#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) 48#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) 49#define timercmp(a, b, CMP) \ 50 (((a)->tv_sec == (b)->tv_sec) ? \ 51 ((a)->tv_usec CMP (b)->tv_usec) : \ 52 ((a)->tv_sec CMP (b)->tv_sec)) 53#define timeradd(a, b, result) \ 54 do { \ 55 (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ 56 (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ 57 if ((result)->tv_usec >= 1000000) \ 58 { \ 59 ++(result)->tv_sec; \ 60 (result)->tv_usec -= 1000000; \ 61 } \ 62 } while (0) 63#define timersub(a, b, result) \ 64 do { \ 65 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ 66 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ 67 if ((result)->tv_usec < 0) { \ 68 --(result)->tv_sec; \ 69 (result)->tv_usec += 1000000; \ 70 } \ 71 } while (0) 72#endif /* defined (__rtems__) || defined (__CYGWIN__) */ 73 74int _EXFUN(gettimeofday, (struct timeval *__p, void *__tz)); 75int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *)); 76int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp)); 77int _EXFUN(getitimer, (int __which, struct itimerval *__value)); 78int _EXFUN(setitimer, (int __which, const struct itimerval *__value, 79 struct itimerval *__ovalue)); 80 81#ifdef __cplusplus 82} 83#endif 84#endif /* _SYS_TIME_H_ */ 85