Commit 709bbc7f authored by Pavel Emelyanov's avatar Pavel Emelyanov

sk: Opencode sk_hash_lookup fns

For simpler unix socket code move.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent be6630bf
...@@ -62,25 +62,30 @@ struct unix_sk_listen_icon { ...@@ -62,25 +62,30 @@ struct unix_sk_listen_icon {
#define SK_HASH_SIZE 32 #define SK_HASH_SIZE 32
#define __gen_static_lookup_func(ret, name, head, _member, _type, _name)\
static ret *name(_type _name) { \
ret *d; \
for (d = head[_name % SK_HASH_SIZE]; d; d = d->next) { \
if (d->_member == _name) \
break; \
} \
return d; \
}
static struct socket_desc *sockets[SK_HASH_SIZE]; static struct socket_desc *sockets[SK_HASH_SIZE];
__gen_static_lookup_func(struct socket_desc, lookup_socket, sockets,
ino, int, ino); static struct socket_desc *lookup_socket(int ino)
{
struct socket_desc *sd;
for (sd = sockets[ino % SK_HASH_SIZE]; sd; sd = sd->next)
if (sd->ino == ino)
return sd;
return NULL;
}
static struct unix_sk_listen_icon *unix_listen_icons[SK_HASH_SIZE]; static struct unix_sk_listen_icon *unix_listen_icons[SK_HASH_SIZE];
__gen_static_lookup_func(struct unix_sk_listen_icon,
lookup_unix_listen_icons, static struct unix_sk_listen_icon *lookup_unix_listen_icons(int peer_ino)
unix_listen_icons, {
peer_ino, unsigned int, ino); struct unix_sk_listen_icon *ic;
for (ic = unix_listen_icons[peer_ino % SK_HASH_SIZE];
ic; ic = ic->next)
if (ic->peer_ino == peer_ino)
return ic;
return NULL;
}
int sk_collect_one(int ino, int family, struct socket_desc *d) int sk_collect_one(int ino, int family, struct socket_desc *d)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment