2 dnl Copyright (C) 2007-2010 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])
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 AC_CACHE_CHECK([whether open recognizes a trailing slash],
19 [gl_cv_func_open_slash],
20 [# Assume that if we have lstat, we can also check symlinks.
21 if test $ac_cv_func_lstat = yes; then
23 ln -s conftest.tmp conftest.lnk
33 if (open ("conftest.lnk/", O_RDONLY) != -1) return 2;
35 return open ("conftest.sl/", O_CREAT, 0600) >= 0;
36 }], [gl_cv_func_open_slash=yes], [gl_cv_func_open_slash=no],
40 freebsd*) gl_cv_func_open_slash="guessing no" ;;
41 solaris2.[0-9]*) gl_cv_func_open_slash="guessing no" ;;
42 hpux*) gl_cv_func_open_slash="guessing no" ;;
43 *) gl_cv_func_open_slash="guessing yes" ;;
47 rm -f conftest.sl conftest.tmp conftest.lnk
49 case "$gl_cv_func_open_slash" in
51 AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
52 [Define to 1 if open() fails to recognize a trailing slash.])
60 AC_DEFUN([gl_REPLACE_OPEN],
62 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
68 # Prerequisites of lib/open.c.
69 AC_DEFUN([gl_PREREQ_OPEN],
71 AC_REQUIRE([AC_C_INLINE])
72 AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])