Re: droped out precise time calculations in src/interfaces/libpq/fe-connect.c

Поиск
Список
Период
Сортировка
От Denis A Ustimenko
Тема Re: droped out precise time calculations in src/interfaces/libpq/fe-connect.c
Дата
Msg-id 20021016095047.GA5053@store.oldham.ru
обсуждение исходный текст
Ответ на Re: droped out precise time calculations in src/interfaces/libpq/fe-connect.c  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: droped out precise time calculations in src/interfaces/libpq/fe-connect.c  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-hackers
On Mon, Oct 14, 2002 at 01:00:07AM -0400, Bruce Momjian wrote:
> 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:
>     

Here is my version of gettimeofday for win32. It was tested with Watcom C 11.0c. I think it can be used. I still belive
thatfine time calculation is the right way.
 

#include<stdio.h>
#ifdef _WIN32
#include<winsock.h>
#else
#include<sys/time.h>
#endif

main()
{   struct timeval t;   if (gettimeofday(&t,NULL)) {       printf("error\n\r");   } else {       printf("the time is
%ld.%ld\n\r",t.tv_sec, t.tv_usec);   }   fflush(stdout);
 
}

#ifdef _WIN32
int gettimeofday(struct timeval *tp, void *tzp)
{   FILETIME time;   __int64 tmp;
   if ( NULL == tp) return -1;
   GetSystemTimeAsFileTime(&time);
   tmp = time.dwHighDateTime;   tmp <<= 32;   tmp |= time.dwLowDateTime;   tmp /= 10; // it was in 100 nanosecond
periods  tp->tv_sec = tmp / 1000000 - 11644473600L; // Windows Epoch begins at 12:00 AM 01.01.1601   tp->tv_usec = tmp
%1000000;   return 0;
 
}
#endif



-- 
Regards
Denis


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Justin Clift
Дата:
Сообщение: Re: Postgresql and multithreading
Следующее
От: Dave Tenny
Дата:
Сообщение: Re: [JDBC] Out of memory error on huge resultset