2 dnl Copyright (C) 2009-2020 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_PREAD],
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 dnl Persuade glibc <unistd.h> to declare pread().
13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
15 AC_CHECK_FUNCS_ONCE([pread])
16 if test $ac_cv_func_pread = yes; then
17 dnl On HP-UX 11.11 with _FILE_OFFSET_BITS=64, pread() on a file returns 0
18 dnl instead of a positive value.
19 dnl On HP-UX 11.31, pread() on a pipe does not fail.
20 AC_CACHE_CHECK([whether pread works],
21 [gl_cv_func_pread_works],
23 dnl Initial guess, used when cross-compiling.
27 hpux*) gl_cv_func_pread_works="guessing no" ;;
28 # Guess yes otherwise.
29 *) gl_cv_func_pread_works="guessing yes" ;;
32 gl_save_CPPFLAGS="$CPPFLAGS"
33 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
36 #include <sys/types.h>
44 /* This test fails on HP-UX 11.00..11.11. */
46 int fd = open ("conftest.c", O_RDONLY);
52 if (pread (fd, &byte_buf, 1, (off_t) 0) != 1)
57 /* This test fails on HP-UX 11.00..11.31. */
59 FILE *fp = popen ("echo", "r");
66 if (pread (fd, &byte_buf, 1, (off_t) 0) >= 0)
73 [gl_cv_func_pread_works=yes],
74 [gl_cv_func_pread_works=no],
76 CPPFLAGS="$gl_save_CPPFLAGS"
78 case "$gl_cv_func_pread_works" in