re PR libfortran/21185 (Improve testsuite results on newlib targets)

PR libfortran/21185
	* runtime/compile_options.c (set_options): Fix typo.
	* runtime/main.c (store_exe_path): If getcwd is not available,
	don't use it.
	* intrinsics/getcwd.c: Same thing here.
	* io/unix.c (fallback_access): New fallback function for access.
	(fix_fd): Don't use dup if it's not available.
	* configure.ac: Check for dup and getcwd.
	* configure: Regenerate.
	* config.h.in: Regenerate.

From-SVN: r128512
This commit is contained in:
Francois-Xavier Coudert 2007-09-15 14:52:46 +00:00 committed by François-Xavier Coudert
parent 7c4d947f29
commit 2515e5a7a0
8 changed files with 65 additions and 5 deletions

View File

@ -1,3 +1,16 @@
2007-09-15 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR libfortran/21185
* runtime/compile_options.c (set_options): Fix typo.
* runtime/main.c (store_exe_path): If getcwd is not available,
don't use it.
* intrinsics/getcwd.c: Same thing here.
* io/unix.c (fallback_access): New fallback function for access.
(fix_fd): Don't use dup if it's not available.
* configure.ac: Check for dup and getcwd.
* configure: Regenerate.
* config.h.in: Regenerate.
2007-09-12 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* io/io.h: Include libgfortran.h first.

View File

@ -273,6 +273,9 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the `dup' function. */
#undef HAVE_DUP
/* Define to 1 if you have the `dup2' function. */
#undef HAVE_DUP2
@ -384,6 +387,9 @@
/* Define to 1 if you have the `ftruncate' function. */
#undef HAVE_FTRUNCATE
/* Define to 1 if you have the `getcwd' function. */
#undef HAVE_GETCWD
/* libc includes geteuid */
#undef HAVE_GETEUID

View File

@ -18481,7 +18481,9 @@ done
for ac_func in gettimeofday stat fstat lstat getpwuid vsnprintf
for ac_func in gettimeofday stat fstat lstat getpwuid vsnprintf dup getcwd
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5

View File

@ -192,7 +192,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 stat fstat lstat getpwuid vsnprintf)
AC_CHECK_FUNCS(gettimeofday stat fstat lstat getpwuid vsnprintf dup getcwd)
# Check for glibc backtrace functions
AC_CHECK_FUNCS(backtrace backtrace_symbols)

View File

@ -37,6 +37,8 @@ Boston, MA 02110-1301, USA. */
#include <unistd.h>
#endif
#ifdef HAVE_GETCWD
extern void getcwd_i4_sub (char *, GFC_INTEGER_4 *, gfc_charlen_type);
iexport_proto(getcwd_i4_sub);
@ -82,3 +84,5 @@ PREFIX(getcwd) (char *cwd, gfc_charlen_type cwd_len)
getcwd_i4_sub (cwd, &status, cwd_len);
return status;
}
#endif

View File

@ -211,13 +211,13 @@ move_pos_offset (stream* st, int pos_off)
static int
fix_fd (int fd)
{
#ifdef HAVE_DUP
int input, output, error;
input = output = error = 0;
/* Unix allocates the lowest descriptors first, so a loop is not
required, but this order is. */
if (fd == STDIN_FILENO)
{
fd = dup (fd);
@ -240,6 +240,7 @@ fix_fd (int fd)
close (STDOUT_FILENO);
if (error)
close (STDERR_FILENO);
#endif
return fd;
}
@ -1775,6 +1776,36 @@ inquire_unformatted (const char *string, int len)
}
#ifndef HAVE_ACCESS
#ifndef W_OK
#define W_OK 2
#endif
#ifndef R_OK
#define R_OK 4
#endif
/* Fallback implementation of access() on systems that don't have it.
Only modes R_OK and W_OK are used in this file. */
static int
fallback_access (const char *path, int mode)
{
if ((mode & R_OK) && open (path, O_RDONLY) < 0)
return -1;
if ((mode & W_OK) && open (path, O_WRONLY) < 0)
return -1;
return 0;
}
#undef access
#define access fallback_access
#endif
/* inquire_access()-- Given a fortran string, determine if the file is
* suitable for access. */

View File

@ -108,8 +108,8 @@ set_options (int num, int options[])
/* If backtrace is required, we set signal handlers on most common
signals. */
#if defined(HAVE_SIGNAL_H) && (defined(SIGSEGV) || defined(SIGBUS) \
|| defined(SIGILL) || defined(SIGFPE))
#if defined(HAVE_SIGNAL) && (defined(SIGSEGV) || defined(SIGBUS) \
|| defined(SIGILL) || defined(SIGFPE))
if (compile_options.backtrace)
{
#if defined(SIGSEGV)

View File

@ -120,7 +120,11 @@ store_exe_path (const char * argv0)
}
memset (buf, 0, sizeof (buf));
#ifdef HAVE_GETCWD
cwd = getcwd (buf, sizeof (buf));
#else
cwd = "";
#endif
/* exe_path will be cwd + "/" + argv[0] + "\0" */
path = malloc (strlen (cwd) + 1 + strlen (argv0) + 1);