diff --git a/pool.c b/pool.c index 015d93c..b84c3a7 100644 --- a/pool.c +++ b/pool.c @@ -67,13 +67,22 @@ struct pool_val *pool(struct pool *p, char *s, int type) { return pool1(p, s, type, strcmp); } -static int llcmp(const char *v1, const char *v2) { - long long *ll1 = (long long *) v1; - long long *ll2 = (long long *) v2; +static long long mangle(long long in) { + int i; + long long out = 0; + for (i = 0; i < 64; i++) { + out |= ((in >> i) & 1) << (63 - i); + } + return out; +} - if (*ll1 < *ll2) { +static int llcmp(const char *v1, const char *v2) { + long long ll1 = mangle(*(long long *) v1); + long long ll2 = mangle(*(long long *) v2); + + if (ll1 < ll2) { return -1; - } else if (*ll1 > *ll2) { + } else if (ll1 > ll2) { return 1; } else { return 0;