DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jerin Jacob <jerinjacobk@gmail.com>
To: Shijith Thotton <sthotton@marvell.com>
Cc: dpdk-dev <dev@dpdk.org>, Thomas Monjalon <thomas@monjalon.net>,
	Jerin Jacob <jerinj@marvell.com>,
	 Pavan Nikhilesh <pbhagavatula@marvell.com>
Subject: Re: [dpdk-dev] [PATCH] eal: add macro to swap two numbers
Date: Mon, 6 Sep 2021 13:47:31 +0530	[thread overview]
Message-ID: <CALBAE1Mbosg2aE9CMkX_zGa6LbaFeMO5pBHzBZ7Stk7G_h3Q3w@mail.gmail.com> (raw)
In-Reply-To: <921c4cfaa08605cac9dd1f63b52139c0860cd622.1627485542.git.sthotton@marvell.com>

On Wed, Jul 28, 2021 at 8:52 PM Shijith Thotton <sthotton@marvell.com> wrote:
>
> Added a macro to swap two numbers and updated common autotest for the
> same.
>
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>


Acked-by: Jerin Jacob <jerinj@marvell.com>


> ---
> 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
>

  reply	other threads:[~2021-09-06  8:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-28 15:21 Shijith Thotton
2021-09-06  8:17 ` Jerin Jacob [this message]
2021-09-27 16:32   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALBAE1Mbosg2aE9CMkX_zGa6LbaFeMO5pBHzBZ7Stk7G_h3Q3w@mail.gmail.com \
    --to=jerinjacobk@gmail.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=pbhagavatula@marvell.com \
    --cc=sthotton@marvell.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).