Hi Jan,
> > __builtin_unreachable() is available since gcc 4.5, released 2010.
> > __attribute__((noreturn)) is avilable since gcc 2.5.0, released 1993.
> > __attribute__((unused)) is available since gcc 2.7, released 1995.
>
> It's probably also worth noting that removing the "#if
> defined(__GNUC__)" special case fine because we depend on gnuefi anyway
> - right?
Well, GNU EFI does actually support a lot of compilers. The interesting
part is in GNU EFI's inc/x86_64/efibind.h:26 (and in the Makefile.defaults
as well), e.g.,
#if defined(GNU_EFI_USE_MS_ABI)
#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__
>= 7)))||(defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3
&& __clang_minor__ >= 2)))
#define HAVE_USE_MS_ABI 1
#else
#error Compiler is too old for GNU_EFI_USE_MS_ABI
#endif
#endif
since you do want to have MS_ABI support. So, reasonable compilers do
support the attributes such that the #else case can simply be dropped
and by this the whole construct.
Christian
> >
> > Signed-off-by: Christian Storm <[email protected]>
> > ---
> > include/ebgpart.h | 4 ----
> > include/utils.h | 12 +-----------
> > tools/ebgpart.c | 2 +-
> > utils.c | 4 ++--
> > 4 files changed, 4 insertions(+), 18 deletions(-)
> >
> > diff --git a/include/ebgpart.h b/include/ebgpart.h
> > index d02cfbe..85b3ad7 100644
> > --- a/include/ebgpart.h
> > +++ b/include/ebgpart.h
> > @@ -33,10 +33,6 @@
> > if (verbosity) fprintf(o, __VA_ARGS__)
> > #endif
> >
> > -#ifndef __unused
> > -#define __unused __attribute__((unused))
> > -#endif
> > -
> > #include <unistd.h>
> > #include <errno.h>
> > #include <stdio.h>
> > diff --git a/include/utils.h b/include/utils.h
> > index ff8f9ef..b496031 100644
> > --- a/include/utils.h
> > +++ b/include/utils.h
> > @@ -20,16 +20,6 @@
> >
> > #define MAX_INFO_SIZE 1024
> >
> > -#if defined(__GNUC__)
> > -#define __noreturn __attribute__((noreturn))
> > -#define unreachable() __builtin_unreachable()
> > -#else
> > -#define __noreturn /**/
> > -#define unreachable()
> > \
> > - do { \
> > - } while (1)
> > -#endif
> > -
> > typedef struct _VOLUME_DESC {
> > EFI_DEVICE_PATH *devpath;
> > CHAR16 *fslabel;
> > @@ -43,7 +33,7 @@ extern UINTN volume_count;
> > typedef enum { DOSFSLABEL, CUSTOMLABEL, NOLABEL } LABELMODE;
> >
> > uint32_t calc_crc32(void *data, int32_t size);
> > -void __noreturn error_exit(CHAR16 *message, EFI_STATUS status);
> > +void __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS
> > status);
> > VOID *mmalloc(UINTN bytes);
> > EFI_STATUS mfree(VOID *p);
> > CHAR16 *get_volume_label(EFI_FILE_HANDLE fh);
> > diff --git a/tools/ebgpart.c b/tools/ebgpart.c
> > index fc3bf3b..7880101 100644
> > --- a/tools/ebgpart.c
> > +++ b/tools/ebgpart.c
> > @@ -553,7 +553,7 @@ PedDisk *ped_disk_new(const PedDevice *dev)
> > return &g_ped_dummy_disk;
> > }
> >
> > -PedPartition *ped_disk_next_partition(const PedDisk *__unused pd,
> > +PedPartition *ped_disk_next_partition(const PedDisk
> > *__attribute__((unused)) pd,
> > const PedPartition *part)
> > {
> > return part->next;
> > diff --git a/utils.c b/utils.c
> > index cb9569d..422356f 100644
> > --- a/utils.c
> > +++ b/utils.c
> > @@ -55,12 +55,12 @@ uint32_t calc_crc32(void *data, int32_t size)
> > return crc;
> > }
> >
> > -void __noreturn error_exit(CHAR16 *message, EFI_STATUS status)
> > +void __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS
> > status)
> > {
> > ERROR(L"%s ( %r )\n", message, status);
> > uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000);
> > uefi_call_wrapper(BS->Exit, 4, this_image, status, 0, NULL);
> > - unreachable();
> > + __builtin_unreachable();
> > }
> >
> > VOID *mmalloc(UINTN bytes)
> >
>
>
> --
> Siemens AG, T RDA IOT
> Corporate Competence Center Embedded Linux
>
Besten Gruß,
Christian
--
Dr. Christian Storm
Siemens AG, Technology, T RDA IOT SES-DE
Otto-Hahn-Ring 6, 81739 München, Germany
--
You received this message because you are subscribed to the Google Groups "EFI
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/efibootguard-dev/20210108202001.pfnaj5f3vlyfwtmb%40MD1ZFJVC.ad001.siemens.net.