From owner-freebsd-arch Thu Nov 15 12:46: 4 2001 Delivered-To: freebsd-arch@freebsd.org Received: from mail12.speakeasy.net (mail12.speakeasy.net [216.254.0.212]) by hub.freebsd.org (Postfix) with ESMTP id D2A3737B419 for ; Thu, 15 Nov 2001 12:46:00 -0800 (PST) Received: (qmail 2677 invoked from network); 15 Nov 2001 20:46:00 -0000 Received: from unknown (HELO laptop.baldwin.cx) ([64.81.54.73]) (envelope-sender ) by mail12.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 15 Nov 2001 20:46:00 -0000 Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20011115201117.34216380A@overcee.netplex.com.au> Date: Thu, 15 Nov 2001 12:45:57 -0800 (PST) From: John Baldwin To: Peter Wemm Subject: Re: Need review - patch for socket locking and ref counting Cc: freebsd-arch@FreeBSD.ORG, Matthew Dillon Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 <>< 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