Date: Thu, 15 Nov 2001 12:45:57 -0800 (PST) From: John Baldwin <jhb@FreeBSD.org> To: Peter Wemm <peter@wemm.org> Cc: freebsd-arch@FreeBSD.ORG, Matthew Dillon <dillon@apollo.backplane.com> Subject: Re: Need review - patch for socket locking and ref counting Message-ID: <XFMail.011115124557.jhb@FreeBSD.org> In-Reply-To: <20011115201117.34216380A@overcee.netplex.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On 15-Nov-01 Peter Wemm wrote: > Matthew Dillon wrote: > >> +static __inline >> +struct mtx * >> +_mtx_pool1_find(void *ptr) >> +{ >> + return(&mtx_pool_ary[(((int)ptr ^ ((int)ptr >> 6)) & MTX_POOL_XMASK) | >> 0 > ]); >> +} > > At the very least, this is not going to compile very well on 64 bit machines. > You cannot cast a pointer to an int. At needs to be uintptr_t at minimum. I would also prefer a generic mechanism for multiple pools with a struct mtx_pool containing a count, index for alloc, and pointer to the array of locks and pass it as the first arg to mtx_pool_foo(). This would also entail a mtx_pool_init(struct mtx_pool *mp, int size); and a mtx_pool_destroy(struct mtx_pool *mp); This is much cleaner and extensible than hardcoding 4 pools of equal size. -- John Baldwin <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.011115124557.jhb>