2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)timedefs.h 1.13 05/08/22 Copyright 1996 J. Schilling */
15 * Generic header for users of time(), gettimeofday() ...
17 * It includes definitions for time_t, struct timeval, ...
19 * Copyright (c) 1996 J. Schilling
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License version 2
24 * as published by the Free Software Foundation.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License along with
32 * this program; see the file COPYING. If not, write to the Free Software
33 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
43 #ifndef _INCL_SYS_TYPES_H
44 #include <sys/types.h> /* Needed for time_t */
45 #define _INCL_SYS_TYPES_H
48 #ifdef TIME_WITH_SYS_TIME
49 # ifndef _INCL_SYS_TIME_H
50 # include <sys/time.h>
51 # define _INCL_SYS_TIME_H
58 #ifdef HAVE_SYS_TIME_H
59 # ifndef _INCL_SYS_TIME_H
60 # include <sys/time.h>
61 # define _INCL_SYS_TIME_H
75 #if defined(__CYGWIN32__) || defined(__EMX__) || defined(__linux__) || defined(__DJGPP__)
77 * Cygnus defines struct timeval in sys/time.h but not timerclear
78 * timerclear is defined in windows32/Sockets.h ???
80 * EMX for OS/2 defines struct timeval in sys/time.h but not timerclear
82 * Linux defines struct timeval in sys/time.h but if __USE_BSD is not
83 * defined, timerclear is missing.
86 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
104 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
109 #define timerfix1(tvp) while ((tvp)->tv_usec < 0) { \
111 (tvp)->tv_usec += 1000000; \
114 #define timerfix2(tvp) while ((tvp)->tv_usec > 1000000) { \
116 (tvp)->tv_usec -= 1000000; \
119 #define timerfix(tvp) do { timerfix1(tvp); timerfix2(tvp); } while (0)
122 * timersub() and timeradd() are defined on FreeBSD with a different
123 * interface (3 parameters).
126 #define timersub(tvp1, tvp2) do { \
127 (tvp1)->tv_sec -= (tvp2)->tv_sec; \
128 (tvp1)->tv_usec -= (tvp2)->tv_usec; \
129 timerfix1(tvp1); timerfix2(tvp1); \
133 #define timeradd(tvp1, tvp2) do { \
134 (tvp1)->tv_sec += (tvp2)->tv_sec; \
135 (tvp1)->tv_usec += (tvp2)->tv_usec; \
136 timerfix1(tvp1); timerfix2(tvp1); \
143 #endif /* _TIMEDEFS_H */