From ed8390ec50b2decdf18a3416d07d37222cb0130d Mon Sep 17 00:00:00 2001 From: Mathew King Date: Tue, 5 Nov 2019 22:21:33 +0000 Subject: Revert "Clean up implicit fall through." This reverts commit 6a703f5b0edfdbf2eee72d59499f73585262a46f. Reason for revert: This change breaks building coreboot Original change's description: > Clean up implicit fall through. > > Directly use the __attribute__ ((fallthrough)) instead of > a macro. > This was suggested in CL:1772474. > > BUG=chromium:997709 > TEST=CQ > BRANCH=None > > Change-Id: Ic6cd417d7c735395a4b136dbb0879a6f1716da98 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1897360 > Tested-by: Manoj Gupta > Reviewed-by: Julius Werner > Commit-Queue: Manoj Gupta Bug: chromium:997709 Change-Id: Icd0de8bcdee44d1b41f313a4f5aaba8108f734ab Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1899735 Reviewed-by: Mathew King Reviewed-by: Julius Werner Commit-Queue: Julius Werner Tested-by: Julius Werner --- firmware/2lib/include/2common.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'firmware/2lib/include/2common.h') diff --git a/firmware/2lib/include/2common.h b/firmware/2lib/include/2common.h index b4e941c5..6c5563a6 100644 --- a/firmware/2lib/include/2common.h +++ b/firmware/2lib/include/2common.h @@ -71,6 +71,27 @@ struct vb2_public_key; #endif #endif +// Have a generic fall-through for different versions of C/C++. +// Taken from boringssl. +#if defined(__cplusplus) && __cplusplus >= 201703L +#define VBOOT_FALLTHROUGH [[fallthrough]] +#elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__clang__) +#define VBOOT_FALLTHROUGH [[clang::fallthrough]] +#elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__GNUC__) && \ + __GNUC__ >= 7 +#define VBOOT_FALLTHROUGH [[gnu::fallthrough]] +#elif defined(__GNUC__) && __GNUC__ >= 7 // gcc 7 +#define VBOOT_FALLTHROUGH __attribute__ ((fallthrough)) +#elif defined(__clang__) +#if __has_attribute(fallthrough) +#define VBOOT_FALLTHROUGH __attribute__ ((fallthrough)) +#else // clang versions that do not support fallthrough. +#define VBOOT_FALLTHROUGH +#endif +#else // C++11 on gcc 6, and all other cases +#define VBOOT_FALLTHROUGH +#endif + /** * Round up a number to a multiple of VB2_WORKBUF_ALIGN * -- cgit v1.2.1