Commit 2515e5a7 by Francois-Xavier Coudert Committed by François-Xavier Coudert

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
parent 7c4d947f
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> 2007-09-12 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* io/io.h: Include libgfortran.h first. * io/io.h: Include libgfortran.h first.
......
...@@ -273,6 +273,9 @@ ...@@ -273,6 +273,9 @@
/* Define to 1 if you have the <dlfcn.h> header file. */ /* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H #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. */ /* Define to 1 if you have the `dup2' function. */
#undef HAVE_DUP2 #undef HAVE_DUP2
...@@ -384,6 +387,9 @@ ...@@ -384,6 +387,9 @@
/* Define to 1 if you have the `ftruncate' function. */ /* Define to 1 if you have the `ftruncate' function. */
#undef HAVE_FTRUNCATE #undef HAVE_FTRUNCATE
/* Define to 1 if you have the `getcwd' function. */
#undef HAVE_GETCWD
/* libc includes geteuid */ /* libc includes geteuid */
#undef HAVE_GETEUID #undef HAVE_GETEUID
......
...@@ -18481,7 +18481,9 @@ done ...@@ -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 do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5 echo "$as_me:$LINENO: checking for $ac_func" >&5
......
...@@ -192,7 +192,7 @@ AC_CHECK_FUNCS(getrusage times mkstemp strtof strtold snprintf ftruncate chsize) ...@@ -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(chdir strerror getlogin gethostname kill link symlink perror)
AC_CHECK_FUNCS(sleep time ttyname signal alarm ctime clock access fork execl) 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(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 # Check for glibc backtrace functions
AC_CHECK_FUNCS(backtrace backtrace_symbols) AC_CHECK_FUNCS(backtrace backtrace_symbols)
......
...@@ -37,6 +37,8 @@ Boston, MA 02110-1301, USA. */ ...@@ -37,6 +37,8 @@ Boston, MA 02110-1301, USA. */
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef HAVE_GETCWD
extern void getcwd_i4_sub (char *, GFC_INTEGER_4 *, gfc_charlen_type); extern void getcwd_i4_sub (char *, GFC_INTEGER_4 *, gfc_charlen_type);
iexport_proto(getcwd_i4_sub); iexport_proto(getcwd_i4_sub);
...@@ -82,3 +84,5 @@ PREFIX(getcwd) (char *cwd, gfc_charlen_type cwd_len) ...@@ -82,3 +84,5 @@ PREFIX(getcwd) (char *cwd, gfc_charlen_type cwd_len)
getcwd_i4_sub (cwd, &status, cwd_len); getcwd_i4_sub (cwd, &status, cwd_len);
return status; return status;
} }
#endif
...@@ -211,13 +211,13 @@ move_pos_offset (stream* st, int pos_off) ...@@ -211,13 +211,13 @@ move_pos_offset (stream* st, int pos_off)
static int static int
fix_fd (int fd) fix_fd (int fd)
{ {
#ifdef HAVE_DUP
int input, output, error; int input, output, error;
input = output = error = 0; input = output = error = 0;
/* Unix allocates the lowest descriptors first, so a loop is not /* Unix allocates the lowest descriptors first, so a loop is not
required, but this order is. */ required, but this order is. */
if (fd == STDIN_FILENO) if (fd == STDIN_FILENO)
{ {
fd = dup (fd); fd = dup (fd);
...@@ -240,6 +240,7 @@ fix_fd (int fd) ...@@ -240,6 +240,7 @@ fix_fd (int fd)
close (STDOUT_FILENO); close (STDOUT_FILENO);
if (error) if (error)
close (STDERR_FILENO); close (STDERR_FILENO);
#endif
return fd; return fd;
} }
...@@ -1775,6 +1776,36 @@ inquire_unformatted (const char *string, int len) ...@@ -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 /* inquire_access()-- Given a fortran string, determine if the file is
* suitable for access. */ * suitable for access. */
......
...@@ -108,8 +108,8 @@ set_options (int num, int options[]) ...@@ -108,8 +108,8 @@ set_options (int num, int options[])
/* If backtrace is required, we set signal handlers on most common /* If backtrace is required, we set signal handlers on most common
signals. */ signals. */
#if defined(HAVE_SIGNAL_H) && (defined(SIGSEGV) || defined(SIGBUS) \ #if defined(HAVE_SIGNAL) && (defined(SIGSEGV) || defined(SIGBUS) \
|| defined(SIGILL) || defined(SIGFPE)) || defined(SIGILL) || defined(SIGFPE))
if (compile_options.backtrace) if (compile_options.backtrace)
{ {
#if defined(SIGSEGV) #if defined(SIGSEGV)
......
...@@ -120,7 +120,11 @@ store_exe_path (const char * argv0) ...@@ -120,7 +120,11 @@ store_exe_path (const char * argv0)
} }
memset (buf, 0, sizeof (buf)); memset (buf, 0, sizeof (buf));
#ifdef HAVE_GETCWD
cwd = getcwd (buf, sizeof (buf)); cwd = getcwd (buf, sizeof (buf));
#else
cwd = "";
#endif
/* exe_path will be cwd + "/" + argv[0] + "\0" */ /* exe_path will be cwd + "/" + argv[0] + "\0" */
path = malloc (strlen (cwd) + 1 + strlen (argv0) + 1); path = malloc (strlen (cwd) + 1 + strlen (argv0) + 1);
......
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