Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
eedb4710
Commit
eedb4710
authored
Dec 10, 1991
by
Dennis Glatting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up file format for a distribution.
From-SVN: r111
parent
b61e1345
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
83 deletions
+91
-83
gcc/objc/hash.c
+72
-68
gcc/objc/hash.h
+19
-15
gcc/objc/objc.h
+0
-0
No files found.
gcc/objc/hash.c
View file @
eedb4710
...
...
@@ -16,10 +16,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
$Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/hash.c,v 0.
8 1991/11/24 01:20:02
dennisg Exp dennisg $
$Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/hash.c,v 0.
9 1991/12/03 02:01:23
dennisg Exp dennisg $
$Author: dennisg $
$Date: 1991/1
1/24 01:20:02
$
$Date: 1991/1
2/03 02:01:23
$
$Log: hash.c,v $
* Revision 0.9 1991/12/03 02:01:23 dennisg
* fixed assert macro.
* added memory allocation adjustment macro for hash size allocation.
*
* Revision 0.8 1991/11/24 01:20:02 dennisg
* changed shorts back to ints.
* the efficiency gained didn't out weight the grossness of the code.
...
...
@@ -58,41 +62,41 @@
#include <hash.h>
#include
<hash-inline.h>
#include
<hash-inline.h>
#include <ObjC.h>
#include
<ObjC-private.h>
#include
<ObjC-private.h>
#include <assert.h>
#include <libc.h>
#include <math.h>
/* These two macros determine
when a hash table is full and
by how much it should be
expanded respectively.
These equations are
percentages. */
#define
FULLNESS(cache)
\
((((cache)->sizeOfHash * 75
) / 100) <= (cache)->entriesInHash)
#define
EXPANSION(cache) \
(((cache)->sizeOfHash * 175 ) / 100 )
#define
MEMORY_ALLOCATION_ADJUST(i) \
((i&0x01)?i:(i-1))
/* These two macros determine
when a hash table is full and
by how much it should be
expanded respectively.
These equations are
percentages. */
#define
FULLNESS(cache)
\
((((cache)->sizeOfHash * 75
) / 100) <= (cache)->entriesInHash)
#define
EXPANSION(cache) \
(((cache)->sizeOfHash * 175 ) / 100 )
#define
MEMORY_ALLOCATION_ADJUST(i) \
((i&0x01)?i:(i-1))
Cache_t
hash_new
(
u_int
sizeOfHash
)
{
Cache_t
retCache
;
assert
(
sizeOfHash
);
/* Memory is allocated on this
machine in even address
chunks. Therefore the
modulus must be odd. */
sizeOfHash
=
MEMORY_ALLOCATION_ADJUST
(
sizeOfHash
);
/* Memory is allocated on this
machine in even address
chunks. Therefore the
modulus must be odd. */
sizeOfHash
=
MEMORY_ALLOCATION_ADJUST
(
sizeOfHash
);
/* Allocate the cache
structure. calloc () insures
...
...
@@ -108,7 +112,7 @@ Cache_t hash_new (u_int sizeOfHash) {
retCache
->
theNodeTable
=
calloc
(
sizeOfHash
,
sizeof
(
CacheNode_t
));
assert
(
retCache
->
theNodeTable
);
retCache
->
sizeOfHash
=
sizeOfHash
;
retCache
->
sizeOfHash
=
sizeOfHash
;
return
retCache
;
}
...
...
@@ -163,44 +167,44 @@ void hash_add (Cache_t* theCache, void* aKey, void* aValue) {
first element on the list. */
(
*
(
*
theCache
)
->
theNodeTable
)[
indx
]
=
aCacheNode
;
/* Bump the number of entries
in the cache. */
++
(
*
theCache
)
->
entriesInHash
;
/* Check the hash table's
fullness. We're going
to expand if it is above
the fullness level. */
if
(
FULLNESS
(
*
theCache
))
{
/* The hash table has reached
its fullness level. Time to
expand it.
I'm using a slow method
here but is built on other
primitive functions thereby
increasing its
correctness. */
CacheNode_t
aNode
=
NULL
;
Cache_t
newCache
=
hash_new
(
MEMORY_ALLOCATION_ADJUST
(
EXPANSION
(
*
theCache
)));
DEBUG_PRINTF
(
stderr
,
"Expanding cache %#x from %d to %d
\n
"
,
*
theCache
,
(
*
theCache
)
->
sizeOfHash
,
newCache
->
sizeOfHash
);
/* Copy the nodes from the
first hash table to the
new one. */
while
(
aNode
=
hash_next
(
*
theCache
,
aNode
))
hash_add
(
&
newCache
,
aNode
->
theKey
,
aNode
->
theValue
);
/* Trash the old cache. */
hash_delete
(
*
theCache
);
/* Return a pointer to the new
hash table. */
*
theCache
=
newCache
;
}
/* Bump the number of entries
in the cache. */
++
(
*
theCache
)
->
entriesInHash
;
/* Check the hash table's
fullness. We're going
to expand if it is above
the fullness level. */
if
(
FULLNESS
(
*
theCache
))
{
/* The hash table has reached
its fullness level. Time to
expand it.
I'm using a slow method
here but is built on other
primitive functions thereby
increasing its
correctness. */
CacheNode_t
aNode
=
NULL
;
Cache_t
newCache
=
hash_new
(
MEMORY_ALLOCATION_ADJUST
(
EXPANSION
(
*
theCache
)));
DEBUG_PRINTF
(
stderr
,
"Expanding cache %#x from %d to %d
\n
"
,
*
theCache
,
(
*
theCache
)
->
sizeOfHash
,
newCache
->
sizeOfHash
);
/* Copy the nodes from the
first hash table to the
new one. */
while
(
aNode
=
hash_next
(
*
theCache
,
aNode
))
hash_add
(
&
newCache
,
aNode
->
theKey
,
aNode
->
theValue
);
/* Trash the old cache. */
hash_delete
(
*
theCache
);
/* Return a pointer to the new
hash table. */
*
theCache
=
newCache
;
}
}
...
...
@@ -237,10 +241,10 @@ void hash_remove (Cache_t theCache, void* aKey) {
}
while
(
!
removed
&&
aCacheNode
);
assert
(
removed
);
}
/* Decrement the number of
entries in the hash table. */
--
theCache
->
entriesInHash
;
/* Decrement the number of
entries in the hash table. */
--
theCache
->
entriesInHash
;
}
...
...
gcc/objc/hash.h
View file @
eedb4710
...
...
@@ -21,10 +21,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
$Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/hash.h,v 0.
6 1991/11/24 01:20:02
dennisg Exp dennisg $
$Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/hash.h,v 0.
7 1991/12/03 02:01:23
dennisg Exp dennisg $
$Author: dennisg $
$Date: 1991/1
1/24 01:20:02
$
$Date: 1991/1
2/03 02:01:23
$
$Log: hash.h,v $
* Revision 0.7 1991/12/03 02:01:23 dennisg
* fixed assert macro.
* added memory allocation adjustment macro for hash size allocation.
*
* Revision 0.6 1991/11/24 01:20:02 dennisg
* changed shorts back to ints.
* the efficiency gained didn't out weight the grossness of the code.
...
...
@@ -98,18 +102,18 @@ typedef struct cache {
*/
CacheNode_t
(
*
theNodeTable
)[];
/* Pointer to an array of
hash nodes. */
/*
* Variables used to track the size of the hash
*
table so to determine when to resize it.
*/
/*
* Variables used to track the size of the hash
*
table so to determine when to resize it.
*/
u_int
sizeOfHash
,
/* Number of buckets
allocated for the hash
table (number of array
entries allocated for
"theNodeTable"). Must be
a power of two. */
entriesInHash
;
/* Current number of entries
in ther hash table. */
a power of two. */
entriesInHash
;
/* Current number of entries
in ther hash table. */
/*
* Variables used to implement indexing
* through the hash table.
...
...
@@ -132,12 +136,12 @@ Cache_t hash_new (u_int sizeOfHash);
void
hash_delete
(
Cache_t
theCache
);
/* Add the key/value pair
to the hash table. If the
hash table reaches a
level of fullnes then
it will be resized.
assert() if the key is
already in the hash. */
hash table reaches a
level of fullnes then
it will be resized.
assert() if the key is
already in the hash. */
void
hash_add
(
Cache_t
*
theCache
,
void
*
aKey
,
void
*
aValue
);
/* Remove the key/value pair
from the hash table.
...
...
gcc/objc/objc.h
View file @
eedb4710
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment