* [PATCH -next] compiler.h: fix compile error with gcc-8 or lower version
@ 2022-09-29 3:38 Yang Yingliang
2022-09-29 9:17 ` Vlastimil Babka
0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2022-09-29 3:38 UTC (permalink / raw)
To: linux-kernel, rust-for-linux, llvm, linux-mm; +Cc: keescook, vbabka
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH -next] compiler.h: fix compile error with gcc-8 or lower version
2022-09-29 3:38 [PATCH -next] compiler.h: fix compile error with gcc-8 or lower version Yang Yingliang
@ 2022-09-29 9:17 ` Vlastimil Babka
0 siblings, 0 replies; 2+ messages in thread
From: Vlastimil Babka @ 2022-09-29 9:17 UTC (permalink / raw)
To: Yang Yingliang, linux-kernel, rust-for-linux, llvm, linux-mm; +Cc: keescook
On 9/29/22 05:38, Yang Yingliang wrote:
> 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
This would be wrong as with 63caa04ec605 we don't want __malloc in
__realloc_size(). Anyway Kees sent the correct version and it's now merged,
thanks.
> +#endif
>
> #ifndef asm_volatile_goto
> #define asm_volatile_goto(x...) asm goto(x)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-29 9:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29 3:38 [PATCH -next] compiler.h: fix compile error with gcc-8 or lower version Yang Yingliang
2022-09-29 9:17 ` Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox