Use a warranty disclaimer in all-permissive license notices, part 2.
[gnulib.git] / m4 / d-ino.m4
blob4edb43c105d81b547778c0a7022e157a7476f72d
1 # d-ino.m4
2 # serial 22
3 dnl Copyright (C) 1997, 1999-2001, 2003-2004, 2006-2007, 2009-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 dnl From Jim Meyering.
10 dnl
11 dnl Check whether struct dirent has a member named d_ino.
13 AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO],
14   [AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
15    AC_CACHE_CHECK([for d_ino member in directory struct],
16                   [gl_cv_struct_dirent_d_ino],
17      [AC_RUN_IFELSE(
18         [AC_LANG_PROGRAM(
19            [[#include <sys/types.h>
20              #include <sys/stat.h>
21              #include <dirent.h>
22            ]],
23            [[DIR *dp = opendir (".");
24              struct dirent *e;
25              struct stat st;
26              if (! dp)
27                return 1;
28              e = readdir (dp);
29              if (! e)
30                { closedir (dp); return 2; }
31              if (lstat (e->d_name, &st) != 0)
32                { closedir (dp); return 3; }
33              if (e->d_ino != st.st_ino)
34                { closedir (dp); return 4; }
35              closedir (dp);
36              return 0;
37            ]])],
38            [gl_cv_struct_dirent_d_ino=yes],
39            [gl_cv_struct_dirent_d_ino=no],
40            [case "$host_os" in
41                                  # Guess yes on glibc systems with Linux kernel.
42               linux*-gnu*)       gl_cv_struct_dirent_d_ino="guessing yes" ;;
43                                  # Guess yes on musl systems with Linux kernel.
44               linux*-musl*)      gl_cv_struct_dirent_d_ino="guessing yes" ;;
45                                  # Guess yes on systems that emulate the Linux system calls.
46               midipix*)          gl_cv_struct_dirent_d_ino="guessing yes" ;;
47                                  # Guess no on native Windows.
48               mingw* | windows*) gl_cv_struct_dirent_d_ino="guessing no" ;;
49                                  # If we don't know, obey --enable-cross-guesses.
50               *)                 gl_cv_struct_dirent_d_ino="$gl_cross_guess_normal" ;;
51             esac
52            ])])
53    case "$gl_cv_struct_dirent_d_ino" in
54      *yes)
55        AC_DEFINE([D_INO_IN_DIRENT], [1],
56          [Define if struct dirent has a member d_ino that actually works.])
57        ;;
58    esac
59   ]