[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compile error in master, restrict is missing

From: Javier Martinez Canillas
Subject: Re: compile error in master, restrict is missing
Date: Wed, 11 Mar 2020 12:30:01 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

Hello Olaf,

On 3/11/20 11:59 AM, Olaf Hering wrote:
> Am Wed, 11 Mar 2020 11:39:08 +0100
> schrieb Daniel Kiper <address@hidden>:
>> Nothing suspicious pooped out. I expect that the issues you are
>> hitting are related to set of configure flags which you are using.
> It turned out --disable-mm-debug does for some reason fix the build with 
> gcc7. But building with gcc48 does still trigger the failure. 

That's expected because unless specified, the default for GCC 4.8 is -std=gnu90
(C90 with GNU extensions) but the restrict type qualifier was introduced in C99.

Does the following patch solve the issue?

>From 2e9879df9ddd4744f7b6c55bac9cf335e5832243 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <address@hidden>
Date: Wed, 11 Mar 2020 12:03:54 +0100
Subject: [PATCH] misc: Disable the restrict keyword when not building with C99

The restrict type qualifier was introduced in the C99 standard, so it will
lead to a compile error if GRUB is not built with -std=c99 or newer.

This check comes from grub-core/lib/zstd/xxhash.h file that does the same.

Signed-off-by: Javier Martinez Canillas <address@hidden>
 include/grub/misc.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/grub/misc.h b/include/grub/misc.h
index cd5a8b4ae82..878ac18da7e 100644
--- a/include/grub/misc.h
+++ b/include/grub/misc.h
@@ -27,6 +27,10 @@
 #include <grub/i18n.h>
 #include <grub/compiler.h>
+#if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))   /* ! C99 */
+#  define restrict   /* disable restrict */
 #define ALIGN_UP(addr, align) \
        ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1))
 #define ALIGN_UP_OVERHEAD(addr, align) ((-(addr)) & ((typeof (addr)) (align) - 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]