aboutsummaryrefslogtreecommitdiff
path: root/gdb/bcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/bcache.c')
-rw-r--r--gdb/bcache.c71
1 files changed, 36 insertions, 35 deletions
diff --git a/gdb/bcache.c b/gdb/bcache.c
index 0d6d205..97485dd 100644
--- a/gdb/bcache.c
+++ b/gdb/bcache.c
@@ -2,21 +2,22 @@
Written by Fred Fish (fnf@cygnus.com)
Copyright 1995, 1998 Free Software Foundation, Inc.
-This file is part of GDB.
+ This file is part of GDB.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "obstack.h"
@@ -30,8 +31,8 @@ static unsigned int hash PARAMS ((void *, int));
static void *lookup_cache PARAMS ((void *, int, int, struct bcache *));
/* FIXME: Incredibly simplistic hash generator. Probably way too expensive
- (consider long strings) and unlikely to have good distribution across hash
- values for typical input. */
+ (consider long strings) and unlikely to have good distribution across hash
+ values for typical input. */
static unsigned int
hash (bytes, count)
@@ -68,7 +69,7 @@ lookup_cache (bytes, count, hashval, bcachep)
struct hashlink **hashtablep;
struct hashlink *linkp;
- hashtablep = bcachep -> indextable[count];
+ hashtablep = bcachep->indextable[count];
if (hashtablep != NULL)
{
linkp = hashtablep[hashval];
@@ -79,7 +80,7 @@ lookup_cache (bytes, count, hashval, bcachep)
location = BCACHE_DATA (linkp);
break;
}
- linkp = linkp -> next;
+ linkp = linkp->next;
}
}
return (location);
@@ -101,9 +102,9 @@ bcache (bytes, count, bcachep)
{
/* Rare enough to just stash unique copies */
location = (void *) obstack_alloc (&bcachep->cache, count);
- bcachep -> cache_bytes += count;
+ bcachep->cache_bytes += count;
memcpy (location, bytes, count);
- bcachep -> bcache_overflows++;
+ bcachep->bcache_overflows++;
}
else
{
@@ -111,26 +112,26 @@ bcache (bytes, count, bcachep)
location = lookup_cache (bytes, count, hashval, bcachep);
if (location != NULL)
{
- bcachep -> cache_savings += count;
- bcachep -> cache_hits++;
+ bcachep->cache_savings += count;
+ bcachep->cache_hits++;
}
else
{
- bcachep -> cache_misses++;
- hashtablepp = &bcachep -> indextable[count];
+ bcachep->cache_misses++;
+ hashtablepp = &bcachep->indextable[count];
if (*hashtablepp == NULL)
{
*hashtablepp = (struct hashlink **)
obstack_alloc (&bcachep->cache, BCACHE_HASHSIZE * sizeof (struct hashlink *));
- bcachep -> cache_bytes += BCACHE_HASHSIZE * sizeof (struct hashlink *);
+ bcachep->cache_bytes += BCACHE_HASHSIZE * sizeof (struct hashlink *);
memset (*hashtablepp, 0, BCACHE_HASHSIZE * sizeof (struct hashlink *));
}
linkpp = &(*hashtablepp)[hashval];
newlink = (struct hashlink *)
obstack_alloc (&bcachep->cache, BCACHE_DATA_ALIGNMENT + count);
- bcachep -> cache_bytes += BCACHE_DATA_ALIGNMENT + count;
+ bcachep->cache_bytes += BCACHE_DATA_ALIGNMENT + count;
memcpy (BCACHE_DATA (newlink), bytes, count);
- newlink -> next = *linkpp;
+ newlink->next = *linkpp;
*linkpp = newlink;
location = BCACHE_DATA (newlink);
}
@@ -149,7 +150,7 @@ print_bcache_statistics (bcachep, id)
for (lmax = lcount = tcount = hcount = tidx = 0; tidx < BCACHE_MAXLENGTH; tidx++)
{
- hashtablep = bcachep -> indextable[tidx];
+ hashtablep = bcachep->indextable[tidx];
if (hashtablep != NULL)
{
tcount++;
@@ -159,7 +160,7 @@ print_bcache_statistics (bcachep, id)
if (linkp != NULL)
{
hcount++;
- for (temp = 0; linkp != NULL; linkp = linkp -> next)
+ for (temp = 0; linkp != NULL; linkp = linkp->next)
{
lcount++;
temp++;
@@ -175,21 +176,21 @@ print_bcache_statistics (bcachep, id)
}
}
printf_filtered (" Cached '%s' statistics:\n", id);
- printf_filtered (" Cache hits: %d\n", bcachep -> cache_hits);
- printf_filtered (" Cache misses: %d\n", bcachep -> cache_misses);
+ printf_filtered (" Cache hits: %d\n", bcachep->cache_hits);
+ printf_filtered (" Cache misses: %d\n", bcachep->cache_misses);
printf_filtered (" Cache hit ratio: ");
- if (bcachep -> cache_hits + bcachep -> cache_misses > 0)
+ if (bcachep->cache_hits + bcachep->cache_misses > 0)
{
- printf_filtered ("%d%%\n", ((bcachep -> cache_hits) * 100) /
- (bcachep -> cache_hits + bcachep -> cache_misses));
+ printf_filtered ("%d%%\n", ((bcachep->cache_hits) * 100) /
+ (bcachep->cache_hits + bcachep->cache_misses));
}
else
{
printf_filtered ("(not applicable)\n");
}
- printf_filtered (" Space used for caching: %d\n", bcachep -> cache_bytes);
- printf_filtered (" Space saved by cache hits: %d\n", bcachep -> cache_savings);
- printf_filtered (" Number of bcache overflows: %d\n", bcachep -> bcache_overflows);
+ printf_filtered (" Space used for caching: %d\n", bcachep->cache_bytes);
+ printf_filtered (" Space saved by cache hits: %d\n", bcachep->cache_savings);
+ printf_filtered (" Number of bcache overflows: %d\n", bcachep->bcache_overflows);
printf_filtered (" Number of index buckets used: %d\n", tcount);
printf_filtered (" Number of hash table buckets used: %d\n", hcount);
printf_filtered (" Number of chained items: %d\n", lcount);