mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-10-13 02:45:02 +08:00
* cache.c (BFD_CACHE_MAX_OPEN): Make private to this file.
(bfd_last_cache, bfd_cache_lookup, bfd_cache_lookup_worker): Likewise. * libbfd-in.h (bfd_cache_lookup_worker, bfd_last_cache): Delete. * libbfd.h: Regenerate.
This commit is contained in:
@ -1,5 +1,10 @@
|
|||||||
2005-10-27 Alan Modra <amodra@bigpond.net.au>
|
2005-10-27 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
|
* cache.c (BFD_CACHE_MAX_OPEN): Make private to this file.
|
||||||
|
(bfd_last_cache, bfd_cache_lookup, bfd_cache_lookup_worker): Likewise.
|
||||||
|
* libbfd-in.h (bfd_cache_lookup_worker, bfd_last_cache): Delete.
|
||||||
|
* libbfd.h: Regenerate.
|
||||||
|
|
||||||
* hppabsd-core.c (hppabsd_core_core_file_p): Use bfd_stat, not fstat.
|
* hppabsd-core.c (hppabsd_core_core_file_p): Use bfd_stat, not fstat.
|
||||||
* sco5-core.c (sco5_core_file_p): Likewise.
|
* sco5-core.c (sco5_core_file_p): Likewise.
|
||||||
* trad-core.c (trad_unix_core_file_p): Likewise.
|
* trad-core.c (trad_unix_core_file_p): Likewise.
|
||||||
|
78
bfd/cache.c
78
bfd/cache.c
@ -1,7 +1,7 @@
|
|||||||
/* BFD library -- caching of file descriptors.
|
/* BFD library -- caching of file descriptors.
|
||||||
|
|
||||||
Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002,
|
Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002,
|
||||||
2003, 2004 Free Software Foundation, Inc.
|
2003, 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
|
Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
|
||||||
|
|
||||||
@ -45,36 +45,20 @@ SUBSECTION
|
|||||||
#include "libbfd.h"
|
#include "libbfd.h"
|
||||||
#include "libiberty.h"
|
#include "libiberty.h"
|
||||||
|
|
||||||
/*
|
/* The maximum number of files which the cache will keep open at
|
||||||
INTERNAL_FUNCTION
|
one time. */
|
||||||
BFD_CACHE_MAX_OPEN macro
|
|
||||||
|
|
||||||
DESCRIPTION
|
#define BFD_CACHE_MAX_OPEN 10
|
||||||
The maximum number of files which the cache will keep open at
|
|
||||||
one time.
|
|
||||||
|
|
||||||
.#define BFD_CACHE_MAX_OPEN 10
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* The number of BFD files we have open. */
|
/* The number of BFD files we have open. */
|
||||||
|
|
||||||
static int open_files;
|
static int open_files;
|
||||||
|
|
||||||
/*
|
/* Zero, or a pointer to the topmost BFD on the chain. This is
|
||||||
INTERNAL_FUNCTION
|
used by the <<bfd_cache_lookup>> macro in @file{libbfd.h} to
|
||||||
bfd_last_cache
|
determine when it can avoid a function call. */
|
||||||
|
|
||||||
SYNOPSIS
|
static bfd *bfd_last_cache = NULL;
|
||||||
extern bfd *bfd_last_cache;
|
|
||||||
|
|
||||||
DESCRIPTION
|
|
||||||
Zero, or a pointer to the topmost BFD on the chain. This is
|
|
||||||
used by the <<bfd_cache_lookup>> macro in @file{libbfd.h} to
|
|
||||||
determine when it can avoid a function call.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bfd *bfd_last_cache = NULL;
|
|
||||||
|
|
||||||
/* Insert a BFD into the cache. */
|
/* Insert a BFD into the cache. */
|
||||||
|
|
||||||
@ -169,40 +153,24 @@ close_one (void)
|
|||||||
return bfd_cache_delete (kill);
|
return bfd_cache_delete (kill);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Check to see if the required BFD is the same as the last one
|
||||||
INTERNAL_FUNCTION
|
looked up. If so, then it can use the stream in the BFD with
|
||||||
bfd_cache_lookup
|
impunity, since it can't have changed since the last lookup;
|
||||||
|
otherwise, it has to perform the complicated lookup function. */
|
||||||
|
|
||||||
DESCRIPTION
|
#define bfd_cache_lookup(x) \
|
||||||
Check to see if the required BFD is the same as the last one
|
((x) == bfd_last_cache \
|
||||||
looked up. If so, then it can use the stream in the BFD with
|
? (FILE *) (bfd_last_cache->iostream) \
|
||||||
impunity, since it can't have changed since the last lookup;
|
: bfd_cache_lookup_worker (x))
|
||||||
otherwise, it has to perform the complicated lookup function.
|
|
||||||
|
|
||||||
.#define bfd_cache_lookup(x) \
|
/* Called when the macro <<bfd_cache_lookup>> fails to find a
|
||||||
. ((x) == bfd_last_cache ? \
|
quick answer. Find a file descriptor for @var{abfd}. If
|
||||||
. (FILE *) (bfd_last_cache->iostream): \
|
necessary, it open it. If there are already more than
|
||||||
. bfd_cache_lookup_worker (x))
|
<<BFD_CACHE_MAX_OPEN>> files open, it tries to close one first, to
|
||||||
|
avoid running out of file descriptors. It will return NULL
|
||||||
|
if it is unable to (re)open the @var{abfd}. */
|
||||||
|
|
||||||
*/
|
static FILE *
|
||||||
|
|
||||||
/*
|
|
||||||
INTERNAL_FUNCTION
|
|
||||||
bfd_cache_lookup_worker
|
|
||||||
|
|
||||||
SYNOPSIS
|
|
||||||
FILE *bfd_cache_lookup_worker (bfd *abfd);
|
|
||||||
|
|
||||||
DESCRIPTION
|
|
||||||
Called when the macro <<bfd_cache_lookup>> fails to find a
|
|
||||||
quick answer. Find a file descriptor for @var{abfd}. If
|
|
||||||
necessary, it open it. If there are already more than
|
|
||||||
<<BFD_CACHE_MAX_OPEN>> files open, it tries to close one first, to
|
|
||||||
avoid running out of file descriptors. It will return NULL
|
|
||||||
if it is unable to (re)open the @var{abfd}.
|
|
||||||
*/
|
|
||||||
|
|
||||||
FILE *
|
|
||||||
bfd_cache_lookup_worker (bfd *abfd)
|
bfd_cache_lookup_worker (bfd *abfd)
|
||||||
{
|
{
|
||||||
bfd *orig_bfd = abfd;
|
bfd *orig_bfd = abfd;
|
||||||
|
@ -652,11 +652,6 @@ extern void _bfd_abort
|
|||||||
extern file_ptr real_ftell (FILE *file);
|
extern file_ptr real_ftell (FILE *file);
|
||||||
extern int real_fseek (FILE *file, file_ptr offset, int whence);
|
extern int real_fseek (FILE *file, file_ptr offset, int whence);
|
||||||
|
|
||||||
FILE * bfd_cache_lookup_worker
|
|
||||||
(bfd *);
|
|
||||||
|
|
||||||
extern bfd *bfd_last_cache;
|
|
||||||
|
|
||||||
/* List of supported target vectors, and the default vector (if
|
/* List of supported target vectors, and the default vector (if
|
||||||
bfd_default_vector[0] is NULL, there is no default). */
|
bfd_default_vector[0] is NULL, there is no default). */
|
||||||
extern const bfd_target * const *bfd_target_vector;
|
extern const bfd_target * const *bfd_target_vector;
|
||||||
|
14
bfd/libbfd.h
14
bfd/libbfd.h
@ -657,11 +657,6 @@ extern void _bfd_abort
|
|||||||
extern file_ptr real_ftell (FILE *file);
|
extern file_ptr real_ftell (FILE *file);
|
||||||
extern int real_fseek (FILE *file, file_ptr offset, int whence);
|
extern int real_fseek (FILE *file, file_ptr offset, int whence);
|
||||||
|
|
||||||
FILE * bfd_cache_lookup_worker
|
|
||||||
(bfd *);
|
|
||||||
|
|
||||||
extern bfd *bfd_last_cache;
|
|
||||||
|
|
||||||
/* List of supported target vectors, and the default vector (if
|
/* List of supported target vectors, and the default vector (if
|
||||||
bfd_default_vector[0] is NULL, there is no default). */
|
bfd_default_vector[0] is NULL, there is no default). */
|
||||||
extern const bfd_target * const *bfd_target_vector;
|
extern const bfd_target * const *bfd_target_vector;
|
||||||
@ -767,21 +762,12 @@ struct _bfd_window_internal {
|
|||||||
unsigned mapped : 1; /* 1 = mmap, 0 = malloc */
|
unsigned mapped : 1; /* 1 = mmap, 0 = malloc */
|
||||||
};
|
};
|
||||||
/* Extracted from cache.c. */
|
/* Extracted from cache.c. */
|
||||||
#define BFD_CACHE_MAX_OPEN 10
|
|
||||||
extern bfd *bfd_last_cache;
|
|
||||||
|
|
||||||
#define bfd_cache_lookup(x) \
|
|
||||||
((x) == bfd_last_cache ? \
|
|
||||||
(FILE *) (bfd_last_cache->iostream): \
|
|
||||||
bfd_cache_lookup_worker (x))
|
|
||||||
bfd_boolean bfd_cache_init (bfd *abfd);
|
bfd_boolean bfd_cache_init (bfd *abfd);
|
||||||
|
|
||||||
bfd_boolean bfd_cache_close (bfd *abfd);
|
bfd_boolean bfd_cache_close (bfd *abfd);
|
||||||
|
|
||||||
FILE* bfd_open_file (bfd *abfd);
|
FILE* bfd_open_file (bfd *abfd);
|
||||||
|
|
||||||
FILE *bfd_cache_lookup_worker (bfd *abfd);
|
|
||||||
|
|
||||||
/* Extracted from reloc.c. */
|
/* Extracted from reloc.c. */
|
||||||
#ifdef _BFD_MAKE_TABLE_bfd_reloc_code_real
|
#ifdef _BFD_MAKE_TABLE_bfd_reloc_code_real
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user