Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jul 2013 20:32:47 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Jung-uk Kim <jkim@FreeBSD.org>
Cc:        dumbbell@FreeBSD.org, freebsd-arch@FreeBSD.org
Subject:   Re: [PATCH] Atomic swap and test-and-set
Message-ID:  <20130731173247.GK4972@kib.kiev.ua>
In-Reply-To: <51F81A74.4030009@FreeBSD.org>
References:  <51F81A74.4030009@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--8BaRf9C5c8wiXWYy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Jul 30, 2013 at 03:56:36PM -0400, Jung-uk Kim wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>=20
> The attached patch implements atomic_swap_<type>() and
> atomic_testandset_<type>() for x86.  <type> is int or long ATM.
>=20
> The semantics of each operation (in atomic(9) style):
>=20
> atomic_swap(p, v)
> 	r =3D *p;
> 	*p =3D v;
> 	return (r);
>=20
> atomic_testandset(p, s)
> 	v =3D (<type>)1 << s % (sizeof(<type>) * NBBY);
> 	r =3D (*p & v) !=3D 0;
> 	*p |=3D v;
> 	return (r);
>=20
> Note atomic_readandclear_<type>() is now obsolete and implemented as a
> macro around atomic_swap_<type>() where the new value v is 0.
>=20
> Please let me know if you have any objection.
I think that the atomic.diff is fine.

You did not documented swap and testandset, which would be good to have
in the manpage.

I think that constraints for all added inlines contradict the explicit
requirement in the gcc documentation, which states that rmw operands
should be specified using the 'same location' output operand for the
input operand (hopefully this can be parsed).  It just happens so that
for "m" compiler cannot do anything else then passing the address.

The problem is not specific to the new functions, it seems to be present
in other functions as well, e.g. cmpset.  This probably can be postponed.

--8BaRf9C5c8wiXWYy
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (FreeBSD)

iQIcBAEBAgAGBQJR+Uo+AAoJEJDCuSvBvK1BNwIP/A6R23nUTIikAx0NRkjQzmlw
eksqbyOIxOKDvWhiIjXxhFbxuU0y55usIiXS0mLQS/6NcaPkGmJWYouCvBbK5ION
FbyXhjbN0yVWa9qYnCn3aipbMrmVw+yTNYkmerEBkv/i/0TGNRfaDPnKzZt29u/K
dsl2aTeTllugh4Zce9JiiNgK6BiBFzsVSiAGFgXqEvbfsGM4waTisH9nS4ReeQyx
ryteWLHjbCWHLJX/hhqSDjL/zYkD767XXlmzdCfLbD+FWZh4gxsgFz/LL3Y+ugwy
ie292+xnDbCVNGz60W8zizuYMTHXiH9J2J51RY8wlJ0RcKfpmNyy2DMqLlMqeCr0
SgQ1/UhKVNDcsXlAm9l8qEgmjRi7p38IXEw4Xlz3mcBGaM8kv/gwAVJwKa4p9CK9
d8OzdBOaV7KKhQrt3defuYs2qCLJk/9U/dYjKpqD4ZXp13Q2XYFRbPzsU1Z+Mt1Y
gRR1OSbBbsLe+aV0BysFlHIntS3+5TI1aV1OIZuAb/ofZ8OSuhegZUwkKT2Peq6n
OqpfIs5EMuLFhYBGOuTHGFXXqzntCSR+pmr11r2QEDg8g/y7H/Pc0qmYdvBpUkbg
DYwcyoUss+BozChMNflQOCd4/Tnjg8gV6Q7cEzhAKi2j+wxqsKWGHhDDR6EU3lUy
R6Dzj7lIBH1jysnbGiOC
=0S+E
-----END PGP SIGNATURE-----

--8BaRf9C5c8wiXWYy--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130731173247.GK4972>