Changeset 0ca7286 in mainline for uspace/app/trace/ipcp.c
- Timestamp:
- 2012-07-21T11:19:27Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2732c94
- Parents:
- 1c1da4b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/trace/ipcp.c
r1c1da4b r0ca7286 38 38 #include <sys/typefmt.h> 39 39 #include <abi/ipc/methods.h> 40 #include <macros.h> 40 41 #include "ipc_desc.h" 41 42 #include "proto.h" … … 64 65 int have_conn[MAX_PHONE]; 65 66 66 #define PCALL_TABLE_CHAINS 32 67 hash_table_t pending_calls; 67 static hash_table_t pending_calls; 68 68 69 69 /* … … 73 73 proto_t *proto_unknown; /**< Protocol with no known methods. */ 74 74 75 static hash_index_t pending_call_hash(unsigned long key[]);76 static int pending_call_compare(unsigned long key[], hash_count_t keys,77 link_t *item); 78 static void pending_call_remove_callback(link_t *item);79 80 hash_table_operations_t pending_call_ops = {75 static size_t pending_call_key_hash(unsigned long key[]); 76 static size_t pending_call_hash(const link_t *item); 77 static bool pending_call_match(unsigned long key[], size_t keys, 78 const link_t *item); 79 80 static hash_table_ops_t pending_call_ops = { 81 81 .hash = pending_call_hash, 82 .compare = pending_call_compare, 83 .remove_callback = pending_call_remove_callback 82 .key_hash = pending_call_key_hash, 83 .match = pending_call_match, 84 .equal = 0, 85 .remove_callback = 0 84 86 }; 85 87 86 88 87 static hash_index_t pending_call_hash(unsigned long key[]) 88 { 89 // printf("pending_call_hash\n"); 90 return key[0] % PCALL_TABLE_CHAINS; 91 } 92 93 static int pending_call_compare(unsigned long key[], hash_count_t keys, 94 link_t *item) 95 { 96 pending_call_t *hs; 97 98 // printf("pending_call_compare\n"); 99 hs = hash_table_get_instance(item, pending_call_t, link); 100 101 // FIXME: this will fail if sizeof(long) < sizeof(void *). 102 return key[0] == hs->call_hash; 103 } 104 105 static void pending_call_remove_callback(link_t *item) 106 { 107 // printf("pending_call_remove_callback\n"); 108 } 89 static size_t pending_call_key_hash(unsigned long key[]) 90 { 91 size_t hash = 17; 92 hash = 31 * hash + key[1]; 93 hash = 31 * hash + key[0]; 94 return hash; 95 } 96 97 static size_t pending_call_hash(const link_t *item) 98 { 99 pending_call_t *hs = hash_table_get_instance(item, pending_call_t, link); 100 unsigned long key[] = { 101 LOWER32(hs->call_hash), 102 UPPER32(hs->call_hash) 103 }; 104 return pending_call_key_hash(key); 105 } 106 107 static bool pending_call_match(unsigned long key[], size_t keys, 108 const link_t *item) 109 { 110 assert(keys == 2); 111 pending_call_t *hs = hash_table_get_instance(item, pending_call_t, link); 112 113 return MERGE_LOUP32(key[0], key[1]) == hs->call_hash; 114 } 115 109 116 110 117 … … 177 184 } 178 185 179 hash_table_create(&pending_calls, PCALL_TABLE_CHAINS, 1, &pending_call_ops);186 hash_table_create(&pending_calls, 0, 2, &pending_call_ops); 180 187 } 181 188 … … 190 197 pending_call_t *pcall; 191 198 proto_t *proto; 192 unsigned long key[1];193 199 oper_t *oper; 194 200 sysarg_t *args; … … 254 260 pcall->oper = oper; 255 261 256 key[0] = hash; 257 258 hash_table_insert(&pending_calls, key, &pcall->link); 262 hash_table_insert(&pending_calls, &pcall->link); 259 263 } 260 264 … … 336 340 link_t *item; 337 341 pending_call_t *pcall; 338 unsigned long key[1];339 342 340 343 if ((hash & IPC_CALLID_ANSWERED) == 0 && hash != IPCP_CALLID_SYNC) { … … 347 350 348 351 hash = hash & ~IPC_CALLID_ANSWERED; 349 key[0] = hash; 352 unsigned long key[] = { 353 LOWER32(hash), 354 UPPER32(hash) 355 }; 350 356 351 357 item = hash_table_find(&pending_calls, key); … … 358 364 359 365 pcall = hash_table_get_instance(item, pending_call_t, link); 360 hash_table_remove(&pending_calls, key, 1);366 hash_table_remove(&pending_calls, key, 2); 361 367 362 368 parse_answer(hash, pcall, call);
Note:
See TracChangeset
for help on using the changeset viewer.