summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-31 19:41:11 +0000
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-31 19:41:11 +0000
commit74b918e93581bd5b5d8dfbb8240c248c4275016d (patch)
treebfeff7227b047cec60eb9fd962576f8748c6f8f0 /libgfortran
parent6a3c46ec49a1b183cefa10dc1d79269b18194188 (diff)
downloadgcc-74b918e93581bd5b5d8dfbb8240c248c4275016d.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123388 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog10
-rw-r--r--libgfortran/config.h.in9
-rwxr-xr-xlibgfortran/configure5
-rw-r--r--libgfortran/configure.ac2
-rw-r--r--libgfortran/intrinsics/stat.c20
5 files changed, 41 insertions, 5 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 4dbc337a2d3..6b8f4f89da2 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,13 @@
+2007-03-31 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ 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.
+
2007-03-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/31052
diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in
index b6004bbe56d..fc8e73c8d40 100644
--- a/libgfortran/config.h.in
+++ b/libgfortran/config.h.in
@@ -378,6 +378,9 @@
/* libm includes frexpl */
#undef HAVE_FREXPL
+/* Define to 1 if you have the `fstat' function. */
+#undef HAVE_FSTAT
+
/* Define to 1 if you have the `ftruncate' function. */
#undef HAVE_FTRUNCATE
@@ -489,6 +492,9 @@
/* libm includes logl */
#undef HAVE_LOGL
+/* Define to 1 if you have the `lstat' function. */
+#undef HAVE_LSTAT
+
/* Define to 1 if you have the <math.h> header file. */
#undef HAVE_MATH_H
@@ -582,6 +588,9 @@
/* libm includes sqrtl */
#undef HAVE_SQRTL
+/* Define to 1 if you have the `stat' function. */
+#undef HAVE_STAT
+
/* Define to 1 if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
diff --git a/libgfortran/configure b/libgfortran/configure
index b7119c1c28a..5cc0013bb78 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -10511,7 +10511,10 @@ fi
done
-for ac_func in gettimeofday
+
+
+
+for ac_func in gettimeofday stat fstat lstat
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 60645a9e8a1..c5fb8753f89 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -177,7 +177,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 execvp pipe dup2 close fdopen strcasestr getrlimit)
-AC_CHECK_FUNCS(gettimeofday)
+AC_CHECK_FUNCS(gettimeofday stat fstat lstat)
# Check for glibc backtrace functions
AC_CHECK_FUNCS(backtrace backtrace_symbols)
diff --git a/libgfortran/intrinsics/stat.c b/libgfortran/intrinsics/stat.c
index 150387dad5b..ce652450404 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