Blame m4/fseeko.m4

Packit 8f70b4
# fseeko.m4 serial 19
Packit 8f70b4
dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
Packit 8f70b4
dnl This file is free software; the Free Software Foundation
Packit 8f70b4
dnl gives unlimited permission to copy and/or distribute it,
Packit 8f70b4
dnl with or without modifications, as long as this notice is preserved.
Packit 8f70b4
Packit 8f70b4
AC_DEFUN([gl_FUNC_FSEEKO],
Packit 8f70b4
[
Packit 8f70b4
  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
Packit 8f70b4
  AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
Packit 8f70b4
  AC_REQUIRE([gl_SYS_TYPES_H])
Packit 8f70b4
  AC_REQUIRE([AC_PROG_CC])
Packit 8f70b4
Packit 8f70b4
  dnl Persuade glibc <stdio.h> to declare fseeko().
Packit 8f70b4
  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
Packit 8f70b4
Packit 8f70b4
  AC_CACHE_CHECK([for fseeko], [gl_cv_func_fseeko],
Packit 8f70b4
    [
Packit 8f70b4
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
Packit 8f70b4
]], [fseeko (stdin, 0, 0);])],
Packit 8f70b4
        [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
Packit 8f70b4
    ])
Packit 8f70b4
Packit 8f70b4
  AC_CHECK_DECLS_ONCE([fseeko])
Packit 8f70b4
  if test $ac_cv_have_decl_fseeko = no; then
Packit 8f70b4
    HAVE_DECL_FSEEKO=0
Packit 8f70b4
  fi
Packit 8f70b4
Packit 8f70b4
  if test $gl_cv_func_fseeko = no; then
Packit 8f70b4
    HAVE_FSEEKO=0
Packit 8f70b4
  else
Packit 8f70b4
    if test $WINDOWS_64_BIT_OFF_T = 1; then
Packit 8f70b4
      REPLACE_FSEEKO=1
Packit 8f70b4
    fi
Packit 8f70b4
    if test $gl_cv_var_stdin_large_offset = no; then
Packit 8f70b4
      REPLACE_FSEEKO=1
Packit 8f70b4
    fi
Packit 8f70b4
    m4_ifdef([gl_FUNC_FFLUSH_STDIN], [
Packit 8f70b4
      gl_FUNC_FFLUSH_STDIN
Packit 8f70b4
      case "$gl_cv_func_fflush_stdin" in
Packit 8f70b4
        *yes) ;;
Packit 8f70b4
        *) REPLACE_FSEEKO=1 ;;
Packit 8f70b4
      esac
Packit 8f70b4
    ])
Packit 8f70b4
  fi
Packit 8f70b4
])
Packit 8f70b4
Packit 8f70b4
dnl Code shared by fseeko and ftello.  Determine if large files are supported,
Packit 8f70b4
dnl but stdin does not start as a large file by default.
Packit 8f70b4
AC_DEFUN([gl_STDIN_LARGE_OFFSET],
Packit 8f70b4
  [
Packit 8f70b4
    AC_CACHE_CHECK([whether stdin defaults to large file offsets],
Packit 8f70b4
      [gl_cv_var_stdin_large_offset],
Packit 8f70b4
      [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
Packit 8f70b4
[[#if defined __SL64 && defined __SCLE /* cygwin */
Packit 8f70b4
  /* Cygwin 1.5.24 and earlier fail to put stdin in 64-bit mode, making
Packit 8f70b4
     fseeko/ftello needlessly fail.  This bug was fixed in 1.5.25, and
Packit 8f70b4
     it is easier to do a version check than building a runtime test.  */
Packit 8f70b4
# include <cygwin/version.h>
Packit 8f70b4
# if CYGWIN_VERSION_DLL_COMBINED < CYGWIN_VERSION_DLL_MAKE_COMBINED (1005, 25)
Packit 8f70b4
  choke me
Packit 8f70b4
# endif
Packit 8f70b4
#endif]])],
Packit 8f70b4
        [gl_cv_var_stdin_large_offset=yes],
Packit 8f70b4
        [gl_cv_var_stdin_large_offset=no])])
Packit 8f70b4
])
Packit 8f70b4
Packit 8f70b4
# Prerequisites of lib/fseeko.c.
Packit 8f70b4
AC_DEFUN([gl_PREREQ_FSEEKO],
Packit 8f70b4
[
Packit 8f70b4
  dnl Native Windows has the function _fseeki64. mingw hides it in some
Packit 8f70b4
  dnl circumstances, but mingw64 makes it usable again.
Packit 8f70b4
  AC_CHECK_FUNCS([_fseeki64])
Packit 8f70b4
  if test $ac_cv_func__fseeki64 = yes; then
Packit 8f70b4
    AC_CHECK_DECLS([_fseeki64])
Packit 8f70b4
  fi
Packit 8f70b4
])