Procházet zdrojové kódy

Only use madvise(2) if available.

Fixes build on OpenSolaris
Bryan Drewery před 11 roky
rodič
revize
c3ae4f6572
4 změnil soubory, kde provedl 7 přidání a 2 odebrání
  1. 1 1
      build/autotools/configure.ac
  2. 1 1
      configure
  3. 2 0
      src/binary.c
  4. 3 0
      src/config.h.in

+ 1 - 1
build/autotools/configure.ac

@@ -195,7 +195,7 @@ AC_FUNC_STRFTIME
 
 #checkpoint
 AC_CACHE_SAVE
-AC_CHECK_FUNCS([clock fsync getrusage isascii getpassphrase])
+AC_CHECK_FUNCS([clock fsync getrusage isascii getpassphrase madvise])
 AC_CHECK_FUNCS([memcpy memset random rename snprintf srandom gettime])
 #checkpoint
 AC_CACHE_SAVE

+ 1 - 1
configure

@@ -8417,7 +8417,7 @@ $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
   fi
 fi
 rm -f confcache
-for ac_func in clock fsync getrusage isascii getpassphrase
+for ac_func in clock fsync getrusage isascii getpassphrase madvise
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"

+ 2 - 0
src/binary.c

@@ -178,7 +178,9 @@ bin_checksum(const char *fname, int todo)
     close(fd);
     werr(ERR_BINSTAT);
   }
+#ifdef HAVE_MADVISE
   madvise(map, size, MADV_SEQUENTIAL);
+#endif
   MD5_Update(&ctx, map, offset);
 
   /* Hash everything after the packdata too */

+ 3 - 0
src/config.h.in

@@ -103,6 +103,9 @@
    zero-length file name argument. */
 #undef HAVE_LSTAT_EMPTY_STRING_BUG
 
+/* Define to 1 if you have the `madvise' function. */
+#undef HAVE_MADVISE
+
 /* Define to 1 if your system has a GNU libc compatible `malloc' function, and
    to 0 otherwise. */
 #undef HAVE_MALLOC