diff options
author | Michal Terepeta <michal.terepeta@gmail.com> | 2018-05-13 18:34:03 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-05-13 18:34:09 -0400 |
commit | eb39f98891482366cf1130fe58d728b93f0dd49f (patch) | |
tree | 94c7adf6e8d239ea6f97853264cd8dd9fb7b6593 /rts/StaticPtrTable.c | |
parent | 7c665f9ce0980ee7c81a44c8f861686395637453 (diff) | |
download | haskell-eb39f98891482366cf1130fe58d728b93f0dd49f.tar.gz |
Fix a few GCC warnings
GCC 8 now generates warnings for incompatible function pointer casts
[-Werror=cast-function-type]. Apparently there are a few of those in rts
code, which makes `./validate` unhappy (since we compile with `-Werror`)
This commit tries to fix these issues by changing the functions to have
the correct type (and, if necessary, moving the casts into those
functions).
For instance, hash/comparison function are declared (`Hash.h`) to take
`StgWord` but we want to use `StgWord64[2]` in `StaticPtrTable.c`.
Instead of casting the function pointers, we can cast the `StgWord`
parameter to `StgWord*`. I think this should be ok since `StgWord`
should be the same size as a pointer.
Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
Test Plan: ./validate
Reviewers: bgamari, erikd, simonmar
Reviewed By: bgamari
Subscribers: rwbarton, thomie, carter
Differential Revision: https://phabricator.haskell.org/D4673
Diffstat (limited to 'rts/StaticPtrTable.c')
-rw-r--r-- | rts/StaticPtrTable.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/rts/StaticPtrTable.c b/rts/StaticPtrTable.c index 5d2737a262..7711377d7f 100644 --- a/rts/StaticPtrTable.c +++ b/rts/StaticPtrTable.c @@ -21,23 +21,24 @@ static Mutex spt_lock; #endif /// Hash function for the SPT. -static int hashFingerprint(HashTable *table, StgWord64 key[2]) { +static int hashFingerprint(const HashTable *table, StgWord key) { + const StgWord64* ptr = (StgWord64*) key; // Take half of the key to compute the hash. - return hashWord(table, (StgWord)key[1]); + return hashWord(table, *(ptr + 1)); } /// Comparison function for the SPT. -static int compareFingerprint(StgWord64 ptra[2], StgWord64 ptrb[2]) { - return ptra[0] == ptrb[0] && ptra[1] == ptrb[1]; +static int compareFingerprint(StgWord a, StgWord b) { + const StgWord64* ptra = (StgWord64*) a; + const StgWord64* ptrb = (StgWord64*) b; + return *ptra == *ptrb && *(ptra + 1) == *(ptrb + 1); } void hs_spt_insert_stableptr(StgWord64 key[2], StgStablePtr *entry) { // hs_spt_insert is called from constructor functions, so // the SPT needs to be initialized here. if (spt == NULL) { - spt = allocHashTable_( (HashFunction *)hashFingerprint - , (CompareFunction *)compareFingerprint - ); + spt = allocHashTable_(hashFingerprint, compareFingerprint); #if defined(THREADED_RTS) initMutex(&spt_lock); #endif |