From owner-svn-src-head@freebsd.org Tue May 29 13:02:45 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ADC99F7B03D; Tue, 29 May 2018 13:02:45 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 0CFBB692BA; Tue, 29 May 2018 13:02:44 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id NeGtfpQsUuYopNeGvf2tiN; Tue, 29 May 2018 07:02:42 -0600 X-Authority-Analysis: v=2.3 cv=GopsBH9C c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=VUJBJC2UJ8kA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=XgJsEXYadUAYOezqnGwA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id A0D0772E; Tue, 29 May 2018 06:02:39 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id w4TD2bOR059887; Tue, 29 May 2018 06:02:37 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id w4TD2bR5059884; Tue, 29 May 2018 06:02:37 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201805291302.w4TD2bR5059884@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Hans Petter Selasky cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r334320 - in head/sys: cddl/compat/opensolaris/kern cddl/compat/opensolaris/sys i386/include In-Reply-To: Message from Hans Petter Selasky of "Tue, 29 May 2018 11:59:02 -0000." <201805291159.w4TBx3e5085835@repo.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 29 May 2018 06:02:37 -0700 X-CMAE-Envelope: MS4wfAMnvk9TnQSuKWFW6kG5eFSYCaGe+HHYbeDNmK43HD9ZQHe2MVfoR4JDkxdHk4zKHPfbTiB4c1SOczsYdmQTyddl3OUintUA2bWYDNUJyWYwl6rV/DUm u/h76Ss78gnmfvjEnSAW5nLFuUDaOxeFvS0nJcsZGRX2lAuN6p7DmDEAvAIdjDaOfIc7uewu467WJtO61oY0i0i7EBV3ADkT+3LZO3gLNjUMLt249pCHWfOL uYvXa7sH2b8Y3J4T+8+gdqt6Bk8wf3DswC/NoAtAiYfdzTW//TZTjZchEIhK7ZL+ X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2018 13:02:46 -0000 In message <201805291159.w4TBx3e5085835@repo.freebsd.org>, Hans Petter Selasky writes: > Author: hselasky > Date: Tue May 29 11:59:02 2018 > New Revision: 334320 > URL: https://svnweb.freebsd.org/changeset/base/334320 > > Log: > Implement atomic_add_64() and atomic_subtract_64() for the i386 target. > > While at it add missing _acq_ and _rel_ variants for 64-bit atomic > operations under i386. > > Reviewed by: kib @ > MFC after: 1 week > Sponsored by: Mellanox Technologies > > Modified: > head/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c > head/sys/cddl/compat/opensolaris/sys/atomic.h > head/sys/i386/include/atomic.h > > Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c > ============================================================================= > = > --- head/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c Tue May > 29 10:29:43 2018 (r334319) > +++ head/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c Tue May > 29 11:59:02 2018 (r334320) > @@ -52,7 +52,8 @@ atomic_init(void) > } > #endif > > -#if !defined(__LP64__) && !defined(__mips_n32) && !defined(ARM_HAVE_ATOMIC64 > ) > +#if !defined(__LP64__) && !defined(__mips_n32) && \ > + !defined(ARM_HAVE_ATOMIC64) && !defined(__i386__) > void > atomic_add_64(volatile uint64_t *target, int64_t delta) > { > > Modified: head/sys/cddl/compat/opensolaris/sys/atomic.h > ============================================================================= > = > --- head/sys/cddl/compat/opensolaris/sys/atomic.h Tue May 29 10:29:43 201 > 8 (r334319) > +++ head/sys/cddl/compat/opensolaris/sys/atomic.h Tue May 29 11:59:02 201 > 8 (r334320) > @@ -36,7 +36,8 @@ > atomic_cmpset_ptr((volatile uintptr_t *)(_a), (uintptr_t)(_b), (uintptr > _t) (_c)) > #define cas32 atomic_cmpset_32 > > -#if !defined(__LP64__) && !defined(__mips_n32) && !defined(ARM_HAVE_ATOMIC64 > ) > +#if !defined(__LP64__) && !defined(__mips_n32) && \ > + !defined(ARM_HAVE_ATOMIC64) && !defined(__i386__) > extern void atomic_add_64(volatile uint64_t *target, int64_t delta); > extern void atomic_dec_64(volatile uint64_t *target); > #endif > @@ -85,7 +86,8 @@ atomic_dec_32_nv(volatile uint32_t *target) > return (atomic_fetchadd_32(target, -1) - 1); > } > > -#if defined(__LP64__) || defined(__mips_n32) || defined(ARM_HAVE_ATOMIC64) > +#if defined(__LP64__) || defined(__mips_n32) || \ > + defined(ARM_HAVE_ATOMIC64) || defined(__i386__) > static __inline void > atomic_dec_64(volatile uint64_t *target) > { > > Modified: head/sys/i386/include/atomic.h > ============================================================================= > = > --- head/sys/i386/include/atomic.h Tue May 29 10:29:43 2018 (r33431 > 9) > +++ head/sys/i386/include/atomic.h Tue May 29 11:59:02 2018 (r33432 > 0) > @@ -134,6 +134,8 @@ uint64_t atomic_load_acq_64(volatile uint64_t *); > void atomic_store_rel_64(volatile uint64_t *, uint64_t); > uint64_t atomic_swap_64(volatile uint64_t *, uint64_t); > uint64_t atomic_fetchadd_64(volatile uint64_t *, uint64_t); > +void atomic_add_64(volatile uint64_t *, uint64_t); > +void atomic_subtract_64(volatile uint64_t *, uint64_t); > > #else /* !KLD_MODULE && __GNUCLIKE_ASM */ > > @@ -581,6 +583,30 @@ atomic_fetchadd_64(volatile uint64_t *p, uint64_t v) > } > } > > +static __inline void > +atomic_add_64(volatile uint64_t *p, uint64_t v) > +{ > + uint64_t t; > + > + for (;;) { > + t = *p; > + if (atomic_cmpset_64(p, t, t + v)) > + break; > + } > +} > + > +static __inline void > +atomic_subtract_64(volatile uint64_t *p, uint64_t v) > +{ > + uint64_t t; > + > + for (;;) { > + t = *p; > + if (atomic_cmpset_64(p, t, t - v)) > + break; > + } > +} > + > #endif /* _KERNEL */ > > #endif /* KLD_MODULE || !__GNUCLIKE_ASM */ > @@ -804,6 +830,16 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); > #define atomic_fetchadd_32 atomic_fetchadd_int > #define atomic_testandset_32 atomic_testandset_int > #define atomic_testandclear_32 atomic_testandclear_int > + > +/* Operations on 64-bit quad words. */ > +#define atomic_cmpset_acq_64 atomic_cmpset_64 > +#define atomic_cmpset_rel_64 atomic_cmpset_64 > +#define atomic_fetchadd_acq_64 atomic_fetchadd_64 > +#define atomic_fetchadd_rel_64 atomic_fetchadd_64 > +#define atomic_add_acq_64 atomic_add_64 > +#define atomic_add_rel_64 atomic_add_64 > +#define atomic_subtract_acq_64 atomic_subtract_64 > +#define atomic_subtract_rel_64 atomic_subtract_64 > > /* Operations on pointers. */ > #define atomic_set_ptr(p, v) \ > Hi Hans, This broke in lib32 on an amd64 system. --- cddl/lib/libnvpair__L --- In file included from /opt/src/svn-current/sys/cddl/contrib/opensolaris/ common/nvpair/opensolaris_fnvpair.c:29: In file included from /opt/src/svn-current/cddl/contrib/opensolaris/lib/ libzpool/common/sys/zfs_context.h:74: /opt/src/svn-current/sys/cddl/compat/opensolaris/sys/atomic.h:94:2: error: implicit declaration of function 'atomic_subtract_64' is invalid in C99 [-Werror,-Wimplicit-function-declaration] atomic_subtract_64(target, 1); ^ -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few.