open.m4 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # open.m4 serial 15
  2. dnl Copyright (C) 2007-2023 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. AC_DEFUN([gl_FUNC_OPEN],
  7. [
  8. AC_REQUIRE([AC_CANONICAL_HOST])
  9. AC_REQUIRE([gl_PREPROC_O_CLOEXEC])
  10. case "$host_os" in
  11. mingw* | pw*)
  12. REPLACE_OPEN=1
  13. ;;
  14. *)
  15. dnl open("foo/") should not create a file when the file name has a
  16. dnl trailing slash. FreeBSD only has the problem on symlinks.
  17. AC_CHECK_FUNCS_ONCE([lstat])
  18. if test "$gl_cv_macro_O_CLOEXEC" != yes; then
  19. REPLACE_OPEN=1
  20. fi
  21. gl_OPEN_TRAILING_SLASH_BUG
  22. case "$gl_cv_func_open_slash" in
  23. *no)
  24. REPLACE_OPEN=1
  25. ;;
  26. esac
  27. ;;
  28. esac
  29. dnl Replace open() for supporting the gnulib-defined fchdir() function,
  30. dnl to keep fchdir's bookkeeping up-to-date.
  31. m4_ifdef([gl_FUNC_FCHDIR], [
  32. if test $REPLACE_OPEN = 0; then
  33. gl_TEST_FCHDIR
  34. if test $HAVE_FCHDIR = 0; then
  35. REPLACE_OPEN=1
  36. fi
  37. fi
  38. ])
  39. dnl Replace open() for supporting the gnulib-defined O_NONBLOCK flag.
  40. m4_ifdef([gl_NONBLOCKING_IO], [
  41. if test $REPLACE_OPEN = 0; then
  42. gl_NONBLOCKING_IO
  43. if test $gl_cv_have_open_O_NONBLOCK != yes; then
  44. REPLACE_OPEN=1
  45. fi
  46. fi
  47. ])
  48. ])
  49. # Prerequisites of lib/open.c.
  50. AC_DEFUN([gl_PREREQ_OPEN],
  51. [
  52. AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
  53. :
  54. ])