From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2BB69A0C4D; Mon, 6 Sep 2021 10:17:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1085A410E6; Mon, 6 Sep 2021 10:17:59 +0200 (CEST) Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by mails.dpdk.org (Postfix) with ESMTP id A39DB40C35 for ; Mon, 6 Sep 2021 10:17:57 +0200 (CEST) Received: by mail-il1-f169.google.com with SMTP id b4so6035009ilr.11 for ; Mon, 06 Sep 2021 01:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c8NVYwTvNWrhtP0FsEgZYBe0EwxSR5lP5D8ma2m65yA=; b=dx7pJvC4m8HWVIpP7crkOpAQVWrSwJaE/crTRSdxZ442LadlyM8uW8so8hZlcpP5gP nnPnqzbiRqI7CW2i72SBlyCVUvAPd9CzzQxZ4H/Wms+mFtr9HbR0xkiDdJS1FrsXUuVY th6LS6GFCuaWkuM/MhygWCli/fXCK2M5PXLRjT9Q1RE6VZbyL4Lxg3IkbTg3yRp4NUm/ qAS+3yClsZI2L+gFOTvk9H8SPwDJmqZcNjoxAyZ0NvIXddEi5GFuS9jrWgOk3jhDCdkm 8CXWuImLc4okS2Up+bBK3AtrwkErurlqNBr/2/giCtNGZ3DEQXmCkchOhcVvtvPzDn6M 7EsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=c8NVYwTvNWrhtP0FsEgZYBe0EwxSR5lP5D8ma2m65yA=; b=NNpFmHnCOMToBxtPQvDr5cKQ73yZWZABQJj1iXElun62Tg2MAe1jR3Nwg3VYOrjy1K BHzPIBoN+GhRFT1y2moLxJB4MFxUt/UUH0ph09xPW5f5wR3SzW1MGXznU4TEAmSm2KC5 MWmCduS2C2GJm5eg+T0HK4iIL/RzzVmdl6F+4WWuZf2W0Zfg1DT0ymiN3yEcqYTZ5Vuj S2pnQ2qr/Djar6ygsZ1qj5YVtB3EbgqWuJk1/wdKdr3NwJWdIf72E2wHoXoWOV/9ULfb Z1UQhi2wHObR+fhmBpkoCVa5D8G1wTnCnchtPC7jDgVoJjb9D8GOYwOP3Lji/rquY1Jj 34pg== X-Gm-Message-State: AOAM53257hGjCWkmKGmEPmrgq5HqDP8t0hivnhkFX9GHVqlJCQBmFzmx 7y24SdHPmYj7jlGIcGmlhMqxxPwC+ZsCPETkkNE= X-Google-Smtp-Source: ABdhPJwuyXntWOrclI7JuE4VLBdaMYf77/i7Kqh1Wmtsr9mo74Tk/ZCNl7JPMQFZlu8jTQ+/F6vqTYBmnUMmJlp5VoE= X-Received: by 2002:a05:6e02:1a4f:: with SMTP id u15mr7627036ilv.251.1630916277057; Mon, 06 Sep 2021 01:17:57 -0700 (PDT) MIME-Version: 1.0 References: <921c4cfaa08605cac9dd1f63b52139c0860cd622.1627485542.git.sthotton@marvell.com> In-Reply-To: <921c4cfaa08605cac9dd1f63b52139c0860cd622.1627485542.git.sthotton@marvell.com> From: Jerin Jacob Date: Mon, 6 Sep 2021 13:47:31 +0530 Message-ID: To: Shijith Thotton Cc: dpdk-dev , Thomas Monjalon , Jerin Jacob , Pavan Nikhilesh Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH] eal: add macro to swap two numbers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Jul 28, 2021 at 8:52 PM Shijith Thotton wrote: > > Added a macro to swap two numbers and updated common autotest for the > same. > > Signed-off-by: Shijith Thotton Acked-by: Jerin Jacob > --- > Needed-for: drivers: add external clock support for cnxk timer @Thomas Monjalon Could you merge this to the main tree if the patch looks OK to you. > > app/test/test_common.c | 4 ++++ > lib/eal/include/rte_common.h | 8 ++++++++ > 2 files changed, 12 insertions(+) > > diff --git a/app/test/test_common.c b/app/test/test_common.c > index 12bd1cad90..ef177cecb1 100644 > --- a/app/test/test_common.c > +++ b/app/test/test_common.c > @@ -30,9 +30,13 @@ test_macros(int __rte_unused unused_parm) > return -1;} > > uintptr_t unused = 0; > + unsigned int smaller = SMALLER, bigger = BIGGER; > > RTE_SET_USED(unused); > > + RTE_SWAP(smaller, bigger); > + if (smaller != BIGGER && bigger != SMALLER) > + FAIL_MACRO(RTE_SWAP); > if ((uintptr_t)RTE_PTR_ADD(SMALLER, PTR_DIFF) != BIGGER) > FAIL_MACRO(RTE_PTR_ADD); > if ((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF) != SMALLER) > diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h > index d5a32c66a5..09661a5469 100644 > --- a/lib/eal/include/rte_common.h > +++ b/lib/eal/include/rte_common.h > @@ -810,6 +810,14 @@ rte_log2_u64(uint64_t v) > /** Number of elements in the array. */ > #define RTE_DIM(a) (sizeof (a) / sizeof ((a)[0])) > > +/** Macro to swap two numbers. */ > +#define RTE_SWAP(a, b) \ > + __extension__ ({ \ > + typeof (a) _a = a; \ > + a = b; \ > + b = _a; \ > + }) > + > /** > * Converts a numeric string to the equivalent uint64_t value. > * As well as straight number conversion, also recognises the suffixes > -- > 2.25.1 >