d-ino.m4 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # serial 20
  2. dnl From Jim Meyering.
  3. dnl
  4. dnl Check whether struct dirent has a member named d_ino.
  5. dnl
  6. # Copyright (C) 1997, 1999-2001, 2003-2004, 2006-2007, 2009-2021 Free Software
  7. # Foundation, Inc.
  8. # This file is free software; the Free Software Foundation
  9. # gives unlimited permission to copy and/or distribute it,
  10. # with or without modifications, as long as this notice is preserved.
  11. AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO],
  12. [AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  13. AC_CACHE_CHECK([for d_ino member in directory struct],
  14. [gl_cv_struct_dirent_d_ino],
  15. [AC_RUN_IFELSE(
  16. [AC_LANG_PROGRAM(
  17. [[#include <sys/types.h>
  18. #include <sys/stat.h>
  19. #include <dirent.h>
  20. ]],
  21. [[DIR *dp = opendir (".");
  22. struct dirent *e;
  23. struct stat st;
  24. if (! dp)
  25. return 1;
  26. e = readdir (dp);
  27. if (! e)
  28. { closedir (dp); return 2; }
  29. if (lstat (e->d_name, &st) != 0)
  30. { closedir (dp); return 3; }
  31. if (e->d_ino != st.st_ino)
  32. { closedir (dp); return 4; }
  33. closedir (dp);
  34. return 0;
  35. ]])],
  36. [gl_cv_struct_dirent_d_ino=yes],
  37. [gl_cv_struct_dirent_d_ino=no],
  38. [case "$host_os" in
  39. # Guess yes on glibc systems with Linux kernel.
  40. linux*-gnu*) gl_cv_struct_dirent_d_ino="guessing yes" ;;
  41. # Guess yes on musl systems with Linux kernel.
  42. linux*-musl*) gl_cv_struct_dirent_d_ino="guessing yes" ;;
  43. # Guess no on native Windows.
  44. mingw*) gl_cv_struct_dirent_d_ino="guessing no" ;;
  45. # If we don't know, obey --enable-cross-guesses.
  46. *) gl_cv_struct_dirent_d_ino="$gl_cross_guess_normal" ;;
  47. esac
  48. ])])
  49. case "$gl_cv_struct_dirent_d_ino" in
  50. *yes)
  51. AC_DEFINE([D_INO_IN_DIRENT], [1],
  52. [Define if struct dirent has a member d_ino that actually works.])
  53. ;;
  54. esac
  55. ]
  56. )