X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=blobdiff_plain;f=libgfortran%2Facinclude.m4;h=4355d3a12fc87f6528eb4441de95df6ae02db531;hp=2dc8f85e16b6019c0c8d6fccd8ecbbe5ec913909;hb=1dc95e51b6a997cb9ed237f0ee1df56782c8a00e;hpb=4f330f9b87ea73a85ab24f4815149c00da3bcfaf diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4 index 2dc8f85e16b..4355d3a12fc 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 +#include +#include +#include + +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])