From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Denis A Ustimenko <denis(at)oldham(dot)ru> |
Cc: | Joe Conway <mail(at)joeconway(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: droped out precise time calculations in src/interfaces/libpq/fe-connect.c |
Date: | 2002-10-14 05:00:07 |
Message-ID: | 200210140500.g9E507n14974@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Denis A Ustimenko wrote:
> On Sun, Oct 13, 2002 at 09:02:55PM -0700, Joe Conway wrote:
> > Denis A Ustimenko wrote:
> > >>Bruce, why have all precise time calculations been droped out in 1.206?
> > >>If there is no
> > >>gettimeofday in win32?
> >
> > gettimeofday was not portable to win32 (at least not that I could find) and
> > hence broke the win32 build of the clients.
> >
>
> GetSystemTimeAsFileTime should help.
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemtimeasfiletime.asp
It's not clear to me how we could get this into something we can deal
with like gettimeofday.
I looked at the Apache APR project, and they have a routine that returns
the microseconds since 1970 for Unix:
/* NB NB NB NB This returns GMT!!!!!!!!!! */
APR_DECLARE(apr_time_t) apr_time_now(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * APR_USEC_PER_SEC + tv.tv_usec;
}
and for Win32:
APR_DECLARE(apr_time_t) apr_time_now(void)
{
LONGLONG aprtime = 0;
FILETIME time;
#ifndef _WIN32_WCE
GetSystemTimeAsFileTime(&time);
#else
SYSTEMTIME st;
GetSystemTime(&st);
SystemTimeToFileTime(&st, &time);
#endif
FileTimeToAprTime(&aprtime, &time);
return aprtime;
}
and FileTimeToAprTime() is:
/* Number of micro-seconds between the beginning of the Windows epoch
* (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970)
*/
#define APR_DELTA_EPOCH_IN_USEC APR_TIME_C(11644473600000000);
__inline void FileTimeToAprTime(apr_time_t *result, FILETIME *input)
{
/* Convert FILETIME one 64 bit number so we can work with it. */
*result = input->dwHighDateTime;
*result = (*result) << 32;
*result |= input->dwLowDateTime;
*result /= 10; /* Convert from 100 nano-sec periods to micro-seconds. */
*result -= APR_DELTA_EPOCH_IN_USEC; /* Convert from Windows epoch to Unix epoch */
return;
}
So, this is what needs to be dealt with to get it working.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2002-10-14 05:15:52 | Re: droped out precise time calculations in src/interfaces/libpq/fe-connect.c |
Previous Message | Bruce Momjian | 2002-10-14 04:49:34 | Let's get 7.3 done |