haiku/headers/posix/sys/time.h
Oliver Tappe 7e965f506d More consolidation of timezone code:
* dropped DaylightSavingTime from real_time_clock code in kernel, it was
  never really being used for what it meant (and just being referred to by
  gettimeofday(), which put a different meaning to it
* adjusted the syscalls get_timezone() & set_timezone() as well as their callers 
  accordingly
* got rid of get_rtc_info() and rtc_info struct in kernel, as it was only
  being referred to by the FAT add-on and that one (like gettimeofday()) put a
  different meaning to tz_minuteswest. Added a comment to FAT's util.c
  showing a possible solution, should the hardcoded GMT timezone pose a problem.
* fixed declaration of gettimeofday() to match POSIX base specs, issue 7
* changed implementation of gettimeofday() to not bother trying to fill struct
  timezone - it was using wrong values before, anyway.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37888 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-03 23:02:57 +00:00

77 lines
1.9 KiB
C

#ifndef _SYS_TIME_H
#define _SYS_TIME_H
/*
** Distributed under the terms of the OpenBeOS License.
*/
#include <sys/types.h>
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
#include <sys/select.h>
/* circular dependency: fd_set needs to be defined and the
* select prototype exported by this file, but <sys/select.h>
* needs struct timeval.
*/
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
struct itimerval {
struct timeval it_interval;
struct timeval it_value;
};
#define ITIMER_REAL 1 /* real time */
#define ITIMER_VIRTUAL 2 /* process virtual time */
#define ITIMER_PROF 3 /* both */
#ifdef __cplusplus
extern "C" {
#endif
extern int getitimer(int which, struct itimerval *value);
extern int setitimer(int which, const struct itimerval *value, struct itimerval *oldValue);
extern int gettimeofday(struct timeval *tv, void *tz);
extern int utimes(const char *name, const struct timeval times[2]);
/* legacy */
#ifdef __cplusplus
}
#endif
/* BSDish macros operating on timeval structs */
#define timeradd(a, b, res) \
do { \
(res)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
(res)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
if ((res)->tv_usec >= 1000000) { \
(res)->tv_usec -= 1000000; \
(res)->tv_sec++; \
} \
} while (0)
#define timersub(a, b, res) \
do { \
(res)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(res)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((res)->tv_usec < 0) { \
(res)->tv_usec += 1000000; \
(res)->tv_sec--; \
} \
} while (0)
#define timerclear(a) ((a)->tv_sec = (a)->tv_usec = 0)
#define timerisset(a) ((a)->tv_sec != 0 || (a)->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)
#endif /* _SYS_TIME_H */