fcntl_h.m4 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # Configure fcntl.h.
  2. dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl Written by Paul Eggert.
  7. AC_DEFUN([gl_FCNTL_H],
  8. [
  9. AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
  10. AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
  11. [AC_RUN_IFELSE(
  12. [AC_LANG_PROGRAM(
  13. [[#include <sys/types.h>
  14. #include <sys/stat.h>
  15. #include <unistd.h>
  16. #include <fcntl.h>
  17. #ifndef O_NOATIME
  18. #define O_NOATIME 0
  19. #endif
  20. #ifndef O_NOFOLLOW
  21. #define O_NOFOLLOW 0
  22. #endif
  23. static int const constants[] =
  24. {
  25. O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
  26. O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
  27. };
  28. ]],
  29. [[
  30. int status = !constants;
  31. {
  32. static char const sym[] = "conftest.sym";
  33. if (symlink (".", sym) != 0
  34. || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
  35. status |= 32;
  36. }
  37. {
  38. static char const file[] = "confdefs.h";
  39. int fd = open (file, O_RDONLY | O_NOATIME);
  40. char c;
  41. struct stat st0, st1;
  42. if (fd < 0
  43. || fstat (fd, &st0) != 0
  44. || sleep (1) != 0
  45. || read (fd, &c, 1) != 1
  46. || close (fd) != 0
  47. || stat (file, &st1) != 0
  48. || st0.st_atime != st1.st_atime)
  49. status |= 64;
  50. }
  51. return status;]])],
  52. [gl_cv_header_working_fcntl_h=yes],
  53. [case $? in #(
  54. 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
  55. 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
  56. 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
  57. *) gl_cv_header_working_fcntl_h='no';;
  58. esac],
  59. [gl_cv_header_working_fcntl_h=cross-compiling])])
  60. case $gl_cv_header_working_fcntl_h in #(
  61. *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
  62. *) ac_val=1;;
  63. esac
  64. AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
  65. [Define to 1 if O_NOATIME works.])
  66. case $gl_cv_header_working_fcntl_h in #(
  67. *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
  68. *) ac_val=1;;
  69. esac
  70. AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
  71. [Define to 1 if O_NOFOLLOW works.])
  72. gl_CHECK_NEXT_HEADERS([fcntl.h])
  73. FCNTL_H='fcntl.h'
  74. AC_SUBST([FCNTL_H])
  75. ])
  76. AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
  77. [
  78. dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
  79. AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
  80. GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
  81. ])
  82. AC_DEFUN([gl_FCNTL_H_DEFAULTS],
  83. [
  84. GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
  85. dnl Assume proper GNU behavior unless another module says otherwise.
  86. REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
  87. ])