DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andre Muezerie <andremue@linux.microsoft.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "Morten Brørup" <mb@smartsharesystems.com>,
	dev@dpdk.org, "Chengwen Feng" <fengchengwen@huawei.com>
Subject: Re: [PATCH v2 01/10] eal: add workaround for __builtin_constant_p
Date: Wed, 19 Feb 2025 17:59:19 -0800	[thread overview]
Message-ID: <20250220015919.GA922@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> (raw)
In-Reply-To: <20250219091011.2c49f342@hermes.local>

On Wed, Feb 19, 2025 at 09:10:11AM -0800, Stephen Hemminger wrote:
> On Wed, 19 Feb 2025 08:50:02 -0800
> Andre Muezerie <andremue@linux.microsoft.com> wrote:
> 
> > On Tue, Feb 18, 2025 at 06:12:04PM +0100, Morten Brørup wrote:
> > > > From: Andre Muezerie [mailto:andremue@linux.microsoft.com]
> > > > Sent: Tuesday, 18 February 2025 17.32
> > > > 
> > > > There's no MSVC equivalent for compiler extension __builtin_constant_p.
> > > > EAL already had __rte_constant which was used as a first attempt to
> > > > workaround __builtin_constant_p when using MSVC. However, there are
> > > > pieces of code that would benefit from being able to provide a default
> > > > value to be used instead of it being always 0 like how it was done by
> > > > __rte_constant.
> > > > 
> > > > A new macro is added here allowing such default to be provided by the
> > > > caller.  
> > > 
> > > NAK to the new macro.
> > > 
> > > Please use the sizeof() hack suggested by Stephen to provide an implementation of __rte_constant(e) for MSVC.
> > > Here's a link to an example of the hack:
> > > https://news.ycombinator.com/item?id=16720172  
> > 
> > Thanks for the link. I tried to use the hack as suggested but turns out it does
> > not work with msvc. It results in error C2100: "you cannot dereference an
> > operand of type 'void'".
> > 
> > I'm open to further suggestions.
> 
> Maybe contact the MSVC team? there really ought to be way to do this.
> The compiler knows what is constant and what is not since it needs this for static assertions.

I reached out to the MSVC team and they suggested a similar hack using _Generic, which works with
msvc. I'll send out an updated series.

  reply	other threads:[~2025-02-20  1:59 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
2025-02-11 22:01 ` [PATCH 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
2025-02-11 22:09   ` Stephen Hemminger
2025-02-12  0:59   ` fengchengwen
2025-02-11 22:01 ` [PATCH 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
2025-02-12  0:59   ` fengchengwen
2025-02-11 22:01 ` [PATCH 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
2025-02-11 22:10   ` Stephen Hemminger
2025-02-12  1:01   ` fengchengwen
2025-02-11 22:02 ` [PATCH 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
2025-02-12  1:03   ` fengchengwen
2025-02-11 22:02 ` [PATCH 05/10] test-pmd: avoid undefined behavior Andre Muezerie
2025-02-12  1:04   ` fengchengwen
2025-02-11 22:02 ` [PATCH 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
2025-02-12  1:04   ` fengchengwen
2025-02-11 22:02 ` [PATCH 07/10] test-pmd: don't return value from void function Andre Muezerie
2025-02-12  1:10   ` fengchengwen
2025-02-11 22:02 ` [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model Andre Muezerie
2025-02-11 22:12   ` Stephen Hemminger
2025-02-12  1:16     ` Andre Muezerie
2025-02-12  1:16   ` fengchengwen
2025-02-11 22:02 ` [PATCH 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
2025-02-11 22:13   ` Stephen Hemminger
2025-02-12  2:07     ` Andre Muezerie
2025-02-18 15:35 ` [PATCH 00/10] enable "app" to be compiled with MSVC David Marchand
2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
2025-02-18 17:12     ` Morten Brørup
2025-02-19 16:50       ` Andre Muezerie
2025-02-19 17:10         ` Stephen Hemminger
2025-02-20  1:59           ` Andre Muezerie [this message]
2025-02-18 16:32   ` [PATCH v2 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
2025-02-18 16:46     ` Bruce Richardson
2025-02-18 17:03       ` Andre Muezerie
2025-02-18 17:07         ` Bruce Richardson
2025-02-19 17:08           ` Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
2025-02-18 16:47     ` Bruce Richardson
2025-02-18 16:32   ` [PATCH v2 05/10] test-pmd: avoid undefined behavior Andre Muezerie
2025-02-18 16:41     ` Bruce Richardson
2025-02-19 17:09       ` Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 07/10] test-pmd: don't return value from void function Andre Muezerie
2025-02-18 16:42     ` Bruce Richardson
2025-02-18 16:32   ` [PATCH v2 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
2025-02-18 16:49     ` Bruce Richardson
2025-02-19  9:15     ` David Marchand
2025-02-19 14:51       ` Andre Muezerie
2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
2025-02-20  2:27     ` Stephen Hemminger
2025-02-20  2:01   ` [PATCH v3 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 05/10] test-pmd: avoid undefined behavior Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 07/10] test-pmd: don't return value from void function Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
2025-02-20  7:57   ` [PATCH v3 00/10] enable "app" " Morten Brørup
2025-02-20 21:30 ` [PATCH v4 " Andre Muezerie
2025-02-20 21:30   ` [PATCH v4 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
2025-02-21 15:31     ` Morten Brørup
2025-02-21 16:47       ` Andre Muezerie
2025-02-20 21:30   ` [PATCH v4 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
2025-02-20 21:30   ` [PATCH v4 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
2025-02-21  9:10     ` Bruce Richardson
2025-02-20 21:30   ` [PATCH v4 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
2025-02-20 21:30   ` [PATCH v4 05/10] test-pmd: avoid undefined behavior Andre Muezerie
2025-02-20 21:31   ` [PATCH v4 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
2025-02-20 21:31   ` [PATCH v4 07/10] test-pmd: don't return value from void function Andre Muezerie
2025-02-20 21:31   ` [PATCH v4 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
2025-02-21  8:40     ` Konstantin Ananyev
2025-02-20 21:31   ` [PATCH v4 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
2025-02-20 21:31   ` [PATCH v4 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
2025-02-20 21:44   ` [PATCH v4 00/10] enable "app" " Stephen Hemminger

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=20250220015919.GA922@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net \
    --to=andremue@linux.microsoft.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=mb@smartsharesystems.com \
    --cc=stephen@networkplumber.org \
    /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).