From: Yang Yingliang <yangyingliang@huawei.com>
To: <linux-kernel@vger.kernel.org>, <rust-for-linux@vger.kernel.org>,
<llvm@lists.linux.dev>, <linux-mm@kvack.org>
Cc: <keescook@chromium.org>, <vbabka@suse.cz>
Subject: [PATCH -next] compiler.h: fix compile error with gcc-8 or lower version
Date: Thu, 29 Sep 2022 11:38:45 +0800 [thread overview]
Message-ID: <20220929033845.485728-1-yangyingliang@huawei.com> (raw)
I got the follow compile error in latest linux-next kernel with gcc-8.4:
In file included from <command-line>:
./include/linux/percpu.h: In function ‘__alloc_reserved_percpu’:
././include/linux/compiler_types.h:279:30: error: expected declaration specifiers before ‘__alloc_size__’
#define __alloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) __malloc
^~~~~~~~~~~~~~
./include/linux/percpu.h:120:74: note: in expansion of macro ‘__alloc_size’
extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align) __alloc_size(1);
__alloc_size is not defined in gcc-8 or lower version, so add back the
conditional test for __alloc_size__ to fix it.
Fixes: 63caa04ec605 ("slab: Remove __malloc attribute from realloc functions")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
include/linux/compiler_types.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index aa81da7a28eb..aae8852ccbdc 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -276,8 +276,13 @@ struct ftrace_likely_data {
* be performing a _reallocation_, as that may alias the existing pointer.
* For these, use __realloc_size().
*/
+#ifdef __alloc_size__
#define __alloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) __malloc
-#define __realloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__)
+#define __realloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__)
+#else
+#define __alloc_size(x, ...) __malloc
+#define __realloc_size(x, ...) __malloc
+#endif
#ifndef asm_volatile_goto
#define asm_volatile_goto(x...) asm goto(x)
--
2.25.1
next reply other threads:[~2022-09-29 3:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-29 3:38 Yang Yingliang [this message]
2022-09-29 9:17 ` Vlastimil Babka
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=20220929033845.485728-1-yangyingliang@huawei.com \
--to=yangyingliang@huawei.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=llvm@lists.linux.dev \
--cc=rust-for-linux@vger.kernel.org \
--cc=vbabka@suse.cz \
/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