This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
All, Here's the big one. This patch proposes an extension to both the GNU Fortran front-end and runtime library (libgfortran) to support three additional I/O specifiers: CARRIAGECONTROL, READONLY, and SHARE for compatibility with legacy compilers/code. Here's a summary of what the specifiers actually do: CARRIAGECONTROL is to control line termination settings between output records. READONLY implies ACTION='READ' and additionally prevents STATUS='DELETE' from deleting a file on CLOSE. SHARE provides OS-level locks. These specifiers are designed to match the syntax and behavior of legacy compilers. For more info see the attached test cases, source code, and documentation. Each comes with an IOPARM_OPEN_ bit, and CC+SHARE have IOPARM_INQUIRE_ bits. The st_parameter_dt structure needs an additional two bytes to propagate information with CARRIAGECONTROL='FORTRAN'. These two bytes still leave plenty of trailing 'pad' for future expansion. Bootstraps and regtests on x86_64-redhat-linux. There's a fair bit to sift through, so feel free to ask for clarification or provide comments/constructive criticism. OK for trunk? --- Fritz Reese From: Fritz Reese <fritzoreese@gmail.com> Date: Wed, 5 Oct 2016 20:18:16 -0400 Subject: [PATCH] New I/O specifiers CARRIAGECONTROL, READONLY, SHARE with -fdec gcc/fortran/ * gfortran.texi: Document. * frontend-passes.c (gfc_code_walker): Add SHARE and CARRIAGECONTROL. * io.c (gfc_free_open, gfc_resolve_open, gfc_match_open): Ditto. * gfortran.h (gfc_open): Add SHARE, CARRIAGECONTROL, and READONLY. * io.c (io_tag, match_open_element): Ditto. * ioparm.def: Ditto. * trans-io.c (gfc_trans_open): Ditto. * io.c (match_dec_etag, match_dec_ftag): New functions. libgfortran/io/ * libgfortran.h (IOPARM_OPEN_HAS_READONLY, IOPARM_OPEN_HAS_SHARE, IOPARM_OPEN_HAS_CC): New for READONLY, SHARE, and CARRIAGECONTROL. * close.c (st_close): Support READONLY. * io.h (st_parameter_open, unit_flags): Support SHARE, CARRIAGECONTROL, and READONLY. * open.c (st_open): Ditto. * transfer.c (data_transfer_init): Ditto. * io.h (st_parameter_dt): New member 'cc' for CARRIAGECONTROL. * write.c (write_check_cc, write_cc): New functions for CARRIAGECONTROL. * transfer.c (next_record_cc): Ditto. * file_pos.c (st_endfile): Support SHARE and CARRIAGECONTROL. * io.h (st_parameter_inquire): Ditto. * open.c (edit_modes, new_unit): Ditto. * inquire.c (inquire_via_unit, inquire_via_filename): Ditto. * io.h (unit_share, unit_cc, cc_fortran, IOPARM_INQUIRE_HAS_SHARE, IOPARM_INQUIRE_HAS_CC): New for SHARE and CARRIAGECONTROL. * open.c (share_opt, cc_opt): Ditto. * read.c (read_x): Support CARRIAGECONTROL. * transfer.c (read_sf, next_record_r, next_record_w): Ditto. * write.c (list_formatted_write_scalar, write_a): Ditto. * unix.h (close_share): New prototype. * unix.c (open_share, close_share): New functions to handle SHARE. * unix.c (open_external): Handle READONLY. Call open_share. * close.c (st_close): Call close_share. gcc/testsuite/ * dec_io_1.f90: New test. * dec_io_2.f90: New test. * dec_io_3.f90: New test. * dec_io_4.f90: New test. * dec_io_5.f90: New test. * dec_io_6.f90: New test. --- gcc/fortran/frontend-passes.c | 2 + gcc/fortran/gfortran.h | 6 +- gcc/fortran/gfortran.texi | 92 ++++++++++++++++- gcc/fortran/io.c | 177 +++++++++++++++++++++++++++++++- gcc/fortran/ioparm.def | 6 + gcc/fortran/trans-io.c | 15 +++ gcc/testsuite/gfortran.dg/dec_io_1.f90 | 101 ++++++++++++++++++ gcc/testsuite/gfortran.dg/dec_io_2.f90 | 104 +++++++++++++++++++ gcc/testsuite/gfortran.dg/dec_io_3.f90 | 15 +++ gcc/testsuite/gfortran.dg/dec_io_4.f90 | 17 +++ gcc/testsuite/gfortran.dg/dec_io_5.f90 | 17 +++ gcc/testsuite/gfortran.dg/dec_io_6.f90 | 15 +++ libgfortran/io/close.c | 16 ++- libgfortran/io/file_pos.c | 2 + libgfortran/io/inquire.c | 58 +++++++++++ libgfortran/io/io.h | 51 +++++++++ libgfortran/io/open.c | 47 +++++++++ libgfortran/io/read.c | 3 +- libgfortran/io/transfer.c | 59 +++++++++-- libgfortran/io/unit.c | 6 + libgfortran/io/unix.c | 89 ++++++++++++++++- libgfortran/io/unix.h | 3 + libgfortran/io/write.c | 141 +++++++++++++++++++++++++- libgfortran/libgfortran.h | 4 + 24 files changed, 1024 insertions(+), 22 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/dec_io_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/dec_io_2.f90 create mode 100644 gcc/testsuite/gfortran.dg/dec_io_3.f90 create mode 100644 gcc/testsuite/gfortran.dg/dec_io_4.f90 create mode 100644 gcc/testsuite/gfortran.dg/dec_io_5.f90 create mode 100644 gcc/testsuite/gfortran.dg/dec_io_6.f90
Attachment:
dec_io.diff
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |