This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATH: Restore file cache for bfd_openr


Alan Modra wrote:
On Wed, Jun 08, 2005 at 09:48:49PM -0700, Mark Mitchell wrote:

Alan Modra wrote:

On Wed, Jun 08, 2005 at 03:43:21PM -0700, Mark Mitchell wrote:


* opncls.c (bfd_openr): Call bfd_set_cacheable on returned BFDs.


I think it makes sense to do this in bfd_fopen instead, if fd != -1.
ie. Make your new bfd_fopen function default to the auto-close/open
behaviour.  Thoughts?

Makes sense to me. May I check in that variation, assuming the same testing shows that it works OK?


Yes. And I meant if fd == -1, of course.

I checked in the attached patch.


Thanks!

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
2005-06-08  Mark Mitchell  <mark@codesourcery.com>

	* opncls.c (bfd_fopen): Mark returned BFD as cacheable if FD == -1.

Index: opncls.c
===================================================================
RCS file: /cvs/src/src/bfd/opncls.c,v
retrieving revision 1.37
diff -c -5 -p -r1.37 opncls.c
*** opncls.c	8 Jun 2005 03:51:32 -0000	1.37
--- opncls.c	9 Jun 2005 07:14:28 -0000
*************** DESCRIPTION
*** 142,151 ****
--- 142,153 ----
  	<<fdopen>>. 
  
  	Calls <<bfd_find_target>>, so @var{target} is interpreted as by
  	that function.
  
+ 	The new BFD is marked as cacheable iff @var{fd} is -1.
+ 
  	If <<NULL>> is returned then an error has occured.   Possible errors
  	are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> or
  	<<system_call>> error.
  */
  
*************** bfd_fopen (const char *filename, const c
*** 196,205 ****
--- 198,213 ----
      {
        _bfd_delete_bfd (nbfd);
        return NULL;
      }
    nbfd->opened_once = TRUE;
+   /* If we opened the file by name, mark it cacheable; we can close it
+      and reopen it later.  However, if a file descriptor was provided,
+      then it may have been opened with special flags that make it
+      unsafe to close and reopen the file.  */
+   if (fd == -1)
+     bfd_set_cacheable (nbfd, TRUE);
  
    return nbfd;
  }
  
  /*

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]