Commit 29e86cb0 by Francois-Xavier Coudert Committed by François-Xavier Coudert

re PR libfortran/31335 (Calls lstat(), stat() and fstat() in libgfortran should…

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
parent 3f5faa7c
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
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment