From owner-svn-src-all@freebsd.org Tue May 29 13:10:50 2018 Return-Path: Delivered-To: svn-src-all@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 0B2E7F7B8AD; Tue, 29 May 2018 13:10:50 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9663D699D9; Tue, 29 May 2018 13:10:49 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.128.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id E78DF2603AE; Tue, 29 May 2018 15:10:47 +0200 (CEST) Subject: Re: svn commit: r334320 - in head/sys: cddl/compat/opensolaris/kern cddl/compat/opensolaris/sys i386/include To: Cy Schubert Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201805291302.w4TD2bR5059884@slippy.cwsent.com> From: Hans Petter Selasky Message-ID: <168f4cd3-07d2-15cb-9cf4-a2d02f6dc260@selasky.org> Date: Tue, 29 May 2018 15:10:34 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <201805291302.w4TD2bR5059884@slippy.cwsent.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2018 13:10:50 -0000 On 05/29/18 15:02, Cy Schubert wrote: > 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); > ^ I only tested buildkernel i386 LINT + GENERIC with this change. I will have a look ASAP. --HPS