* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128512
138bc75d-0d04-0410-961f-
82ee72b054a4
+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.
/* 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
/* 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
-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
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)
#include <unistd.h>
#endif
+#ifdef HAVE_GETCWD
+
extern void getcwd_i4_sub (char *, GFC_INTEGER_4 *, gfc_charlen_type);
iexport_proto(getcwd_i4_sub);
getcwd_i4_sub (cwd, &status, cwd_len);
return status;
}
+
+#endif
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);
close (STDOUT_FILENO);
if (error)
close (STDERR_FILENO);
+#endif
return fd;
}
}
+#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. */
/* 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)
}
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);