From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH v5 2/4] examples: add lthread subsystem for performance-thread Date: Thu, 3 Dec 2015 08:31:39 -0800 Message-ID: <20151203083139.32b82334@xeon-e3> References: <1449134905-28261-1-git-send-email-ian.betts@intel.com> <1449134905-28261-3-git-send-email-ian.betts@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: ibetts Return-path: Received: from mail-pf0-f169.google.com (mail-pf0-f169.google.com [209.85.192.169]) by dpdk.org (Postfix) with ESMTP id 11A02567E for ; Thu, 3 Dec 2015 17:31:34 +0100 (CET) Received: by pfu207 with SMTP id 207so10865475pfu.2 for ; Thu, 03 Dec 2015 08:31:33 -0800 (PST) In-Reply-To: <1449134905-28261-3-git-send-email-ian.betts@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, 3 Dec 2015 09:28:23 +0000 ibetts wrote: > +/* > + * Atomically set a value and return the old value > + */ > +static inline uint64_t > +atomic64_xchg(uint64_t *ptr, uint64_t val) __attribute__ ((always_inline)); > +static inline uint64_t > +atomic64_xchg(uint64_t *ptr, uint64_t val) You don't need a forward declaration for this. Instead do: static inline uint64_t __attribute__((always_inline)) atomic_xchg64(uint64_t *ptr, uint64_t val) Really should be in rte_atomic.h as a primitive and the assembly macro is missing change to ptr so Gcc might optmize it away. Something like this mayb? static inline uint64_t __attribute__ ((always_inline)); rte_atomic64_xchg(uint64_t *ptr, uint64_t val) { asm volatile ( MPLOCKED "xchgq %[ptr],%[val];" : [val] "=r" (val) [ptr] "=m" (*ptr) : [ptr] "m" (*ptr), "a" (val) : "memory"); return val; }