8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 16:03:03 +01:00

Cleanup usage of gettimeofday.

This commit is contained in:
eku 2003-10-31 11:33:45 +00:00
parent d89e031272
commit da0d0f068f
8 changed files with 22 additions and 53 deletions

View File

@ -1,4 +1,4 @@
dnl $Id: configure.in,v 1.172 2003-10-30 12:47:59 eku Exp $
dnl $Id: configure.in,v 1.173 2003-10-31 11:33:33 eku Exp $
dnl ############################# INITIALISATION ###############################
@ -368,6 +368,11 @@ if test "$ac_cv_func_gettimeofday" = "yes"; then
[AC_MSG_RESULT(no)])
;;
esac
AH_BOTTOM([#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE
#define GETTIMEOFDAY(x) gettimeofday((x), (struct timezone *)0)
#else
#define GETTIMEOFDAY(x) gettimeofday((x))
#endif])
fi
AC_CHECK_FUNCS(time times)
AC_SEARCH_LIBS(gethostname,nsl)

View File

@ -538,11 +538,7 @@ FBUDF_API ISC_TIMESTAMP* getExactTimestamp(ISC_TIMESTAMP* rc)
#endif
timeval tv;
#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE
(void)gettimeofday(&tv, (struct timezone *)0);
#else
(void)gettimeofday(&tv);
#endif
GETTIMEOFDAY(&tv);
tm times = *localtime(reinterpret_cast<const time_t*>(&tv.tv_sec));

View File

@ -237,11 +237,7 @@ void MISC_get_time(timeval* current)
*
**************************************/
#ifdef HAVE_GETTIMEOFDAY
#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE
(void)gettimeofday(current, (timezone*)0);
#else
(void)gettimeofday(current);
#endif
GETTIMEOFDAY(current);
#else
timeb buffer;

View File

@ -1166,15 +1166,9 @@ void API_ROUTINE gds__log(const TEXT* text, ...)
TEXT name[MAXPATHLEN];
#ifdef HAVE_GETTIMEOFDAY
{
struct timeval tv;
#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE
(void)gettimeofday(&tv, (struct timezone *)0);
#else
(void)gettimeofday(&tv);
#endif
now = tv.tv_sec;
}
struct timeval tv;
GETTIMEOFDAY(&tv);
now = tv.tv_sec;
#else
now = time((time_t *)0);
#endif

View File

@ -241,11 +241,7 @@ void API_ROUTINE perf_get_info(FRBRD **handle, PERF * perf)
times(&perf->perf_times);
#ifdef HAVE_GETTIMEOFDAY
#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE
(void)gettimeofday(&tp, (struct timezone *)0);
#else
(void)gettimeofday(&tp);
#endif
GETTIMEOFDAY(&tp);
perf->perf_elapsed = tp.tv_sec * 100 + tp.tv_usec / 10000;
#else
ftime(&time_buffer);

View File

@ -2855,22 +2855,16 @@ static void service_get(SVC service,
*
**************************************/
int ch = 'Z';
ULONG elapsed_time;
#ifdef HAVE_GETTIMEOFDAY
struct timeval start_time, end_time;
#else
time_t start_time, end_time;
#endif
time_t elapsed_time;
#ifdef HAVE_GETTIMEOFDAY
#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE
(void)gettimeofday(&start_time, (struct timezone *)0);
#else
(void)gettimeofday(&start_time);
#endif
struct timeval start_time, end_time;
GETTIMEOFDAY(&start_time);
#else
time_t start_time, end_time;
time(&start_time);
#endif
*return_length = 0;
service->svc_flags &= ~SVC_timeout;
@ -2878,11 +2872,7 @@ static void service_get(SVC service,
if (service_empty(service))
THREAD_SLEEP(1);
#ifdef HAVE_GETTIMEOFDAY
#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE
(void)gettimeofday(&end_time, (struct timezone *)0);
#else
(void)gettimeofday(&end_time);
#endif
GETTIMEOFDAY(&end_time);
elapsed_time = end_time.tv_sec - start_time.tv_sec;
#else
time(&end_time);

View File

@ -41,7 +41,7 @@
*
*/
/*
$Id: inet.cpp,v 1.80 2003-10-29 10:53:35 robocop Exp $
$Id: inet.cpp,v 1.81 2003-10-31 11:33:44 eku Exp $
*/
#include "firebird.h"
#include "../jrd/ib_stdio.h"
@ -266,12 +266,8 @@ static ULONG inet_debug_timer(void)
**************************************/
#ifdef HAVE_GETTIMEOFDAY
struct timeval tv;
#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE
(void)gettimeofday(&tv, (struct timezone *)0);
#else
(void)gettimeofday(&tv);
#endif
return (tv.tv_sec*1000 + tv.tv_usec - INET_start_time);
GETTIMEOFDAY(&tv);
return (tv.tv_sec * 1000 + tv.tv_usec - INET_start_time);
#else
struct timeb now;
ftime(&now);

View File

@ -588,13 +588,9 @@ static SLONG get_tod(void)
*
**************************************/
#ifdef HAVE_GETTIMEOFDAY
#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE
struct timeval tp1;
(void)gettimeofday(&tp1, (struct timezone *)0);
#else
(void)gettimeofday(&tp1);
#endif
GETTIMEOFDAY(&tp1);
if (!base_seconds)
base_seconds = tp1.tv_sec;
return (tp1.tv_sec - base_seconds) * 1000000 + tp1.tv_usec;