linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Jakub Acs <acsjakub@amazon.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	kernel test robot <lkp@intel.com>,
	llvm@lists.linux.dev,  oe-kbuild-all@lists.linux.dev,
	 Linux Memory Management List <linux-mm@kvack.org>,
	Miguel Ojeda <ojeda@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>
Subject: Re: [akpm-mm:mm-new 36/102] error[E0425]: cannot find value `VM_READ` in crate `bindings`
Date: Fri, 10 Oct 2025 09:47:43 +0200	[thread overview]
Message-ID: <CANiq72=bMmDdVMgTAtThciUNQND4cqW42+Udzk6s_X7XZZZpVw@mail.gmail.com> (raw)
In-Reply-To: <CANiq72kndiqwEm-OZLd6JumAaBy7KrzYf_rDjwhtw5Uh4vdTCg@mail.gmail.com>

On Fri, Oct 10, 2025 at 8:59 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> The best would be to use C23-like `enum : unsigned long { ... }`, but
> sadly we don't have a recent enough GCC as a minimum in the kernel
> (GCC 13).

The `mode` attribute also influences the `enum` constants -- doing
something like:

    enum { ... } __mode(pointer);

will make `VM_MERGEABLE` either `long` or `unsigned long` depending on
the compiler and version.

So with:

    #ifdef __clang__
        #define __unsigned_long_enum : unsigned long
    #else
        #define __unsigned_long_enum __mode(pointer)
    #endif

And then using it like:

    enum __unsigned_long_enum { ... };

I can get quite close: old GCC will use `int` for smaller constants
and `unsigned long` for the bigger ones, and everything else (new GCC
and all Clangs) will use `unsigned long` for everything.

Perhaps this may be useful on its own for C in some cases.

Cheers,
Miguel


      parent reply	other threads:[~2025-10-10  7:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09 17:42 kernel test robot
2025-10-09 18:05 ` Andrew Morton
2025-10-09 18:14   ` Miguel Ojeda
2025-10-09 18:15     ` Miguel Ojeda
2025-10-09 19:23       ` Andrew Morton
2025-10-10  6:07     ` Jakub Acs
2025-10-10  6:59       ` Miguel Ojeda
2025-10-10  7:44         ` Jakub Acs
2025-10-10  8:13           ` Miguel Ojeda
2025-10-10  8:19             ` Miguel Ojeda
2025-10-10  7:47         ` Miguel Ojeda [this message]

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='CANiq72=bMmDdVMgTAtThciUNQND4cqW42+Udzk6s_X7XZZZpVw@mail.gmail.com' \
    --to=miguel.ojeda.sandonis@gmail.com \
    --cc=acsjakub@amazon.de \
    --cc=akpm@linux-foundation.org \
    --cc=aliceryhl@google.com \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=ojeda@kernel.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