From: Florian Forster Date: Thu, 13 Jan 2011 13:27:45 +0000 (+0100) Subject: sn_network_get_hashval(): Return a 64bit integer value. X-Git-Tag: v1.1.0~21 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e6b060578b9e783b8c6e5ca164b988a37c753f81;p=sort-networks.git sn_network_get_hashval(): Return a 64bit integer value. --- diff --git a/src/sn-info.c b/src/sn-info.c index e2bc9c9..c89d297 100644 --- a/src/sn-info.c +++ b/src/sn-info.c @@ -112,7 +112,7 @@ int main (int argc, char **argv) " Normalized: %4s\n" " Sorts: %7s\n" " Rating: %4i\n" - " Hash: 0x%08"PRIx32"\n" + " Hash: 0x%"PRIx64"\n" "\n", comparators_num, (normalized ? "yes" : "no"), diff --git a/src/sn_comparator.c b/src/sn_comparator.c index 0726504..1c9a3e6 100644 --- a/src/sn_comparator.c +++ b/src/sn_comparator.c @@ -109,14 +109,14 @@ int sn_comparator_compare (const sn_comparator_t *c0, return (0); } /* int sn_comparator_compare */ -uint32_t sn_comparator_get_hashval (const sn_comparator_t *c) /* {{{ */ +uint64_t sn_comparator_get_hashval (const sn_comparator_t *c) /* {{{ */ { if (c == NULL) return (0); /* 100937 and 103319 are some random prime numbers */ - return ((((uint32_t) c->min) * 100937) - + (((uint32_t) c->max) * 103319)); + return ((((uint64_t) c->min) * 100937) + + (((uint64_t) c->max) * 103319)); } /* }}} uint32_t sn_comparator_get_hashval */ /* vim: set shiftwidth=2 softtabstop=2 : */ diff --git a/src/sn_comparator.h b/src/sn_comparator.h index db9bc07..780cd8f 100644 --- a/src/sn_comparator.h +++ b/src/sn_comparator.h @@ -117,7 +117,7 @@ void sn_comparator_swap (sn_comparator_t *c, int con0, int con1); int sn_comparator_compare (const sn_comparator_t *c0, const sn_comparator_t *c1); -uint32_t sn_comparator_get_hashval (const sn_comparator_t *c); +uint64_t sn_comparator_get_hashval (const sn_comparator_t *c); #endif /* SN_COMPARATOR_H */ diff --git a/src/sn_hashtable.c b/src/sn_hashtable.c index 0656644..4efb76e 100644 --- a/src/sn_hashtable.c +++ b/src/sn_hashtable.c @@ -109,7 +109,7 @@ int sn_hashtable_account (sn_hashtable_t *ht, const sn_network_t *n) /* {{{ */ if ((ht == NULL) || (n == NULL)) return (EINVAL); - hash = sn_network_get_hashval (n); + hash = (uint32_t) sn_network_get_hashval (n); h0 = (uint8_t) (hash >> 24); h1 = (uint8_t) (hash >> 16); diff --git a/src/sn_network.c b/src/sn_network.c index c421995..9dd2329 100644 --- a/src/sn_network.c +++ b/src/sn_network.c @@ -1187,20 +1187,20 @@ sn_network_t *sn_network_unserialize (char *buffer, /* {{{ */ return (n); } /* }}} sn_network_t *sn_network_unserialize */ -uint32_t sn_network_get_hashval (const sn_network_t *n) /* {{{ */ +uint64_t sn_network_get_hashval (const sn_network_t *n) /* {{{ */ { - uint32_t hash; + uint64_t hash; int i; if (n == NULL) return (0); - hash = (uint32_t) n->inputs_num; + hash = (uint64_t) n->inputs_num; for (i = 0; i < n->stages_num; i++) hash = (hash * 104207) + sn_stage_get_hashval (n->stages[i]); return (hash); -} /* }}} uint32_t sn_network_get_hashval */ +} /* }}} uint64_t sn_network_get_hashval */ /* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/sn_network.h b/src/sn_network.h index f29c9b3..2e92898 100644 --- a/src/sn_network.h +++ b/src/sn_network.h @@ -356,7 +356,7 @@ int sn_network_serialize (sn_network_t *n, char **ret_buffer, */ sn_network_t *sn_network_unserialize (char *buffer, size_t buffer_size); -uint32_t sn_network_get_hashval (const sn_network_t *n); +uint64_t sn_network_get_hashval (const sn_network_t *n); #endif /* SN_NETWORK_H */ diff --git a/src/sn_stage.c b/src/sn_stage.c index dc00b44..1a7b2f9 100644 --- a/src/sn_stage.c +++ b/src/sn_stage.c @@ -626,20 +626,20 @@ sn_stage_t *sn_stage_unserialize (char **ret_buffer, size_t *ret_buffer_size) return (s); } /* sn_stage_t *sn_stage_unserialize */ -uint32_t sn_stage_get_hashval (const sn_stage_t *s) /* {{{ */ +uint64_t sn_stage_get_hashval (const sn_stage_t *s) /* {{{ */ { - uint32_t hash; + uint64_t hash; int i; if (s == NULL) return (0); - hash = (uint32_t) s->depth; + hash = (uint64_t) s->depth; for (i = 0; i < s->comparators_num; i++) hash = (hash * 99991) + sn_comparator_get_hashval (s->comparators + i); return (hash); -} /* }}} uint32_t sn_stage_get_hashval */ +} /* }}} uint64_t sn_stage_get_hashval */ /* vim: set shiftwidth=2 softtabstop=2 expandtab fdm=marker : */ diff --git a/src/sn_stage.h b/src/sn_stage.h index 8cd77cf..cdba998 100644 --- a/src/sn_stage.h +++ b/src/sn_stage.h @@ -254,7 +254,7 @@ int sn_stage_serialize (sn_stage_t *s, */ sn_stage_t *sn_stage_unserialize (char **buffer, size_t *buffer_size); -uint32_t sn_stage_get_hashval (const sn_stage_t *s); +uint64_t sn_stage_get_hashval (const sn_stage_t *s); #endif /* SN_STAGE_H */