[RFC PATCH] _gfortran_{ioparm,filename,line} vs. thread-safety

Jerry DeLisle jvdelisle@verizon.net
Wed Oct 5 14:53:00 GMT 2005


Jakub Jelinek wrote:
> On Wed, Oct 05, 2005 at 12:24:09PM +0300, Janne Blomqvist wrote:
> 
>>I think this if statement could be replaced with something like
>>
>>if (m > s->file_length)
>>  {
>>    *len = s->file_length - where;
>>    return NULL;
>>  }
>>
>>and then call generate_error in the calling function. That way there
>>would be no need to add the st_parameter_dt argument to salloc_w_at,
>>preserving the "purity" of the IO API.
> 
> 

Yes please do preserve.

> Good idea, added to my tree.  There is a slight difference though,
> the generate_error was called with ERROR_END while the callers, if
> they ever check the return value (some of them don't :( ) use
> ERROR_OS. 

That if clause is there originally because on exceeding the file length for an 
internal character array unit, the error message was "SUCCESS" which makes no sense.

We can add a check in here in transfer.c:  I will do that later if you don't 
want to hold up your patch for the nit picks.  (I am working on another that 
will touch on this anyway, handling the case of stride != 1)

I bootstrapped and regression tested your patch on i686-pc-linux-gnu with no new 
regressions. :)

Regards,

Jerry

      if (is_internal_unit())
	{
	  if (is_array_io())
	    {
	      bytes_left = (int) current_unit->bytes_left;
	      p = salloc_w (current_unit->s, &bytes_left);
	      if (p != NULL)
		{
		  memset(p, ' ', bytes_left);
	          current_unit->bytes_left = current_unit->recl;
		}
	    }
	  else
	    {
	      length = 1;
	      p = salloc_w (current_unit->s, &length);
	    }



More information about the Fortran mailing list