Couple of minor items in his.c in the 7/10 snapshot under Linux/gcc

Joe St Sauver JOE at OREGON.UOREGON.EDU
Wed Jul 11 15:43:34 UTC 2001


>Date: Wed, 11 Jul 2001 08:18:29 -0700
>From: Russ Allbery <rra at stanford.edu>
>Subject: Re: Couple of minor items in his.c in the 7/10 snapshot under Linux/gcc
>
>Okay, I'm really confused then... his.c includes innd.h, which includes
>portable/time.h, which should include both time.h and sys/time.h and
>struct timeval really should be defined in one or the other.  Could you
>take a look at those two system header files and see if struct timeval is
>wrapped around some weird feature test macro or something?

  [in /usr/include ...]
  % grep timeval time.h
  /* POSIX.1b structure for a time value.  This is like a `struct timeval' but
  
  ... and that's the only timeval reference in that file... the context of that
  reference:

  #if !defined __timespec_defined && \
      ((defined _TIME_H && defined __USE_POSIX199309) || defined __need_timespec)
  # define __timespec_defined     1
  
  /* POSIX.1b structure for a time value.  This is like a `struct timeval' but
     has nanoseconds instead of microseconds.  */
  struct timespec
    {
      long int tv_sec;            /* Seconds.  */
      long int tv_nsec;           /* Nanoseconds.  */
    };
  
  #endif /* timespec not defined and <time.h> or need timespec.  */
  #undef  __need_timespec


[in /usr/include/sys] potentially relevant chunks include:

  #ifndef _SYS_TIME_H
  #define _SYS_TIME_H     1

  #include <features.h>
  
  #include <time.h>
  #include <sys/select.h>
  
  #define __need_timeval
  #include <bits/time.h>
  
  #ifndef __suseconds_t_defined
  typedef __suseconds_t suseconds_t;
  # define __suseconds_t_defined
  #endif
  
  
  __BEGIN_DECLS
  
  /* Macros for converting between `struct timeval' and `struct timespec'.  */
  #define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \
          (ts)->tv_sec = (tv)->tv_sec;                                    \
          (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
  }
  #define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \
          (tv)->tv_sec = (ts)->tv_sec;                                    \
          (tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
  }

And because I suspect that you'll be interested in <bits/time.h>, potentially
relevant chunks there look like:

  #ifdef __need_timeval
  # undef __need_timeval
  # ifndef _STRUCT_TIMEVAL
  #  define _STRUCT_TIMEVAL       1
  #  include <bits/types.h>
  
  /* A time value that is accurate to the nearest
     microsecond but also has a range of years.  */
  struct timeval
    {
      __time_t tv_sec;            /* Seconds.  */
      __suseconds_t tv_usec;      /* Microseconds.  */
    };
  # endif /* struct timeval */
  #endif  /* need timeval */

Regards,

Joe


More information about the inn-workers mailing list