From: Uros Bizjak <ubizjak@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org,
netdev@vger.kernel.org, Nadav Amit <nadav.amit@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Dennis Zhou <dennis@kernel.org>, Tejun Heo <tj@kernel.org>,
Christoph Lameter <cl@linux.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andy Lutomirski <luto@kernel.org>,
Ingo Molnar <mingo@kernel.org>, Brian Gerst <brgerst@gmail.com>,
Denys Vlasenko <dvlasenk@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v3 2/6] compiler.h: Introduce TYPEOF_UNQUAL() macro
Date: Mon, 9 Dec 2024 14:01:09 +0100 [thread overview]
Message-ID: <CAFULd4YHuiyzuzAwuZxsp_kRca-hnR+NqHU8cfk8JDqATMNSMQ@mail.gmail.com> (raw)
In-Reply-To: <20241209113039.GN21636@noisy.programming.kicks-ass.net>
[-- Attachment #1: Type: text/plain, Size: 676 bytes --]
On Mon, Dec 9, 2024 at 12:30 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Sun, Dec 08, 2024 at 09:45:17PM +0100, Uros Bizjak wrote:
> > Define TYPEOF_UNQUAL() to use __typeof_unqual__() as typeof operator
> > when available, to return unqualified type of the expression.
> >
> > Current version of sparse doesn't know anything about __typeof_unqual__()
> > operator. Avoid the usage of __typeof_unqual__() when sparse checking
> > is active to prevent sparse errors with unknowing keyword.
>
> Ooooh, new toys.
>
> I suppose __unqual_scalar_typeof() wants to be using this when
> available?
Yes, the attached patch compiles and boots OK.
Uros.
[-- Attachment #2: unqual_scalar_typeof.diff.txt --]
[-- Type: text/plain, Size: 1289 bytes --]
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 5d6544545658..87a9ce3ebd13 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -486,15 +486,19 @@ struct ftrace_likely_data {
* __unqual_scalar_typeof(x) - Declare an unqualified scalar type, leaving
* non-scalar types unchanged.
*/
+
+#if defined(CONFIG_CC_HAS_TYPEOF_UNQUAL) && !defined(__CHECKER__)
+# define __unqual_scalar_typeof(x) __typeof_unqual__(x)
+#else
/*
* Prefer C11 _Generic for better compile-times and simpler code. Note: 'char'
* is not type-compatible with 'signed char', and we define a separate case.
*/
-#define __scalar_type_to_expr_cases(type) \
+ #define __scalar_type_to_expr_cases(type) \
unsigned type: (unsigned type)0, \
signed type: (signed type)0
-#define __unqual_scalar_typeof(x) typeof( \
+ #define __unqual_scalar_typeof(x) typeof( \
_Generic((x), \
char: (char)0, \
__scalar_type_to_expr_cases(char), \
@@ -503,6 +507,7 @@ struct ftrace_likely_data {
__scalar_type_to_expr_cases(long), \
__scalar_type_to_expr_cases(long long), \
default: (x)))
+#endif
/* Is this type a native word size -- useful for atomic operations */
#define __native_word(t) \
next prev parent reply other threads:[~2024-12-09 13:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-08 20:45 [PATCH v3 0/6] Enable strict percpu address space checks Uros Bizjak
2024-12-08 20:45 ` [PATCH v3 1/6] x86/kgdb: Use IS_ERR_PCPU() macro Uros Bizjak
2024-12-08 20:45 ` [PATCH v3 2/6] compiler.h: Introduce TYPEOF_UNQUAL() macro Uros Bizjak
2024-12-09 11:30 ` Peter Zijlstra
2024-12-09 13:01 ` Uros Bizjak [this message]
2024-12-10 16:37 ` Uros Bizjak
2024-12-08 20:45 ` [PATCH v3 3/6] percpu: Use TYPEOF_UNQUAL() in variable declarations Uros Bizjak
2024-12-08 20:45 ` [PATCH v3 4/6] percpu: Use TYPEOF_UNQUAL() in *_cpu_ptr() accessors Uros Bizjak
2024-12-08 20:45 ` [PATCH v3 5/6] percpu: Repurpose __percpu tag as a named address space qualifier Uros Bizjak
2024-12-08 20:45 ` [PATCH v3 6/6] percpu/x86: Enable strict percpu checks via named AS qualifiers Uros Bizjak
2024-12-10 3:59 ` [PATCH v3 0/6] Enable strict percpu address space checks Dennis Zhou
2024-12-13 3:35 ` Andrew Morton
2024-12-13 4:28 ` Uros Bizjak
2024-12-13 7:13 ` Dan Carpenter
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=CAFULd4YHuiyzuzAwuZxsp_kRca-hnR+NqHU8cfk8JDqATMNSMQ@mail.gmail.com \
--to=ubizjak@gmail.com \
--cc=brgerst@gmail.com \
--cc=cl@linux.com \
--cc=dennis@kernel.org \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=nadav.amit@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=x86@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