unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
blob 1b8b9d8858947c36a4e4b78d2f2066d3ae6342ed 2094 bytes (raw)
name: m4/copy-file-range.m4 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
# copy-file-range.m4
dnl Copyright 2019-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

AC_DEFUN([gl_FUNC_COPY_FILE_RANGE],
[
  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
  AC_REQUIRE([AC_CANONICAL_HOST])

  dnl Persuade glibc <unistd.h> to declare copy_file_range.
  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])

  dnl Use AC_LINK_IFELSE, rather than AC_CHECK_FUNCS or a variant,
  dnl since we don't want AC_CHECK_FUNCS's checks for glibc stubs.
  dnl Programs that use copy_file_range must fall back on read+write
  dnl anyway, and there's little point to substituting the Gnulib stub
  dnl for a glibc stub.
  AC_CACHE_CHECK([for copy_file_range], [gl_cv_func_copy_file_range],
    [AC_LINK_IFELSE(
       [AC_LANG_PROGRAM(
          [[#include <unistd.h>
          ]],
          [[ssize_t (*func) (int, off_t *, int, off_t *, size_t, unsigned)
              = copy_file_range;
            return func (0, 0, 0, 0, 0, 0) & 127;
          ]])
       ],
       [gl_cv_func_copy_file_range=yes],
       [gl_cv_func_copy_file_range=no])
    ])

  if test "$gl_cv_func_copy_file_range" != yes; then
    HAVE_COPY_FILE_RANGE=0
  else
    AC_DEFINE([HAVE_COPY_FILE_RANGE], 1,
      [Define to 1 if the function copy_file_range exists.])

    case $host_os in
      linux*)
        AC_CACHE_CHECK([whether copy_file_range is known to work],
          [gl_cv_copy_file_range_known_to_work],
          [AC_COMPILE_IFELSE(
             [AC_LANG_PROGRAM(
                [[#include <linux/version.h>
                ]],
                [[#if LINUX_VERSION_CODE < KERNEL_VERSION (5, 3, 0)
                   #error "copy_file_range is buggy"
                  #endif
                ]])],
             [gl_cv_copy_file_range_known_to_work=yes],
             [gl_cv_copy_file_range_known_to_work=no])])
        if test "$gl_cv_copy_file_range_known_to_work" = no; then
          REPLACE_COPY_FILE_RANGE=1
        fi;;
    esac
  fi
])

debug log:

solving 1b8b9d8858 ...
found 1b8b9d8858 in https://git.savannah.gnu.org/cgit/emacs.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).