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 @@
...
@@ -16,10 +16,14 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* 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 $
$Author: dennisg $
$Date: 1991/1
1/24 01:20:02
$
$Date: 1991/1
2/03 02:01:23
$
$Log: hash.c,v $
$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
* Revision 0.8 1991/11/24 01:20:02 dennisg
* changed shorts back to ints.
* changed shorts back to ints.
* the efficiency gained didn't out weight the grossness of the code.
* the efficiency gained didn't out weight the grossness of the code.
...
@@ -58,41 +62,41 @@
...
@@ -58,41 +62,41 @@
#include <hash.h>
#include <hash.h>
#include
<hash-inline.h>
#include
<hash-inline.h>
#include <ObjC.h>
#include <ObjC.h>
#include
<ObjC-private.h>
#include
<ObjC-private.h>
#include <assert.h>
#include <assert.h>
#include <libc.h>
#include <libc.h>
#include <math.h>
#include <math.h>
/* These two macros determine
/* These two macros determine
when a hash table is full and
when a hash table is full and
by how much it should be
by how much it should be
expanded respectively.
expanded respectively.
These equations are
These equations are
percentages. */
percentages. */
#define
FULLNESS(cache)
\
#define
FULLNESS(cache)
\
((((cache)->sizeOfHash * 75
) / 100) <= (cache)->entriesInHash)
((((cache)->sizeOfHash * 75
) / 100) <= (cache)->entriesInHash)
#define
EXPANSION(cache) \
#define
EXPANSION(cache) \
(((cache)->sizeOfHash * 175 ) / 100 )
(((cache)->sizeOfHash * 175 ) / 100 )
#define
MEMORY_ALLOCATION_ADJUST(i) \
#define
MEMORY_ALLOCATION_ADJUST(i) \
((i&0x01)?i:(i-1))
((i&0x01)?i:(i-1))
Cache_t
hash_new
(
u_int
sizeOfHash
)
{
Cache_t
hash_new
(
u_int
sizeOfHash
)
{
Cache_t
retCache
;
Cache_t
retCache
;
assert
(
sizeOfHash
);
assert
(
sizeOfHash
);
/* Memory is allocated on this
/* Memory is allocated on this
machine in even address
machine in even address
chunks. Therefore the
chunks. Therefore the
modulus must be odd. */
modulus must be odd. */
sizeOfHash
=
MEMORY_ALLOCATION_ADJUST
(
sizeOfHash
);
sizeOfHash
=
MEMORY_ALLOCATION_ADJUST
(
sizeOfHash
);
/* Allocate the cache
/* Allocate the cache
structure. calloc () insures
structure. calloc () insures
...
@@ -108,7 +112,7 @@ Cache_t hash_new (u_int sizeOfHash) {
...
@@ -108,7 +112,7 @@ Cache_t hash_new (u_int sizeOfHash) {
retCache
->
theNodeTable
=
calloc
(
sizeOfHash
,
sizeof
(
CacheNode_t
));
retCache
->
theNodeTable
=
calloc
(
sizeOfHash
,
sizeof
(
CacheNode_t
));
assert
(
retCache
->
theNodeTable
);
assert
(
retCache
->
theNodeTable
);
retCache
->
sizeOfHash
=
sizeOfHash
;
retCache
->
sizeOfHash
=
sizeOfHash
;
return
retCache
;
return
retCache
;
}
}
...
@@ -163,44 +167,44 @@ void hash_add (Cache_t* theCache, void* aKey, void* aValue) {
...
@@ -163,44 +167,44 @@ void hash_add (Cache_t* theCache, void* aKey, void* aValue) {
first element on the list. */
first element on the list. */
(
*
(
*
theCache
)
->
theNodeTable
)[
indx
]
=
aCacheNode
;
(
*
(
*
theCache
)
->
theNodeTable
)[
indx
]
=
aCacheNode
;
/* Bump the number of entries
/* Bump the number of entries
in the cache. */
in the cache. */
++
(
*
theCache
)
->
entriesInHash
;
++
(
*
theCache
)
->
entriesInHash
;
/* Check the hash table's
/* Check the hash table's
fullness. We're going
fullness. We're going
to expand if it is above
to expand if it is above
the fullness level. */
the fullness level. */
if
(
FULLNESS
(
*
theCache
))
{
if
(
FULLNESS
(
*
theCache
))
{
/* The hash table has reached
/* The hash table has reached
its fullness level. Time to
its fullness level. Time to
expand it.
expand it.
I'm using a slow method
I'm using a slow method
here but is built on other
here but is built on other
primitive functions thereby
primitive functions thereby
increasing its
increasing its
correctness. */
correctness. */
CacheNode_t
aNode
=
NULL
;
CacheNode_t
aNode
=
NULL
;
Cache_t
newCache
=
Cache_t
newCache
=
hash_new
(
MEMORY_ALLOCATION_ADJUST
(
EXPANSION
(
*
theCache
)));
hash_new
(
MEMORY_ALLOCATION_ADJUST
(
EXPANSION
(
*
theCache
)));
DEBUG_PRINTF
(
stderr
,
"Expanding cache %#x from %d to %d
\n
"
,
DEBUG_PRINTF
(
stderr
,
"Expanding cache %#x from %d to %d
\n
"
,
*
theCache
,
(
*
theCache
)
->
sizeOfHash
,
newCache
->
sizeOfHash
);
*
theCache
,
(
*
theCache
)
->
sizeOfHash
,
newCache
->
sizeOfHash
);
/* Copy the nodes from the
/* Copy the nodes from the
first hash table to the
first hash table to the
new one. */
new one. */
while
(
aNode
=
hash_next
(
*
theCache
,
aNode
))
while
(
aNode
=
hash_next
(
*
theCache
,
aNode
))
hash_add
(
&
newCache
,
aNode
->
theKey
,
aNode
->
theValue
);
hash_add
(
&
newCache
,
aNode
->
theKey
,
aNode
->
theValue
);
/* Trash the old cache. */
/* Trash the old cache. */
hash_delete
(
*
theCache
);
hash_delete
(
*
theCache
);
/* Return a pointer to the new
/* Return a pointer to the new
hash table. */
hash table. */
*
theCache
=
newCache
;
*
theCache
=
newCache
;
}
}
}
}
...
@@ -237,10 +241,10 @@ void hash_remove (Cache_t theCache, void* aKey) {
...
@@ -237,10 +241,10 @@ void hash_remove (Cache_t theCache, void* aKey) {
}
while
(
!
removed
&&
aCacheNode
);
}
while
(
!
removed
&&
aCacheNode
);
assert
(
removed
);
assert
(
removed
);
}
}
/* Decrement the number of
/* Decrement the number of
entries in the hash table. */
entries in the hash table. */
--
theCache
->
entriesInHash
;
--
theCache
->
entriesInHash
;
}
}
...
...
gcc/objc/hash.h
View file @
eedb4710
...
@@ -21,10 +21,14 @@
...
@@ -21,10 +21,14 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* 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 $
$Author: dennisg $
$Date: 1991/1
1/24 01:20:02
$
$Date: 1991/1
2/03 02:01:23
$
$Log: hash.h,v $
$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
* Revision 0.6 1991/11/24 01:20:02 dennisg
* changed shorts back to ints.
* changed shorts back to ints.
* the efficiency gained didn't out weight the grossness of the code.
* the efficiency gained didn't out weight the grossness of the code.
...
@@ -98,18 +102,18 @@ typedef struct cache {
...
@@ -98,18 +102,18 @@ typedef struct cache {
*/
*/
CacheNode_t
(
*
theNodeTable
)[];
/* Pointer to an array of
CacheNode_t
(
*
theNodeTable
)[];
/* Pointer to an array of
hash nodes. */
hash nodes. */
/*
/*
* Variables used to track the size of the hash
* Variables used to track the size of the hash
*
table so to determine when to resize it.
*
table so to determine when to resize it.
*/
*/
u_int
sizeOfHash
,
/* Number of buckets
u_int
sizeOfHash
,
/* Number of buckets
allocated for the hash
allocated for the hash
table (number of array
table (number of array
entries allocated for
entries allocated for
"theNodeTable"). Must be
"theNodeTable"). Must be
a power of two. */
a power of two. */
entriesInHash
;
/* Current number of entries
entriesInHash
;
/* Current number of entries
in ther hash table. */
in ther hash table. */
/*
/*
* Variables used to implement indexing
* Variables used to implement indexing
* through the hash table.
* through the hash table.
...
@@ -132,12 +136,12 @@ Cache_t hash_new (u_int sizeOfHash);
...
@@ -132,12 +136,12 @@ Cache_t hash_new (u_int sizeOfHash);
void
hash_delete
(
Cache_t
theCache
);
void
hash_delete
(
Cache_t
theCache
);
/* Add the key/value pair
/* Add the key/value pair
to the hash table. If the
to the hash table. If the
hash table reaches a
hash table reaches a
level of fullnes then
level of fullnes then
it will be resized.
it will be resized.
assert() if the key is
assert() if the key is
already in the hash. */
already in the hash. */
void
hash_add
(
Cache_t
*
theCache
,
void
*
aKey
,
void
*
aValue
);
void
hash_add
(
Cache_t
*
theCache
,
void
*
aKey
,
void
*
aValue
);
/* Remove the key/value pair
/* Remove the key/value pair
from the hash table.
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