From 3244be050048e2ce5e60c2d4a5a5dac193e4b2a5 Mon Sep 17 00:00:00 2001
From: Hans Leidekker <hans@codeweavers.com>
Date: Fri, 7 Dec 2012 09:22:40 +0100
Subject: [PATCH] configure: Fix detection of fallocate on old glibc.

---
 configure    | 35 ++++++++++++++++++++++++++++++++++-
 configure.ac | 10 +++++++++-
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 2da54779495..c1e10d78c7a 100755
--- a/configure
+++ b/configure
@@ -12931,7 +12931,6 @@ for ac_func in \
 	chsize \
 	dlopen \
 	epoll_create \
-	fallocate \
 	ffs \
 	finite \
 	fnmatch \
@@ -13494,6 +13493,40 @@ $as_echo "#define HAVE_SCHED_SETAFFINITY 1" >>confdefs.h
 
 fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fallocate" >&5
+$as_echo_n "checking for fallocate... " >&6; }
+if ${wine_cv_have_fallocate+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#define _GNU_SOURCE
+#include <fcntl.h>
+int
+main ()
+{
+fallocate(-1, 0, 0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  wine_cv_have_fallocate=yes
+else
+  wine_cv_have_fallocate=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $wine_cv_have_fallocate" >&5
+$as_echo "$wine_cv_have_fallocate" >&6; }
+if test "$wine_cv_have_fallocate" = "yes"
+then
+
+$as_echo "#define HAVE_FALLOCATE 1" >>confdefs.h
+
+fi
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
 $as_echo_n "checking for inline... " >&6; }
diff --git a/configure.ac b/configure.ac
index 4c7655a7568..01d84cdc8d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1976,7 +1976,6 @@ AC_CHECK_FUNCS(\
 	chsize \
 	dlopen \
 	epoll_create \
-	fallocate \
 	ffs \
 	finite \
 	fnmatch \
@@ -2117,6 +2116,15 @@ then
   AC_DEFINE(HAVE_SCHED_SETAFFINITY, 1, [Define to 1 if you have the `sched_setaffinity' function.])
 fi
 
+AC_CACHE_CHECK([for fallocate],wine_cv_have_fallocate,
+                AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[#define _GNU_SOURCE
+#include <fcntl.h>]], [[fallocate(-1, 0, 0, 0);]])],[wine_cv_have_fallocate=yes],[wine_cv_have_fallocate=no]))
+if test "$wine_cv_have_fallocate" = "yes"
+then
+  AC_DEFINE(HAVE_FALLOCATE, 1, [Define to 1 if you have the `fallocate' function.])
+fi
+
 dnl **** Check for types ****
 
 AC_C_INLINE
-- 
GitLab