Blame m4/ftruncate.m4

Packit Service 4684c1
# serial 20
Packit Service 4684c1
Packit Service 4684c1
# See if we need to emulate a missing ftruncate function using chsize.
Packit Service 4684c1
Packit Service 4684c1
# Copyright (C) 2000-2001, 2003-2007, 2009-2020 Free Software Foundation, Inc.
Packit Service 4684c1
# This file is free software; the Free Software Foundation
Packit Service 4684c1
# gives unlimited permission to copy and/or distribute it,
Packit Service 4684c1
# with or without modifications, as long as this notice is preserved.
Packit Service 4684c1
Packit Service 4684c1
AC_DEFUN([gl_FUNC_FTRUNCATE],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
Packit Service 4684c1
  AC_CHECK_FUNCS_ONCE([ftruncate])
Packit Service 4684c1
  if test $ac_cv_func_ftruncate = yes; then
Packit Service 4684c1
    m4_ifdef([gl_LARGEFILE], [
Packit Service 4684c1
      AC_REQUIRE([AC_CANONICAL_HOST])
Packit Service 4684c1
      case "$host_os" in
Packit Service 4684c1
        mingw*)
Packit Service 4684c1
          dnl Native Windows, and Large File Support is requested.
Packit Service 4684c1
          dnl The MSVCRT _chsize() function only accepts a 32-bit file size,
Packit Service 4684c1
          dnl and the mingw64 ftruncate64() function is unreliable (it may
Packit Service 4684c1
          dnl delete the file, see
Packit Service 4684c1
          dnl <https://web.archive.org/web/20160425005423/http://mingw-w64.sourcearchive.com/documentation/2.0-1/ftruncate64_8c_source.html>).
Packit Service 4684c1
          dnl Use gnulib's ftruncate() implementation instead.
Packit Service 4684c1
          REPLACE_FTRUNCATE=1
Packit Service 4684c1
          ;;
Packit Service 4684c1
      esac
Packit Service 4684c1
    ], [
Packit Service 4684c1
      :
Packit Service 4684c1
    ])
Packit Service 4684c1
  else
Packit Service 4684c1
    HAVE_FTRUNCATE=0
Packit Service 4684c1
  fi
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# Prerequisites of lib/ftruncate.c.
Packit Service 4684c1
AC_DEFUN([gl_PREREQ_FTRUNCATE],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_CHECK_FUNCS([chsize])
Packit Service 4684c1
])