WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Avoid floating point in hash table implementation.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Avoid floating point in hash table implementation.
From: Xen patchbot -3.0-testing <patchbot-3.0-testing@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 10 Mar 2006 19:48:22 +0000
Delivery-date: Fri, 10 Mar 2006 19:50:16 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 56ee79e28f1dfdd0da9711bd866d4d4765e93a3e
# Parent  578a7cd07970be6836fcc8d58b503469e5abf0de
Avoid floating point in hash table implementation.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r 578a7cd07970 -r 56ee79e28f1d tools/xenstore/hashtable.c
--- a/tools/xenstore/hashtable.c        Wed Mar  8 22:57:59 2006
+++ b/tools/xenstore/hashtable.c        Wed Mar  8 22:58:05 2006
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <math.h>
+#include <stdint.h>
 
 /*
 Credit for primes table: Aaron Krowne
@@ -22,7 +23,7 @@
 805306457, 1610612741
 };
 const unsigned int prime_table_length = sizeof(primes)/sizeof(primes[0]);
-const float max_load_factor = 0.65;
+const unsigned int max_load_factor = 65; /* percentage */
 
 /*****************************************************************************/
 struct hashtable *
@@ -48,7 +49,7 @@
     h->entrycount   = 0;
     h->hashfn       = hashf;
     h->eqfn         = eqf;
-    h->loadlimit    = (unsigned int) ceil(size * max_load_factor);
+    h->loadlimit    = (unsigned int)(((uint64_t)size * max_load_factor) / 100);
     return h;
 }
 
@@ -121,7 +122,8 @@
         }
     }
     h->tablelength = newsize;
-    h->loadlimit   = (unsigned int) ceil(newsize * max_load_factor);
+    h->loadlimit   = (unsigned int)
+        (((uint64_t)newsize * max_load_factor) / 100);
     return -1;
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>