aboutsummaryrefslogtreecommitdiff
path: root/gdb/bcache.h
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2002-07-12 15:23:10 +0000
committerAndrew Cagney <cagney@redhat.com>2002-07-12 15:23:10 +0000
commitaf5f3db67c5dcbbc7b2038fe781d03301b94783d (patch)
tree458bedb8fa453f6b845b5ff34fa7874edb6b499c /gdb/bcache.h
parent120d20f2664d24f5080a5578f8ff93c10f4a8a9c (diff)
downloadgdb-af5f3db67c5dcbbc7b2038fe781d03301b94783d.zip
gdb-af5f3db67c5dcbbc7b2038fe781d03301b94783d.tar.gz
gdb-af5f3db67c5dcbbc7b2038fe781d03301b94783d.tar.bz2
* bcache.h: Update copyright.
(struct bstring, struct bcache): Move definition to "bcache.c". Replaced by opaque declaration. (bcache_xfree): Replace free_bcache. (bcache_xmalloc, bcache_memory_used): Declare. * bcache.c: Update copyright. (struct bstring, struct bcache): Moved to here from "bcache.h". Update comments. (bcache_xmalloc, bcache_memory_used): New functions. (bcache_xfree): Replace function free_bcache. * Makefile.in (objfiles.o): Add $(bcache_h). (objfiles_h): Remove $(bcache_h). (symfile.o): Add $(bcache_h). * symmisc.c: Update copyright. (print_symbol_bcache_statistics): Pass psymbol_cache by value. (print_objfile_statistics): Use bcache_memory_used. * symfile.c: Include "bcache.h". (reread_symbols): Use bcache_xfree. (reread_symbols): Use bcache_xmalloc and bcache_xfree. (add_psymbol_to_list): Pass psymbol_cache by value. (add_psymbol_with_dem_name_to_list): Ditto. * objfiles.h: Update copyright. (struct bcache): Declare opaque. Do not include "bcache.h". (struct objfile): Change psymbol_cache and macro_cache to ``struct bcache'' pointers. * dwarf2read.c (macro_start_file): Pass macro_cache by value. * objfiles.c: Include "bcache.h". Update copyright. (allocate_objfile): Use bcache_xmalloc to create psymbol_cache and macro_cache. (free_objfile): Use bcache_xfree.
Diffstat (limited to 'gdb/bcache.h')
-rw-r--r--gdb/bcache.h62
1 files changed, 11 insertions, 51 deletions
diff --git a/gdb/bcache.h b/gdb/bcache.h
index 2b03ead..61fbbe6 100644
--- a/gdb/bcache.h
+++ b/gdb/bcache.h
@@ -1,7 +1,8 @@
/* Include file cached obstack implementation.
Written by Fred Fish <fnf@cygnus.com>
Rewritten by Jim Blandy <jimb@cygnus.com>
- Copyright 1999, 2000 Free Software Foundation, Inc.
+
+ Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
This file is part of GDB.
@@ -63,68 +64,27 @@
any chance of sharing its space with future duplicates. */
-/* The type used to hold a single bcache string. The user data is
- stored in d.data. Since it can be any type, it needs to have the
- same alignment as the most strict alignment of any type on the host
- machine. I don't know of any really correct way to do this in
- stock ANSI C, so just do it the same way obstack.h does.
-
- It would be nicer to have this stuff hidden away in bcache.c, but
- struct objstack contains a struct bcache directly --- not a pointer
- to one --- and then the memory-mapped stuff makes this a real pain.
- We don't strictly need to expose struct bstring, but it's better to
- have it all in one place. */
-
-struct bstring {
- struct bstring *next;
- size_t length;
-
- union
- {
- char data[1];
- double dummy;
- }
- d;
-};
-
-
-/* The structure for a bcache itself.
- To initialize a bcache, just fill it with zeros. */
-struct bcache {
- /* All the bstrings are allocated here. */
- struct obstack cache;
-
- /* How many hash buckets we're using. */
- unsigned int num_buckets;
-
- /* Hash buckets. This table is allocated using malloc, so when we
- grow the table we can return the old table to the system. */
- struct bstring **bucket;
-
- /* Statistics. */
- unsigned long unique_count; /* number of unique strings */
- long total_count; /* total number of strings cached, including dups */
- long unique_size; /* size of unique strings, in bytes */
- long total_size; /* total number of bytes cached, including dups */
- long structure_size; /* total size of bcache, including infrastructure */
-};
-
+struct bcache;
/* Find a copy of the LENGTH bytes at ADDR in BCACHE. If BCACHE has
never seen those bytes before, add a copy of them to BCACHE. In
either case, return a pointer to BCACHE's copy of that string. */
extern void *bcache (const void *addr, int length, struct bcache *bcache);
-/* Free all the storage that BCACHE refers to. The result is a valid,
- but empty, bcache. This does not free BCACHE itself, since that
- might be part of some larger object. */
-extern void free_bcache (struct bcache *bcache);
+/* Free all the storage used by BCACHE. */
+extern void bcache_xfree (struct bcache *bcache);
+
+/* Create a new bcache object. */
+extern struct bcache *bcache_xmalloc (void);
/* Print statistics on BCACHE's memory usage and efficacity at
eliminating duplication. TYPE should be a string describing the
kind of data BCACHE holds. Statistics are printed using
`printf_filtered' and its ilk. */
extern void print_bcache_statistics (struct bcache *bcache, char *type);
+extern int bcache_memory_used (struct bcache *bcache);
+
/* The hash function */
extern unsigned long hash(const void *addr, int length);
+
#endif /* BCACHE_H */