bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] gettimeofday() for Win32


From: Bruno Haible
Subject: Re: [bug-gnulib] gettimeofday() for Win32
Date: Thu, 25 Aug 2005 15:32:00 +0200
User-agent: KMail/1.5

Hi,

Martin Lambers wrote:
> I'd like to provide a gettimeofday() function for systems that do not
> have it (at least Win32).
>
> I already wrote a module that works, see below. But this module
> overwrites the existing gettimeofday module. I do not know how to
> integrate the changes into the existing module because of the autoconf
> and M4 magic that is involved.
>
> I have two questions: Would you consider integrating such changes into
> the existing module at all?

Jim?

> If so, how can this be done?

It can be done by merging your .m4 file with Jim's one, and put a big
#if inside lib/gettimeofday.c. But first, can you please bring your
proposed code up to gnulib standards?

  - Indentation by 2 characters, not by 4.
  - A space before the opening parenthesis in function/macro calls.
  - Use #ifdef _WIN32, not #ifdef WIN32.

And compare the code with GNU clisp's gettimeofday emulations. (I wrote
that code => no copyright problems when porting it to gnulib.)

/* an emulation of gettimeofday(3). */
int
gettimeofday (struct timeval * tp, struct timezone * tzp)
{
  if (tp != NULL || tzp != NULL)
    {
      struct timeb timebuf;
      ftime (&timebuf);
      if (tp != NULL)
        {
          tp->tv_sec = timebuf.time;
          tp->tv_usec = (long)(timebuf.millitm) * (1000000/1000);
        }
      if (tzp != NULL)
        {
          tzp->tz_minuteswest = timebuf.timezone;
          tzp->tz_dsttime = 0;      /* ?? */
        }
    }
  return 0;
}

What's the right way to fill the struct timezone?

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]