Commit Graph

58 Commits

Author SHA1 Message Date
Janne Blomqvist 67c24a8bd6 PR 53796 Improve INQUIRE(RECL=...) handling
The current F2018 draft (N2137) specifies behavior of the RECL=
specifier in the INQUIRE statement, where it previously was left as
undefined. Namely:

- If the unit is not connected, RECL= should be given the value -1.
- If the unit is connected with stream access, RECL= should be given
  the value -2.

Further, as PR 53796 describes, the handling of RECL= is poor in other
ways as well. When the recl is set to the maximum possible
(GFC_INTEGER_8_HUGE / LLONG_MAX), which it does by default except for
preconnected units, and when INQUIRE(RECL=) is used with a 4 byte
integer, the value is truncated and the 4 byte value is thus
-1. Fixing this to generate an error is a lot of work, as currently
the truncation is done by the frontend, the library sees only an 8
byte value with no indication that the frontend is going to copy it to
a 4 byte one. Instead, this patch does a bit twiddling trick such that
the truncated 4 byte value is GFC_INTEGER_4_HUGE while still being
0.99999999 * GFC_INTEGER_8_HUGE which is large enough for all
practical purposes.

Finally, the patch removes GFORTRAN_DEFAULT_RECL which was used only
for preconnected units, and instead uses the same approach as describe
above.

Regtested on x86_64-pc-linux-gnu, Ok for trunk.

gcc/fortran/ChangeLog:

2017-11-28  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/53796
	* gfortran.texi: Remove mentions of GFORTRAN_DEFAULT_RECL.

libgfortran/ChangeLog:

2017-11-28  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/53796
	* io/inquire.c (inquire_via_unit): Set recl to -1 for unconnected
	units.
	* io/io.h (default_recl): New variable.
	* io/open.c (new_unit): Set recl to default_recl for sequential,
	-2 for stream access.
	* io/transfer.c (read_block_form): Test against default_recl
	instead of DEFAULT_RECL.
	(write_block): Likewise.
	* io/unit.c (init_units): Calculate max_offset, default_recl.
	* libgfortran.h (DEFAULT_RECL): Remove.
	* runtime/environ.c: Remove GFORTRAN_DEFAULT_RECL.

gcc/testsuite/ChangeLog:

2017-11-28  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/53796
	* gfortran.dg/inquire_recl_f2018.f90: New test.

From-SVN: r255215
2017-11-28 21:28:50 +02:00
Janne Blomqvist 5675291ddb PR 83097 Use __BYTE_ORDER__ predefined macro instead of runtime check
By using the __BYTE_ORDER__ predefined macro we don't need the
determine_endianness function anymore.

Regtested on x86_64-pc-linux-gnu.

libgfortran/ChangeLog:

2017-11-22  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/83097
	* io/inquire.c (inquire_via_unit): Use __BYTE_ORDER__ predefined
	macro.
	* io/open.c (st_open): Likewise.
	* io/transfer.c (data_transfer_init): Likewise.
	* io/write.c (btoa_big): Likewise.
	(otoa_big): Likewise.
	(ztoa_big): Likewise.
	* libgfortran.h (big_endian): Remove variable.
	(GFOR_POINTER_TO_L1): Use __BYTE_ORDER__ macro.
	* runtime/main.c (determine_endianness): Remove function.
	(init): Remove call to determine_endianness.
	* runtime/minimal.c: Remove setting big_endian variable.

From-SVN: r255072
2017-11-22 21:19:13 +02:00
Jerry DeLisle f29876bba0 close.c: Fix white space in pointer declarations and comment formats where applicable.
2017-04-11  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	* close.c: Fix white space in pointer declarations and comment
	formats where applicable.
	* fbuf.c: Likewise.
	* fbuf.h: Likewise.
	* format.c: Likewise.
	* inquire.c: Likewise.
	* intrinsics.c: Likewise.
	* list_read.c: Likewise.
	* lock.c: Likewise.
	* open.c: Likewise.
	* read.c: Likewise.
	* transfer.c: Likewise.
	* unit.c: Likewise.
	* unix.c: Likewise.
	* unix.h: Likewise.
	* write.c: Likewise.

From-SVN: r246842
2017-04-11 14:51:25 +00:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Fritz Reese 0ef33d4462 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.

From-SVN: r241550
2016-10-26 12:11:44 +00:00
Jerry DeLisle a40278c3e3 re PR libfortran/77868 (Fail to NULL guard check for internal unit in inquire_via_unit)
2016-10-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/77868
	* io/inquire.c (inquire_via_unit): NULL guard the check for
	internal unit passed into child IO procedure.

	* gfortran.dg/dtio_15.f90: Fix spaces in dg-do.
	* gfortran.dg/class_array_20.f03: Likewise.
	* gfortran.dg/class_array_21.f03: Likewise.
	* gfortran.dg/finalize_29.f08: Likewise.
	* gfortran.dg/unlimited_polymorphic_23.f90: Likewise.

From-SVN: r240794
2016-10-05 16:32:24 +00:00
Jerry DeLisle ddd12b5fb0 2016-10-04 Jerry DeLisle <jvdelisle@gcc.gnu.org>
io/inquire.c (inquire_via_unit): Add check for internal unit
	passed into child IO procedure.

From-SVN: r240768
2016-10-05 04:39:33 +00:00
Jerry DeLisle 4a8d4422b0 re PR fortran/48298 ([F03] User-Defined Derived-Type IO (DTIO))
2016-09-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/48298
	* io/inquire.c (inquire_via_unit): Adjust error check for the
	two possible internal unit KINDs.
	* io/io.h: Adjust defines for is_internal_unit and
	is_char4_unit. (gfc_unit): Add internal unit data to structure.
	(get_internal_unit): Change declaration to set_internal_unit.
	(free_internal_unit): Change name to stash_internal_unit_number.
	(get_unique_unit_number): Adjust parameter argument.
	Define IOPARM_DT_HAS_UDTIO. (gfc_saved_unit): New structure.
	* io/list_read.c (next_char_internal): Use is_char4_unit.
	* io/open.c (st_open): Adjust call to get_unique_unit_number.
	* io/transfer.c (write_block): Use is_char4_unit.
	(data_transfer_init): Update check for unit numbers.
	(st_read_done): Free the various allocated memories used for the
	internal units and stash the negative unit number and pointer to unit
	structure to allow reuse. (st_write_done): Likewise stash the freed
	unit.
	* io/unit.c: Create a fixed size buffer of 16 gfc_saved_unit's to use
	as a stack to save newunit unit numbers and unit structure for reuse.
	(get_external_unit): Change name to get_gfc_unit to better
	reflect what it does. (find_unit): Change call to get_gfc_unit.
	(find_or_create_unit): Likewise. (get_internal_unit): Change
	name to set_internal_unit. Move internal unit from the dtp
	structure to the gfc_unit structure so that it can be passed to
	child I/O statements through the UNIT.
	(free_internal_unit): Change name to stash_internal_unit_number.
	Push the common.unit number onto the newunit stack, saving it
	for possible reuse later. (get_unit): Set the internal unit
	KIND. Use get_unique_unit_number to get a negative unit number
	for the internal unit. Use get_gfc_unit to get the unit structure
	and use set_internal_unit to initialize it.
	(init_units): Initialize the newunit stack.
	(get_unique_unit_number): Check the stack for an available unit
	number and use it. If none there get the next most negative
	number. (close_units): Free any unit structures pointed to from the save
	stack.

2016-09-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/48298
	* gfortran.h (gfc_dt): Add *udtio.
	* ioparm.def: Add bit IOPARM_dt_f2003 to align with library use of bit
	25. Add IOPARM_dt_dtio bit to common flags.
	* resolve.c (resolve_transfer): Set dt->udtio to expression.
	* io.c (gfc_match_inquire): Adjust error message for internal
	unit KIND.
	* libgfortran.h: Adjust defines for GFC_INTERNAL_UNIT4,
	GFC_INTERNAL_UNIT, and GFC_INVALID_UNIT.
	* trans-io.c (build_dt): Set common_unit to reflect the KIND of
	the internal unit. Set mask bit for presence of dt->udtio.

2016-09-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/48298
	* gfortran.dg/negative_unit_check.f90: Update test.
	* gfortran.dg/dtio_14.f90: New test.

From-SVN: r240456
2016-09-23 20:36:21 +00:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Jerry DeLisle bb295963d4 re PR fortran/61933 (Inquire on internal units)
2015-01-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/61933
	* io/inquire.c (inquire_via_unit): Set existing to true for
	any negative unit that is currently connected and any positive
	units within range of KIND=4 value.  The unit value for any out
	of range case that may occur if the user is using a KIND=8 will
	have been set to -2 which is reserved and can never be opened,
	and therefore the unit does not exist.

From-SVN: r220024
2015-01-23 02:01:10 +00:00
Jerry DeLisle 351b443252 re PR fortran/61933 (Inquire on internal units)
2015-01-14  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/61933
	* io/inquire.c (inquire_via_unit): Set existing to true if a
	gfc_unit stucture was found for the given unit number.
	* runtime/error.c (translate_error): Add case for
	LIBERROR_INQUIRE_INTERNAL_UNIT.

From-SVN: r219631
2015-01-15 03:57:29 +00:00
Jakub Jelinek 5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Janne Blomqvist f5aa660f90 Fix indentation
From-SVN: r215340
2014-09-18 00:59:09 +03:00
Janne Blomqvist 010718fc37 PR libfortran/62768 Use gfc_unit.filename also when HAVE_TTYNAME{_R} is not defined.
2014-09-18  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/62768
	* io/inquire.c (inquire_via_unit): Use gfc_unit.filename also when
	HAVE_TTYNAME{_R} is not defined.

From-SVN: r215338
2014-09-18 00:44:15 +03:00
Janne Blomqvist 0e05c303e5 PR libfortran/62768 Handle filenames with embedded null characters.
testsuite ChangeLog:

2014-09-17  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/62768
	* gfortran.dg/filename_null.f90: New test.

libgfortran ChangeLog:

2014-09-17  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/62768
	* io/io.h (gfc_unit): Store C string for the filename.
	* io/close.c (st_close): Use gfc_unit.filename.
	* io/inquire.c (inquire_via_unit): Likewise.
	* io/open.c (new_unit): Likewise.
	(already_open): Likewise, unlink file before freeing filename.
	* io/unit.c (init_units): Likewise.
	(close_unit_1): Likewise.
	(filename_from_unit): Likewise.
	* io/unix.c (compare_file_filename): Likewise.
	(find_file0): Likewise.
	(delete_file): Likewise.

From-SVN: r215307
2014-09-17 00:40:28 +03:00
Jerry DeLisle 75b2dba9ae re PR fortran/60148 (strings in NAMELIST do not honor DELIM= in open statement)
2014-03-03  Jerry DeLisle  <jvdelisle@gcc.gnu>

	PR libfortran/60148
	* io/inquire.c (inquire_via_unit): In the case of
	DELIM_UNSPECIFIED set inquire return string to "NONE".
	* io/list_read.c (read_character): In the case of DELIM_NONE and
	namelists, complete the character read using the namelist
	variable length.
	* io/open.c (new_unit): Don't set delim status to none if not
	specified so that DELIM_UNSPECIFIED can be used later.
	* io/transfer.c (data_transfer_init): For namelist I/O, if the
	unit delim status is unspecified set the current status to quote.
	Otherwise, set current status to the unit status.
	* io/unit.c (get_internel_unit, init_unit): Remember to set
	flags_delim initially to DELIM_UNSPECIFIED so defaults come out
	correctly.
	* io/write.c (write_character): Add a new function argument
	"mode" to signify that raw output is to be used vs output with
	delimiters. If the mode is set to DELIM (1) proceed with
	delimiters. (list_formatted_write_scalar): Write the separator
	only if a delimiter was previously specified. Update the call to
	write_character with the mode argument given.
	(namelist_write_newline): Use the mode argument. (nml_write_obj):
	Use the mode argument. Remove use of tmp_delim. Write the
	semi-colon or comma correctly only when needed with using
	delimiters. Cleanup whitespace.
	(namelist_write): If delim is not specified in namelist I/O,
	default	to using quotes. Get rid of the tmp_delim variable and
	use the new mode argument in write_character.

From-SVN: r208302
2014-03-04 04:33:40 +00:00
Tobias Burnus 76a4b7ad2d re PR fortran/60286 (INQUIRE reports STDOUT as not writable)
2014-02-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/60286
        * libgfortran/io/inquire.c (yes, no): New static const char
        * vars.
        (inquire_via_unit): Use them. Use OPEN mode instead of using
        POSIX's access to query about write=, read= and readwrite=.

2014-02-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/60286
        * gfortran.dg/inquire_16.f90: New.

From-SVN: r207979
2014-02-21 08:37:06 +01:00
Richard Sandiford f0bcf62899 Update copyright years in libgfortran/
From-SVN: r206296
2014-01-02 22:25:45 +00:00
Richard Sandiford e3c063ceda Update copyright years in libgfortran.
From-SVN: r195167
2013-01-14 18:20:58 +00:00
Jerry DeLisle 797332eda9 re PR fortran/48976 (INQUIRE with STREAM= not supported)
2012-12-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/48976
	* io/inquire.c (inquire_via_unit): Set user stream inquiry variable to
	appropriate value based on unit access method. (inquire_via_filename):
	Since filename is not associated with an open unit, set stream inquiry
	to UNKNOWN.
	* io/io.h: Define inquire stream parameters.

From-SVN: r194733
2012-12-27 18:07:33 +00:00
Janne Blomqvist ed10039e8b PR 50016 Slow I/O on MingW due to _commit
frontend ChangeLog:

2011-11-09  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/50016
	* gfortran.texi (Data consistency and durability): New section.


testsuite ChangeLog:

2011-11-09  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/50016
	* gfortran.dg/inquire_size.f90: Don't flush the unit.

libgfortran ChangeLog:

2011-11-09  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/50016
	* io/inquire.c (inquire_via_unit): Flush the unit and use ssize.
	* io/unix.c (buf_flush): Don't call _commit.

From-SVN: r181207
2011-11-09 17:46:15 +02:00
Janne Blomqvist 08810e5257 Update file position for inquire lazily.
libgfortran ChangeLog:

2011-10-31  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/inquire.c (inquire_via_unit): Check whether we're at the
	beginning or end if the position is unspecified. If the position
	is not one of the 3 standard ones, return unspecified.
	* io/io.h (update_position): Remove prototype.
	* io/transfer.c (next_record): Set the position to unspecified,
	letting inquire figure it out more exactly when needed.
	* io/unit.c (update_position): Remove function.


testsuite ChangeLog:

2011-10-31  Janne Blomqvist  <jb@gcc.gnu.org>

	* gfortran.dg/inquire_5.f90: Update testcase to match the standard
	and current implementation.

From-SVN: r180703
2011-10-31 16:59:19 +02:00
Janne Blomqvist 6a0f6e7799 PR 47432 Use ttyname_r() if available
From-SVN: r169337
2011-01-27 22:05:45 +02:00
Janne Blomqvist ce66b6f6ca PR 44931 Move struct unix_stream to unix.c
From-SVN: r166325
2010-11-04 21:29:28 +02:00
Jerry DeLisle c613801e8b re PR fortran/44931 (For INPUT_UNIT, INQUIRE NAME= should not return "stdin")
2010-08-14  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/44931
	* io/inquire.c (inquire_via_unit): Add special case for __MINGW32__ to
	return special file names CONIN$, CONOUT$, and CONERR$.

From-SVN: r163245
2010-08-14 18:59:18 +00:00
David Edelsohn f32013906e * io/inquire.c: Include io.h before string.h.
From-SVN: r162788
2010-07-31 17:37:25 -04:00
Jerry DeLisle 01b9977477 re PR fortran/44931 (For INPUT_UNIT, INQUIRE NAME= should not return "stdin")
2010-07-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/44931
	* io/inquire.c (inquire_via_unit): Use ttyname to return actual device
	file name for stdin, stdout, and stderr.  If ttyname does not succeed
	fall back to default names for these units. Include string.h to allow
	using strlen function.
	* unix.c: Remove typedef of unix_stream structure, move to unix.h.
	* unix.h: Add typedef of unix_stream structure so that it is
	accessible to inquire.c.

From-SVN: r162667
2010-07-29 01:32:23 +00:00
Paul Thomas a1ff2ab8e4 transfer.c: Update copyright.
2010-04-01  Paul Thomas  <pault@gcc.gnu.org>

	* io/transfer.c : Update copyright.
	* io/unix.c : ditto
	* io/read.c : ditto
	* io/io.h : ditto
	* io/unix.h : ditto
	* io/inquire.c : ditto
	* io/format.c : ditto
	* io/list_read.c : ditto
	* runtime/error.c : ditto
	* libgfortran.h : ditto
	* intrinsics/date_and_time.c: ditto
	* intrinsics/args.c : ditto

From-SVN: r157924
2010-04-01 18:22:00 +00:00
Jerry DeLisle 41c3cddc6b re PR fortran/43409 (I/O: INQUIRE for SIZE does not work.)
2010-03-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/43409
	* ioparm.def: Change inquire size variable to type pointer to
	GFC_IO_INT type.

2010-03-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/43409
	* io/unix.h: Add prototype for new function to return file size.
	* io/unix.c (file_size): New function.
	* io/inquire.c (inquire_via_unit): Use new function.
	(inquire_via_filename): Use new function.

From-SVN: r157593
2010-03-20 14:39:00 +00:00
Janne Blomqvist 92cbdb6845 Split up io/io.h
From-SVN: r153825
2009-11-02 23:52:59 +02:00
Jakub Jelinek 748086b7b2 Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
From-SVN: r145841
2009-04-09 17:00:19 +02:00
Jakub Jelinek e14568432a re PR libfortran/37839 (st_parameter_dt has unwanted padding, is out of sync with compiler)
PR libfortran/37839
	* trans-io.c (gfc_build_io_library_fndecls): Decrease pad size back
	to 16 pointers plus 32 integers.  Don't use max integer kind
	alignment, only gfc_intio_kind's alignment.
	(gfc_trans_inquire): Only set flags2 if mask2 is non-zero.
	* ioparm.def: Fix order, bitmasks and types of inquire round, sign
	and pending fields.  Move u in dt before id.
	* io.c (gfc_free_inquire): Free decimal and size exprs.
	(match_inquire_element): Match size instead of matching blank twice.
	(gfc_resolve_inquire): Resolve size.

	* gfortran.dg/f2003_inquire_1.f03: New test.
	* gfortran.dg/f2003_io_1.f03: Remove xfail.
	* gfortran.dg/f2003_io_4.f03: Likewise.
	* gfortran.dg/f2003_io_5.f03: Likewise.
	* gfortran.dg/f2003_io_6.f03: Likewise.
	* gfortran.dg/f2003_io_7.f03: Likewise.

	* io/io.h (IOPARM_INQUIRE_HAS_ROUND, IOPARM_INQUIRE_HAS_SIGN,
	IOPARM_INQUIRE_HAS_PENDING): Adjust values.
	(st_parameter_inquire): Reorder and fix types of round, sign and
	pending fields.
	(st_parameter_43, st_parameter_44): Removed.
	(st_parameter_dt): Put back struct definition directly to u.p
	declaration.  Change type of u.p.size_used from gfc_offset to
	GFC_IO_INT.  Decrease back size of u.pad to 16 pointers and
	32 ints.  Put id, pos, asynchronous, blank, decimal, delim,
	pad, round and sign fields after the union.
	* io/inquire.c (inquire_via_unit, inquire_via_filename): Only read
	flags2 if it is defined.
	* io/transfer.c (read_sf, read_block_form, write_block): Cast
	additions to size_used to GFC_IO_INT instead of gfc_offset.
	(data_transfer_init): Clear whole u.p struct.  Adjust
	for moving id, pos, asynchronous, blank, decimal, delim, pad,
	round and sign fields from u.p directly into st_parameter_dt.
	(finalize_transfer): Don't cast size_used to GFC_IO_INT.
	* io/file_pos.c (st_endfile): Clear whole u.p struct.

From-SVN: r142111
2008-11-22 09:10:41 +01:00
Jerry DeLisle 105b713696 re PR fortran/37498 (Incorrect array value returned - 4.3 ABI Broken)
2008-09-25  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR libfortran/37498
	* list_read.c (eat_separator): Revert previous patch and move
	delim_status, decimal_status, and pad_status to gfc_unit.
	(parse_real): Ditto. (read_real): Ditto.
	* read.c (read_a): Likewise. (read_a_char4): Likewise.
	(read_f): Likewise.
	* inquire.c (inquire_via_unit): Add missing check for
	IOPARM_INQUIRE_HAS_FLAGS2. (inquire_via_filename): Likewise.
	* io.h (unit_sign_s): Move delim_status, decimal_status, and pad_status
	to gfc_unit.
	* transfer.c (read_sf): Ditto. (read_block_form): Ditto.
	(formatted_transfer_scalar): Ditto. (data_transfer_init): Ditto.
	* write.c (write_default_char4): Ditto. (write_utf8_char4): Ditto.
	(write_character): Ditto. (write_real_g0): Ditto.
	(list_formatted_write_scalar): Ditto. (nml_write_obj): Ditto.
	(namelist_write): Ditto.
	* write_float.def (calculate_sign): Ditto. (output_float): Ditto.

From-SVN: r140684
2008-09-26 06:19:42 +00:00
Jerry DeLisle cea93abbe2 re PR libfortran/35863 ([F2003] Implement ENCODING="UTF-8")
2008-06-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/35863
	* libgfortran.h: Change l8_to_l4_offset to big_endian and add endian_off.
	* runtime/main.c: Fix error in comment. Change l8_to_l4_offset to
	big_endian. (determine_endianness): Add endian_off and set its value
	according to big_endian.
	* gfortran.map: Add symbol for new _gfortran_transfer_character_wide.
	* io/io.h: Add prototype declarations for new functions.
	* io/list_read.c (list_formatted_read_scalar): Modify to handle kind=4.
	(list_formatted_read): Calculate stride based on kind for character type
	and use it when calling list_formatted_read_scalar.
	* io/inquire.c (inquire_via_unit): Change l8_to_l4_offset to big_endian.
	* io/open.c (st_open): Change l8_to_l4_offset to big_endian.
	* io/read.c (read_a_char4): New function to handle formatted read.
	* io/write.c: Define GFC_CHAR4(x) to improve readability of code.
	(write_a_char4): New function to handle formatted write.
	(write_character): Modify to accept the kind parameter and adjust for
	endianess of the machine. (list_formatted_write): Calculate the stride
	resulting from the kind and adjust the list_formatted_write_scalar call
	accordingly. (nml_write_obj): Adjust calls to write_character.
	(namelist_write): Likewise.
	* io/transfer.c (formatted_transfer_scaler): Rename 'len' argument to
	'kind' argument to better describe what it is. Add calls to new
	functions for kind == 4. (formatted_transfer): Modify to handle the case
	of type character and kind equals 4 to pass in the kind to the transfer
	routines. (transfer_character_wide): Add this new function.
	(transfer_array): Don't set kind to the character string length. Adjust
	strides bases on character kind.
	(unformatted_read): Adjust size based on kind for character types.
	(unformatted_write): Likewise. (data_transfer_init): Change
	l8_to_l4_offset to big_endian.

From-SVN: r136763
2008-06-13 20:28:08 +00:00
Jerry DeLisle 931149a6b7 PR fortran/25829 28655
2008-04-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/25829 28655
	* io/open.c (edit_modes): Set flags.async. (new_unit) Set flags.async
	and flags.status. (st_open): Initialize flags.async.
	* io/list_read.c (read_charactor): Use delim_status instead of
	flags.delim.
	* io/read.c (read_x): Use pad_status instead of flags.pad.
	* io/inquire.c (inquire_via_unit): Add new checks.
	(inquire_via_filename): Likewise.
	* io/io.h (st_parameter_inquire): Add new flags.
	(st_parameter_dt): Likewise.
	* io/unit.c (get_internal_unit): Set flags.async. (init_units): Set
	flags.async.
	* io/transfer.c: Add delim and pad option arrays. (read_sf): Use
	pad_status instead of flags.pad. (read_block): Likewise.
	(data_transfer_init): Set flags.async and add checks.
	* io/write.c (write_character): Use delim_status.
	(list_formatted_write_scalar): Likewise. (nml_write_obj): Likewise.
	(namelist_write): Likewise.

From-SVN: r133988
2008-04-07 22:05:52 +00:00
Jerry DeLisle 17c2c96cdc inquire.c (inquire_via_unit): If a unit is opened...
2008-01-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	* io/inquire.c (inquire_via_unit): If a unit is opened, return values
	according to the open action for DIRECT, FORMATTED, and	UNFORMATTED.
	(inquire_via_filename): Return "UNKNOWN" for SEQUENTIAL, DIRECT,
	FORAMATTED, and UNFORMATTED inquiries.
	* io/unix.c (inquire_sequential): Return "UNKNOWN" when appropriate
	for files that are not opened. (inquire_direct): Same.
	(inquire_formatted): Same.

From-SVN: r131672
2008-01-20 06:33:49 +00:00
Jerry DeLisle 6ae786d29d re PR libfortran/33055 (Runtime error in INQUIRE unit existance with -fdefault-integer-8)
2007-10-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/33055
	* io/inquire.c (inquire_via_unit):  If inquiring by unit, check for
	an error condition from the IOSTAT variable and set EXIST to false if
	there was a bad unit number.

From-SVN: r129344
2007-10-15 13:59:02 +00:00
Francois-Xavier Coudert d74b97cc7e re PR fortran/31675 (Fortran front-end and libgfortran should have a common header file)
PR fortran/31675

	* libgfortran.h: New file.
	* iso-fortran-env.def: Use macros in the new header instead of
	hardcoded integer constants.
	* Make-lang.in (F95_PARSER_OBJS, GFORTRAN_TRANS_DEPS): Add
	fortran/libgfortran.h.
	* gfortran.h (GFC_STD_*, GFC_FPE_*, options_convert,
	ioerror_codes): Remove.
	* trans.c (ERROR_ALLOCATION): Remove.
	(gfc_call_malloc, gfc_allocate_with_status,
	gfc_allocate_array_with_status): Use LIBERROR_ALLOCATION.
	* trans-types.h (GFC_DTYPE_*): Remove.
	* trans-decl.c (gfc_generate_function_code): Use
	GFC_CONVERT_NATIVE instead of CONVERT_NATIVE.
	* trans-io.c (set_parameter_value, set_parameter_ref): Use
	LIBERROR_* macros instead of IOERROR_ macros.
	* trans-intrinsic.c (gfc_conv_intrinsic_function): Use
	LIBERROR_END and LIBERROR_EOR instead of hardcoded constants.
	* options.c (gfc_init_options): Use GFC_CONVERT_NATIVE instead of
	CONVERT_NATIVE.
	(gfc_handle_option): Use GFC_CONVERT_* macros instead of CONVERT_*.

	* libgfortran.h: Include gcc/fortran/libgfortran.h.
	Remove M_PI, GFC_MAX_DIMENSIONS, GFC_DTYPE_*, GFC_NUM_RANK_BITS,
	error_codes, GFC_STD_*, GFC_FPE_* and unit_convert.
	* runtime/environ.c (variable_table): Use GFC_*_UNIT_NUMBER instead
	of hardcoded constants.
	(do_parse, init_unformatted): Use GFC_CONVERT_* macros instead of
	CONVERT_*.
	* runtime/string.c (find_option): Use LIBERROR_BAD_OPTION instead
	of ERROR_BAD_OPTION.
	* runtime/error.c (translate_error, generate_error): Use
	LIBERROR_* macros instead of ERROR_*.
	* io/file_pos.c (formatted_backspace, unformatted_backspace,
	st_backspace, st_rewind, st_flush): Rename macros.
	* io/open.c (convert_opt, edit_modes, new_unit, already_open,
	st_open): Likewise.
	* io/close.c (st_close): Likewise.
	* io/list_read.c (next_char, convert_integer, parse_repeat,
	read_logical, read_integer, read_character, parse_real,
	check_type, list_formatted_read_scalar, namelist_read,
	nml_err_ret): Likewise.
	* io/read.c (convert_real, read_l, read_decimal, read_radix,
	read_f): Likewise.
	* io/inquire.c (inquire_via_unit): Likewise.
	* io/unit.c (get_internal_unit): Likewise.
	* io/transfer.c (read_sf, read_block, read_block_direct,
	write_block, write_buf, unformatted_read, unformatted_write,
	formatted_transfer_scalar, us_read, us_write, data_transfer_init,
	skip_record, next_record_r, write_us_marker, next_record_w_unf,
	next_record_w, finalize_transfer, st_read, st_write_done):
	Likewise.
	* io/format.c (format_error): Likewise.

From-SVN: r128050
2007-09-03 16:44:15 +00:00
Francois-Xavier Coudert 36ae8a61ad minloc1.m4: Update copyright year and ajust headers order.
* m4/minloc1.m4: Update copyright year and ajust headers order.
	* m4/maxloc1.m4: Likewise.
	* m4/in_pack.m4: Likewise.
	* m4/sum.m4: Likewise.
	* m4/fraction.m4: Likewise.
	* m4/all.m4: Likewise.
	* m4/set_exponent.m4: Likewise.
	* m4/transpose.m4: Likewise.
	* m4/eoshift1.m4: Likewise.
	* m4/spacing.m4: Likewise.
	* m4/eoshift3.m4: Likewise.
	* m4/minval.m4: Likewise.
	* m4/count.m4: Likewise.
	* m4/maxval.m4: Likewise.
	* m4/exponent.m4: Likewise.
	* m4/shape.m4: Likewise.
	* m4/head.m4: Likewise.
	* m4/cshift1.m4: Likewise.
	* m4/minloc0.m4: Likewise.
	* m4/nearest.m4: Likewise.
	* m4/maxloc0.m4: Likewise.
	* m4/pow.m4: Likewise.
	* m4/in_unpack.m4: Likewise.
	* m4/matmull.m4: Likewise.
	* m4/product.m4: Likewise.
	* m4/reshape.m4: Likewise.
	* m4/any.m4: Likewise.
	* m4/rrspacing.m4: Likewise.
	* m4/matmul.m4: Likewise.
	* runtime/backtrace.c: Likewise.
	* runtime/environ.c: Likewise.
	* runtime/in_pack_generic.c: Likewise.
	* runtime/compile_options.c: Likewise.
	* runtime/in_unpack_generic.c: Likewise.
	* runtime/main.c: Likewise.
	* runtime/stop.c: Likewise.
	* runtime/string.c: Likewise.
	* runtime/memory.c: Likewise.
	* runtime/error.c: Likewise.
	* runtime/pause.c: Likewise.
	* intrinsics/ierrno.c: Likewise.
	* intrinsics/system_clock.c: Likewise.
	* intrinsics/cshift0.c: Likewise.
	* intrinsics/unlink.c: Likewise.
	* intrinsics/ctime.c: Likewise.
	* intrinsics/etime.c: Likewise.
	* intrinsics/cpu_time.c: Likewise.
	* intrinsics/malloc.c: Likewise.
	* intrinsics/hostnm.c: Likewise.
	* intrinsics/sleep.c: Likewise.
	* intrinsics/exit.c: Likewise.
	* intrinsics/perror.c: Likewise.
	* intrinsics/transpose_generic.c: Likewise.
	* intrinsics/pack_generic.c: Likewise.
	* intrinsics/spread_generic.c: Likewise.
	* intrinsics/stat.c: Likewise.
	* intrinsics/string_intrinsics.c: Likewise.
	* intrinsics/getcwd.c: Likewise.
	* intrinsics/date_and_time.c: Likewise.
	* intrinsics/unpack_generic.c: Likewise.
	* intrinsics/move_alloc.c: Likewise.
	* intrinsics/getlog.c: Likewise.
	* intrinsics/eoshift0.c: Likewise.
	* intrinsics/eoshift2.c: Likewise.
	* intrinsics/reshape_generic.c: Likewise.
	* intrinsics/system.c: Likewise.
	* intrinsics/iso_c_binding.c: Likewise.
	* intrinsics/env.c: Likewise.
	* intrinsics/kill.c: Likewise.
	* intrinsics/reshape_packed.c: Likewise.
	* intrinsics/time.c: Likewise.
	* intrinsics/gerror.c: Likewise.
	* intrinsics/access.c: Likewise.
	* intrinsics/fnum.c: Likewise.
	* intrinsics/abort.c: Likewise.
	* intrinsics/rename.c: Likewise.
	* intrinsics/signal.c: Likewise.
	* intrinsics/symlnk.c: Likewise.
	* intrinsics/random.c: Likewise.
	* intrinsics/umask.c: Likewise.
	* intrinsics/getXid.c: Likewise.
	* intrinsics/rand.c: Likewise.
	* intrinsics/chdir.c: Likewise.
	* intrinsics/chmod.c: Likewise.
	* intrinsics/clock.c: Likewise.
	* intrinsics/args.c: Likewise.
	* intrinsics/link.c: Likewise.
	* c99_protos.h: Likewise.
	* config/fpu-387.h: Likewise.
	* config/fpu-aix.h: Likewise.
	* config/fpu-sysv.h: Likewise.
	* config/fpu-generic.h: Likewise.
	* config/fpu-glibc.h: Likewise.
	* io/file_pos.c: Likewise.
	* io/open.c: Likewise.
	* io/size_from_kind.c: Likewise.
	* io/close.c: Likewise.
	* io/list_read.c: Likewise.
	* io/read.c: Likewise.
	* io/inquire.c: Likewise.
	* io/unit.c: Likewise.
	* io/unix.c: Likewise.
	* io/transfer.c: Likewise.
	* io/intrinsics.c: Likewise.
	* io/format.c: Likewise.
	* io/lock.c: Likewise.
	* io/write.c: Likewise.
	* io/write_float.def: Likewise.
	* fmain.c: Likewise.
	* generated/minval_r8.c: Regenerate.
	* generated/minloc1_16_r16.c: Regenerate.
	* generated/maxloc1_4_r8.c: Regenerate.
	* generated/sum_i8.c: Regenerate.
	* generated/eoshift3_4.c: Regenerate.
	* generated/transpose_c8.c: Regenerate.
	* generated/any_l16.c: Regenerate.
	* generated/eoshift1_8.c: Regenerate.
	* generated/pow_r8_i8.c: Regenerate.
	* generated/reshape_r16.c: Regenerate.
	* generated/pow_i4_i16.c: Regenerate.
	* generated/maxval_i2.c: Regenerate.
	* generated/product_r4.c: Regenerate.
	* generated/maxloc1_8_i4.c: Regenerate.
	* generated/exponent_r16.c: Regenerate.
	* generated/maxloc0_4_r4.c: Regenerate.
	* generated/fraction_r16.c: Regenerate.
	* generated/in_unpack_i8.c: Regenerate.
	* generated/matmul_r8.c: Regenerate.
	* generated/product_i2.c: Regenerate.
	* generated/fraction_r4.c: Regenerate.
	* generated/minloc0_4_r16.c: Regenerate.
	* generated/reshape_c4.c: Regenerate.
	* generated/minloc0_4_i1.c: Regenerate.
	* generated/maxloc0_4_r16.c: Regenerate.
	* generated/maxloc0_4_i2.c: Regenerate.
	* generated/minloc1_8_r16.c: Regenerate.
	* generated/maxloc1_8_r16.c: Regenerate.
	* generated/set_exponent_r8.c: Regenerate.
	* generated/in_unpack_i16.c: Regenerate.
	* generated/transpose_c16.c: Regenerate.
	* generated/maxloc0_8_i8.c: Regenerate.
	* generated/pow_c4_i8.c: Regenerate.
	* generated/sum_r16.c: Regenerate.
	* generated/sum_i1.c: Regenerate.
	* generated/minloc1_4_r8.c: Regenerate.
	* generated/transpose_r10.c: Regenerate.
	* generated/pow_i8_i4.c: Regenerate.
	* generated/maxloc1_16_r16.c: Regenerate.
	* generated/minloc1_16_i4.c: Regenerate.
	* generated/maxloc1_16_i4.c: Regenerate.
	* generated/minloc0_16_i8.c: Regenerate.
	* generated/maxloc0_16_i8.c: Regenerate.
	* generated/nearest_r8.c: Regenerate.
	* generated/spacing_r16.c: Regenerate.
	* generated/transpose_i8.c: Regenerate.
	* generated/count_16_l16.c: Regenerate.
	* generated/maxval_r16.c: Regenerate.
	* generated/count_8_l8.c: Regenerate.
	* generated/product_c10.c: Regenerate.
	* generated/minloc1_8_i4.c: Regenerate.
	* generated/minloc0_16_i16.c: Regenerate.
	* generated/matmul_r16.c: Regenerate.
	* generated/eoshift1_16.c: Regenerate.
	* generated/minloc0_4_r4.c: Regenerate.
	* generated/pow_c16_i16.c: Regenerate.
	* generated/set_exponent_r10.c: Regenerate.
	* generated/pow_i16_i16.c: Regenerate.
	* generated/product_c4.c: Regenerate.
	* generated/sum_r4.c: Regenerate.
	* generated/pow_c16_i4.c: Regenerate.
	* generated/rrspacing_r10.c: Regenerate.
	* generated/in_pack_c16.c: Regenerate.
	* generated/minloc0_4_i2.c: Regenerate.
	* generated/maxloc0_8_i1.c: Regenerate.
	* generated/reshape_i4.c: Regenerate.
	* generated/minloc0_8_i8.c: Regenerate.
	* generated/matmul_c8.c: Regenerate.
	* generated/spacing_r4.c: Regenerate.
	* generated/in_pack_c4.c: Regenerate.
	* generated/all_l16.c: Regenerate.
	* generated/minloc1_16_r10.c: Regenerate.
	* generated/sum_i2.c: Regenerate.
	* generated/minloc0_16_i1.c: Regenerate.
	* generated/reshape_c16.c: Regenerate.
	* generated/maxloc0_16_i1.c: Regenerate.
	* generated/maxloc1_8_r8.c: Regenerate.
	* generated/minval_i16.c: Regenerate.
	* generated/reshape_r10.c: Regenerate.
	* generated/exponent_r10.c: Regenerate.
	* generated/maxval_i4.c: Regenerate.
	* generated/any_l4.c: Regenerate.
	* generated/minval_i8.c: Regenerate.
	* generated/maxloc1_4_i8.c: Regenerate.
	* generated/fraction_r10.c: Regenerate.
	* generated/maxloc0_16_i16.c: Regenerate.
	* generated/shape_i4.c: Regenerate.
	* generated/pow_r16_i8.c: Regenerate.
	* generated/maxloc0_8_r4.c: Regenerate.
	* generated/rrspacing_r8.c: Regenerate.
	* generated/pow_c10_i4.c: Regenerate.
	* generated/minloc1_4_i16.c: Regenerate.
	* generated/minloc0_4_r10.c: Regenerate.
	* generated/maxloc1_4_i16.c: Regenerate.
	* generated/minloc0_8_i16.c: Regenerate.
	* generated/maxloc0_4_r10.c: Regenerate.
	* generated/maxloc0_8_i16.c: Regenerate.
	* generated/minloc1_8_r10.c: Regenerate.
	* generated/product_i4.c: Regenerate.
	* generated/minloc0_16_r4.c: Regenerate.
	* generated/sum_c16.c: Regenerate.
	* generated/maxloc1_8_r10.c: Regenerate.
	* generated/maxloc0_16_r4.c: Regenerate.
	* generated/transpose_c10.c: Regenerate.
	* generated/minloc1_16_r8.c: Regenerate.
	* generated/minloc0_8_i1.c: Regenerate.
	* generated/maxloc0_4_i4.c: Regenerate.
	* generated/transpose_r4.c: Regenerate.
	* generated/maxloc1_16_r8.c: Regenerate.
	* generated/pow_i16_i8.c: Regenerate.
	* generated/cshift1_4.c: Regenerate.
	* generated/maxloc0_8_i2.c: Regenerate.
	* generated/sum_r10.c: Regenerate.
	* generated/nearest_r16.c: Regenerate.
	* generated/sum_c4.c: Regenerate.
	* generated/maxloc1_16_r10.c: Regenerate.
	* generated/count_4_l16.c: Regenerate.
	* generated/pow_c8_i8.c: Regenerate.
	* generated/matmul_i8.c: Regenerate.
	* generated/in_pack_i4.c: Regenerate.
	* generated/pow_i4_i8.c: Regenerate.
	* generated/minloc0_16_i2.c: Regenerate.
	* generated/minloc1_8_r8.c: Regenerate.
	* generated/maxloc0_16_i2.c: Regenerate.
	* generated/exponent_r4.c: Regenerate.
	* generated/spacing_r10.c: Regenerate.
	* generated/matmul_c16.c: Regenerate.
	* generated/pow_c4_i16.c: Regenerate.
	* generated/maxval_r10.c: Regenerate.
	* generated/count_4_l4.c: Regenerate.
	* generated/shape_i16.c: Regenerate.
	* generated/minval_i1.c: Regenerate.
	* generated/maxloc1_4_i1.c: Regenerate.
	* generated/matmul_r10.c: Regenerate.
	* generated/minloc1_4_i8.c: Regenerate.
	* generated/pow_r10_i8.c: Regenerate.
	* generated/minloc0_8_r4.c: Regenerate.
	* generated/in_unpack_c4.c: Regenerate.
	* generated/matmul_l4.c: Regenerate.
	* generated/product_i16.c: Regenerate.
	* generated/minloc0_16_r16.c: Regenerate.
	* generated/reshape_r8.c: Regenerate.
	* generated/pow_r10_i16.c: Regenerate.
	* generated/all_l4.c: Regenerate.
	* generated/in_pack_c10.c: Regenerate.
	* generated/minloc0_4_i4.c: Regenerate.
	* generated/minloc0_8_i2.c: Regenerate.
	* generated/matmul_i1.c: Regenerate.
	* generated/reshape_c10.c: Regenerate.
	* generated/minval_r4.c: Regenerate.
	* generated/maxloc1_4_r4.c: Regenerate.
	* generated/pow_r8_i16.c: Regenerate.
	* generated/sum_i4.c: Regenerate.
	* generated/maxval_r8.c: Regenerate.
	* generated/count_16_l8.c: Regenerate.
	* generated/transpose_c4.c: Regenerate.
	* generated/eoshift1_4.c: Regenerate.
	* generated/eoshift3_8.c: Regenerate.
	* generated/minval_r16.c: Regenerate.
	* generated/minloc1_4_i1.c: Regenerate.
	* generated/minval_i2.c: Regenerate.
	* generated/maxloc1_4_i2.c: Regenerate.
	* generated/pow_i8_i16.c: Regenerate.
	* generated/product_r8.c: Regenerate.
	* generated/maxloc1_8_i8.c: Regenerate.
	* generated/maxloc0_4_r8.c: Regenerate.
	* generated/maxloc0_16_r16.c: Regenerate.
	* generated/in_unpack_i4.c: Regenerate.
	* generated/matmul_r4.c: Regenerate.
	* generated/sum_c10.c: Regenerate.
	* generated/minloc1_4_r16.c: Regenerate.
	* generated/fraction_r8.c: Regenerate.
	* generated/maxloc1_4_r16.c: Regenerate.
	* generated/set_exponent_r4.c: Regenerate.
	* generated/minloc0_8_r16.c: Regenerate.
	* generated/in_unpack_c16.c: Regenerate.
	* generated/reshape_c8.c: Regenerate.
	* generated/maxloc0_8_r16.c: Regenerate.
	* generated/nearest_r10.c: Regenerate.
	* generated/maxloc0_8_i4.c: Regenerate.
	* generated/pow_c4_i4.c: Regenerate.
	* generated/matmul_i2.c: Regenerate.
	* generated/minloc1_4_r4.c: Regenerate.
	* generated/transpose_i16.c: Regenerate.
	* generated/matmul_c10.c: Regenerate.
	* generated/minloc0_16_i4.c: Regenerate.
	* generated/maxloc0_16_i4.c: Regenerate.
	* generated/pow_i8_i8.c: Regenerate.
	* generated/nearest_r4.c: Regenerate.
	* generated/minloc1_16_i8.c: Regenerate.
	* generated/maxloc1_16_i8.c: Regenerate.
	* generated/transpose_i4.c: Regenerate.
	* generated/count_8_l4.c: Regenerate.
	* generated/minloc1_4_i2.c: Regenerate.
	* generated/matmul_l16.c: Regenerate.
	* generated/maxloc1_8_i1.c: Regenerate.
	* generated/minloc0_16_r10.c: Regenerate.
	* generated/minloc1_8_i8.c: Regenerate.
	* generated/minloc0_4_r8.c: Regenerate.
	* generated/product_r16.c: Regenerate.
	* generated/product_c8.c: Regenerate.
	* generated/pow_r16_i16.c: Regenerate.
	* generated/sum_r8.c: Regenerate.
	* generated/pow_c16_i8.c: Regenerate.
	* generated/in_pack_i16.c: Regenerate.
	* generated/minloc0_8_i4.c: Regenerate.
	* generated/matmul_c4.c: Regenerate.
	* generated/minloc1_16_i16.c: Regenerate.
	* generated/reshape_i8.c: Regenerate.
	* generated/spacing_r8.c: Regenerate.
	* generated/in_pack_c8.c: Regenerate.
	* generated/maxloc1_8_r4.c: Regenerate.
	* generated/minloc1_16_i1.c: Regenerate.
	* generated/maxloc1_16_i1.c: Regenerate.
	* generated/reshape_i16.c: Regenerate.
	* generated/minval_r10.c: Regenerate.
	* generated/pow_r4_i8.c: Regenerate.
	* generated/minloc1_8_i1.c: Regenerate.
	* generated/minval_i4.c: Regenerate.
	* generated/maxloc1_4_i4.c: Regenerate.
	* generated/maxloc1_8_i2.c: Regenerate.
	* generated/maxval_i8.c: Regenerate.
	* generated/eoshift3_16.c: Regenerate.
	* generated/any_l8.c: Regenerate.
	* generated/maxloc0_16_r10.c: Regenerate.
	* generated/rrspacing_r4.c: Regenerate.
	* generated/shape_i8.c: Regenerate.
	* generated/maxloc0_8_r8.c: Regenerate.
	* generated/minloc0_4_i16.c: Regenerate.
	* generated/maxloc0_4_i16.c: Regenerate.
	* generated/minloc1_4_r10.c: Regenerate.
	* generated/minloc1_8_i16.c: Regenerate.
	* generated/pow_c10_i8.c: Regenerate.
	* generated/maxloc1_4_r10.c: Regenerate.
	* generated/maxloc1_8_i16.c: Regenerate.
	* generated/in_unpack_c10.c: Regenerate.
	* generated/minloc0_8_r10.c: Regenerate.
	* generated/maxloc0_8_r10.c: Regenerate.
	* generated/minloc1_16_r4.c: Regenerate.
	* generated/maxloc1_16_r4.c: Regenerate.
	* generated/minloc0_16_r8.c: Regenerate.
	* generated/pow_i16_i4.c: Regenerate.
	* generated/product_i8.c: Regenerate.
	* generated/maxloc0_16_r8.c: Regenerate.
	* generated/sum_i16.c: Regenerate.
	* generated/maxloc0_4_i8.c: Regenerate.
	* generated/transpose_r8.c: Regenerate.
	* generated/cshift1_8.c: Regenerate.
	* generated/maxloc1_16_i16.c: Regenerate.
	* generated/matmul_i4.c: Regenerate.
	* generated/pow_c8_i4.c: Regenerate.
	* generated/pow_i4_i4.c: Regenerate.
	* generated/minloc1_8_r4.c: Regenerate.
	* generated/sum_c8.c: Regenerate.
	* generated/count_8_l16.c: Regenerate.
	* generated/minloc1_16_i2.c: Regenerate.
	* generated/maxloc1_16_i2.c: Regenerate.
	* generated/in_pack_i8.c: Regenerate.
	* generated/transpose_r16.c: Regenerate.
	* generated/maxval_i16.c: Regenerate.
	* generated/exponent_r8.c: Regenerate.
	* generated/matmul_i16.c: Regenerate.
	* generated/count_4_l8.c: Regenerate.
	* generated/pow_c8_i16.c: Regenerate.
	* generated/maxval_i1.c: Regenerate.
	* generated/minloc1_4_i4.c: Regenerate.
	* generated/minloc1_8_i2.c: Regenerate.
	* generated/pow_c10_i16.c: Regenerate.
	* generated/product_c16.c: Regenerate.
	* generated/reshape_r4.c: Regenerate.
	* generated/in_unpack_c8.c: Regenerate.
	* generated/minloc0_8_r8.c: Regenerate.
	* generated/matmul_l8.c: Regenerate.
	* generated/product_r10.c: Regenerate.
	* generated/set_exponent_r16.c: Regenerate.
	* generated/cshift1_16.c: Regenerate.
	* generated/product_i1.c: Regenerate.
	* generated/all_l8.c: Regenerate.
	* generated/maxloc0_4_i1.c: Regenerate.
	* generated/rrspacing_r16.c: Regenerate.
	* generated/minloc0_4_i8.c: Regenerate.
	* generated/pow_r4_i16.c: Regenerate.
	* generated/count_16_l4.c: Regenerate.
	* generated/maxval_r4.c: Regenerate.

From-SVN: r127990
2007-08-31 14:01:34 +00:00
Jerry DeLisle 5d75fb81c7 re PR libfortran/33055 (Runtime error in INQUIRE unit existance with -fdefault-integer-8)
2007-08-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/33055
	Revert previous patch.

From-SVN: r127877
2007-08-29 02:26:01 +00:00
Jerry DeLisle 128997b6a5 re PR libfortran/33055 (Runtime error in INQUIRE unit existance with -fdefault-integer-8)
2007-08-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/33055
	* trans-io.c (create_dummy_iostat): New function to create a unique
	dummy variable expression to use with IOSTAT.
	(gfc_trans_inquire): Use the new function to pass unit number error info
	to run-time library if a regular IOSTAT variable was not given.

	PR libfortran/33055
	* io/inquire.c (inquire_via_unit):  If inquiring by unit, check for 
	an error condition from the IOSTAT variable and set EXIST to false if
	there was a bad unit number.

From-SVN: r127817
2007-08-26 22:04:48 +00:00
Jerry DeLisle 16d962d92c re PR libfortran/31532 (INQUIRE(...,POSITION=...) not standard conforming)
2007-04-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/31532
	* io/file_pos.c (st_backspace): Set flags.position for end of file
	condition and use new function update_position.
	(st_endfile): Use new function update_position.
	* io/io.h: Add prototype for new function.
	* io/inquire.c (inquire_via_unit): If not direct access, set NEXTREC
	to zero.
	* io/unit.c (update_position): New function to update position info
	used by inquire.
	* io/transfer.c (next_record): Fix typo and use new function.

From-SVN: r124252
2007-04-28 02:03:21 +00:00
Jerry DeLisle 701306112e re PR fortran/29053 (Consecutive STREAM I/O file positions mixed up)
2006-09-14  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29053
	* io.h (gfc_unit): Add variable, strm_pos, to track
	STREAM I/O file position.
	* file_pos.c (st_rewind): Set strm_pos to beginning.
	* open.c (new_unit): Initialize strm_pos.
	* read.c (read_x): Bump strm_pos.
	* inquire.c (inquire_via_unit): Return strm_pos value.
	* transfer.c (read_block),(read_block_direct),(write_block)
	(write_buf): Seek to strm_pos - 1.  Update strm_pos when done.
	(pre_position): Initialize strm_pos.
	(data_transfer_init): Set strm_pos if DT_HAS_REC.
	(finalize_transfer): Flush file, no need to update strm_pos.

From-SVN: r116970
2006-09-15 13:16:15 +00:00
Jerry DeLisle 91b30ee5b9 re PR fortran/25828 ([f2003] ACCESS='STREAM' io support)
2006-08-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/25828
	* libgfortran.h: Rename GFC_LARGE_IO_INT to GFC_IO_INT.
	* io/file_pos.c (st_backspace): Ignore if access=STREAM.
	(st_rewind): Handle case of access=STREAM.
	* io/open.c (access_opt): Add STREAM_ACCESS.
	(edit_modes): Set current_record to zero only if not STREAM.
	(new_unit): Initialize maxrec, recl, and last_record for STREAM.
	* io/read.c (read_x): Advance file position for STREAM.
	* io/io.h (enum unit_access): Align IOPARM flags with frontend.
	Add ACCESS_STREAM. Add prototype for is_stream_io () function.
	Use GFC_IO_INT.
	* io/inquire.c (inquire_via_unit): Add text for access = "STREAM".
	* io/unit.c (is_stream_io): New function to return true if access =
	STREAM.
	* io/transfer.c (file_mode): Add modes for unformatted stream and
	formatted stream. (current_mode): Return appropriate file mode based
	on access flags.
	(read_block): Handle formatted stream reads.
	(read_block_direct): Handle unformatted stream reads.
	(write_block): Handle formatted stream writes.
	(write_buf): Handle unformatted stream writes.
	(unformatted_read): Fix up, use temporary for size.
	(pre_position): Position file for STREAM access.
	(data_transfer_init): Initialize for stream access, skip irrelevent
	error checks.
	(next_record_r),(next_record_w), and (next_record): Do nothing for
	stream I/O.
	(finalize_transfer): Flush when all done if stream I/O.

From-SVN: r116172
2006-08-15 23:06:44 +00:00
Thomas Koenig 181c9f4a9b re PR fortran/23815 (Add -byteswapio flag)
2005-12-10  Thomas Koenig  <Thomas.Koenig@online.de>

	PR fortran/23815
	* io.c (top level):  Add convert to io_tag.
	(resolve_tag):  convert is GFC_STD_GNU.
	(match_open_element):  Add convert.
	(gfc_free_open):  Likewise.
	(gfc_resolve_open):  Likewise.
	(gfc_free_inquire):  Likewise.
	(match_inquire_element):  Likewise.
	* dump-parse-tree.c (gfc_show_code_node):  Add
	convet for open and inquire.
	gfortran.h: Add convert to gfc_open and gfc_inquire.
	* trans-io.c (gfc_trans_open):  Add convert.
	(gfc_trans_inquire):  Likewise.
	* ioparm.def:  Add convert to open and inquire.
	* gfortran.texi:  Document CONVERT.

2005-12-10  Thomas Koenig  <Thomas.Koenig@online.de>

	PR fortran/23815
	* io/file_pos.c (unformatted_backspace):  If flags.convert
	does not equal CONVERT_NATIVE, reverse the record marker.
	* io/open.c:  Add convert_opt[].
	(st_open):  If no convert option is given, set CONVERT_NATIVE.
	If CONVERT_BIG or CONVERT_LITTLE are given, set flags.convert to
	CONVERT_NATIVE or CONVERT_SWAP (depending on wether we have
	a big- or little-endian system).
	* io/transfer.c (unformatted_read):  Remove unused attribute
	from arguments.
	If we need to reverse
	bytes, break up large transfers into a loop.  Split complex
	numbers into its two parts.
	(unformatted_write):  Likewise.
	(us_read):  If flags.convert does not equal CONVERT_NATIVE,
	reverse the record marker.
	(next_record_w): Likewise.
	(reverse_memcpy):  New function.
	* io/inquire.c (inquire_via_unit):  Implement convert.
	* io/io.h (top level):  Add enum unit_convert.
	Add convert to st_parameter_open and st_parameter_inquire.
	Define IOPARM_OPEN_HAS_CONVERT and IOPARM_INQUIRE_HAS_CONVERT.
	Increase padding for st_parameter_dt.
	Declare reverse_memcpy().

2005-12-10  Thomas Koenig  <Thomas.Koenig@online.de>

	PR fortran/23815
	* gfortran.dg/unf_io_convert_1.f90:  New test.
	* gfortran.dg/unf_io_convert_2.f90:  New test.
	* gfortran.dg/unf_io_convert_3.f90:  New test.

From-SVN: r108358
2005-12-10 20:01:56 +00:00
Jakub Jelinek 5e805e44c0 re PR fortran/14943 (read/write code generation is not thread safe)
gcc/fortran/
	PR fortran/14943
	PR fortran/21647
	* Make-lang.in (fortran/trans-io.o): Depend on fortran/ioparm.def.
	* dump-parse-tree.c (gfc_show_code_node): Dump c->block for
	EXEC_{READ,WRITE,IOLENGTH} nodes.
	* io.c (terminate_io, match_io, gfc_match_inquire): Put data
	transfer commands into EXEC_{READ,WRITE,IOLENGTH}'s code->block.
	* resolve.c (resolve_blocks): Handle EXEC_{READ,WRITE,IOLENGTH}.
	* trans-io.c (ioparm_unit, ioparm_err, ioparm_end, ioparm_eor,
	ioparm_list_format, ioparm_library_return, ioparm_iostat,
	ioparm_exist, ioparm_opened, ioparm_number, ioparm_named,
	ioparm_rec, ioparm_nextrec, ioparm_size, ioparm_recl_in,
	ioparm_recl_out, ioparm_iolength, ioparm_file, ioparm_file_len,
	ioparm_status, ioparm_status_len, ioparm_access, ioparm_access_len,
	ioparm_form, ioparm_form_len, ioparm_blank, ioparm_blank_len,
	ioparm_position, ioparm_position_len, ioparm_action,
	ioparm_action_len, ioparm_delim, ioparm_delim_len, ioparm_pad,
	ioparm_pad_len, ioparm_format, ioparm_format_len, ioparm_advance,
	ioparm_advance_len, ioparm_name, ioparm_name_len,
	ioparm_internal_unit, ioparm_internal_unit_len,
	ioparm_internal_unit_desc, ioparm_sequential, ioparm_sequential_len,
	ioparm_direct, ioparm_direct_len, ioparm_formatted,
	ioparm_formatted_len, ioparm_unformatted, ioparm_unformatted_len,
	ioparm_read, ioparm_read_len, ioparm_write, ioparm_write_len,
	ioparm_readwrite, ioparm_readwrite_len, ioparm_namelist_name,
	ioparm_namelist_name_len, ioparm_namelist_read_mode, ioparm_iomsg,
	ioparm_iomsg_len, ioparm_var): Remove.
	(enum ioparam_type, enum iofield_type, enum iofield,
	enum iocall): New enums.
	(gfc_st_parameter_field, gfc_st_parameter): New typedefs.
	(st_parameter, st_parameter_field, iocall): New variables.
	(ADD_FIELD, ADD_STRING): Remove.
	(dt_parm, dt_post_end_block): New variables.
	(gfc_build_st_parameter): New function.
	(gfc_build_io_library_fndecls): Use it.  Initialize iocall
	array rather than ioparm_*, add extra first arguments to
	the function types.
	(set_parameter_const): New function.
	(set_parameter_value): Add type argument, return a bitmask.
	Changed to set a field in automatic structure variable rather
	than set a field in a global _gfortran_ioparm variable.
	(set_parameter_ref): Likewise.  If requested var has different
	size than what field should point to, call with a temporary and
	then copy into the user variable.  Add postblock argument.
	(set_string): Remove var_len argument, add type argument, return
	a bitmask.  Changed to set fields in automatic structure variable
	rather than set a field in a global _gfortran_ioparm variable.
	(set_internal_unit): Remove iunit, iunit_len, iunit_desc arguments,
	add var argument.  Return a bitmask.  Changed to set fields in
	automatic structure variable rather than set a field in a global
	_gfortran_ioparm variable.
	(set_flag): Removed.
	(io_result): Add var argument.  Changed to read common.flags field
	from automatic structure variable and bitwise AND it with 3.
	(set_error_locus): Add var argument.  Changed to set fields in
	automatic structure variable rather than set a field in a global
	_gfortran_{filename,line} variables.
	(gfc_trans_open): Use gfc_start_block rather than gfc_init_block.
	Create a temporary st_parameter_* structure.  Adjust callers of
	all above mentioned functions.  Pass address of the temporary
	variable as first argument to the generated function call.
	Use iocall array rather than ioparm_* separate variables.
	(gfc_trans_close, build_filepos, gfc_trans_inquire): Likewise.
	(build_dt): Likewise.  Change first argument to tree from tree *.
	Don't dereference code->ext.dt if last_dt == INQUIRE.  Emit
	IOLENGTH argument setup here.  Set dt_parm/dt_post_end_block
	variables and gfc_trans_code the nested data transfer commands
	in code->block.
	(gfc_trans_iolength): Just set last_dt and call build_dt immediately.
	(transfer_namelist_element): Pass address of dt_parm variable
	to generated functions.  Use iocall array rather than ioparm_*
	separate variables.
	(gfc_trans_backspace, gfc_trans_endfile, gfc_trans_rewind,
	gfc_trans_flush, gfc_trans_read, gfc_trans_write): Use iocall array
	rather than ioparm_* separate variables.
	(gfc_trans_dt_end): Likewise.  Pass address of dt_parm variable
	as first argument to generated function.  Adjust io_result caller.
	Prepend dt_post_end_block before io_result code.
	(transfer_expr): Use iocall array rather than ioparm_* separate
	variables.  Pass address of dt_parm variables as first argument
	to generated functions.
	* ioparm.def: New file.
gcc/testsuite/
	PR fortran/24774
	* gfortran.dg/inquire_9.f90: New test.

	PR fortran/21647
	* gfortran.fortran-torture/execute/inquire_5.f90: New test.
libgfortran/
	PR fortran/24774
	PR fortran/14943
	PR fortran/21647
	* Makefile.am (AM_CPPFLAGS): Add gcc directories as -I paths,
	add -D_GNU_SOURCE.
	* Makefile.in: Regenerated.
	* acinclude.m4 (LIBGFOR_CHECK_SYNC_FETCH_AND_ADD,
	LIBGFOR_CHECK_GTHR_DEFAULT, LIBGFOR_CHECK_PRAGMA_WEAK): New macros.
	* configure.ac: Add them.
	* configure: Rebuilt.
	* config.h.in: Rebuilt.
	* libtool-version: Bump libgfortran.so SONAME to libgfortran.so.1.
	* libgfortran.h (library_start, show_locus, internal_error,
	generate_error, find_option): Add st_parameter_common * argument.
	(library_end): Change into a dummy macro.
	* io/io.h: Include gthr.h.
	(SUPPORTS_WEAK): Define if HAVE_PRAGMA_WEAK.
	(CHARACTER): Remove define.
	(st_parameter, global_t): Remove typedef.
	(ioparm, g, ionml, current_unit): Remove variables.
	(init_error_stream): Remove prototype.
	(CHARACTER1, CHARACTER2): Define.
	(st_parameter_common, st_parameter_open, st_parameter_close,
	st_parameter_filepos, st_parameter_inquire, st_parameter_dt): New
	typedefs.
	(IOPARM_LIBRETURN_MASK, IOPARM_LIBRETURN_OK, IOPARM_LIBRETURN_ERROR,
	IOPARM_LIBRETURN_END, IOPARM_LIBRETURN_EOR, IOPARM_ERR, IOPARM_END,
	IOPARM_EOR, IOPARM_HAS_IOSTAT, IOPARM_HAS_IOMSG, IOPARM_COMMON_MASK,
	IOPARM_OPEN_HAS_RECL_IN, IOPARM_OPEN_HAS_FILE, IOPARM_OPEN_HAS_STATUS,
	IOPARM_OPEN_HAS_ACCESS, IOPARM_OPEN_HAS_FORM, IOPARM_OPEN_HAS_BLANK,
	IOPARM_OPEN_HAS_POSITION, IOPARM_OPEN_HAS_ACTION,
	IOPARM_OPEN_HAS_DELIM, IOPARM_OPEN_HAS_PAD, IOPARM_CLOSE_HAS_STATUS,
	IOPARM_INQUIRE_HAS_EXIST, IOPARM_INQUIRE_HAS_OPENED,
	IOPARM_INQUIRE_HAS_NUMBER, IOPARM_INQUIRE_HAS_NAMED,
	IOPARM_INQUIRE_HAS_NEXTREC, IOPARM_INQUIRE_HAS_RECL_OUT,
	IOPARM_INQUIRE_HAS_FILE, IOPARM_INQUIRE_HAS_ACCESS,
	IOPARM_INQUIRE_HAS_FORM, IOPARM_INQUIRE_HAS_BLANK,
	IOPARM_INQUIRE_HAS_POSITION, IOPARM_INQUIRE_HAS_ACTION,
	IOPARM_INQUIRE_HAS_DELIM, IOPARM_INQUIRE_HAS_PAD,
	IOPARM_INQUIRE_HAS_NAME, IOPARM_INQUIRE_HAS_SEQUENTIAL,
	IOPARM_INQUIRE_HAS_DIRECT, IOPARM_INQUIRE_HAS_FORMATTED,
	IOPARM_INQUIRE_HAS_UNFORMATTED, IOPARM_INQUIRE_HAS_READ,
	IOPARM_INQUIRE_HAS_WRITE, IOPARM_INQUIRE_HAS_READWRITE,
	IOPARM_DT_LIST_FORMAT, IOPARM_DT_NAMELIST_READ_MODE,
	IOPARM_DT_HAS_REC, IOPARM_DT_HAS_SIZE, IOPARM_DT_HAS_IOLENGTH,
	IOPARM_DT_HAS_FORMAT, IOPARM_DT_HAS_ADVANCE,
	IOPARM_DT_HAS_INTERNAL_UNIT, IOPARM_DT_HAS_NAMELIST_NAME,
	IOPARM_DT_IONML_SET): Define.
	(gfc_unit): Add lock, waiting and close fields.  Change file
	from flexible array member into pointer to char.
	(open_external): Add st_parameter_open * argument.
	(find_file, file_exists): Add file and file_len arguments.
	(flush_all_units): New prototype.
	(max_offset, unit_root, unit_lock): New variable.
	(is_internal_unit, is_array_io, next_array_record,
	parse_format, next_format, unget_format, format_error,
	read_block, write_block, next_record, convert_real,
	read_a, read_f, read_l, read_x, read_radix, read_decimal,
	list_formatted_read, finish_list_read, namelist_read,
	namelist_write, write_a, write_b, write_d, write_e, write_en,
	write_es, write_f, write_i, write_l, write_o, write_x, write_z,
	list_formatted_write, get_unit): Add st_parameter_dt * argument.
	(insert_unit): Remove prototype.
	(find_or_create_unit, unlock_unit): New prototype.
	(new_unit): Return gfc_unit *.  Add st_parameter_open *
	and gfc_unit * arguments.
	(free_fnodes): Remove prototype.
	(free_format_data): New prototype.
	(scratch): Remove.
	(init_at_eol): Remove prototype.
	(free_ionml): New prototype.
	(inc_waiting_locked, predec_waiting_locked, dec_waiting_unlocked):
	New inline functions.
	* io/unit.c (max_offset, unit_root, unit_lock): New variables.
	(insert): Adjust os_error caller.
	(insert_unit): Made static.  Allocate memory here, initialize
	lock and after inserting it return it, locked.
	(delete_unit): Adjust for deletion of g.
	(find_unit_1): New function.
	(find_unit): Use it.
	(find_or_create_unit): New function.
	(get_unit): Add dtp argument, change meaning of the int argument
	as creation request flag.  Adjust for different st_* calling
	conventions, lock internal unit's lock before returning it
	and removal of g.  Call find_unit_1 instead of find_unit.
	(is_internal_unit, is_array_io): Add dtp argument, adjust for
	removal of most of global variables.
	(init_units): Initialize unit_lock.  Adjust insert_unit callers
	and adjust for g removal.
	(close_unit_1): New function.
	(close_unit): Use it.
	(unlock_unit): New function.
	(close_units): Lock unit_lock, use close_unit_1 rather than
	close_unit.
	* io/close.c (st_close): Add clp argument.  Adjust for new
	st_* calling conventions and internal function API changes.
	* io/file_pos.c (st_backspace, st_endfile, st_rewind, st_flush):
	Add fpp argument.  Adjust for new st_* calling conventions and
	internal function API changes.
	(formatted_backspace, unformatted_backspace): Likewise.  Add
	u argument.
	* io/open.c (edit_modes, st_open): Add opp argument.  Adjust for
	new st_* calling conventions and internal function API changes.
	(already_open): Likewise.  If not HAVE_UNLINK_OPEN_FILE, unlink
	scratch file.  Instead of calling close_unit just call sclose,
	free u->file if any and clear a few u fields before calling
	new_unit.
	(new_unit): Return gfc_unit *.  Add opp and u arguments.
	Adjust for new st_* calling conventions and internal function
	API changes.  Don't allocate unit here, rather than work with
	already created unit u already locked on entry.  In case
	of failure, close_unit it.
	* io/unix.c: Include unix.h.
	(BUFFER_SIZE, unix_stream): Moved to unix.h.
	(unit_to_fd): Add unlock_unit call.
	(tempfile): Add opp argument, use its fields rather than ioparm.
	(regular_file): Likewise.
	(open_external): Likewise.  Only unlink file if fd >= 0.
	(init_error_stream): Add error argument, set structure it points
	to rather than filling static variable and returning its address.
	(FIND_FILE0_DECL, FIND_FILE0_ARGS): Define.
	(find_file0): Use them.  Don't crash if u->s == NULL.
	(find_file): Add file and file_len arguments, use them instead
	of ioparm.  Add locking.  Pass either an array of 2 struct stat
	or file and file_len pair to find_file0.
	(flush_all_units_1, flush_all_units): New functions.
	(file_exists): Add file and file_len arguments, use them instead
	of ioparm.
	* io/unix.h: New file.
	* io/lock.c (ioparm, g, ionml): Remove variables.
	(library_start): Add cmp argument, adjust for new st_* calling
	conventions.
	(library_end): Remove.
	(free_ionml): New function.
	* io/inquire.c (inquire_via_unit, inquire_via_filename,
	st_inquire): Add iqp argument, adjust for new st_* calling
	conventions and internal function API changes.
	* io/format.c (FARRAY_SIZE): Decrease to 64.
	(fnode_array, format_data): New typedefs.
	(avail, array, format_string, string, error, saved_token, value,
	format_string_len, reversion_ok, saved_format): Remove variables.
	(colon_node): Add const.
	(free_fnode, free_fnodes): Remove.
	(free_format_data): New function.
	(next_char, unget_char, get_fnode, format_lex, parse_format_list,
	format_error, parse_format, revert, unget_format, next_test): Add
	fmt or dtp arguments, pass it all around, adjust for internal
	function API changes and adjust for removal of global variables.
	(next_format): Likewise.  Constify return type.
	(next_format0): Constify return type.
	* io/transfer.c (current_unit, sf_seen_eor, eor_condition, max_pos,
	skips, pending_spaces, scratch, line_buffer, advance_status,
	transfer): Remove variables.
	(transfer_integer, transfer_real, transfer_logical,
	transfer_character, transfer_complex, transfer_array, current_mode,
	read_sf, read_block, read_block_direct, write_block,
	write_block_direct, unformatted_read, unformatted_write,
	type_name, write_constant_string, require_type,
	formatted_transfer_scalar, us_read, us_write, pre_position,
	data_transfer_init, next_record_r, next_record_w, next_record,
	finalize_transfer, iolength_transfer, iolength_transfer_init,
	st_iolength, st_iolength_done, st_read, st_read_done, st_write,
	st_write_done, st_set_nml_var, st_set_nml_var_dim,
	next_array_record): Add dtp argument, pass it all around, adjust for
	internal function API changes and removal of global variables.
	* io/list_read.c (repeat_count, saved_length, saved_used,
	input_complete, at_eol, comma_flag, last_char, saved_string,
	saved_type, namelist_mode, nml_read_error, value, parse_err_msg,
	nml_err_msg, prev_nl): Remove variables.
	(push_char, free_saved, next_char, unget_char, eat_spaces,
	eat_separator, finish_separator, nml_bad_return, convert_integer,
	parse_repeat, read_logical, read_integer, read_character,
	parse_real, read_complex, read_real, check_type,
	list_formatted_read_scalar, list_formatted_read, finish_list_read,
	find_nml_node, nml_untouch_nodes, nml_match_name, nml_query,
	namelist_read): Add dtp argument, pass it all around, adjust for
	internal function API changes and removal of global variables.
	(nml_parse_qualifier): Likewise.  Add parse_err_msg argument.
	(nml_read_obj): Likewise.  Add pprev_nl, nml_err_msg, clow and
	chigh arguments.
	(nml_get_obj_data): Likewise.  Add pprev_nl and nml_err_msg
	arguments.
	(init_at_eol): Removed.
	* io/read.c (convert_real, read_l, read_a, next_char, read_decimal,
	read_radix, read_f, read_x): Add dtp argument, pass it all around,
	adjust for internal function API changes and removal of global
	variables.
	(set_integer): Adjust internal_error caller.
	* io/write.c (no_leading_blank, nml_delim): Remove variables.
	(write_a, calculate_sign, calculate_G_format, output_float,
	write_l, write_float, write_int, write_decimal, write_i, write_b,
	write_o, write_z, write_d, write_e, write_f, write_en, write_es,
	write_x, write_char, write_logical, write_integer, write_character,
	write_real, write_complex, write_separator,
	list_formatted_write_scalar, list_formatted_write, nml_write_obj,
	namelist_write): Add dtp argument, pass it all around, adjust for
	internal function API changes and removal of global variables.
	(extract_int, extract_uint, extract_real): Adjust internal_error
	callers.
	* runtime/fpu.c (_GNU_SOURCE): Don't define here.
	* runtime/error.c: Include ../io/unix.h.
	(filename, line): Remove variables.
	(st_printf): Pass address of a local variable to init_error_stream.
	(show_locus): Add cmp argument.  Use fields it points to rather than
	filename and line variables.
	(os_error, runtime_error): Remove show_locus calls.
	(internal_error): Add cmp argument.  Pass it down to show_locus.
	(generate_error): Likewise.  Use flags bitmask instead of non-NULL
	check for iostat and iomsg parameter presence, adjust for st_*
	calling convention changes.
	* runtime/stop.c (stop_numeric, stop_string): Remove show_locus
	calls.
	* runtime/pause.c (pause_numeric, pause_string): Likewise.
	* runtime/string.c: Include ../io/io.h.
	(find_option): Add cmp argument.  Pass it down to generate_error.
	* intrinsics/flush.c (recursive_flush): Remove.
	(flush_i4, flush_i8): Use flush_all_units.  Add unlock_unit
	call.
	* intrinsics/rand.c: Include ../io/io.h.
	(rand_seed_lock): New variable.
	(srand, irand): Add locking.
	(init): New constructor function.
	* intrinsics/random.c: Include ../io/io.h.
	(random_lock): New variable.
	(random_r4, random_r8, arandom_r4, arandom_r8): Add locking.
	(random_seed): Likewise.  open failed if fd < 0.  Set i correctly.
	(init): New constructor function.
	* intrinsics/system_clock.c (tp0, t0): Remove.
	(system_clock_4, system_clock_8): Don't subtract tp0/t0 from current
	time, use just integer arithmetics.
	* intrinsics/tty.c (isatty_l4, isatty_l8, ttynam_sub): Add
	unlock_unit calls.

From-SVN: r107328
2005-11-21 23:03:56 +01:00
Jakub Jelinek 090037799c string.c (find_option): Change 3rd argument to const st_option *.
* runtime/string.c (find_option): Change 3rd argument to
	const st_option *.
	* libgfortran.h (find_option): Likewise.
	* runtime/environ.c (rounding, precision, signal_choices): Constify.
	(init_choice, show_choice): Change 2nd argument to const choice *.
	* io/open.c (access_opt, action_opt, blank_opt, delim_opt, form_opt,
	position_opt, status_opt, pad_opt): Constify.
	* io/transfer.c (advance_opt): Likewise.
	* io/inquire.c (undefined): Likewise.
	* io/close.c (status_opt): Likewise.
	* io/format.c (posint_required, period_required, nonneg_required,
	unexpected_element, unexpected_end, bad_string, bad_hollerith,
	reversion_error): Likewise.
	* io/unix.c (yes, no, unknown): Change from const char *
	into const char [].

From-SVN: r104773
2005-09-29 15:53:59 +02:00
Kelley Cook fe2ae685a1 All files: Update FSF address.
2005-08-17  Kelley Cook  <kcook@gcc.gnu.org>

	* All files: Update FSF address.

From-SVN: r103194
2005-08-17 02:49:08 +00:00
Francois-Xavier Coudert 293fcb2e28 re PR libfortran/20950 ([4.0 only] segfault in INQUIRE asking for SEQUENTIAL status)
PR libfortran/20950
	* io/inquire.c (inquire_via_unit): Check for the gfc_unit being
	NULL when setting ioparm.sequential.
	* gfortran.dg/pr20950.f: New test.

From-SVN: r98312
2005-04-18 07:34:32 +00:00
Francois-Xavier Coudert 14fd645e24 re PR libfortran/20660 (INQUIRE incorrectly reports the existence of UNITS)
PR libfortran/20660
    * io/inquire.c (inquire_via_unit): Non-opened units should still be
    reported by an INQUIRE statement as existing.
    * io/transfer.c (data_transfer_init): Never accept negative units.

    PR libfortran/20660
    * gfortran.dg/negative_unit.f: New test.

From-SVN: r97326
2005-03-31 15:30:06 +00:00