sim: dv-cfi: check for posix_fallocate
authorMike Frysinger <vapier@gentoo.org>
Mon, 7 Nov 2011 16:28:52 +0000 (16:28 +0000)
committerMike Frysinger <vapier@gentoo.org>
Mon, 7 Nov 2011 16:28:52 +0000 (16:28 +0000)
Some systems (like OS X) do not have posix_fallocate.  Add a configure
check for it before we try to use it.  This is less work than trying
to support old systems.

URL: http://sourceware.org/bugzilla/show_bug.cgi?id=13161
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
sim/common/ChangeLog
sim/common/config.in
sim/common/configure
sim/common/configure.ac
sim/common/dv-cfi.c

index b5c5ed4ccf872118df7f524ccd0e13b3fda2ac01..b1c7f85b9003324dd2ea0dc58b23af0fb404e74d 100644 (file)
@@ -1,3 +1,10 @@
+2011-11-07  Mike Frysinger  <vapier@gentoo.org>
+
+       PR sim/13161
+       * configure.ac (AC_CHECK_FUNCS): Add posix_fallocate.
+       * configure, config.in: Regenerate.
+       * dv-cfi.c (attach_cfi_regs): Check for HAVE_POSIX_FALLOCATE.
+
 2011-10-19  Mike Frysinger  <vapier@gentoo.org>
 
        * acinclude.m4: Call AC_CHECK_LIB when $hardware contains cfi.
index 6f93ff432e2d1f641d30e597af9e0d9863401083..5792785ffee17813e8c9e3b32c05e86e2a0eac77 100644 (file)
@@ -43,6 +43,9 @@
 /* Define to 1 if you have the `munmap' function. */
 #undef HAVE_MUNMAP
 
+/* Define to 1 if you have the `posix_fallocate' function. */
+#undef HAVE_POSIX_FALLOCATE
+
 /* Define to 1 if you have the `sigaction' function. */
 #undef HAVE_SIGACTION
 
index 4b80825f4dd58282a7cf31eb4c51a5e17f430c5f..a8148bd1fcf5490b2f740bf5e78a1663025b254c 100755 (executable)
@@ -4393,7 +4393,7 @@ fi
 
 done
 
-for ac_func in mmap munmap lstat truncate ftruncate
+for ac_func in mmap munmap lstat truncate ftruncate posix_fallocate
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
index a683f37a33a1d6bd527159531892a9f5b79805da..e771575b5a11ee99999ca5ad6d20b3e3ab5c0673 100644 (file)
@@ -34,7 +34,7 @@ AC_SUBST(TARGET_SUBDIR)
 
 # These aren't all needed yet, but will be eventually.
 AC_CHECK_HEADERS(stdlib.h string.h strings.h time.h sys/times.h sys/stat.h sys/mman.h)
-AC_CHECK_FUNCS(mmap munmap lstat truncate ftruncate)
+AC_CHECK_FUNCS(mmap munmap lstat truncate ftruncate posix_fallocate)
 AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino],
 [struct stat.st_mode], [struct stat.st_nlink], [struct stat.st_uid],
 [struct stat.st_gid], [struct stat.st_rdev], [struct stat.st_size],
index a1ecaf9d57b8e7bb99a0618ea61a7dfd3d93992b..04b004bdeefaf240ac26a6e9fd3a75708cc37191 100644 (file)
@@ -727,7 +727,7 @@ attach_cfi_regs (struct hw *me, struct cfi *cfi)
   /* Figure out where our initial flash data is coming from.  */
   if (fd != -1 && fd_writable)
     {
-#ifdef HAVE_MMAP
+#if defined (HAVE_MMAP) && defined (HAVE_POSIX_FALLOCATE)
       posix_fallocate (fd, 0, cfi->dev_size);
 
       cfi->mmap = mmap (NULL, cfi->dev_size,