From owner-svn-src-head@freebsd.org Fri Nov 24 12:10:43 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD21ADE2CE5; Fri, 24 Nov 2017 12:10:43 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 878F4720FE; Fri, 24 Nov 2017 12:10:43 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vAOCAggv092284; Fri, 24 Nov 2017 12:10:42 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vAOCAg0w092283; Fri, 24 Nov 2017 12:10:42 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201711241210.vAOCAg0w092283@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 24 Nov 2017 12:10:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326161 - head/sys/i386/include X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/i386/include X-SVN-Commit-Revision: 326161 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 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: Fri, 24 Nov 2017 12:10:43 -0000 Author: hselasky Date: Fri Nov 24 12:10:42 2017 New Revision: 326161 URL: https://svnweb.freebsd.org/changeset/base/326161 Log: Implement atomic_fetchadd_64() for i386. This function is needed by the atomic64 header file in the LinuxKPI for i386. Reviewed by: kib MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/i386/include/atomic.h Modified: head/sys/i386/include/atomic.h ============================================================================== --- head/sys/i386/include/atomic.h Fri Nov 24 12:08:50 2017 (r326160) +++ head/sys/i386/include/atomic.h Fri Nov 24 12:10:42 2017 (r326161) @@ -129,6 +129,7 @@ int atomic_cmpset_64(volatile uint64_t *, uint64_t, u 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); #else /* !KLD_MODULE && __GNUCLIKE_ASM */ @@ -563,6 +564,17 @@ atomic_swap_64(volatile uint64_t *p, uint64_t v) return (atomic_swap_64_i386(p, v)); else return (atomic_swap_64_i586(p, v)); +} + +static __inline uint64_t +atomic_fetchadd_64(volatile uint64_t *p, uint64_t v) +{ + + for (;;) { + uint64_t t = *p; + if (atomic_cmpset_64(p, t, t + v)) + return (t); + } } #endif /* _KERNEL */