#ifndef __sys_time_h
#define __sys_time_h

/* Freenet programmers library - sys/time.h - 23/5/95 */

#ifndef __sys_types_h
#include "sys/types.h"
#endif

/*
 * Structure defining a time of day
 */
struct timeval {
  long tv_sec;         /* Seconds past midnight */
  long tv_usec;        /* Microseconds within the current second */
};

/*
 * Structure defining a timezone
 */
struct timezone {
  int tz_minuteswest;  /* Minutes west of Greenwich */
  int tz_dsttime;      /* Type of DST in use */
};

/*
 * Type of DST recognised
 */
#define DST_NONE    0  /* Not on DST */
#define DST_USA     1  /* USA style DST */
#define DST_AUST    2  /* Australian style DST */
#define DST_WET     3  /* Western European DST */
#define DST_MET     4  /* Middle European DST */
#define DST_EET     5  /* Eastern European DST */
#define DST_CAN     6  /* Canada */
#define DST_GB      7  /* Great Britain and Eire */
#define DST_RUM     8  /* Rumania */
#define DST_TUR     9  /* Turkey */
#define DST_AUSTALT 10 /* Australian style with shift in 1986 */

/*
 * Is a timeval structure set?
 */
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)

/*
 * Compare two timeval structures (doesn't work for <= or >= ops)
 */
#define timercmp(tvp, uvp, cmp) \
          ((tvp)->tv_sec cmp (uvp)->tv_sec || \
           (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)

/*
 * Clear a timeval structure
 */
#define timerclear(tvp) (void)((tvp)->tv_sec = (tvp)->tv_usec = 0)

/*
 * Get the time of day
 */
extern void gettimeofday(struct timeval */*tv*/, struct timezone */*tz*/);

#endif
