Changeset bc216a0 in mainline for uspace/app/trace/ipcp.c
- Timestamp:
- 2012-08-07T22:13:44Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- da68871a
- Parents:
- b17518e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/trace/ipcp.c
rb17518e rbc216a0 53 53 ipc_callid_t call_hash; 54 54 55 link_t link;55 ht_link_t link; 56 56 } pending_call_t; 57 57 … … 73 73 proto_t *proto_unknown; /**< Protocol with no known methods. */ 74 74 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); 75 76 static size_t pending_call_key_hash(void *key) 77 { 78 ipc_callid_t *call_id = (ipc_callid_t *)key; 79 return *call_id; 80 } 81 82 static size_t pending_call_hash(const ht_link_t *item) 83 { 84 pending_call_t *hs = hash_table_get_inst(item, pending_call_t, link); 85 return hs->call_hash; 86 } 87 88 static bool pending_call_key_equal(void *key, const ht_link_t *item) 89 { 90 ipc_callid_t *call_id = (ipc_callid_t *)key; 91 pending_call_t *hs = hash_table_get_inst(item, pending_call_t, link); 92 93 return *call_id == hs->call_hash; 94 } 79 95 80 96 static hash_table_ops_t pending_call_ops = { 81 97 .hash = pending_call_hash, 82 98 .key_hash = pending_call_key_hash, 83 . match = pending_call_match,99 .key_equal = pending_call_key_equal, 84 100 .equal = 0, 85 101 .remove_callback = 0 86 102 }; 87 88 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 116 103 117 104 … … 184 171 } 185 172 186 hash_table_create(&pending_calls, 0, 2, &pending_call_ops); 173 bool ok = hash_table_create(&pending_calls, 0, 0, &pending_call_ops); 174 assert(ok); 187 175 } 188 176 … … 338 326 void ipcp_call_in(ipc_call_t *call, ipc_callid_t hash) 339 327 { 340 link_t *item;328 ht_link_t *item; 341 329 pending_call_t *pcall; 342 330 … … 350 338 351 339 hash = hash & ~IPC_CALLID_ANSWERED; 352 unsigned long key[] = { 353 LOWER32(hash), 354 UPPER32(hash) 355 }; 356 357 item = hash_table_find(&pending_calls, key); 340 341 item = hash_table_find(&pending_calls, &hash); 358 342 if (item == NULL) 359 343 return; /* No matching question found */ … … 363 347 */ 364 348 365 pcall = hash_table_get_inst ance(item, pending_call_t, link);366 hash_table_remove(&pending_calls, key, 2);349 pcall = hash_table_get_inst(item, pending_call_t, link); 350 hash_table_remove(&pending_calls, &hash); 367 351 368 352 parse_answer(hash, pcall, call);
Note:
See TracChangeset
for help on using the changeset viewer.