From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stephen@networkplumber.org>
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 <dev@dpdk.org>; Thu,  3 Dec 2015 17:31:34 +0100 (CET)
Received: by pfu207 with SMTP id 207so10865475pfu.2
 for <dev@dpdk.org>; Thu, 03 Dec 2015 08:31:33 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20150623.gappssmtp.com; s=20150623;
 h=date:from:to:cc:subject:message-id:in-reply-to:references
 :mime-version:content-type:content-transfer-encoding;
 bh=nu/1hpM//WWKjxy8D3J/zMrWWah6AeC/NIF1LD+AtkA=;
 b=v941hup7vrIZYPPF52GIHQugCxCNvTgiczRGaiaKydrEYJ3Y/+wz4q6UFKK8FukLIW
 hwTmHzrn6J/G8n2Cwo0HtjdV52gNos5YsWVlN6Be6dvf8wEBO5Ym6T6Sk5TuhRQpwf/1
 BozEPee0t2hi7D5BqibOqW511pvMc+V1/oN7W2oMBuN30SEw+e6DK4hi2rN/gmCdrkD2
 VKzs1qBT9NerU9peEMjWTY7mH83ZnMVi7i97oO8DahTsSMmaC7ZZe/IfkwSVcCXyUMgy
 8l+MKkBfIdJQwlM6QP4Gt5TZinfePNBGDrNZlI5a46iuvFAHDOgEZrtICKIS9zBHbNPN
 yPig==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to
 :references:mime-version:content-type:content-transfer-encoding;
 bh=nu/1hpM//WWKjxy8D3J/zMrWWah6AeC/NIF1LD+AtkA=;
 b=WUc38MRgx5SmfPu5YVR+Z23bwhIwQJa58an4XnGia1iJ4jxPNvlp0lhQrWNLTTqDS2
 eMr2ExW8cNK2MF+dGDFmP/LqoDaEZNcoFwk/1pUFakuzbtLsdmUY5kOXS5jLDvMCNqWc
 srV7Z50Sxmjt24ymbx8bTuWY59Gt57Dv47/HzWK0PREuzp2BKBVOLUjjRdyg7uBSqw12
 eRbuJ8WsPc2CBnyA7ue14+Y/ZcZYLUGVPS1WmQimCKhZBLr3p3qBC9ZphaGGcpaTbPRi
 zEvCCGg6LlWqo9n+wW3VGkZ8V25MT44NrZQfyNZJ12+fDWalLlxHib0rO6RgzE7pZHlZ
 AtgQ==
X-Gm-Message-State: ALoCoQlb2nwumCg0UNT4soWVKleEAVjkfz9ilpcAbfbry2IaBmTuD/XG9d7z6QgPgGMmjBiciFZ3
X-Received: by 10.98.9.88 with SMTP id e85mr14369695pfd.7.1449160293212;
 Thu, 03 Dec 2015 08:31:33 -0800 (PST)
Received: from xeon-e3 (static-50-53-82-155.bvtn.or.frontiernet.net.
 [50.53.82.155])
 by smtp.gmail.com with ESMTPSA id jj5sm11780332pac.4.2015.12.03.08.31.31
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 03 Dec 2015 08:31:32 -0800 (PST)
Date: Thu, 3 Dec 2015 08:31:39 -0800
From: Stephen Hemminger <stephen@networkplumber.org>
To: ibetts <ian.betts@intel.com>
Message-ID: <20151203083139.32b82334@xeon-e3>
In-Reply-To: <1449134905-28261-3-git-send-email-ian.betts@intel.com>
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
Subject: Re: [dpdk-dev] [PATCH v5 2/4] examples: add lthread subsystem for
 performance-thread
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 03 Dec 2015 16:31:34 -0000

On Thu,  3 Dec 2015 09:28:23 +0000
ibetts <ian.betts@intel.com> 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;
}