aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics/stat.c
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2007-03-31 19:41:11 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2007-03-31 19:41:11 +0000
commit29e86cb09c6ffe497456341864551b504c9a6f4f (patch)
treebfeff7227b047cec60eb9fd962576f8748c6f8f0 /libgfortran/intrinsics/stat.c
parent3f5faa7ceae547a56f1335e66a359c0a8063a182 (diff)
downloadgcc-29e86cb09c6ffe497456341864551b504c9a6f4f.zip
gcc-29e86cb09c6ffe497456341864551b504c9a6f4f.tar.gz
gcc-29e86cb09c6ffe497456341864551b504c9a6f4f.tar.bz2
re PR libfortran/31335 (Calls lstat(), stat() and fstat() in libgfortran should be protected by autoconf HAVE_{L,,F}STAT macros)
PR libfortran/31335 * intrinsics/stat.c: Only provide STAT and FSTAT library routines if stat() and fstat() library functions are available. When lstat() is not available, use stat() instead. * configure.ac: Add checks for stat, fstat and lstat. * configure: Regenerate. * config.h.in: Regenerate. From-SVN: r123388
Diffstat (limited to 'libgfortran/intrinsics/stat.c')
-rw-r--r--libgfortran/intrinsics/stat.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/libgfortran/intrinsics/stat.c b/libgfortran/intrinsics/stat.c
index 150387d..ce65245 100644
--- a/libgfortran/intrinsics/stat.c
+++ b/libgfortran/intrinsics/stat.c
@@ -49,6 +49,9 @@ Boston, MA 02110-1301, USA. */
#include <errno.h>
+
+#ifdef HAVE_STAT
+
/* SUBROUTINE STAT(FILE, SARRAY, STATUS)
CHARACTER(len=*), INTENT(IN) :: FILE
INTEGER, INTENT(OUT), :: SARRAY(13)
@@ -88,9 +91,12 @@ stat_i4_sub_0 (char *name, gfc_array_i4 *sarray, GFC_INTEGER_4 *status,
memcpy (str, name, name_len);
str[name_len] = '\0';
+ /* On platforms that don't provide lstat(), we use stat() instead. */
+#ifdef HAVE_LSTAT
if (is_lstat)
val = lstat(str, &sb);
else
+#endif
val = stat(str, &sb);
if (val == 0)
@@ -204,9 +210,12 @@ stat_i8_sub_0 (char *name, gfc_array_i8 *sarray, GFC_INTEGER_8 *status,
memcpy (str, name, name_len);
str[name_len] = '\0';
+ /* On platforms that don't provide lstat(), we use stat() instead. */
+#ifdef HAVE_LSTAT
if (is_lstat)
val = lstat(str, &sb);
else
+#endif
val = stat(str, &sb);
if (val == 0)
@@ -319,13 +328,13 @@ stat_i8 (char *name, gfc_array_i8 *sarray, gfc_charlen_type name_len)
}
-/* SUBROUTINE STAT(FILE, SARRAY, STATUS)
+/* SUBROUTINE LSTAT(FILE, SARRAY, STATUS)
CHARACTER(len=*), INTENT(IN) :: FILE
INTEGER, INTENT(OUT), :: SARRAY(13)
INTEGER, INTENT(OUT), OPTIONAL :: STATUS
- FUNCTION STAT(FILE, SARRAY)
- INTEGER STAT
+ FUNCTION LSTAT(FILE, SARRAY)
+ INTEGER LSTAT
CHARACTER(len=*), INTENT(IN) :: FILE
INTEGER, INTENT(OUT), :: SARRAY(13) */
@@ -351,7 +360,10 @@ lstat_i8 (char *name, gfc_array_i8 *sarray, gfc_charlen_type name_len)
return val;
}
+#endif
+
+#ifdef HAVE_FSTAT
/* SUBROUTINE FSTAT(UNIT, SARRAY, STATUS)
INTEGER, INTENT(IN) :: UNIT
@@ -546,3 +558,5 @@ fstat_i8 (GFC_INTEGER_8 *unit, gfc_array_i8 *sarray)
fstat_i8_sub (unit, sarray, &val);
return val;
}
+
+#endif