diff options
author | Janne Blomqvist <jb@gcc.gnu.org> | 2016-10-09 21:05:56 +0300 |
---|---|---|
committer | Janne Blomqvist <jb@gcc.gnu.org> | 2016-10-09 21:05:56 +0300 |
commit | b9233944298c0975a7cab3b1053c3ea388e9fd15 (patch) | |
tree | c793adb9e84177e3ddeb8a327cecd0543a6f697f /libgfortran/io/io.h | |
parent | df74f099d381013b4f52a32654f9a97c5bd39327 (diff) | |
download | gcc-b9233944298c0975a7cab3b1053c3ea388e9fd15.zip gcc-b9233944298c0975a7cab3b1053c3ea388e9fd15.tar.gz gcc-b9233944298c0975a7cab3b1053c3ea388e9fd15.tar.bz2 |
PR 67585 Handle EINTR
Many POSIX systems have the bad habit of not restarting interrupted
syscalls. On these systems it's up to the user to check for an error
with errno == EINTR and restart manually. This patch does this for
libgfortran, so that GFortran users don't have to do it.
2016-10-09 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/67585
* io/io.h: TEMP_FAILURE_RETRY: Define macro if not found.
* io/unix.c (raw_read): Handle EINTR.
(raw_write): Check for return value -1.
(raw_seek): Handle EINTR.
(raw_tell): Likewise.
(raw_size): Likewise.
(raw_truncate): Likewise.
(raw_close): Likewise.
(buf_flush): Call raw_seek instead of lseek.
(buf_read): Likewise.
(buf_write): Likewise.
(fd_to_stream): Handle EINTR.
(tempfile_open): Likewise.
(regular_file2): Likewise.
(compare_file_filename): Likewise.
(find_file): Likewise.
(inquire_sequential): Likewise.
(inquire_direct): Likewise.
(inquire_formatted): Likewise.
From-SVN: r240902
Diffstat (limited to 'libgfortran/io/io.h')
-rw-r--r-- | libgfortran/io/io.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h index 87c3558..ea93fba 100644 --- a/libgfortran/io/io.h +++ b/libgfortran/io/io.h @@ -660,6 +660,21 @@ typedef struct gfc_saved_unit } gfc_saved_unit; +/* TEMP_FAILURE_RETRY macro from glibc. */ + +#ifndef TEMP_FAILURE_RETRY +/* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno' + set to EINTR. */ + +# define TEMP_FAILURE_RETRY(expression) \ + (__extension__ \ + ({ long int __result; \ + do __result = (long int) (expression); \ + while (__result == -1L && errno == EINTR); \ + __result; })) +#endif + + /* unit.c */ /* Maximum file offset, computed at library initialization time. */ |