[Patch] Don't provide lstat gfortran intrinsic if target doesn't support lstat.
Danny Smith
dannysmith@clear.net.nz
Mon Oct 23 09:44:00 GMT 2006
> From: FX Coudert
> Sent: Monday, 23 October 2006 12:27 a.m.
>
>
> > Sure that could be done. However, I think it is simpler
> just to test
> > for existence of of lstat without presuming that "LSTAT is formally
> > the
> > same as STAT" on windows. gfortran should not be making such
> > decisions
> > for any target.
FX wrote:
> I know that it's easier to test for the existence of lstat, and if
> lstat is not available, make the libgfortran LSTAT internally call
> stat instead.
>
> FX
>
OK, This is what g77 used to do and is what signal intrinsic still does:
keep the fortran intrinsic but set errno to ENOSYS and return an invalid
value
if function is not supported.
2006-10-22 Danny Smith <dannysmith@users.sourceforge.net>
* configure.ac: Test for lstat.
* configure: Regenerate.
* config.h.in: Regenerate.
* instrinsics/stat.c: Set errno to ENOSYS when lstat intrinsic
called on target with no lstat support.
Index: configure.ac
===================================================================
--- configure.ac (revision 117900)
+++ configure.ac (working copy)
@@ -172,7 +172,7 @@
AC_CHECK_FUNCS(getrusage times mkstemp strtof strtold snprintf
ftruncate chsize)
AC_CHECK_FUNCS(chdir strerror getlogin gethostname kill link symlink
perror)
AC_CHECK_FUNCS(sleep time ttyname signal alarm ctime clock access fork
execl)
-AC_CHECK_FUNCS(wait setmode)
+AC_CHECK_FUNCS(wait setmode lstat)
# Check for types
AC_CHECK_TYPES([intptr_t])
Index: intrinsics/stat.c
===================================================================
--- intrinsics/stat.c (revision 117900)
+++ intrinsics/stat.c (working copy)
@@ -89,7 +89,14 @@
str[name_len] = '\0';
if (is_lstat)
+#ifdef HAVE_LSTAT
val = lstat(str, &sb);
+#else
+ {
+ val = -1;
+ errno = ENOSYS;
+ }
+#endif
else
val = stat(str, &sb);
@@ -178,7 +185,6 @@
iexport(lstat_i4_sub);
-
static void
stat_i8_sub_0 (char *name, gfc_array_i8 *sarray, GFC_INTEGER_8 *status,
gfc_charlen_type name_len, int is_lstat)
@@ -205,7 +211,14 @@
str[name_len] = '\0';
if (is_lstat)
+#ifdef HAVE_LSTAT
val = lstat(str, &sb);
+#else
+ {
+ val = -1;
+ errno = ENOSYS;
+ }
+#endif
else
val = stat(str, &sb);
More information about the Fortran
mailing list