1 1.1 christos # open.m4 serial 15 2 1.1.1.2 christos dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. 3 1.1 christos dnl This file is free software; the Free Software Foundation 4 1.1 christos dnl gives unlimited permission to copy and/or distribute it, 5 1.1 christos dnl with or without modifications, as long as this notice is preserved. 6 1.1 christos 7 1.1 christos AC_DEFUN([gl_FUNC_OPEN], 8 1.1 christos [ 9 1.1 christos AC_REQUIRE([AC_CANONICAL_HOST]) 10 1.1 christos AC_REQUIRE([gl_PREPROC_O_CLOEXEC]) 11 1.1 christos case "$host_os" in 12 1.1 christos mingw* | pw*) 13 1.1 christos REPLACE_OPEN=1 14 1.1 christos ;; 15 1.1 christos *) 16 1.1 christos dnl open("foo/") should not create a file when the file name has a 17 1.1 christos dnl trailing slash. FreeBSD only has the problem on symlinks. 18 1.1 christos AC_CHECK_FUNCS_ONCE([lstat]) 19 1.1 christos if test "$gl_cv_macro_O_CLOEXEC" != yes; then 20 1.1 christos REPLACE_OPEN=1 21 1.1 christos fi 22 1.1 christos gl_OPEN_TRAILING_SLASH_BUG 23 1.1 christos case "$gl_cv_func_open_slash" in 24 1.1 christos *no) 25 1.1 christos REPLACE_OPEN=1 26 1.1 christos ;; 27 1.1 christos esac 28 1.1 christos ;; 29 1.1 christos esac 30 1.1 christos dnl Replace open() for supporting the gnulib-defined fchdir() function, 31 1.1 christos dnl to keep fchdir's bookkeeping up-to-date. 32 1.1 christos m4_ifdef([gl_FUNC_FCHDIR], [ 33 1.1 christos if test $REPLACE_OPEN = 0; then 34 1.1 christos gl_TEST_FCHDIR 35 1.1 christos if test $HAVE_FCHDIR = 0; then 36 1.1 christos REPLACE_OPEN=1 37 1.1 christos fi 38 1.1 christos fi 39 1.1 christos ]) 40 1.1 christos dnl Replace open() for supporting the gnulib-defined O_NONBLOCK flag. 41 1.1 christos m4_ifdef([gl_NONBLOCKING_IO], [ 42 1.1 christos if test $REPLACE_OPEN = 0; then 43 1.1 christos gl_NONBLOCKING_IO 44 1.1 christos if test $gl_cv_have_open_O_NONBLOCK != yes; then 45 1.1 christos REPLACE_OPEN=1 46 1.1 christos fi 47 1.1 christos fi 48 1.1 christos ]) 49 1.1 christos ]) 50 1.1 christos 51 1.1 christos # Prerequisites of lib/open.c. 52 1.1 christos AC_DEFUN([gl_PREREQ_OPEN], 53 1.1 christos [ 54 1.1 christos AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T]) 55 1.1 christos : 56 1.1 christos ]) 57