From 076de37a9f550be5ef8be07440f0db8a0c27412f Mon Sep 17 00:00:00 2001 From: eku Date: Wed, 14 Aug 2002 11:14:01 +0000 Subject: [PATCH] Huge 'gettimeofday' cleanup: o check for the availability in configure o check for the number of arguments in configure o synchronised config.h.in and MSVC pendant NOTE: If you have problems on your system, don't change the source. Extend the tests in configure.in!!! --- autogen.sh | 3 ++- configure.in | 9 ++++++- src/extlib/fbudf/fbudf.cpp | 7 ++++-- src/include/gen/autoconfig_msvc.h | 42 +++++++++++++++++++++++-------- src/journal/misc.cpp | 24 ++++-------------- src/jrd/gds.cpp | 36 +++++++++++++------------- src/jrd/isc.cpp | 4 ++- src/jrd/perf.cpp | 29 +++++++++------------ src/jrd/svc.cpp | 28 +++++++++++++-------- src/make.new/config/config.h.in | 34 ++++++++++++++----------- src/wal/driver.cpp | 14 +++++------ 11 files changed, 128 insertions(+), 102 deletions(-) diff --git a/autogen.sh b/autogen.sh index 63a4dbc860..3e3f419528 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,7 +2,7 @@ # # Run this to generate all the initial makefiles, etc. # -# $Id: autogen.sh,v 1.2 2002-08-14 05:44:28 eku Exp $ +# $Id: autogen.sh,v 1.3 2002-08-14 11:13:56 eku Exp $ PKG_NAME=Firebird2 SRCDIR=`dirname $0` @@ -40,6 +40,7 @@ autoconf || exit 1 if test x$NOCONFIGURE = x then echo Running $SRCDIR/configure $conf_flags "$@" ... + rm -f config.cache config.log $SRCDIR/configure $conf_flags "$@" \ && echo Now type \`make\' to compile $PKG_NAME else diff --git a/configure.in b/configure.in index f4e9ea218c..9054f6b4d3 100644 --- a/configure.in +++ b/configure.in @@ -66,6 +66,13 @@ AC_TRY_COMPILE([#include [AC_MSG_RESULT(yes)], [AC_DEFINE(socklen_t, int) AC_MSG_RESULT(no)]) +AC_MSG_CHECKING(Checking if gettimeofday accepts second (timezone) argument) +AC_TRY_COMPILE([#include +], +[struct timeval tp; gettimeofday(&tp, (struct timezone *)0);], +[AC_DEFINE(GETTIMEOFDAY_RETURNS_TIMEZONE) AC_MSG_RESULT(yes)], +[AC_MSG_RESULT(no)]) + AC_CHECK_LIB(dl, main) AC_CHECK_LIB(c,main) AC_CHECK_LIB(m, main) @@ -80,7 +87,7 @@ AC_CHECK_LIB(curses, main) AC_CHECK_LIB(readline, main,,,$LIBS) AC_CHECK_LIB(stdc++, main,,, $LIBS) -AC_CHECK_FUNCS(strlcpy strlcat) +AC_CHECK_FUNCS(strlcpy strlcat gettimeofday time) AC_C_BIGENDIAN AC_C_CONST diff --git a/src/extlib/fbudf/fbudf.cpp b/src/extlib/fbudf/fbudf.cpp index ee5840de40..47fd6db774 100644 --- a/src/extlib/fbudf/fbudf.cpp +++ b/src/extlib/fbudf/fbudf.cpp @@ -528,8 +528,11 @@ FBUDF_API ISC_TIMESTAMP* getExactTimestamp(ISC_TIMESTAMP* rc) #endif timeval tv; - gettimeofday(&tv, NULL); - +#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE + (void)gettimeofday(&tv, (struct timezone *)0); +#else + (void)gettimeofday(&tv); +#endif tm times = *localtime(&tv.tv_sec); diff --git a/src/include/gen/autoconfig_msvc.h b/src/include/gen/autoconfig_msvc.h index 126f4306f3..31a91e6541 100644 --- a/src/include/gen/autoconfig_msvc.h +++ b/src/include/gen/autoconfig_msvc.h @@ -24,30 +24,49 @@ /* Headers */ #define HAVE_ASSERT_H +#define HAVE_CTYPE_H #undef HAVE_UNISTD_H #define HAVE_FCNTL_H +#undef HAVE_GRP_H +#undef HAVE_PWD_H +#undef HAVE_LIBIO_H +#undef HAVE_LOCALE_H +#undef HAVE_MATH_H +#undef HAVE_PTHREAD_H #undef HAVE_SYS_TYPES_H +#define HAVE_SYS_STAT_H +#undef HAVE_SYS_UIO_H +#undef HAVE_SYS_WAIT_H #define HAVE_TIME_H #undef HAVE_SYS_TIME_H -#define HAVE_SYS_STAT_H -#define HAVE_CTYPE_H -#undef HAVE_SYS_UIO_H -#undef HAVE_LIB_IO_H -#undef HAVE_WAIT_H -#undef HAVE_SYS_WAIT_H +#undef HAVE_SYS_TIMEB_H #undef HAVE_SYS_PARAM_H -#undef HAVE_VARARGS_H +#undef HAVE_SYS_IOCTL_H +#define HAVE_SETJMP_H #define HAVE_STDARG_H #define HAVE_STDLIB_H #define HAVE_STRING_H #define HAVE_SIGNAL_H #undef HAVE_READLINE_READLINE_H -#define HAVE_SETJMP_H +#undef HAVE_UNISTD_H +#undef HAVE_VARARGS_H -/* types */ +/* Functions */ +#undef HAVE_STRLCPY +#undef HAVE_STRLCAT +#define HAVE_GETTIMEOFDAY +#undef HAVE_TIME + +/* Types */ #undef socklen_t -/* functions */ +/* gettimeofday accepts second (timezone) argument */ +#undef GETTIMEOFDAY_RETURNS_TIMEZONE + +/* Are we doing 64bit IO on unix */ +#undef UNIX_64_BIT_IO + +/* Functions */ #define snprintf _snprintf /* Is the platform big endian? */ @@ -83,5 +102,6 @@ #undef sgi #undef mpexl #undef UNIXWARE +#undef SINIXZ -#endif \ No newline at end of file +#endif diff --git a/src/journal/misc.cpp b/src/journal/misc.cpp index 2e7193da17..f86bafc750 100644 --- a/src/journal/misc.cpp +++ b/src/journal/misc.cpp @@ -59,20 +59,6 @@ #define TOMORROW "TOMORROW" #define YESTERDAY "YESTERDAY" -#ifndef WIN_NT -#ifdef NETWARE_386 -#define GETTIMEOFDAY(time,tz) gettimeofday (time) -#endif - -#ifndef GETTIMEOFDAY -#define GETTIMEOFDAY(time,tz) gettimeofday (time, tz) -#define TIMEOFDAY_TZ -#endif -#endif - -#if !defined(WIN_NT) -extern struct tm *localtime(); -#endif static void now_to_date(struct tm *, SLONG[2]); @@ -247,12 +233,12 @@ void MISC_get_time( struct timeval *current) * Get the current time of day. * **************************************/ -#ifdef GETTIMEOFDAY -#ifdef TIMEOFDAY_TZ - struct timezone tzp; +#ifdef HAVE_GETTIMEOFDAY +#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE + (void)gettimeofday(current, (struct timezone *)0); +#else + (void)gettimeofday(current); #endif - - GETTIMEOFDAY(current, &tzp); #else struct timeb buffer; diff --git a/src/jrd/gds.cpp b/src/jrd/gds.cpp index b97e260e2d..87c61ae564 100644 --- a/src/jrd/gds.cpp +++ b/src/jrd/gds.cpp @@ -45,6 +45,10 @@ #include "../jrd/iberr.h" #include "../jrd/gds_proto.h" +#ifdef HAVE_UNISTD_H +#include +#endif + #ifndef WIN_NT #include #endif @@ -92,7 +96,6 @@ #endif #ifdef UNIX -#include #ifdef SUPERSERVER #include #include @@ -211,11 +214,6 @@ static CONST SCHAR *FAR_VARIABLE CONST messages[] = { 0 /* Null entry to terminate list */ }; -#ifndef GETTIMEOFDAY -#define GETTIMEOFDAY(time,tz) gettimeofday ((struct timeval*)time, (struct timezone*)tz) -#define TIMEOFDAY_TZ -#endif - #ifdef NETWARE_386 extern int regular_malloc; struct timezon { @@ -1931,26 +1929,26 @@ void API_ROUTINE gds__log(TEXT * text, ...) **************************************/ va_list ptr; IB_FILE *file; - SLONG t[2]; -#if !(defined VMS || defined PC_PLATFORM || defined WIN_NT) - SLONG z[2]; -#endif int oldmask; + time_t now; #if defined(STACK_EFFICIENT) && !defined(DEV_BUILD) && !defined(DEBUG_GDS_ALLOC) TEXT *name = (TEXT *) gds__alloc((SLONG) (sizeof(TEXT) * MAXPATHLEN)); #else /* STACK_EFFICIENT */ TEXT name[MAXPATHLEN]; #endif /* STACK_EFFICIENT */ -#if !(defined VMS || defined PC_PLATFORM || defined WIN_NT) - GETTIMEOFDAY(t, z); -#define LOG_TIME_OBTAINED -#endif - -#ifdef LOG_TIME_OBTAINED -#undef LOG_TIME_OBTAINED +#ifdef HAVE_GETTIMEOFDAY + { + struct timeval tv; +#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE + (void)gettimeofday(&tv, (struct timezone *)0); #else - time(t); + (void)gettimeofday(&tv); +#endif + now = tv.tv_sec; + } +#else + now = time((time_t *)0); #endif gds__prefix(name, LOGFILE); @@ -1960,7 +1958,7 @@ void API_ROUTINE gds__log(TEXT * text, ...) if ((file = ib_fopen(name, FOPEN_APPEND_TYPE)) != NULL) { ib_fprintf(file, "%s%s\t%.25s\t", ISC_get_host(name, MAXPATHLEN), - gdslogid, ctime(t)); + gdslogid, ctime(now)); VA_START(ptr, text); ib_vfprintf(file, text, ptr); ib_fprintf(file, "\n\n"); diff --git a/src/jrd/isc.cpp b/src/jrd/isc.cpp index fc891de85f..f8d4572123 100644 --- a/src/jrd/isc.cpp +++ b/src/jrd/isc.cpp @@ -28,7 +28,7 @@ * 01-Feb-2002 Paul Reeves: Removed hard-coded registry path */ /* -$Id: isc.cpp,v 1.12 2002-07-29 15:37:54 skywalker Exp $ +$Id: isc.cpp,v 1.13 2002-08-14 11:13:58 eku Exp $ */ #ifdef DARWIN #define _STLP_CCTYPE @@ -151,7 +151,9 @@ static LKSB wake_lock; #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include diff --git a/src/jrd/perf.cpp b/src/jrd/perf.cpp index 9b1f22a535..4953eea9d0 100644 --- a/src/jrd/perf.cpp +++ b/src/jrd/perf.cpp @@ -46,7 +46,6 @@ #if (defined WIN_NT || defined PC_PLATFORM) #include #define NO_TIMES -#define NO_GETTIMEOFDAY #endif #endif /* NETWARE_386 */ @@ -69,7 +68,6 @@ static SCHAR *report = "elapsed = !e cpu = !u reads = !r writes = !w fetches = !f marks = !m$"; #ifdef VMS -#define NO_GETTIMEOFDAY #define TICK 100 extern void ftime(); #endif @@ -242,11 +240,11 @@ void API_ROUTINE perf_get_info(int **handle, PERF * perf) SCHAR *p, buffer[256]; SSHORT l, buffer_length, item_length; STATUS jrd_status[20]; -#ifdef NO_GETTIMEOFDAY +#ifdef HAVE_GETTIMEOFDAY + struct timeval tp; +#else struct timeb time_buffer; #define LARGE_NUMBER 696600000 /* to avoid overflow, get rid of decades) */ -#else - struct timeval tp; #endif /* If there isn't a database, zero everything out */ @@ -263,21 +261,18 @@ void API_ROUTINE perf_get_info(int **handle, PERF * perf) times(&perf->perf_times); -#ifdef NO_GETTIMEOFDAY +#ifdef HAVE_GETTIMEOFDAY +#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE + (void)gettimeofday(&tp, (struct timezone *)0); +#else + (void)gettimeofday(&tp); +#endif + perf->perf_elapsed = tp.tv_sec * 100 + tp.tv_usec / 10000; +#else ftime(&time_buffer); perf->perf_elapsed = (time_buffer.time - LARGE_NUMBER) * 100 + (time_buffer.millitm / 10); - -#else -#ifdef M88K - gettimeofday(&tp); -#else - gettimeofday(&tp, 0L); -#endif /* M88K */ - - perf->perf_elapsed = tp.tv_sec * 100 + tp.tv_usec / 10000; - -#endif /* NO_GETTIMEOFDAY */ +#endif if (!*handle) return; diff --git a/src/jrd/svc.cpp b/src/jrd/svc.cpp index d1988521c1..022181d453 100644 --- a/src/jrd/svc.cpp +++ b/src/jrd/svc.cpp @@ -2982,21 +2982,25 @@ static void service_get(SVC service, ULONG end_time; ULONG elapsed_seconds; ULONG elapsed_tenths; -#endif -#ifdef WIN_NT - time_t start_time, end_time; #else +#ifdef HAVE_GETTIMEOFDAY struct timeval start_time, end_time; +#else + time_t start_time, end_time; #endif +#endif /* NETWARE */ #ifdef NETWARE_386 start_time = GetCurrentTicks(); #else -#ifdef WIN_NT - time(&start_time); +#ifdef HAVE_GETTIMEOFDAY +#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE + (void)gettimeofday(&start_time, (struct timezone *)0); #else - gettimeofday(&start_time, NULL); + (void)gettimeofday(&start_time); #endif +#else + time(&start_time); #endif /* NETWARE */ *return_length = 0; service->svc_flags &= ~SVC_timeout; @@ -3009,12 +3013,16 @@ static void service_get(SVC service, elapsed_time = end_time - start_time; TicksToSeconds(elapsed_time, &elapsed_seconds, &elapsed_tenths); #else -#ifdef WIN_NT +#ifdef HAVE_GETTIMEOFDAY +#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE + (void)gettimeofday(&end_time, (struct timezone *)0); +#else + (void)gettimeofday(&end_time); +#endif + elapsed_time = end_time.tv_sec - start_time.tv_sec; +#else time(&end_time); elapsed_time = end_time - start_time; -#else - gettimeofday(&end_time, NULL); - elapsed_time = end_time.tv_sec - start_time.tv_sec; #endif #endif /* NETWARE */ diff --git a/src/make.new/config/config.h.in b/src/make.new/config/config.h.in index 6ce66cf185..f77b6b3b74 100644 --- a/src/make.new/config/config.h.in +++ b/src/make.new/config/config.h.in @@ -18,36 +18,41 @@ #undef HAVE_ERRNO_H #undef HAVE_FCNTL_H #undef HAVE_GRP_H +#undef HAVE_PWD_H #undef HAVE_LIBIO_H -#undef HAVE_LIB_IO_H #undef HAVE_LOCALE_H #undef HAVE_MATH_H -#undef HAVE_PWD_H -#undef HAVE_READLINE_READLINE_H #undef HAVE_PTHREAD_H -#undef HAVE_SIGNAL_H +#undef HAVE_SYS_TYPES_H +#undef HAVE_SYS_STAT_H +#undef HAVE_SYS_UIO_H +#undef HAVE_SYS_WAIT_H +#undef HAVE_TIME_H +#undef HAVE_SYS_TIME_H +#undef HAVE_SYS_TIMEB_H +#undef HAVE_SYS_PARAM_H +#undef HAVE_SYS_IOCTL_H #undef HAVE_SETJMP_H #undef HAVE_STDARG_H #undef HAVE_STDLIB_H #undef HAVE_STRING_H -#undef HAVE_SYS_TYPES_H -#undef HAVE_SYS_STAT_H -#undef HAVE_SYS_UIO_H -#undef HAVE_SYS_IOCTL_H -#undef HAVE_SYS_WAIT_H -#undef HAVE_SYS_TIME_H -#undef HAVE_SYS_TIMEB_H -#undef HAVE_SYS_PARAM_H -#undef HAVE_TIME_H +#undef HAVE_SIGNAL_H +#undef HAVE_READLINE_READLINE_H #undef HAVE_UNISTD_H #undef HAVE_VARARGS_H +/* Functions */ #undef HAVE_STRLCPY #undef HAVE_STRLCAT +#undef HAVE_GETTIMEOFDAY +#undef HAVE_TIME -/* types */ +/* Types */ #undef socklen_t +/* gettimeofday accepts second (timezone) argument */ +#undef GETTIMEOFDAY_RETURNS_TIMEZONE + /* Are we doing 64bit IO on unix */ #undef UNIX_64_BIT_IO @@ -84,5 +89,6 @@ #undef sgi #undef mpexl #undef UNIXWARE +#undef SINIXZ #endif diff --git a/src/wal/driver.cpp b/src/wal/driver.cpp index ecacc5ae72..78766fb4a4 100644 --- a/src/wal/driver.cpp +++ b/src/wal/driver.cpp @@ -52,10 +52,6 @@ #include "../jrd/isc_f_proto.h" #include "../jrd/misc_proto.h" -#ifndef GETTIMEOFDAY -#define GETTIMEOFDAY(tp,tzp) gettimeofday (tp, tzp) -#endif - static void do_mem_benchmark(void); static void do_sem_benchmark(WAL); static SLONG get_tod(void); @@ -573,10 +569,14 @@ static SLONG get_tod(void) * Functional description * **************************************/ -#if !(defined WIN_NT) +#ifdef HAVE_GETTIMEOFDAY +#ifdef GETTIMEOFDAY_RETURNS_TIMEZONE struct timeval tp1; - GETTIMEOFDAY(&tp1, NULL); + (void)gettimeofday(&tp1, (struct timezone *)0); +#else + (void)gettimeofday(&tp1); +#endif if (!base_seconds) base_seconds = tp1.tv_sec; return (tp1.tv_sec - base_seconds) * 1000000 + tp1.tv_usec; @@ -832,4 +832,4 @@ static void toggle_debug_msg_flag( STATUS * status_vector, WAL WAL_handle) else WAL_segment->wals_flags2 |= WALS2_DEBUG_MSGS; WALC_release(WAL_handle); -} \ No newline at end of file +}