Rust for Linux List
 help / color / mirror / Atom feed
From: FUJITA Tomonori <tomo@flapping.org>
To: a.hindborg@kernel.org, gary@garyguo.net, ojeda@kernel.org
Cc: acourbot@nvidia.com, aliceryhl@google.com,
	anna-maria@linutronix.de, bjorn3_gh@protonmail.com,
	boqun@kernel.org, dakr@kernel.org, daniel.almeida@collabora.com,
	frederic@kernel.org, jstultz@google.com, lossin@kernel.org,
	lyude@redhat.com, sboyd@kernel.org, tamird@kernel.org,
	tglx@kernel.org, tmgross@umich.edu, work@onurozkan.dev,
	rust-for-linux@vger.kernel.org,
	FUJITA Tomonori <fujita.tomonori@gmail.com>
Subject: [PATCH v4 1/2] rust: bindings: set HZ to CONFIG_HZ
Date: Fri, 25 Sep 2026 08:25:29 +0900	[thread overview]
Message-ID: <20260924232530.446588-2-tomo@flapping.org> (raw)
In-Reply-To: <20260924232530.446588-1-tomo@flapping.org>

From: FUJITA Tomonori <fujita.tomonori@gmail.com>

include/uapi/asm-generic/param.h defines HZ as __USER_HZ and
include/asm-generic/param.h then sets it to CONFIG_HZ. bindgen keeps the
first definition of a macro and ignores a later #undef, so the generated
binding is __USER_HZ.

Redefine HZ in rust/bindings/lib.rs, the same way compat_ptr_ioctl is
redefined there. Nothing in the tree reads bindings::HZ today, so this
prevents accidental misuse rather than fixing a bug.

Suggested-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
---
 rust/bindings/lib.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/rust/bindings/lib.rs b/rust/bindings/lib.rs
index 439ab88a5da1..98313fc31024 100644
--- a/rust/bindings/lib.rs
+++ b/rust/bindings/lib.rs
@@ -83,3 +83,8 @@ mod bindings_helper {
         None
     }
 };
+
+// `bindgen` keeps the first definition of a macro and ignores a later `#undef`.
+// The generated `HZ` is therefore `__USER_HZ` from
+// `include/uapi/asm-generic/param.h`, not `CONFIG_HZ`.
+pub const HZ: u32 = CONFIG_HZ;
-- 
2.43.0


  reply	other threads:[~2026-09-24 23:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 23:25 [PATCH v4 0/2] Add Delta::to_jiffies_timeout() FUJITA Tomonori
2026-09-24 23:25 ` FUJITA Tomonori [this message]
2026-09-24 23:25 ` [PATCH v4 2/2] rust: time: add Delta::to_jiffies_timeout() for timeout conversion FUJITA Tomonori
2026-09-25  8:00   ` Andreas Hindborg
2026-09-25  9:39     ` FUJITA Tomonori
2026-09-25 14:48       ` Miguel Ojeda
2026-09-28  9:37         ` Andreas Hindborg
2026-09-28  9:45           ` Miguel Ojeda
2026-09-28  9:57             ` Andreas Hindborg
2026-09-29 10:15 ` [PATCH v4 0/2] Add Delta::to_jiffies_timeout() Andreas Hindborg

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=20260924232530.446588-2-tomo@flapping.org \
    --to=tomo@flapping.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=anna-maria@linutronix.de \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=frederic@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=jstultz@google.com \
    --cc=lossin@kernel.org \
    --cc=lyude@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tamird@kernel.org \
    --cc=tglx@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /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