From owner-freebsd-arch@FreeBSD.ORG Wed Jun 9 18:37:19 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CA15A16A4CE for ; Wed, 9 Jun 2004 18:37:19 +0000 (GMT) Received: from darkness.comp.waw.pl (darkness.comp.waw.pl [195.117.238.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id 580F243D46 for ; Wed, 9 Jun 2004 18:37:19 +0000 (GMT) (envelope-from pjd@darkness.comp.waw.pl) Received: by darkness.comp.waw.pl (Postfix, from userid 1009) id B9D8AACAF4; Wed, 9 Jun 2004 20:37:03 +0200 (CEST) Date: Wed, 9 Jun 2004 20:37:03 +0200 From: Pawel Jakub Dawidek To: Julian Elischer Message-ID: <20040609183703.GX12007@darkness.comp.waw.pl> References: <57019.1086804305@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KZCIPwrNpw38UenM" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 5.2.1-RC2 i386 cc: arch@freebsd.org cc: Poul-Henning Kamp Subject: Re: cvs commit: src/sys/kern kern_proc.c X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2004 18:37:19 -0000 --KZCIPwrNpw38UenM Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 09, 2004 at 11:23:48AM -0700, Julian Elischer wrote: +> I do actually agree that a general purpose reference counting=20 +> API is very difficult to use in every situation and that there=20 +> are situations where you just HAVE to roll your own.. Maybe we can use macros to do this, something like: #define REFCNT_MTX(foo, prefix, type, mtx_field, refcnt_field, destroy_func= ) \ foo void \ prefix ## _hold(type *obj) \ { \ \ mtx_lock(&obj->mtx_field); \ obj->refcnt_field++; \ mtx_unlock(&obj->mtx_field); \ } \ \ foo void \ prefix ## _free(type *obj) \ { \ int refcnt; \ \ mtx_lock(&obj->mtx_field); \ refcnt =3D --obj->refcnt_field; \ mtx_unlock(&obj->mtx_field); \ if (refcnt =3D=3D 0) \ destroy_func(obj); \ } And the same for REFCNT_ATOMIC() and REFCNT_SPIN()? 'foo' could be for example 'static' or 'static __inline'. --=20 Pawel Jakub Dawidek http://www.FreeBSD.org pjd@FreeBSD.org http://garage.freebsd.pl FreeBSD committer Am I Evil? Yes, I Am! --KZCIPwrNpw38UenM Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAx1jPForvXbEpPzQRAq2JAJ47cECI0Tkw1cnV2Ve2XhDn+TN0YQCeJ5aQ Vvxce9IR1yBIH5qvHGtFTsU= =g99S -----END PGP SIGNATURE----- --KZCIPwrNpw38UenM--