2 dnl Copyright (C) 2007-2017 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.
7 AC_DEFUN([gl_FUNC_OPEN],
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_PREPROC_O_CLOEXEC])
16 dnl open("foo/") should not create a file when the file name has a
17 dnl trailing slash. FreeBSD only has the problem on symlinks.
18 AC_CHECK_FUNCS_ONCE([lstat])
19 if test "$gl_cv_macro_O_CLOEXEC" != yes; then
22 AC_CACHE_CHECK([whether open recognizes a trailing slash],
23 [gl_cv_func_open_slash],
24 [# Assume that if we have lstat, we can also check symlinks.
25 if test $ac_cv_func_lstat = yes; then
27 ln -s conftest.tmp conftest.lnk
39 if (open ("conftest.lnk/", O_RDONLY) != -1)
42 if (open ("conftest.sl/", O_CREAT, 0600) >= 0)
46 [gl_cv_func_open_slash=yes],
47 [gl_cv_func_open_slash=no],
51 freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
52 gl_cv_func_open_slash="guessing no" ;;
54 gl_cv_func_open_slash="guessing yes" ;;
58 rm -f conftest.sl conftest.tmp conftest.lnk
60 case "$gl_cv_func_open_slash" in
62 AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
63 [Define to 1 if open() fails to recognize a trailing slash.])
69 dnl Replace open() for supporting the gnulib-defined fchdir() function,
70 dnl to keep fchdir's bookkeeping up-to-date.
71 m4_ifdef([gl_FUNC_FCHDIR], [
72 if test $REPLACE_OPEN = 0; then
74 if test $HAVE_FCHDIR = 0; then
79 dnl Replace open() for supporting the gnulib-defined O_NONBLOCK flag.
80 m4_ifdef([gl_NONBLOCKING_IO], [
81 if test $REPLACE_OPEN = 0; then
83 if test $gl_cv_have_open_O_NONBLOCK != yes; then
90 # Prerequisites of lib/open.c.
91 AC_DEFUN([gl_PREREQ_OPEN],
93 AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])