3 dnl Copyright (C) 2008-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
9 AC_DEFUN([gl_FUNC_FDATASYNC],
11 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST])
14 dnl Using AC_CHECK_FUNCS_ONCE would break our subsequent AC_SEARCH_LIBS
15 AC_CHECK_DECLS_ONCE([fdatasync])
17 AC_SUBST([FDATASYNC_LIB])
19 if test $ac_cv_have_decl_fdatasync = no; then
21 dnl Mac OS X 10.7 has fdatasync but does not declare it.
22 dnl Likewise Android with API level < 9.
23 gl_CHECK_FUNCS_ANDROID([fdatasync], [[#include <unistd.h>]])
24 if test $ac_cv_func_fdatasync = no; then
26 case "$gl_cv_onwards_func_fdatasync" in
27 future*) REPLACE_FDATASYNC=1 ;;
33 dnl Solaris <= 2.6 has fdatasync() in libposix4.
34 dnl Solaris 7..9 has it in librt.
35 dnl Solaris 10 sometimes has it in librt <https://bugs.gnu.org/21059>.
37 AC_SEARCH_LIBS([fdatasync], [rt posix4],
38 [test "$ac_cv_search_fdatasync" = "none required" ||
39 FDATASYNC_LIB=$ac_cv_search_fdatasync])
43 dnl Android 4.3 does not have fdatasync but declares it, and future
44 dnl Android versions have it.
45 gl_CHECK_FUNCS_ANDROID([fdatasync], [[#include <unistd.h>]])
46 if test $ac_cv_func_fdatasync = no; then
48 case "$gl_cv_onwards_func_fdatasync" in
49 future*) REPLACE_FDATASYNC=1 ;;
56 dnl For backward compatibility.
57 LIB_FDATASYNC="$FDATASYNC_LIB"
58 AC_SUBST([LIB_FDATASYNC])