lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Fri, 7 Jun 2024 13:46:16 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Alice Ryhl <aliceryhl@...gle.com>, a.hindborg@...sung.com, alex.gaynor@...il.com, 
	ardb@...nel.org, benno.lossin@...ton.me, bjorn3_gh@...tonmail.com, 
	boqun.feng@...il.com, gary@...yguo.net, jbaron@...mai.com, 
	jpoimboe@...nel.org, linux-kernel@...r.kernel.org, 
	linux-trace-kernel@...r.kernel.org, mathieu.desnoyers@...icios.com, 
	mhiramat@...nel.org, ojeda@...nel.org, rostedt@...dmis.org, 
	rust-for-linux@...r.kernel.org, wedsonaf@...il.com
Subject: Re: [PATCH 1/3] rust: add static_call support

On Fri, Jun 7, 2024 at 12:52 PM Peter Zijlstra <peterz@...radead.org> wrote:
>
> I'm sorry, but 30+ years of reading ! as NOT (or factorial) isn't going
> to go away. So I'm reading your macros do NOT rule.

It makes it clear what is macro call or not. They could have gone for
UPPERCASE names (for instance), yes. On the other hand, they do not
work like C macros and are ~hygienic, so it also makes sense to avoid
confusion here.

I mean, I am not suggesting to do a CPP-pass to Rust files, but if
someone really, really wanted to mix them in a single file, it would
be nice to not confuse the two kinds. :)

Generally they feel "closer" to the language (given what they
do/support) compared to the CPP ones, so it also makes sense they
don't "shout" so much compared to UPPERCASE, if that makes sense.

> The above exaple fails, because the next token is :ident, whatever the
> heck that might be. Also, extra points for line-noise due to lack of
> whitespace.

$name:ident means "match what Rust would consider an identifier here
and call it $name for the purposes of this macro".

So, for instance, $x:ident matches:

    a
    a2
    a_b

But it would not match:

    2a
    a-b
    a _b

For the usual reasons why those are not identifiers.

https://godbolt.org/z/G7v4j67dc

    fn f(x: i32) -> i32 {
        x * 2
    }

    macro_rules! f {
        ($x:ident) => { $x * 2 }
    }

    fn main() {
        let a = 42;

        let b = f(a);       // Function.
        let c = f!(a);      // Macro.

        //let c = f!(a2);   // Works, but the variable does not exist.
        //let c = f!(2a);   // Error: no rules expected the token `2a`.

        //let c = f!(a_b);  // Works, but the variable does not exist.
        //let c = f!(a-b);  // Error: no rules expected the token `-`.
        //let c = f!(a_ b); // Error: no rules expected the token `b`.

        println!("{a} {b} {c}");
    }

I hope this makes it clearer.

> You just need to extend the rust thing to be able to consume C header
> files.

I agree, because in practice it is quite useful for a language like
Rust that consuming C header files is "natively" supported.

Though it also has downsides and is a big decision, which is why, like
Alice mentioned, some people agree, and some people don't.
Nevertheless, we have been doing our best for a long time to get the
best we can for the kernel -- just 2 days ago we told the Rust project
in one of our meetings that it would be nice to see that particular
"project goal" from that document realized (among others).

Cheers,
Miguel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ