aboutsummaryrefslogtreecommitdiff
path: root/gdb/bcache.h
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1996-03-24 00:22:50 +0000
committerFred Fish <fnf@specifix.com>1996-03-24 00:22:50 +0000
commit4cfb23a94c8cd4aac096c54ee7f8fe28cdc5f525 (patch)
tree3221fbbd6af66a2ba9fba00d639f686928d07278 /gdb/bcache.h
parenta319972ce65345235a584dc629ca3ae29b25fa44 (diff)
downloadgdb-4cfb23a94c8cd4aac096c54ee7f8fe28cdc5f525.zip
gdb-4cfb23a94c8cd4aac096c54ee7f8fe28cdc5f525.tar.gz
gdb-4cfb23a94c8cd4aac096c54ee7f8fe28cdc5f525.tar.bz2
* os9kread.c (os9k_process_one_symbol): Note nonportable
assumption that an int can hold a char *. * bcache.h (struct hashlink): Wrap data[] inside union with double to force longest alignment. (BCACHE_DATA): New macro to access data[]. (BCACHE_ALIGNMENT): New macro to get offset to data[]. * bcache.c (lookup_cache, bcache): Use BCACHE_DATA to get address of cached data. Use BCACHE_ALIGNMENT to compute amount of space to allocate for each hashlink struct.
Diffstat (limited to 'gdb/bcache.h')
-rw-r--r--gdb/bcache.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/gdb/bcache.h b/gdb/bcache.h
index e389c8e..1e6d25a 100644
--- a/gdb/bcache.h
+++ b/gdb/bcache.h
@@ -25,11 +25,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define BCACHE_HASHSIZE (1 << BCACHE_HASHLENGTH)
#define BCACHE_MAXLENGTH 128
+/* Note that the user data is stored in 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. So do it the same way obstack does. */
+
struct hashlink {
struct hashlink *next;
- char data[1];
+ union {
+ char data[1];
+ double dummy;
+ } d;
};
+/* BCACHE_DATA is used to get the address of the cached data. */
+
+#define BCACHE_DATA(p) ((p)->d.data)
+
+/* BCACHE_DATA_ALIGNMENT is used to get the offset of the start of
+ cached data within the hashlink struct. This value, plus the
+ size of the cached data, is the amount of space to allocate for
+ a hashlink struct to hold the next pointer and the data. */
+
+#define BCACHE_DATA_ALIGNMENT \
+ (((char *) &BCACHE_DATA((struct hashlink*) 0) - (char *) 0))
+
struct bcache {
struct obstack cache;
struct hashlink **indextable[BCACHE_MAXLENGTH];