Changeset bc216a0 in mainline for uspace/app/trace/proto.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/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.