Changeset bc216a0 in mainline for uspace/app
- Timestamp:
- 2012-08-07T22:13:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- da68871a
- Parents:
- b17518e
- Location:
- uspace/app
- Files:
-
- 3 edited
-
mkexfat/mkexfat.c (modified) (2 diffs)
-
trace/ipcp.c (modified) (6 diffs)
-
trace/proto.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkexfat/mkexfat.c
rb17518e rbc216a0 49 49 #include <str.h> 50 50 #include <getopt.h> 51 #include <macros.h> 51 52 #include "exfat.h" 52 53 #include "upcase.h" … … 87 88 #define FIRST_FREE_CLUSTER 2 88 89 89 #define min(x, y) ((x) < (y) ? (x) : (y))90 90 91 91 typedef struct exfat_cfg { -
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); -
uspace/app/trace/proto.c
rb17518e rbc216a0 45 45 46 46 typedef struct { 47 unsignedsrv;47 int srv; 48 48 proto_t *proto; 49 link_t link;49 ht_link_t link; 50 50 } srv_proto_t; 51 51 52 52 typedef struct { 53 sysarg_t method;53 int method; 54 54 oper_t *oper; 55 link_t link;55 ht_link_t link; 56 56 } method_oper_t; 57 57 58 59 60 61 static size_t srv_proto_key_hash(unsigned long key[]) 62 { 63 return key[0]; 64 } 65 66 static size_t srv_proto_hash(const link_t *item) 67 { 68 srv_proto_t *sp = hash_table_get_instance(item, srv_proto_t, link); 69 unsigned long key = sp->srv; 70 return srv_proto_key_hash(&key); 71 } 72 73 static bool srv_proto_match(unsigned long key[], size_t keys, const link_t *item) 74 { 75 srv_proto_t *sp = hash_table_get_instance(item, srv_proto_t, link); 76 77 return key[0] == sp->srv; 58 /* Hash table operations. */ 59 60 static size_t srv_proto_key_hash(void *key) 61 { 62 return *(int *)key; 63 } 64 65 static size_t srv_proto_hash(const ht_link_t *item) 66 { 67 srv_proto_t *sp = hash_table_get_inst(item, srv_proto_t, link); 68 return sp->srv; 69 } 70 71 static bool srv_proto_key_equal(void *key, const ht_link_t *item) 72 { 73 srv_proto_t *sp = hash_table_get_inst(item, srv_proto_t, link); 74 return sp->srv == *(int *)key; 78 75 } 79 76 … … 81 78 .hash = srv_proto_hash, 82 79 .key_hash = srv_proto_key_hash, 83 . match = srv_proto_match,80 .key_equal = srv_proto_key_equal, 84 81 .equal = 0, 85 82 .remove_callback = 0 … … 87 84 88 85 89 static size_t method_oper_key_hash(unsigned long key[]) 90 { 91 return key[0]; 92 } 93 94 static size_t method_oper_hash(const link_t *item) 95 { 96 method_oper_t *mo = hash_table_get_instance(item, method_oper_t, link); 97 unsigned long key = mo->method; 98 return method_oper_key_hash(&key); 99 } 100 101 static bool method_oper_match(unsigned long key[], size_t keys, 102 const link_t *item) 103 { 104 method_oper_t *mo = hash_table_get_instance(item, method_oper_t, link); 105 106 return key[0] == mo->method; 86 static size_t method_oper_key_hash(void *key) 87 { 88 return *(int *)key; 89 } 90 91 static size_t method_oper_hash(const ht_link_t *item) 92 { 93 method_oper_t *mo = hash_table_get_inst(item, method_oper_t, link); 94 return mo->method; 95 } 96 97 static bool method_oper_key_equal(void *key, const ht_link_t *item) 98 { 99 method_oper_t *mo = hash_table_get_inst(item, method_oper_t, link); 100 return mo->method == *(int *)key; 107 101 } 108 102 … … 110 104 .hash = method_oper_hash, 111 105 .key_hash = method_oper_key_hash, 112 . match = method_oper_match,106 .key_equal = method_oper_key_equal, 113 107 .equal = 0, 114 108 .remove_callback = 0 … … 118 112 void proto_init(void) 119 113 { 120 hash_table_create(&srv_proto, 0, 1, &srv_proto_ops); 114 /* todo: check return value. */ 115 bool ok = hash_table_create(&srv_proto, 0, 0, &srv_proto_ops); 116 assert(ok); 121 117 } 122 118 … … 139 135 proto_t *proto_get_by_srv(int srv) 140 136 { 141 link_t *item; 142 srv_proto_t *sp; 143 144 unsigned long key = srv; 145 item = hash_table_find(&srv_proto, &key); 137 ht_link_t *item = hash_table_find(&srv_proto, &srv); 146 138 if (item == NULL) return NULL; 147 139 148 s p = hash_table_get_instance(item, srv_proto_t, link);140 srv_proto_t *sp = hash_table_get_inst(item, srv_proto_t, link); 149 141 return sp->proto; 150 142 } … … 153 145 { 154 146 proto->name = name; 155 hash_table_create(&proto->method_oper, 0, 1, &method_oper_ops); 147 /* todo: check return value. */ 148 bool ok = hash_table_create(&proto->method_oper, 0, 0, &method_oper_ops); 149 assert(ok); 156 150 } 157 151 … … 184 178 oper_t *proto_get_oper(proto_t *proto, int method) 185 179 { 186 unsigned long key; 187 link_t *item; 188 method_oper_t *mo; 189 190 key = method; 191 item = hash_table_find(&proto->method_oper, &key); 180 ht_link_t *item = hash_table_find(&proto->method_oper, &method); 192 181 if (item == NULL) return NULL; 193 182 194 m o = hash_table_get_instance(item, method_oper_t, link);183 method_oper_t *mo = hash_table_get_inst(item, method_oper_t, link); 195 184 return mo->oper; 196 185 }
Note:
See TracChangeset
for help on using the changeset viewer.
