aboutsummaryrefslogtreecommitdiff
path: root/system/include/libc/sys/time.h
diff options
context:
space:
mode:
Diffstat (limited to 'system/include/libc/sys/time.h')
-rw-r--r--system/include/libc/sys/time.h108
1 files changed, 40 insertions, 68 deletions
diff --git a/system/include/libc/sys/time.h b/system/include/libc/sys/time.h
index 2bd2421e..3ce824e6 100644
--- a/system/include/libc/sys/time.h
+++ b/system/include/libc/sys/time.h
@@ -1,85 +1,57 @@
-/* time.h -- An implementation of the standard Unix <sys/time.h> file.
- Written by Geoffrey Noer <noer@cygnus.com>
- Public domain; no rights reserved. */
-
-#ifndef _SYS_TIME_H_
-#define _SYS_TIME_H_
-
-#include <_ansi.h>
-#include <sys/types.h>
-#include <time.h> /* XXX Emscripten */
-
+#ifndef _SYS_TIME_H
+#define _SYS_TIME_H
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef _WINSOCK_H
-#define _TIMEVAL_DEFINED
-struct timeval {
- time_t tv_sec;
- suseconds_t tv_usec;
-};
+#include <features.h>
-struct timezone {
- int tz_minuteswest;
- int tz_dsttime;
-};
+#include <sys/select.h>
-#ifdef __CYGWIN__
-#include <cygwin/sys_time.h>
-#endif /* __CYGWIN__ */
+int gettimeofday (struct timeval *__restrict, void *__restrict);
-#endif /* _WINSOCK_H */
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
-#define ITIMER_REAL 0
-#define ITIMER_VIRTUAL 1
-#define ITIMER_PROF 2
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
-struct itimerval {
- struct timeval it_interval;
- struct timeval it_value;
+struct itimerval
+{
+ struct timeval it_interval;
+ struct timeval it_value;
};
-/* BSD time macros used by RTEMS code */
-#if defined (__rtems__) || defined (__CYGWIN__) || defined (EMSCRIPTEN)
+int getitimer (int, struct itimerval *);
+int setitimer (int, const struct itimerval *__restrict, struct itimerval *__restrict);
+int utimes (const char *, const struct timeval [2]);
-/* Convenience macros for operations on timevals.
- NOTE: `timercmp' does not work for >= or <=. */
-#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
-#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
-#define timercmp(a, b, CMP) \
- (((a)->tv_sec == (b)->tv_sec) ? \
- ((a)->tv_usec CMP (b)->tv_usec) : \
- ((a)->tv_sec CMP (b)->tv_sec))
-#define timeradd(a, b, result) \
- do { \
- (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
- (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
- if ((result)->tv_usec >= 1000000) \
- { \
- ++(result)->tv_sec; \
- (result)->tv_usec -= 1000000; \
- } \
- } while (0)
-#define timersub(a, b, result) \
- do { \
- (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
- (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
- if ((result)->tv_usec < 0) { \
- --(result)->tv_sec; \
- (result)->tv_usec += 1000000; \
- } \
- } while (0)
-#endif /* defined (__rtems__) || defined (__CYGWIN__) */
+#endif
-int _EXFUN(gettimeofday, (struct timeval *__p, void *__tz));
-int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *));
-int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp));
-int _EXFUN(getitimer, (int __which, struct itimerval *__value));
-int _EXFUN(setitimer, (int __which, const struct itimerval *__value,
- struct itimerval *__ovalue));
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+struct timezone {
+ int tz_minuteswest;
+ int tz_dsttime;
+};
+int futimes(int, const struct timeval [2]);
+int futimesat(int, const char *, const struct timeval [2]);
+int lutimes(const char *, const struct timeval [2]);
+int settimeofday(const struct timeval *, const struct timezone *);
+int adjtime (const struct timeval *, struct timeval *);
+#define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
+#define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
+#define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \
+ (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec)
+#define timeradd(s,t,a) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
+ ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
+ ((a)->tv_usec -= 1000000, (a)->tv_sec++) )
+#define timersub(s,t,a) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
+ ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
+ ((a)->tv_usec += 1000000, (a)->tv_sec--) )
+#endif
#ifdef __cplusplus
}
#endif
-#endif /* _SYS_TIME_H_ */
+#endif