summaryrefslogtreecommitdiff
path: root/debian/patches/0003-ipc-use-fast-modulo-operation-in-local-hash-table.patch
blob: c517291ef7da60331e4f6b08b0282b76f3bef7a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 3a0fae39873c9c7d73dc978888e45b87ad27d44e Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Tue, 30 Sep 2014 03:58:43 +0200
Subject: [PATCH gnumach 3/3] ipc: use fast modulo operation in local hash
 table

* ipc/ipc_table.h: Document that table sizes must be powers of two.
* ipc/ipc_hash.c (IH_LOCAL_HASH): Use fast modulo operation.
---
 ipc/ipc_hash.c  | 2 +-
 ipc/ipc_table.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/ipc/ipc_hash.c b/ipc/ipc_hash.c
index 8285717..c2c6d6e 100644
--- a/ipc/ipc_hash.c
+++ b/ipc/ipc_hash.c
@@ -326,7 +326,7 @@ ipc_hash_global_delete(
  */
 
 #define	IH_LOCAL_HASH(obj, size)				\
-		((((mach_port_index_t) (vm_offset_t) (obj)) >> 6) % (size))
+	((((mach_port_index_t) (vm_offset_t) (obj)) >> 6) & (size - 1))
 
 /*
  *	Routine:	ipc_hash_local_lookup
diff --git a/ipc/ipc_table.h b/ipc/ipc_table.h
index 3cc5f56..311b9a7 100644
--- a/ipc/ipc_table.h
+++ b/ipc/ipc_table.h
@@ -45,6 +45,8 @@
  *	an ipc_table_size structure.  These structures must
  *	be elements of an array, ipc_table_entries.
  *
+ *	Every its_size value must must be a power of two.
+ *
  *	The array must end with two elements with the same its_size value.
  *	Except for the terminating element, the its_size values must
  *	be strictly increasing.  The largest (last) its_size value
-- 
2.1.0