From: oetiker Date: Tue, 22 May 2007 20:44:57 +0000 (+0000) Subject: * better tests for madvise, fadvise and fdatasync X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=27bd57bf63ac4fcf8e5aa0c0e657dd0def4fe396;p=rrdtool-all.git * better tests for madvise, fadvise and fdatasync * fix inclusion of fcntl.h * clenups for configure.ac -- Bernhard Fischer rep dot nop gmail com git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@1070 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/configure.ac b/program/configure.ac index 30787101..adc8e3b0 100644 --- a/program/configure.ac +++ b/program/configure.ac @@ -52,6 +52,11 @@ AH_TOP([ ]) AH_BOTTOM([ +/* enable posix_fadvise on linux */ +#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FCNTL_H) +#define _XOPEN_SOURCE 600 +#include +#endif /* define strrchr, strchr and memcpy, memmove in terms of bsd funcs make sure you are NOT using bcopy, index or rindex in the code */ @@ -70,17 +75,11 @@ char *strchr (), *strrchr (); # endif #endif -/* enable posix_fadvise on linux */ -#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FCNTL_H) -#define _XOPEN_SOURCE 600 -#include -#endif - #ifdef NO_NULL_REALLOC # define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) )) #else # define rrd_realloc(a,b) realloc((a), (b)) -#endif +#endif #ifdef NEED_MALLOC_MALLOC_H # include @@ -223,7 +222,7 @@ CONFIGURE_PART(Checking for Header Files) dnl Checks for header files. AC_HEADER_STDC AC_HEADER_DIRENT -AC_CHECK_HEADERS(sys/stat.h sys/types.h fcntl.h time.h locale.h fp_class.h malloc.h unistd.h ieeefp.h math.h sys/time.h sys/times.h sys/param.h sys/resource.h float.h) +AC_CHECK_HEADERS(sys/stat.h sys/types.h fcntl.h locale.h fp_class.h malloc.h unistd.h ieeefp.h math.h sys/times.h sys/param.h sys/resource.h float.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -250,6 +249,10 @@ dnl of the form HAVE_FUNCTION AC_CHECK_FUNCS(tzset mbstowcs opendir readdir chdir chroot getuid setlocale strerror strerror_r snprintf vsnprintf fpclass class fp_class isnan memmove strchr mktime getrusage gettimeofday posix_fadvise madvise) +AC_CHECK_DECLS(fdatasync, [], [], [#include ]) +AC_CHECK_DECLS(posix_fadvise, [], [], [#define _XOPEN_SOURCE 600 +#include ]) +AC_CHECK_DECLS(madvise, [], [], [#include ]) if test "x$enable_mmap" = xyes; then case "$host" in diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c index eedbf4a9..f1eb1161 100644 --- a/program/src/rrd_tool.c +++ b/program/src/rrd_tool.c @@ -364,11 +364,8 @@ int main(int argc, char *argv[]) struct rusage myusage; struct timeval starttime; struct timeval currenttime; - struct timezone tz; - tz.tz_minuteswest =0; - tz.tz_dsttime=0; - gettimeofday(&starttime,&tz); + gettimeofday(&starttime, NULL); #endif RemoteMode=1; if ((argc == 3) && strcmp("",argv[2])){ @@ -426,7 +423,7 @@ int main(int argc, char *argv[]) #if HAVE_GETRUSAGE getrusage(RUSAGE_SELF,&myusage); - gettimeofday(¤ttime,&tz); + gettimeofday(¤ttime,NULL); printf("OK u:%1.2f s:%1.2f r:%1.2f\n", (double)myusage.ru_utime.tv_sec+ (double)myusage.ru_utime.tv_usec/1000000.0, diff --git a/program/src/rrd_tool.h b/program/src/rrd_tool.h index 029126e3..6663c56e 100644 --- a/program/src/rrd_tool.h +++ b/program/src/rrd_tool.h @@ -24,12 +24,11 @@ extern "C" { #ifdef MUST_DISABLE_FPMASK #include #endif - + #include #include #include #include -#include #include #if HAVE_SYS_PARAM_H @@ -72,16 +71,26 @@ extern "C" { # include #endif - #if HAVE_UNISTD_H # include #endif -#if HAVE_SYS_TIME_H + +#if TIME_WITH_SYS_TIME # include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif #endif + #if HAVE_SYS_TIMES_H # include #endif + + #if HAVE_SYS_RESOURCE_H # include #if (defined(__svr4__) && defined(__sun__)) @@ -108,7 +117,7 @@ char *strtok_r(char *str, const char *sep, char **last); #else /* unix-only includes */ -#ifndef isnan +#if !defined isnan && !defined HAVE_ISNAN int isnan(double value); #endif diff --git a/program/src/rrd_update.c b/program/src/rrd_update.c index 608c3146..ed79a6a1 100644 --- a/program/src/rrd_update.c +++ b/program/src/rrd_update.c @@ -10,7 +10,7 @@ #include #include #ifdef HAVE_MMAP - #include +# include #endif #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) @@ -430,9 +430,9 @@ _rrd_update(const char *filename, const char *tmplt, int argc, const char **argv #ifdef HAVE_MADVISE /* when we use mmaping we tell the kernel the mmap equivalent of POSIX_FADV_RANDOM */ - madvise(rrd_mmaped_file,rrd_filesize,MADV_RANDOM); + madvise(rrd_mmaped_file,rrd_filesize,POSIX_MADV_RANDOM); +#endif #endif -#endif /* loop through the arguments. */ for(arg_i=0; arg_i