X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/6a43ef8e8508df7d732e639ec75f657f4363e27a..d7aff0d6929c16d15992304dd44c5f528df8f895:/nt/inc/sys/time.h diff --git a/nt/inc/sys/time.h b/nt/inc/sys/time.h dissimilarity index 64% index c90d1fd62f..f8fb022d22 100644 --- a/nt/inc/sys/time.h +++ b/nt/inc/sys/time.h @@ -1,24 +1,62 @@ -#ifndef SYS_TIME_H_INCLUDED -#define SYS_TIME_H_INCLUDED - -/* - * sys/time.h doesn't exist on NT - */ - -struct timeval - { - long tv_sec; /* seconds */ - long tv_usec; /* microseconds */ - }; -struct timezone - { - int tz_minuteswest; /* minutes west of Greenwich */ - int tz_dsttime; /* type of dst correction */ - }; - -void gettimeofday (struct timeval *, struct timezone *); - -#endif /* SYS_TIME_H_INCLUDED */ - -/* end of sys/time.h */ - +#ifndef SYS_TIME_H_INCLUDED +#define SYS_TIME_H_INCLUDED + +/* + * sys/time.h either doesn't exist on Windows, or doesn't necessarily + * have the below stuff. + */ + +/* The guards are for MinGW64, which defines these structs on its + system headers which are included by ms-w32.h. */ +/* Allow inclusion of sys/time.h and winsock2.h in any order. Needed + for running the configure test, which is only relevant to MinGW. */ +#ifndef _TIMEVAL_DEFINED +#define _TIMEVAL_DEFINED +struct timeval +{ + long tv_sec; /* seconds */ + long tv_usec; /* microseconds */ +}; +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#define timercmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec != (uvp)->tv_sec) ? \ + ((tvp)->tv_sec cmp (uvp)->tv_sec) : \ + ((tvp)->tv_usec cmp (uvp)->tv_usec)) +#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 +#endif /* _TIMEVAL_DEFINED */ + +#ifndef _TIMEZONE_DEFINED +#define _TIMEZONE_DEFINED +struct timezone +{ + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; +#endif + + +/* This needs to be compatible with Posix signature, in order to pass + the configure test for the type of the second argument; see + m4/gettimeofday.m4. We use '__restrict' here, rather than + 'restrict', for the benefit of the old nt/configure.bat build, + which does not force the use of -std= switch to GCC, and that + causes compilation errors with 'restrict', which is a C99 + extension. */ +int gettimeofday (struct timeval *__restrict, struct timezone *__restrict); + +#define ITIMER_REAL 0 +#define ITIMER_PROF 1 + +struct itimerval +{ + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +int getitimer (int, struct itimerval *); +int setitimer (int, struct itimerval *, struct itimerval *); + +#endif /* SYS_TIME_H_INCLUDED */ + +/* end of sys/time.h */ +