diff options
author | Francois-Xavier Coudert <coudert@clipper.ens.fr> | 2005-08-27 18:01:54 +0200 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2005-08-27 16:01:54 +0000 |
commit | 10c682a0cb57e9ed0d5bb47a20af7932486b56a5 (patch) | |
tree | 3714317919d36904c407fd6ec57fe25087da4709 /libgfortran/acinclude.m4 | |
parent | ec53fc93d0fbfac2037da571ce5e637ef0c437ee (diff) | |
download | gcc-10c682a0cb57e9ed0d5bb47a20af7932486b56a5.zip gcc-10c682a0cb57e9ed0d5bb47a20af7932486b56a5.tar.gz gcc-10c682a0cb57e9ed0d5bb47a20af7932486b56a5.tar.bz2 |
acinclude.m4 (LIBGFOR_CHECK_UNLINK_OPEN_FILE): Add check to see if target can unlink open files.
* acinclude.m4 (LIBGFOR_CHECK_UNLINK_OPEN_FILE): Add check to see
if target can unlink open files.
* configure.ac: Use this new test.
* config.h.in: Regenerate.
* configure: Regenerate.
* Makefile.in: Regenerate.
* aclocal.ac: Regenerate.
* io/io.h: Add prototype for unpack_filename.
* io/close.c (st_close): Delete file after closing unit if
HAVE_UNLINK_OPEN_FILE is not defined.
* io/unix.c (unpack_filename): Unlink scratch file after opening
it only if HAVE_UNLINK_OPEN_FILE is defined.
From-SVN: r103566
Diffstat (limited to 'libgfortran/acinclude.m4')
-rw-r--r-- | libgfortran/acinclude.m4 | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4 index 2dc8f85..4355d3a 100644 --- a/libgfortran/acinclude.m4 +++ b/libgfortran/acinclude.m4 @@ -148,3 +148,38 @@ extern void bar(void) __attribute__((alias(ULP "foo")));], AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1, [Define to 1 if the target supports __attribute__((alias(...))).]) fi]) + +dnl Check whether target can unlink a file still open. +AC_DEFUN([LIBGFOR_CHECK_UNLINK_OPEN_FILE], [ + AC_CACHE_CHECK([whether the target can unlink an open file], + have_unlink_open_file, [ + AC_TRY_RUN([ +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/stat.h> + +int main () +{ + int fd; + + fd = open ("testfile", O_RDWR | O_CREAT, S_IWRITE | S_IREAD); + if (fd <= 0) + return 0; + if (unlink ("testfile") == -1) + return 1; + write (fd, "This is a test\n", 15); + close (fd); + + if (open ("testfile", O_RDONLY, S_IWRITE | S_IREAD) == -1 && errno == ENOENT) + return 0; + else + return 1; +}], have_unlink_open_file=yes, have_unlink_open_file=no, [ +case "${target}" in + *mingw*) have_unlink_open_file=no ;; + *) have_unlink_open_file=yes;; +esac])]) +if test x"$have_unlink_open_file" = xyes; then + AC_DEFINE(HAVE_UNLINK_OPEN_FILE, 1, [Define if target can unlink open files.]) +fi]) |