~ubuntu-branches/ubuntu/hoary/binutils/hoary

« back to all changes in this revision

Viewing changes to bfd/doc/cache.texi

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2005-03-18 13:07:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050318130752-j4i37zgqclj53b94
Tags: 2.15-5ubuntu2
debian/rules: Call pkgstriptranslations if present (the package does not
use debhelper, thus it does not happen automatically).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
@section File caching
 
2
The file caching mechanism is embedded within BFD and allows
 
3
the application to open as many BFDs as it wants without
 
4
regard to the underlying operating system's file descriptor
 
5
limit (often as low as 20 open files).  The module in
 
6
@code{cache.c} maintains a least recently used list of
 
7
@code{BFD_CACHE_MAX_OPEN} files, and exports the name
 
8
@code{bfd_cache_lookup}, which runs around and makes sure that
 
9
the required BFD is open. If not, then it chooses a file to
 
10
close, closes it and opens the one wanted, returning its file
 
11
handle.
 
12
 
 
13
@findex BFD_CACHE_MAX_OPEN macro
 
14
@subsubsection @code{BFD_CACHE_MAX_OPEN macro}
 
15
@strong{Description}@*
 
16
The maximum number of files which the cache will keep open at
 
17
one time.
 
18
@example
 
19
#define BFD_CACHE_MAX_OPEN 10
 
20
@end example
 
21
 
 
22
@findex bfd_last_cache
 
23
@subsubsection @code{bfd_last_cache}
 
24
@strong{Synopsis}
 
25
@example
 
26
extern bfd *bfd_last_cache;
 
27
@end example
 
28
@strong{Description}@*
 
29
Zero, or a pointer to the topmost BFD on the chain.  This is
 
30
used by the @code{bfd_cache_lookup} macro in @file{libbfd.h} to
 
31
determine when it can avoid a function call.
 
32
 
 
33
@findex bfd_cache_lookup
 
34
@subsubsection @code{bfd_cache_lookup}
 
35
@strong{Description}@*
 
36
Check to see if the required BFD is the same as the last one
 
37
looked up. If so, then it can use the stream in the BFD with
 
38
impunity, since it can't have changed since the last lookup;
 
39
otherwise, it has to perform the complicated lookup function.
 
40
@example
 
41
#define bfd_cache_lookup(x) \
 
42
    ((x)==bfd_last_cache? \
 
43
      (FILE*) (bfd_last_cache->iostream): \
 
44
       bfd_cache_lookup_worker(x))
 
45
@end example
 
46
 
 
47
@findex bfd_cache_init
 
48
@subsubsection @code{bfd_cache_init}
 
49
@strong{Synopsis}
 
50
@example
 
51
bfd_boolean bfd_cache_init (bfd *abfd);
 
52
@end example
 
53
@strong{Description}@*
 
54
Add a newly opened BFD to the cache.
 
55
 
 
56
@findex bfd_cache_close
 
57
@subsubsection @code{bfd_cache_close}
 
58
@strong{Synopsis}
 
59
@example
 
60
bfd_boolean bfd_cache_close (bfd *abfd);
 
61
@end example
 
62
@strong{Description}@*
 
63
Remove the BFD @var{abfd} from the cache. If the attached file is open,
 
64
then close it too.
 
65
 
 
66
@strong{Returns}@*
 
67
@code{FALSE} is returned if closing the file fails, @code{TRUE} is
 
68
returned if all is well.
 
69
 
 
70
@findex bfd_open_file
 
71
@subsubsection @code{bfd_open_file}
 
72
@strong{Synopsis}
 
73
@example
 
74
FILE* bfd_open_file (bfd *abfd);
 
75
@end example
 
76
@strong{Description}@*
 
77
Call the OS to open a file for @var{abfd}.  Return the @code{FILE *}
 
78
(possibly @code{NULL}) that results from this operation.  Set up the
 
79
BFD so that future accesses know the file is open. If the @code{FILE *}
 
80
returned is @code{NULL}, then it won't have been put in the
 
81
cache, so it won't have to be removed from it.
 
82
 
 
83
@findex bfd_cache_lookup_worker
 
84
@subsubsection @code{bfd_cache_lookup_worker}
 
85
@strong{Synopsis}
 
86
@example
 
87
FILE *bfd_cache_lookup_worker (bfd *abfd);
 
88
@end example
 
89
@strong{Description}@*
 
90
Called when the macro @code{bfd_cache_lookup} fails to find a
 
91
quick answer.  Find a file descriptor for @var{abfd}.  If
 
92
necessary, it open it.  If there are already more than
 
93
@code{BFD_CACHE_MAX_OPEN} files open, it tries to close one first, to
 
94
avoid running out of file descriptors.
 
95