Commit Graph

61 Commits

Author SHA1 Message Date
Janne Blomqvist eb6a1e56e0 Copyright years and whitespace fix for r180734
From-SVN: r180736
2011-11-01 14:03:38 +02:00
Janne Blomqvist ea5e3c042b Cleanup NEWUNIT allocation.
2011-11-01  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/io.h (next_available_newunit): Remove prototype.
	* io/unit.h (next_available_newunit): Make variable static,
	initialize it.
	(init_units): Don't initialize next_available_newunit.
	(get_unique_unit_number): Use atomic builtin if available.

From-SVN: r180734
2011-11-01 13:44:12 +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 3469bd8660 Introduce a size member function to struct stream.
2011-10-31  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/unix.h (struct stream): Add size function pointer.
	(ssize): New inline function.
	(file_length): Remove prototype.
	* io/unix.c (raw_size): New function.
	(raw_init): Initialize st.size pointer.
	(buf_size): New function.
	(buf_init): Initialize st.size pointer.
	(open_internal): Likewise.
	(open_internal4): Likewise.
	(file_length): Remove function.
	* io/file_pos.c (st_rewind): Use ssize instead of file_length.
	* io/open.c (test_endfile): Likewise.
	* io/transfer.c (data_transfer_init): Likewise.
	(next_record_r): Likewise.
	(next_record_w): Likewise.
	* io/unit.c (update_position): Likewise.

From-SVN: r180702
2011-10-31 16:52:26 +02:00
Janne Blomqvist 7d5ee21935 Simplify handling of special files.
2011-10-31  Janne Blomqvist  <jb@gcc.gnu.org>

* io/file_pos.c (st_rewind): Handle regular and special files
identically.
* io/intrinsics.c (fseek_sub): Don't check whether we think the
file is seekable, just do what the caller says.
* io/transfer.c (skip_record): First try to seek, then fallback to
reading and throwing away what we read.
* io/unit.c (update_position): Don't check whether file is
seekable, just try to do what we're told.
(unit_truncate): Likewise.
* io/unix.c (struct unix_stream): Remove special_file flag.
(buf_flush): Remove code for handling unseekable files.
(buf_seek): Likewise.
(fd_to_stream): Use buffered IO only for regular files.
(file_length): Remove is_seekable() call.
(is_seekable): Remove function.
(is_special): Likewise.
* io/unix.h: Remove prototypes for is_seekable and is_special.

From-SVN: r180701
2011-10-31 16:45:50 +02:00
Jim Meyering 046957830e remove useless if-before-free tests
Change "if (E) free (E);" to "free (E);" everywhere except in the
libgo/, intl/, zlib/ and classpath/ directories.
Also transform equivalent variants like
"if (E != NULL) free (E);" and allow an extra cast on the
argument to free.  Otherwise, the tested and freed "E"
expressions must be identical, modulo white space.

From-SVN: r172785
2011-04-20 18:19:03 +00:00
Janne Blomqvist 3571367557 Don't update the position flag for non-seekable files, check for stell() error.
From-SVN: r162810
2010-08-02 09:22:23 +03:00
Jerry DeLisle 74db2a472a re PR fortran/37077 (Implement Internal Unit I/O for character KIND=4)
2010-07-16  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/37077
	* io/read.c (read_default_char4): Add support for reading into a
	kind-4 character variable from a character(kind=4) internal unit.
	* io/io.h (read_block_form4): Add prototype.
	* io/unit.c (get_internal_unit): Add call to fbuf_init.
	(free_internal_unit): Add call to fbuf_destroy. (get_unit): Fix
	whitespace.
	* io/transfer.c (read_sf_internal): Use fbuf_alloc to allocate a string
	to recieve the wide characters translated to single byte chracters.
	(read_block_form): Fix whitespace. (read_block_form4): New function to
	read from a character(kind=4) internal unit into a character(kind=4)
	variable. (read_block_direct): Fix whitespace. (write_block): Fix
	whitespace. (formatted_transfer_scalar_read): Likewise.
	(formatted_transfer_scalar_write): Likewise.
	* io/write.c (write_character): Add support for list directed write of
	a kind=1 character string to a character(kind=4) internal unit.

From-SVN: r162260
2010-07-16 14:16:04 +00:00
Jerry DeLisle c7421e06ca re PR fortran/37077 (Implement Internal Unit I/O for character KIND=4)
2010-07-12  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/37077
	* io/read.c: Fix comment.
	* io/io.h (is_char4_unit): New macro.
	* io/unit.c (get_internal_unit): Call new function open_internal4.
	* io/unix.c (mem_alloc_r4): New function. (mem_alloc_w4): New function.
	(mem_read4): New function, temporary stub. (mem_write4): New function.
	(open_internal4): New function to set stream pointers to use the new
	mem functions.
	* io/transfer.c (write_block): Use new mem_alloc_w4 to access internal
	units of kind=4.
	* io/unix.h: Add prototypes for open_internal4, mem_alloc_w4, and
	mem_alloc_r4.
	* io/write.c (memset4): New helper function. (memcpy4): New helper
	function. (write_default_char4): Use new helper functions.
	(write_a): Likewise. (write_l): Likewise. (write_boz): Likewise.
	(write_decimal): Likewise. (write_x): Likewise.
	(write_integer): Likewise.
	* io/write_float.def (output_float): Add code blocks to handle internal
	unit kind=4 output utilizing gfc_char4_t pointers. (write_infnan): Use
	new helper functions. (OUTPUT_FLOAT_FMT_G): Update this macro likewise.

From-SVN: r162123
2010-07-13 02:12:08 +00:00
Janne Blomqvist bb408e876c Remove free_mem
From-SVN: r159160
2010-05-07 18:55:59 +03:00
Janne Blomqvist 92cbdb6845 Split up io/io.h
From-SVN: r153825
2009-11-02 23:52:59 +02:00
Jerry DeLisle 379924dd59 re PR libfortran/35862 ([F2003] Implement new rounding modes for run time)
2009-09-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/35862
	* io.h (gfc_unit): Add round_status.
	(format_token): Add enumerators for rounding format specifiers.
	* transfer.c (round_opt): New options table.
	(formatted_transfer_scalar_read): Add set round_status for each rounding
	format token. (formatted_transfer_scalar_write): Likewise.
	* format.c (format_lex): Tokenize the rounding format specifiers.
	(parse_format_list): Parse the rounding format specifiers.
	* write_float.def (outout_float): Modify rounding code to use new
	variable rchar to set the appropriate rounding. Fix some whitespace.
	* unit.c (get_internal_unit): Initialize rounding mode for internal
	units. (init_units): Likewise.

From-SVN: r152263
2009-09-29 02:47:54 +00:00
Jerry DeLisle dcfddbd49c re PR fortran/40008 (F2008: Add NEWUNIT= for OPEN statement)
2009-06-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/40008
	* libgfortran.h: Define IOPARM_OPEN_HAS_NEWUNIT.
	* io/open.c (st_open): Don't error on negative unit number if NEWUNIT
	was specified. If NEWUNIT is specified, call new function to get the
	unique unit number and assign it.
	* io/io.h (st_parameter_open): Add pointer to newunit.  Add prototype for
	next_available_newunit. Add prototype for new function,
	get_unique_unit_number.
	* io/unit.c: Declare next_available_newunit. Define the first newunit
	number. (init_units): Initialize next_available_unit.
	(get_unique_unit_number): New function. Fix whitespace and comments.
	* io/transfer.c (data_transfer_init): Update error message to not be
	specific to OPEN statements.

From-SVN: r148253
2009-06-07 19:00:47 +00: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
Janne Blomqvist 2ac7316d99 open.c (already_open): Test for POSIX close return value.
2009-04-08  Janne Blomqvist  <jb@gcc.gnu.org>

        * io/open.c (already_open): Test for POSIX close return value.
        * io/unit.c (close_unit_1): Likewise.
        * io/unix.c (raw_close): Return 0 for success for preconnected units.

From-SVN: r145761
2009-04-08 20:06:34 +03:00
Jerry DeLisle 7812c78c34 [multiple changes]
2009-04-05  Daniel Kraft  <d@domob.eu>

	PR fortran/38654
	* io/read.c (read_f): Reworked to speed up floating point parsing.
	(convert_real): Use pointer-casting instead of memcpy and temporaries.

2009-04-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/37754
	* io/io.h (format_hash_entry): New structure for hash table.
	(format_hash_table): The hash table itself.
	(free_format_data): Revise function prototype.
	(free_format_hash_table, init_format_hash,
	free_format_hash): New function prototypes.
	* io/unit.c (close_unit_1): Use free_format_hash_table.
	* io/transfer.c (st_read_done, st_write_done): Free format data if
	internal unit.
	* io/format.c (free_format_hash_table): New function that frees any
	memory allocated previously for cached format data.
	(reset_node): New static helper function to reset the format counters
	for a format node.
	(reset_fnode_counters): New static function recursively calls reset_node
	to traverse the	fnode tree.
	(format_hash): New simple hash function based on XOR, probabalistic,
	tosses collisions.
	(save_parsed_format): New static function to save the parsed format
	data to use again.
	(find_parsed_format): New static function searches the hash table
	looking for a match.
	(free_format_data): Revised to accept pointer to format data rather than
	the dtp pointer so that the function can be used in more places.
	(format_lex): Editorial.
	(parse_format_list): Set flag used to determine of format data hashing
	is to be used.  Internal units are not persistent enough for this.
	(revert): Move to ne location in file.
	(parse_format): Use new functions to look for previously parsed
	format strings and use them rather than re-parse.  If not found, saves
	the parsed format data for later use.
	
2009-04-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/37754
	* io/transfer.c (formatted_transfer_scalar): Remove this function by
	factoring it into two new functions, one for read and one for write,
	eliminating all the conditionals for read or write mode.
	(formatted transfer_scalar_read): New function.
	(formatted transfer_scalar_write): New function.
	(formatted_transfer): Use new functions.

2009-04-05  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/25561 libfortran/37754
	* io/io.h (struct stream): Define new stream interface function
	pointers, and inline functions for accessing it.
	(struct fbuf): Use int instead of size_t, remove flushed element.
	(mem_alloc_w): New prototype.
	(mem_alloc_r): New prototype.
	(stream_at_bof): Remove prototype.
	(stream_at_eof): Remove prototype.
	(file_position): Remove prototype.
	(flush): Remove prototype.
	(stream_offset): Remove prototype.
	(unit_truncate): New prototype.
	(read_block_form): Change to return pointer, int* argument.
	(hit_eof): New prototype.
	(fbuf_init): Change prototype.
	(fbuf_reset): Change prototype.
	(fbuf_alloc): Change prototype.
	(fbuf_flush): Change prototype.
	(fbuf_seek): Change prototype.
	(fbuf_read): New prototype.
	(fbuf_getc_refill): New prototype.
	(fbuf_getc): New inline function.
        * io/fbuf.c (fbuf_init): Use int, get rid of flushed.
	(fbuf_debug): New function.
	(fbuf_reset): Flush, and return position offset.
	(fbuf_alloc): Simplify, don't flush, just realloc.
	(fbuf_flush): Make usable for read mode, salvage remaining bytes.
	(fbuf_seek): New whence argument.
	(fbuf_read): New function.
	(fbuf_getc_refill): New function.
	* io/file_pos.c (formatted_backspace): Use new stream interface.
	(unformatted_backspace): Likewise.
	(st_backspace): Make sure format buffer is reset, use new stream
	interface, use unit_truncate.
	(st_endfile): Likewise.
	(st_rewind): Likewise.
	* io/intrinsics.c: Use new stream interface.
	* io/list_read.c (push_char): Don't use u.p.scratch, use realloc
	to resize.
	(free_saved): Don't check u.p.scratch.
	(next_char): Use new stream interface, use fbuf_getc() for external files.
	(finish_list_read): flush format buffer.
	(nml_query): Update to use modified interface:s
	* io/open.c (test_endfile): Use new stream interface.
	(edit_modes): Likewise.
	(new_unit): Likewise, set bytes_left to 1 for stream files.
	* io/read.c (read_l): Use new read_block_form interface.
	(read_utf8): Likewise.
	(read_utf8_char1): Likewise.
	(read_default_char1): Likewise.
	(read_utf8_char4): Likewise.
	(read_default_char4): Likewise.
	(read_a): Likewise.
	(read_a_char4): Likewise.
	(read_decimal): Likewise.
	(read_radix): Likewise.
	(read_f): Likewise.
	* io/transfer.c (read_sf): Use fbuf_read and mem_alloc_r, remove
	usage of u.p.line_buffer.
	(read_block_form): Update interface to return pointer, use
	fbuf_read for direct access.
	(read_block_direct): Update to new stream interface.
	(write_block): Use mem_alloc_w for internal I/O.
	(write_buf): Update to new stream interface.
	(formatted_transfer_scalar): Don't use u.p.line_buffer, use
	fbuf_seek for external files.
	(us_read): Update to new stream interface.
	(us_write): Likewise.
	(data_transfer_init): Always check if we switch modes and flush.
	(skip_record): Use new stream interface, fix comparison.
	(next_record_r): Check for and reset u.p.at_eof, use new stream
	interface, use fbuf_getc for spacing.
	(write_us_marker): Update to new stream interface, don't inline.
	(next_record_w_unf): Likewise.
	(sset): New function.
	(next_record_w): Use new stream interface, use fbuf for printing
	newline.
	(next_record): Use new stream interface.
	(finalize_transfer): Remove sfree call, use new stream interface.
	(st_iolength_done): Don't use u.p.scratch.
	(st_read): Don't check for end of file.
	(st_read_done): Don't use u.p.scratch, use unit_truncate.
	(hit_eof): New function.
	* io/unit.c (init_units): Always init fbuf for formatted units.
	(update_position): Use new stream interface.
	(unit_truncate): New function.
	(finish_last_advance_record): Use fbuf to print newline.
	* io/unix.c: Remove unused SSIZE_MAX macro.
	(BUFFER_SIZE): Make static const variable rather than macro.
	(struct unix_stream): Remove dirty_offset, len, method,
	small_buffer. Order elements by decreasing size.
	(struct int_stream): Remove.
	(move_pos_offset): Remove usage of dirty_offset.
	(reset_stream): Remove.
	(do_read): Rename to raw_read, update to match new stream
	interface.
	(do_write): Rename to raw_write, update to new stream interface.
	(raw_seek): New function.
	(raw_tell): New function.
	(raw_truncate): New function.
	(raw_close): New function.
	(raw_flush): New function.
	(raw_init): New function.
	(fd_alloc): Remove.
	(fd_alloc_r_at): Remove.
	(fd_alloc_w_at): Remove.
	(fd_sfree): Remove.
	(fd_seek): Remove.
	(fd_truncate): Remove.
	(fd_sset): Remove.
	(fd_read): Remove.
	(fd_write): Remove.
	(fd_close): Remove.
	(fd_open): Remove.
	(fd_flush): Rename to buf_flush, update to new stream interface
	and unix_stream.
	(buf_read): New function.
	(buf_write): New function.
	(buf_seek): New function.
	(buf_tell): New function.
	(buf_truncate): New function.
	(buf_close): New function.
	(buf_init): New function.
	(mem_alloc_r_at): Rename to mem_alloc_r, change prototype.
	(mem_alloc_w_at): Rename to mem_alloc_w, change prototype.
	(mem_read): Change to match new stream interface.
	(mem_write): Likewise.
	(mem_seek): Likewise.
	(mem_tell): Likewise.
	(mem_truncate): Likewise.
	(mem_close): Likewise.
	(mem_flush): New function.
	(mem_sfree): Remove.
	(empty_internal_buffer): Cast to correct type.
	(open_internal): Use correct type, init function pointers.
	(fd_to_stream): Test whether to open file as buffered or raw.
	(output_stream): Remove mode set.
	(error_stream): Likewise.
	(flush_all_units_1): Use new stream interface.
	(flush_all_units): Likewise.
	(stream_at_bof): Remove.
	(stream_at_eof): Remove.
	(file_position): Remove.
	(file_length): Update logic to use stream interface.
	(flush): Remove.
	(stream_offset): Remove.
	* io/write.c (write_utf8_char4): Use int instead of size_t.
	(write_x): Extra safety check.
	(namelist_write_newline): Use new stream interface.

From-SVN: r145571
2009-04-05 20:13:56 +00:00
Janne Blomqvist f3ed1d0222 Revert part of patch accidentally committed to trunk rather than fortran-dev (I hate svn)
From-SVN: r144994
2009-03-22 13:32:29 +02:00
Janne Blomqvist 9e544d738a PR libfortran/25561 libfortran/37754
2009-03-22  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/25561 libfortran/37754
	* io/io.h (struct stream): Define new stream interface function
	pointers, and inline functions for accessing it.
	(struct fbuf): Use int instead of size_t, remove flushed element.
	(mem_alloc_w): New prototype.
	(mem_alloc_r): New prototype.
	(stream_at_bof): Remove prototype.
	(stream_at_eof): Remove prototype.
	(file_position): Remove prototype.
	(flush): Remove prototype.
	(stream_offset): Remove prototype.
	(unit_truncate): New prototype.
	(read_block_form): Change to return pointer, int* argument.
	(hit_eof): New prototype.
	(fbuf_init): Change prototype.
	(fbuf_reset): Change prototype.
	(fbuf_alloc): Change prototype.
	(fbuf_flush): Change prototype.
	(fbuf_seek): Change prototype.
	(fbuf_read): New prototype.
	(fbuf_getc_refill): New prototype.
	(fbuf_getc): New inline function.
        * io/fbuf.c (fbuf_init): Use int, get rid of flushed.
	(fbuf_debug): New function.
	(fbuf_reset): Flush, and return position offset.
	(fbuf_alloc): Simplify, don't flush, just realloc.
	(fbuf_flush): Make usable for read mode, salvage remaining bytes.
	(fbuf_seek): New whence argument.
	(fbuf_read): New function.
	(fbuf_getc_refill): New function.
	* io/file_pos.c (formatted_backspace): Use new stream interface.
	(unformatted_backspace): Likewise.
	(st_backspace): Make sure format buffer is reset, use new stream
	interface, use unit_truncate.
	(st_endfile): Likewise.
	(st_rewind): Likewise.
	* io/intrinsics.c: Use new stream interface.
	* io/list_read.c (push_char): Don't use u.p.scratch, use realloc
	to resize.
	(free_saved): Don't check u.p.scratch.
	(next_char): Use new stream interface, use fbuf_getc() for external files.
	(finish_list_read): flush format buffer.
	(nml_query): Update to use modified interface:s
	* io/open.c (test_endfile): Use new stream interface.
	(edit_modes): Likewise.
	(new_unit): Likewise, set bytes_left to 1 for stream files.
	* io/read.c (read_l): Use new read_block_form interface.
	(read_utf8): Likewise.
	(read_utf8_char1): Likewise.
	(read_default_char1): Likewise.
	(read_utf8_char4): Likewise.
	(read_default_char4): Likewise.
	(read_a): Likewise.
	(read_a_char4): Likewise.
	(read_decimal): Likewise.
	(read_radix): Likewise.
	(read_f): Likewise.
	* io/transfer.c (read_sf): Use fbuf_read and mem_alloc_r, remove
	usage of u.p.line_buffer.
	(read_block_form): Update interface to return pointer, use
	fbuf_read for direct access.
	(read_block_direct): Update to new stream interface.
	(write_block): Use mem_alloc_w for internal I/O.
	(write_buf): Update to new stream interface.
	(formatted_transfer_scalar): Don't use u.p.line_buffer, use
	fbuf_seek for external files.
	(us_read): Update to new stream interface.
	(us_write): Likewise.
	(data_transfer_init): Always check if we switch modes and flush.
	(skip_record): Use new stream interface, fix comparison.
	(next_record_r): Check for and reset u.p.at_eof, use new stream
	interface, use fbuf_getc for spacing.
	(write_us_marker): Update to new stream interface, don't inline.
	(next_record_w_unf): Likewise.
	(sset): New function.
	(next_record_w): Use new stream interface, use fbuf for printing
	newline.
	(next_record): Use new stream interface.
	(finalize_transfer): Remove sfree call, use new stream interface.
	(st_iolength_done): Don't use u.p.scratch.
	(st_read): Don't check for end of file.
	(st_read_done): Don't use u.p.scratch, use unit_truncate.
	(hit_eof): New function.
	* io/unit.c (init_units): Always init fbuf for formatted units.
	(update_position): Use new stream interface.
	(unit_truncate): New function.
	(finish_last_advance_record): Use fbuf to print newline.
	* io/unix.c: Remove unused SSIZE_MAX macro.
	(BUFFER_SIZE): Make static const variable rather than macro.
	(struct unix_stream): Remove dirty_offset, len, method,
	small_buffer. Order elements by decreasing size.
	(struct int_stream): Remove.
	(move_pos_offset): Remove usage of dirty_offset.
	(reset_stream): Remove.
	(do_read): Rename to raw_read, update to match new stream
	interface.
	(do_write): Rename to raw_write, update to new stream interface.
	(raw_seek): New function.
	(raw_tell): New function.
	(raw_truncate): New function.
	(raw_close): New function.
	(raw_flush): New function.
	(raw_init): New function.
	(fd_alloc): Remove.
	(fd_alloc_r_at): Remove.
	(fd_alloc_w_at): Remove.
	(fd_sfree): Remove.
	(fd_seek): Remove.
	(fd_truncate): Remove.
	(fd_sset): Remove.
	(fd_read): Remove.
	(fd_write): Remove.
	(fd_close): Remove.
	(fd_open): Remove.
	(fd_flush): Rename to buf_flush, update to new stream interface
	and unix_stream.
	(buf_read): New function.
	(buf_write): New function.
	(buf_seek): New function.
	(buf_tell): New function.
	(buf_truncate): New function.
	(buf_close): New function.
	(buf_init): New function.
	(mem_alloc_r_at): Rename to mem_alloc_r, change prototype.
	(mem_alloc_w_at): Rename to mem_alloc_w, change prototype.
	(mem_read): Change to match new stream interface.
	(mem_write): Likewise.
	(mem_seek): Likewise.
	(mem_tell): Likewise.
	(mem_truncate): Likewise.
	(mem_close): Likewise.
	(mem_flush): New function.
	(mem_sfree): Remove.
	(empty_internal_buffer): Cast to correct type.
	(open_internal): Use correct type, init function pointers.
	(fd_to_stream): Test whether to open file as buffered or raw.
	(output_stream): Remove mode set.
	(error_stream): Likewise.
	(flush_all_units_1): Use new stream interface.
	(flush_all_units): Likewise.
	(stream_at_bof): Remove.
	(stream_at_eof): Remove.
	(file_position): Remove.
	(file_length): Update logic to use stream interface.
	(flush): Remove.
	(stream_offset): Remove.
	* io/write.c (write_utf8_char4): Use int instead of size_t.
	(write_x): Extra safety check.
	(namelist_write_newline): Use new stream interface.

[[Split portion of a mixed commit.]]

From-SVN: r144993.2
2009-03-22 12:51:05 +02:00
Jerry DeLisle 8217a6359f re PR libfortran/38735 ([4.4 Regresssion] Default BLANK= mode for internal units is wrong)
2009-01-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/38735
	* io/unit.c (get_internal_unit): Set default BLANK= status to NULL for
	internal units.

From-SVN: r143102
2009-01-05 22:55:15 +00:00
Jerry DeLisle 264a5255d8 re PR libfortran/38097 (I/O with blanks in exponent fails; blank="NULL", BN edit descriptor)
2008-11-16  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/38097
	* io/read.c (read_f): Initialize exponent. Fix comment. Set loop
	conditions for BZ/BN.
	* io/unit.c (get_internal_unit): Initialize flags.blank.
	* io/transfer.c (data_transfer_init): Fix whitespace.

From-SVN: r141919
2008-11-16 16:12:16 +00:00
Janne Blomqvist 15877a88eb Part 1 of PR 25561.
2008-05-15  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/25561
	* Makefile.am: Add fbuf.c to gfor_io_src.
	* Makefile.in: Regenerate.
	* io/io.h (read_block): Remove.
	(struct stream): Remove alloc_r_at function pointer.
	(salloc_r): Remove.
	(salloc_r_at): Remove.
	(salloc_w_at): Remove.
	(salloc_w): Remove offset argument.
	(struct fbuf): New struct for format buffer.
	(struct gfc_unit): Add fbuf.
	(read_block_form): New prototype.
	(fbuf_init): Likewise.
	(fbuf_destroy): Likewise.
	(fbuf_reset): Likewise.
	(fbuf_alloc): Likewise.
	(fbuf_flush): Likewise.
	(fbuf_seek): Likewise.
	* io/file_pos.c (formatted_backspace): Change to use sread.
	(unformatted_backspace): Likewise.
	(st_backspace): Flush format buffer.
	(st_rewind): Likewise.
	* io/list_read.c (next_char): Likewise.
	(nml_query): Tidying, flush format buffer.
	* io/open.c (new_unit): Init format buffer.
	* io/read.c (read_l): Change to use read_block_form.
	(read_a): Likewise.
	(read_decimal): Likewise.
	(read_radix): Likewise.
	(read_f): Likewise.
	(read_x): Empty reads also for stream I/O.
	* io/transfer.c (read_sf): Change to use sread.
	(read_block): Rename to read_block_form, change prototype, use sread.
	(read_block_direct): Don't seek stream files.
	(write_block): Change to use fbuf if external file, don't seek stream
	files.
	(write_buf): Don't seek stream files.
	(formatted_transfer_scalar): Use fbuf for external files.
	(us_read): Change to use sread.
	(pre_position): Do nothing for stream I/O.
	(data_transfer_init): Flush fbuf when switching from write to read, if
	POS is specified, seek stream file to correct offset.
	(skip_record): Change to use sread.
	(min_off): New function.
	(next_record_r): Change to use sread.
	(next_record_w): Change to use sset/sseek, flush fbuf.
	(finalize_transfer): Flush fbuf.
	* io/unit.c (init_units): Init fbuf for stdout, stderr.
	(close_unit_1): Destroy fbuf.
	(finish_last_advance_record): Flush fbuf, no need to seek.
	* io/unix.c (fd_alloc_r_at): Remove unused where argument.
	(fd_alloc_w_at): Likewise.
	(fd_read): Remove third argument to fd_alloc_r_at.
	(fd_write): Remove third argument to fd_alloc_w_at.
	(fd_sset): Likewise.
	(fd_open): Don't set alloc_r_at.
	(mem_alloc_r_at): Remove unused where argument.
	(mem_alloc_w_at): Likewise.
	(mem_read): Don't incorrectly return previous errno, remove unused
	third argument to alloc function.
	(mem_write): Likewise.
	(mem_set): Likewise.
	(open_internal): Don't set alloc_r_at pointer.
	* io/fbuf.c: New file.

From-SVN: r135373
2008-05-15 18:53:34 +03: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 10256cbe95 PR fortran/25829 28655
2008-04-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/25829 28655
	* gfortran.map: Add new symbol, _gfortran_st_wait.
	* libgfortran.h (st_paramter_common): Add new I/O parameters.
	* open.c (st_option decimal_opt[], st_option encoding_opt[],
	st_option round_opt[], st_option sign_opt[], st_option async_opt[]): New
	parameter option arrays. (edit_modes): Add checks for new parameters.
	(new_unit): Likewise. (st_open): Likewise.
	* list_read.c (CASE_SEPERATORS): Add ';' as a valid separator.
	(eat_separator): Handle deimal comma. (read_logical): Fix whitespace.
	(parse_real): Handle decimal comma. (read_real): Handle decimal comma.
	* read.c (read_a): Use decimal status flag to allow comma in place of a
	decimal point. (read_f): Allow comma as acceptable character in float.
	According to decimal flag, substitute a period for a comma.
	(read_x): If decimal status flag is comma, disable the read_comma flag,
	not allowing comma as a delimiter, an extension otherwise.
	* io.h: (unit_decimal, unit_encoding, unit_round, unit_sign,
	unit_async): New enumerators. Add all new I/O parameters.
	* unix.c (unix_stream, int_stream): Add io_mode	asychronous I/O	control.
	(move_pos_offset, fd_alloc_w_at): Fix some whitespace.
	(fd_sfree): Use new enumerator. (fd_read): Likewise.
	(fd_write): Likewise. (fd_close): Fix whitespace.
	(fd_open): Use new enumertors. (tempfile, regular_file,
	open_external): Fix whitespace. (output_stream, error_stream): Set
	method. (stream_offset): Fix whitespace.
	* transfer.c: (st_option decimal_opt[], sign_opt[], blank_opt[]): New
	option arrays. 	(formatted_transfer_scalar): Set sf_read_comma flag
	based on new decimal_status flag. (data_transfer_init): Initialize new
	parameters. Add checks for decimal, sign, and blank. (st_wait): New stub.
	* format.c: (format_lex): Add format specifiers DP, DC, and D.
	(parse_format_list): Parse the new specifiers.
	* write.c (write_decimal): Use new sign enumerators to set the sign.
	(write_complex): Handle decimal comma and semi-colon separator.
	(nml_write_obj): Likewise.
	* write_float.def: Revise sign enumerators. (calculate_sign): Use new
	sign enumerators. (output_float): Likewise. Use new decimal_status flag
	to set the decimal character to a point or a comma.

From-SVN: r133943
2008-04-05 22:18:03 +00:00
Janne Blomqvist 4dabf73695 re PR libfortran/35063 (Clean up use of destroy_unit_mutex())
gcc:

2008-03-01  Janne Blomqvist  <jb@gcc.gnu.org>

	PR gcc/35063
	* gthr.h: Add __gthread_mutex_destroy as a function that must be
	implemented.
	* gthr-vxworks.h (__gthread_mutex_destroy): Null implementation.
	* gthr-single.h (__gthread_mutex_destroy): Likewise.
	* gthr-rtems.h (__gthread_mutex_destroy): Likewise.
	* gthr-mipssde.h (__gthread_mutex_destroy): Likewise.
	* gthr-nks.h (__gthread_mutex_destroy): Likewise.
	* gthr-solaris.h (__gthread_mutex_destroy): Call mutex_destroy.
	* gthr-win32.h (__GTHREAD_MUTEX_DESTROY_FUNCTION): Remove.
	(__gthread_mutex_destroy_function): Rename to
	__gthread_mutex_destroy.
	* gthr-dce.h (__gthread_mutex_destroy): Call
	pthread_mutex_destroy.
	* gthr-tpf.h (__gthread_mutex_destroy): Likewise.
	* gthr-posix.h (__gthread_mutex_destroy): Likewise.
	* gthr-posix95.h (__gthread_mutex_destroy): Likewise.


libgfortran:

2008-03-01  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/35063
	* io/unit.c (destroy_unit_mutex): Call __gthread_mutex_destroy
	instead of macro kludge.

From-SVN: r132800
2008-03-01 12:46:31 +02:00
Jerry DeLisle ef4195d63d [multiple changes]
2008-02-10  Danny Smith  <dannysmith@users.sourceforge.net>

	PR gcc/35063
	* gthr-win32.h (__gthread_mutex_destroy_function): New function
	to CloseHandle after unlocking to prevent accumulation of handle
	count. 

2008-02-10  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/35063
	* io/unit.c (destroy_unit_mutex): New function that uses
	__gthread_mutex_destroy_function or pthread_mutex_destroy after
	unlocking and before free_mem for final closure of I/O unit.
	(delete_root): Use new function.
	(free_internal_unit): Likewise.
	(close_unit_1): Likewise.

From-SVN: r132217
2008-02-10 18:06:34 +00:00
Thomas Koenig 9370b3c0f9 re PR fortran/34565 (internal write to string array fails)
2008-01-03  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/34565
	* io/io.h:  Adjust protoypes for open_internal(),
	next_array_record() and init_loop_spec().
	* io/list_read.c (next_char):  Use argument "finished"
	of next_array_record to check for end on internal file.
	* io/unit.c:  Calculate the offset for an array
	internal file and supply this informatin to open_internal().
	* io/unix.c (open_internal):  Set the offset for the internal
	file on open.
	* io/transfer.c (init_loop_spec):  Calculate the starting
	record in case of negative strides.  Return size of 0 for
	an empty array.
	(next_array_record):  Use an extra flag to signal that the
	array is finished.
	(next_record_r):  Use the new flag to next_array_record().
	(next_record_w):  Likewise.

2008-01-03  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/34565
	* gfortran.dg/internal_readwrite_1.f90:  New test.
	* gfortran.dg/internal_readwrite_2.f90:  New test.

From-SVN: r131305
2008-01-03 19:49:38 +00:00
Thomas Koenig 108bc19009 re PR libfortran/34370 (file positioning after nonadvancing i/o)
2007-12-13  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/34370
	PR libfortran/34323
	PR libfortran/34405
	* io/io.h:  Add previous_nonadvancing_write to gfc_unit.
	Add prototype for finish_last_advance_record.
	* io/file_pos.c (st_backspace):  Generate error if backspace is
	attempted for direct access or unformatted stream.
	If there are bytes left from a previous ADVANCE="no", write
	them out before performing the backspace.
	(st_endfile):  Generate error if endfile is attempted for
	direct access.
	If there are bytes left from a previous ADVANCE="no", write
	them out before performing the endfile.
	(st_rewind):  Generate error if rewind is attempted for
	direct access.
	* unit.c (close_unit_1):  Move functionality to write
	previously written bytes to...
	(finish_last_advance_record):  ... here.
	* transfer.c (data_transfer_init):  If reading, reset
	previous_nonadvancing_write.
	(finalize_transfer):  Set the previous_noadvancing_write
	flag if we are writing and ADVANCE="no" was specified.
	Only call next_record() if advance="no" wasn't specified.

2007-12-13  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/34370
	PR libfortran/34323
	PR libfortran/34405
	* gfortran.dg/advance_6.f90:  New test case.
	* gfortran.dg/direct_io_7.f90:  New test case.
	* gfortran.dg/streamio_13.f90:  New test case.

From-SVN: r130912
2007-12-13 19:35:09 +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
Steven G. Kargl 8eacc23d94 [multiple changes]
2007-07-02  Steven G. Kargl  <kargl@gcc.gnu.org>

	Restore collateral damage from ISO C Binding merge.

        2007-06-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/32456
	* io/unit.c (filename_from_unit): Don't use find_unit, instead search
	for unit directly.

From-SVN: r126238
2007-07-02 23:29:27 +00:00
Christopher D. Rickett a8b3b0b633 [multiple changes]
2007-07-01  Christopher D. Rickett  <crickett@lanl.gov>

	* interface.c (gfc_compare_derived_types): Special case for comparing
	derived types across namespaces.
	(gfc_compare_types): Deal with BT_VOID.
	(compare_parameter): Use BT_VOID to accept ISO C Binding pointers.
	* trans-expr.c (gfc_conv_function_call): Remove setting parm_kind
	to SCALAR
	(gfc_conv_initializer): Deal with ISO C Binding NULL_PTR and 
	NULL_FUNPTR.
	(gfc_conv_expr): Convert expressions for ISO C Binding derived types.
	* symbol.c (gfc_set_default_type): BIND(C) variables should not be
	implicitly declared.
	(check_conflict): Add BIND(C) and check for conflicts.
	(gfc_add_explicit_interface): Whitespace.	
	(gfc_add_is_bind_c): New function.  
	(gfc_copy_attr): Use it.
	(gfc_new_symbol): Initialize ISO C Binding objects.
	(get_iso_c_binding_dt):  New function.
	(verify_bind_c_derived_type): Ditto.
	(gen_special_c_interop_ptr): Ditto.
	(add_formal_arg): Ditto.
	(gen_cptr_param): Ditto.
	(gen_fptr_param): Ditto.
	(gen_shape_param): Ditto.
	(add_proc_interface): Ditto.
	(build_formal_args): Ditto.
	(generate_isocbinding_symbol):  Ditto.
	(get_iso_c_sym):  Ditto.
	* decl.c (num_idents_on_line, has_name_equals): New variables.
	(verify_c_interop_param): New function.
	(build_sym): Finish binding labels and deal with COMMON blocks.
	(add_init_expr_to_sym): Check if the initialized expression is
	an iso_c_binding named constants
	(variable_decl): Set ISO C Binding type_spec components.
	(gfc_match_kind_spec): Check match for C interoperable kind.
	(match_char_spec): Fix comment. Chnage gfc_match_small_int
	to gfc_match_small_int_expr.  Check for C interoperable kind.
	(match_type_spec): Clear the current binding label.
	(match_attr_spec): Add DECL_IS_BIND_C.  If BIND(C) is found, use it
	to set attributes.
	(set_binding_label): New function.
	(set_com_block_bind_c): Ditto.
	(verify_c_interop): Ditto.
	(verify_com_block_vars_c_interop): Ditto.
	(verify_bind_c_sym): Ditto.
	(set_verify_bind_c_sym): Ditto.
	(set_verify_bind_c_com_block): Ditto.
	(get_bind_c_idents): Ditto.
	(gfc_match_bind_c_stmt): Ditto.
	(gfc_match_data_decl): Use num_idents_on_line.
	(match_result): Deal with right paren in BIND(C).
	(gfc_match_suffix): New function.
	(gfc_match_function_decl): Use it.  Code is re-arranged to deal with
	ISO C Binding result clauses.
	(gfc_match_subroutine):  Deal with BIND(C).
 	(gfc_match_bind_c): New function.
	(gfc_get_type_attr_spec): New function.  Code is re-arranged in and
	taken from gfc_match_derived_decl.
	(gfc_match_derived_decl): Add check for BIND(C).
	* trans-common.c: Forward declare gfc_get_common.
	(gfc_sym_mangled_common_id): Change arg from 'const char *name' to
	'gfc_common_head *com'.  Check for ISO C Binding of the common block.
	(build_common_decl): 'com->name' to 'com in SET_DECL_ASSEMBLER_NAME.
	* gfortran.h: Add GFC_MAX_BINDING_LABEL_LEN
	(bt): Add BT_VOID
	(sym_flavor): Add FL_VOID.
 	(iso_fortran_env_symbol, iso_c_binding_symbol, intmod_id): New enum
	(CInteropKind_t): New struct.
	(c_interop_kinds_table): Use it.  Declare an array of structs.
	(symbol_attribute): Add is_bind_c, is_c_interop, and is_iso_c
	bitfields.
	(gfc_typespec): Add is_c_interop; is_iso_c, and f90_type members.
	(gfc_symbol): Add from_intmod, intmod_sym_id, binding_label, and
	common_block members.
	(gfc_common_head): Add binding_label and is_bind_c members.
	(gfc_gsymbol): Add sym_name, mod_name, and binding_label members.
	Add prototypes for get_c_kind, gfc_validate_c_kind, 
	gfc_check_any_c_kind, gfc_add_is_bind_c, gfc_add_value,
	verify_c_interop, verify_c_interop_param, verify_bind_c_sym,
	verify_bind_c_derived_type, verify_com_block_vars_c_interop,
	generate_isocbinding_symbol, get_iso_c_sym, gfc_iso_c_sub_interface
	* iso-c-binding.def: New file. This file contains the definitions
	of the types provided by the Fortran 2003 ISO_C_BINDING intrinsic
	module.
	* trans-const.c (gfc_conv_constant_to_tree): Deal with C_NULL_PTR
	 or C_NULL_FUNPTR expressions.
	* expr.c (gfc_copy_expr): Add BT_VOID case.  For BT_CHARACTER, the
	ISO C Binding requires a minimum string length of 1 for '\0'.  
	* module.c (intmod_sym): New struct.
	(pointer_info): Add binding_label member.
	(write_atom): Set len to 0 for NULL pointers. Check for NULL p and *p.
	(ab_attribute): Add AB_IS_BIND_C, AB_IS_C_INTEROP and AB_IS_ISO_C.
	(attr_bits): Add "IS_BIND_C", "IS_C_INTEROP", and "IS_ISO_C".
	(mio_symbol_attribute): Deal with ISO C Binding attributes.
	(bt_types): Add "VOID".
	(mio_typespec): Deal with ISO C Binding components.
	(mio_namespace_ref): Add intmod variable. 
	(mio_symbol): Check for symbols from an intrinsic module.
	(load_commons): Check for BIND(C) common block.
	(read_module): Read binding_label and use it.
	(write_common): Add label.  Write BIND(C) info.
	(write_blank_common): Blank commons are not BIND(C).  Explicitly
	set is_bind_c=0.
	(write_symbol): Deal with binding_label.
	(sort_iso_c_rename_list): New function.
	(import_iso_c_binding_module): Ditto.
	(create_int_parameter): Add to args.
	(use_iso_fortran_env_module): Adjust to deal with iso_c_binding
	intrinsic module.
	* trans-types.c (c_interop_kinds_table): new array of structs. 
	(gfc_validate_c_kind): New function.
	(gfc_check_any_c_kind): Ditto.
	(get_real_kind_from_node): Ditto.
	(get_int_kind_from_node): Ditto.
	(get_int_kind_from_width): Ditto.
	(get_int_kind_from_minimal_width): Ditto.
	(init_c_interop_kinds): Ditto.
	(gfc_init_kinds): call init_c_interop_kinds.
	(gfc_typenode_for_spec): Adjust for BT_VOID and ISO C Binding pointers.
	Adjust handling of BT_DERIVED.
	(gfc_sym_type): Whitespace.
	(gfc_get_derived_type):  Account for iso_c_binding derived types
	* resolve.c (is_scalar_expr_ptr): New function.
	(gfc_iso_c_func_interface): Ditto.
	(resolve_function): Use gfc_iso_c_func_interface. 
	(set_name_and_label): New function.
	(gfc_iso_c_sub_interface): Ditto.
	(resolve_specific_s0): Use gfc_iso_c_sub_interface.
	(resolve_bind_c_comms): New function.
	(resolve_bind_c_derived_types): Ditto.
	(gfc_verify_binding_labels): Ditto.
	(resolve_fl_procedure): Check for ISO C interoperability.
	(resolve_symbol): Check C interoperability.
	(resolve_types): Walk the namespace.  Check COMMON blocks.
	* trans-decl.c (gfc_sym_mangled_identifier):  Prevent the mangling
	of identifiers that have an assigned binding label.
	(gfc_sym_mangled_function_id): Use the binding label rather than
	the mangled name.
	(gfc_finish_var_decl): Put variables that are BIND(C) into a common
	segment of the object file, because this is what C would do.
	(gfc_create_module_variable): Conver to proper types
	(set_tree_decl_type_code): New function.
	(generate_local_decl): Check dummy variables and derived types for
	ISO C Binding attributes.
	* match.c (gfc_match_small_int_expr): New function.
	(gfc_match_name_C): Ditto.
	(match_common_name): Deal with ISO C Binding in COMMON blocks
	* trans-io.c (transfer_expr):  Deal with C_NULL_PTR or C_NULL_FUNPTR
	expressions
	* match.h: Add prototypes for gfc_match_small_int_expr,
	gfc_match_name_C, match_common_name, set_com_block_bind_c,
	set_binding_label, set_verify_bind_c_sym,
	set_verify_bind_c_com_block, get_bind_c_idents,
	gfc_match_bind_c_stmt, gfc_match_suffix, gfc_match_bind_c,
	gfc_get_type_attr_spec
	* parse.c (decode_statement): Use gfc_match_bind_c_stmt
	(parse_derived): Init *derived_sym = NULL, and gfc_current_block
	later for valiadation.
	* primary.c (got_delim): Set ISO C Binding components of ts.
	(match_logical_constant): Ditto.
	(match_complex_constant): Ditto.
	(match_complex_constant): Ditto.
	(gfc_match_rvalue): Check for existence of at least one arg for
	C_LOC, C_FUNLOC, and C_ASSOCIATED.
	* misc.c (gfc_clear_ts): Clear ISO C Bindoing components in ts.
	(get_c_kind): New function.

2007-07-01  Christopher D. Rickett  <crickett@lanl.gov>

	* Makefile.in: Add support for iso_c_generated_procs.c and
	iso_c_binding.c.
	* Makefile.am: Ditto.
	* intrinsics/iso_c_generated_procs.c: New file containing helper
	functions.
	* intrinsics/iso_c_binding.c: Ditto.
	* intrinsics/iso_c_binding.h: New file
	* gfortran.map: Include the __iso_c_binding_c_* functions.
	* libgfortran.h: define GFC_NUM_RANK_BITS.

2007-06-23  Christopher D. Rickett  <crickett@lanl.gov>

	* bind_c_array_params.f03: New files for Fortran 2003 ISO C Binding.
	* bind_c_coms.f90: Ditto.
	* bind_c_coms_driver.c: Ditto.
	* bind_c_dts.f90: Ditto.
	* bind_c_dts_2.f03: Ditto.
	* bind_c_dts_2_driver.c: Ditto.
	* bind_c_dts_3.f03: Ditto.
	* bind_c_dts_4.f03: Ditto.
	* bind_c_dts_driver.c: Ditto.
	* bind_c_implicit_vars.f03: Ditto.
	* bind_c_procs.f03: Ditto.
	* bind_c_usage_2.f03: Ditto.
	* bind_c_usage_3.f03: Ditto.
	* bind_c_usage_5.f03: Ditto.
	* bind_c_usage_6.f03: Ditto.
	* bind_c_usage_7.f03: Ditto.
	* bind_c_vars.f90: Ditto.
	* bind_c_vars_driver.c: Ditto.
	* binding_c_table_15_1.f03: Ditto.
	* binding_label_tests.f03: Ditto.
	* binding_label_tests_10.f03: Ditto.
	* binding_label_tests_10_main.f03: Ditto.
	* binding_label_tests_11.f03: Ditto.
	* binding_label_tests_11_main.f03: Ditto.
	* binding_label_tests_12.f03: Ditto.
	* binding_label_tests_13.f03: Ditto.
	* binding_label_tests_13_main.f03: Ditto.
	* binding_label_tests_14.f03: Ditto.
	* binding_label_tests_2.f03: Ditto.
	* binding_label_tests_3.f03: Ditto.
	* binding_label_tests_4.f03: Ditto.
	* binding_label_tests_5.f03: Ditto.
	* binding_label_tests_6.f03: Ditto.
	* binding_label_tests_7.f03: Ditto.
	* binding_label_tests_8.f03: Ditto.
	* binding_label_tests_9.f03: Ditto.
	* c_assoc.f90: Ditto.
	* c_assoc_2.f03: Ditto.
	* c_f_pointer_shape_test.f90: Ditto.
	* c_f_pointer_tests.f90: Ditto.
	* c_f_tests_driver.c: Ditto.
	* c_funloc_tests.f03: Ditto.
	* c_funloc_tests_2.f03: Ditto.
	* c_funloc_tests_3.f03: Ditto.
	* c_funloc_tests_3_funcs.c: Ditto.
	* c_kind_params.f90: Ditto.
	* c_kind_tests_2.f03: Ditto.
	* c_kinds.c: Ditto.
	* c_loc_driver.c: Ditto.
	* c_loc_test.f90: Ditto.
	* c_loc_tests_2.f03: Ditto.
	* c_loc_tests_2_funcs.c: Ditto.
	* c_loc_tests_3.f03: Ditto.
	* c_loc_tests_4.f03: Ditto.
	* c_loc_tests_5.f03: Ditto.
	* c_loc_tests_6.f03: Ditto.
	* c_loc_tests_7.f03: Ditto.
	* c_loc_tests_8.f03: Ditto.
	* c_ptr_tests.f03: Ditto.
	* c_ptr_tests_10.f03: Ditto.
	* c_ptr_tests_5.f03: Ditto.
	* c_ptr_tests_7.f03: Ditto.
	* c_ptr_tests_7_driver.c: Ditto.
	* c_ptr_tests_8.f03: Ditto.
	* c_ptr_tests_8_funcs.c: Ditto.
	* c_ptr_tests_9.f03: Ditto.
	* c_ptr_tests_driver.c: Ditto.
	* c_size_t_driver.c: Ditto.
	* c_size_t_test.f03: Ditto.
	* com_block_driver.f90: Ditto.
	* global_vars_c_init.f90: Ditto.
	* global_vars_c_init_driver.c: Ditto.
	* global_vars_f90_init.f90: Ditto.
	* global_vars_f90_init_driver.c: Ditto.
	* interop_params.f03: Ditto.
	* iso_c_binding_only.f03: Ditto.
	* iso_c_binding_rename_1.f03: Ditto.
	* iso_c_binding_rename_1_driver.c: Ditto.
	* iso_c_binding_rename_2.f03: Ditto.
	* iso_c_binding_rename_2_driver.c: Ditto.
	* kind_tests_2.f03: Ditto.
	* kind_tests_3.f03: Ditto.
	* module_md5_1.f90: Ditto.
	* only_clause_main.c: Ditto.
	* print_c_kinds.f90: Ditto.
	* test_bind_c_parens.f03: Ditto.
	* test_c_assoc.c: Ditto.
	* test_com_block.f90: Ditto.
	* test_common_binding_labels.f03: Ditto.
	* test_common_binding_labels_2.f03: Ditto.
	* test_common_binding_labels_2_main.f03: Ditto.
	* test_common_binding_labels_3.f03: Ditto.
	* test_common_binding_labels_3_main.f03: Ditto.
	* test_only_clause.f90: Ditto.
	* use_iso_c_binding.f90: Ditto.
	* value_5.f90: Ditto.
	* value_test.f90: Ditto.
	* value_tests_f03.f90: Ditto.

From-SVN: r126185
2007-07-02 02:47:21 +00:00
Jerry DeLisle d1d92e95d2 re PR libfortran/32456 (IO error message should show Unit/Filename)
2007-06-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/32456
	* io/unit.c (filename_from_unit): Don't use find_unit, instead search
	for unit directly.

From-SVN: r126119
2007-06-29 19:39:21 +00:00
Jerry DeLisle 87557722c8 re PR libfortran/32456 (IO error message should show Unit/Filename)
2007-06-24  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/32456
	* runtime/error.c (show_locus): Update to emit the unit number
	and file name involved with the error.  Use new function
	filename_from_unit.
	* libgfortran.h (filename_from_unit): Declare new function.
	* io/unit.c (init_units): Set the unit file name for stdin, stdout,
	and stderr for use later in error reporting.
	(filename_from_unit): Add this new function.

From-SVN: r125989
2007-06-24 22:56:21 +00:00
Jerry DeLisle d10fb73e91 re PR libfortran/31501 (libgfortran internal unit I/O performance issues)
2007-04-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/31501
	* io/list_read.c (next_char): Fix whitespace.
	* io/io.h: Remove prototypes and define macros for is_array_io,
	is_stream_io, and is_internal_unit.
	* io/unit.c (is_array_io), (is_internal_unit), (is_stream_io): Delete
	these functions.
	* io/transfer.c (read_sf): Change handling of internal_unit to make a
	single call to salloc_r and use memcpy to transfer the data.

From-SVN: r124266
2007-04-28 23:23:35 +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 138469296c re PR fortran/31366 ([4.2 only] Last record truncated for read after short write, direct access file)
2007-04-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31366
	* io/transfer.c (read_block_direct): Do not generate error when reading
	past EOF on a short record that is less than the RECL= specified.
	
2007-04-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31207
	* io/unit.c (close_unit_1): If there are bytes previously written from
	ADVANCE="no", move to the end before closing.

From-SVN: r123401
2007-04-01 15:23:48 +00:00
Jerry DeLisle 807fb853ee re PR fortran/29563 (Internal read loses data.)
2006-10-25  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29563
	* io/io.h (st_parameter_dt): Add new flag at_eof.
	* io/list_read.c (next_char): Set flag when EOF and return '\n' to
	signal EOR.  Check flag on next call and jump out.
	* io/unit.c (get_internal_unit): Initialize new flag.

From-SVN: r118059
2006-10-26 04:35:45 +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
Jerry DeLisle 397bc09a65 re PR fortran/28339 (gfortran misses a record from a format statement)
2006-07-21  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/28339
	* io/transfer.c (next_record_w): Use next_array_record result to set
	END_FILE. (write_block): Test for END_FILE before the next write occurs.
	* io/unit.c (get_internal_unit): Initialize iunit->endfile for internal
	unit.

From-SVN: r115670
2006-07-22 03:14:27 +00:00
John David Anglin 9b7e4f4ff8 re PR libgomp/27254 (FAIL: libgomp.fortran/reduction6.f90)
PR libgomp/27254
	* io/unit.c (get_internal_unit): Initialize and lock thread mutex
	for internal units.

From-SVN: r114765
2006-06-19 03:07:54 +00:00
Jerry DeLisle 54ffdb125c re PR libfortran/20257 (Fortran runtime error: End of record occurs when writing large arrays)
2006-04-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/20257
	* io/io.h: Add prototypes for get_internal_unit and free_internal_unit.
	* io/unit.c (get_internal_unit): Initialize unit number, not zero.
	(free_internal_unit): New function to consolidate freeing memory.
	(get_unit): Initialize internal_unit_desc to NULL when unit is
	external.
	* io/unix.c (mem_close): Check for not NULL before freeing memory.
	* io/transfer.c (read_block): Reset bytes_left and skip error if unit
	is preconnected and default record length is reached.
	(read_block_direct): Ditto.
	(write_block): Ditto.
	(write_buf): Ditto.
	(data_transfer_init): Only flush if not internal unit.
	(finalize_transfer): Ditto and delete code to free memory used by
	internal units.
	(st_read_done): Use new function - free_internal_unit.
	(st_write_done): Use new function - free_internal unit.

From-SVN: r113190
2006-04-23 02:04:58 +00:00
Jerry DeLisle 6f34d6e078 re PR fortran/26766 ([F2003] Recursive I/O still (again) broken)
2006-04-12  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/26766
	* io/io.h: Add bit to identify associated unit as internal.
	* io/unit.c (get_external_unit): Renamed the find_unit_1 function to
	reflect the external unit functionality vs internal unit.
	(get_internal_unit): New function to allocate and initialize an internal
	unit structure.
	(get_unit): Use get_internal_unit and get_external_unit.
	(is_internal_unit): Revised to use new bit added in io.h.
	* io/transfer.c (data_transfer_init): Fix line width.
	(st_read_done): Free memory allocated for internal unit.
	(st_write_done): Add test to only flush and truncate when not an
	internal unit.  Free memory allocated for internal unit.

From-SVN: r112914
2006-04-13 06:24:58 +00:00
Jerry DeLisle 494ef4c254 re PR fortran/25264 (write to internal unit from the string itself gives wrong result ?)
2005-12-16  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/25264
	PR libgfortran/25349
	* io/unit.c (get_unit): Delete code that cleared the string when the
	unit was opened, which is too soon.
	* io/transfer.c (next_record_w): Pass done flag in.  Change logic for
	setting max_pos.  Add code to position unit and pad record as needed.

From-SVN: r108671
2005-12-16 19:32:21 +00:00
Jerry DeLisle ee17607ab3 re PR fortran/25109 (formatted reads with embedded blanks in input fields)
2005-11-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/25109
	* io/unit.c (init_units): Set default flag to BLANK_NULL per
	requirement of F95 standard.  Set PAD_YES for stdin.

From-SVN: r107588
2005-11-28 00:23:28 +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
Jerry DeLisle 965eec1676 re PR libfortran/24224 (Generalized internal array IO not implemented.)
2005-10-24  Jerry DeLisle  <jvdelisle@verizon.net>

        PR libgfortran/24224
        * libgfortran.h: Remove array stride error code.
        * runtime/error.c: Remove array stride error.
        * io/io.h: Change name of 'nml_loop_spec' to 'array_loop_spec' to be
        generic.  Add pointer to array_loop_spec and rank to gfc_unit
        structure.
        * io/list_read.c: Revise nml_loop_spec references to array_loop_spec.
        * io/transfer.c (init_loop_spec): New function to initialize
        an array_loop_spec.
        (next_array_record): New function to return the index to the next array
        record by incrementing through the array_loop_spec.
        (next_record_r): Use new function.
        (next_record_w): Use new function.
        (finalize_transfer): Free memory allocated for array_loop_spec.
        * io/unit.c (get_array_unit_len): Delete this function. Use new
        function init_loop_spec to initialize the array_loop_spec.

From-SVN: r105878
2005-10-25 01:32:33 +00:00
Jakub Jelinek 1449b8cba8 libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
	GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
	(gfc_itoa, xtoa): Add 2 extra arguments.
	* runtime/environ.c: Include stdio.h.
	(check_buffered): Use sprintf.
	* runtime/error.c: Include assert.h.
	(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
	buffers.
	(st_printf, st_sprintf): Adjust callers.
	* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
	static buffers.
	(write_int, write_decimal): Add 2 extra arguments to conv
	function pointer, adjust caller.
	(write_integer): Adjust gfc_itoa caller.

	* io/unit.c (get_array_unit_len): Return 0 rather than NULL.

	* io/read.c (read_f): Remove spurious pointer dereference.

From-SVN: r104855
2005-10-01 13:50:10 +02:00
Jerry DeLisle 59154ed24c PR fortran/21875 Internal Unit Array I/O, NIST
2005-09-14  Jerry DeLisle  <jvdelisle@verizon.net

	PR fortran/21875 Internal Unit Array I/O, NIST
	* libgfortran.h: Add run time error code for array stride.
	* runtime/error.c (translate_error): Add error message for
	array stride.
	* io/io.h: Add array descriptor pointer to IOPARM structure.
	Add prtotypes for two new functions.
	* io/transfer.c (data_transfer_init): Removed initialization and
	moved to unit.c (get_unit)
	* io/transfer.c (next_record_r): Include internal unit read
	functionality.
	* io/transfer.c (next_record_w): Include internal unit write
	functionality, including padding of character array records.
	* io/unit.c (get_array_unit_len): New function to return the number
	of records in the character array 'file' from the array descriptor.
	* io/unit.c (get_unit): Gathered initialization code from
	init_data_transfer for internal units and added initialization of
	character array unit.
	* io/unit.c (is_array_io): New function to determine if internal unit
	is an array.
	* io/unix.c (mem_alloc_w_at): Add error checks for bad record length
	and end of file.

From-SVN: r104276
2005-09-14 20:18:19 +00: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
Jerry DeLisle d1cc97e081 re PR libfortran/22570 (Null Characters instead of blanks in text output.)
2005-07-22 Jerry DeLisle <jvdelisle@verizon.net>

	PR libfortran/22570
	* io/unit.c (init_units): Replace BLANK_ZERO with
	BLANK_UNSPECIFIED.

From-SVN: r102288
2005-07-22 17:43:31 +00:00