aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io/unix.c
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2007-09-15 14:52:46 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2007-09-15 14:52:46 +0000
commit2515e5a7a08bdb033e3fe6370774cf7359b9811e (patch)
tree0048e16af72d2eef9bf9f9e8ac0d78574ea4bf40 /libgfortran/io/unix.c
parent7c4d947f29a565331ef92c4f0a15624b4821269a (diff)
downloadgcc-2515e5a7a08bdb033e3fe6370774cf7359b9811e.zip
gcc-2515e5a7a08bdb033e3fe6370774cf7359b9811e.tar.gz
gcc-2515e5a7a08bdb033e3fe6370774cf7359b9811e.tar.bz2
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
Diffstat (limited to 'libgfortran/io/unix.c')
-rw-r--r--libgfortran/io/unix.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 8acc02e..6cb578f 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -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. */