From ac136250b26ddcb54d61ed8428f110b607cb3c88 Mon Sep 17 00:00:00 2001 From: Bill XIE Date: Fri, 8 Jul 2022 16:53:21 +0800 Subject: commonlib: Substitude macro "__unused" in compiler.h Since there are many identifiers whose name contain "__unused" in headers of musl libc, introducing a macro which expands "__unused" to the source of a util may have disastrous effect during its compiling under a musl-based platform. However, it is hard to detect musl at build time as musl is notorious for having explicitly been refusing to add a macro like "__MUSL__" to announce its own presence. Using __always_unused and __maybe_unused for everything may be a good idea. This is how it works in the Linux kernel, so that would at least make us match some other standard rather than doing our own thing (especially since the other compiler.h shorthand macros are also inspired by Linux). Signed-off-by: Bill XIE Change-Id: I547ae3371d7568f5aed732ceefe0130a339716a9 Reviewed-on: https://review.coreboot.org/c/coreboot/+/65717 Tested-by: build bot (Jenkins) Reviewed-by: Felix Singer Reviewed-by: Julius Werner --- src/soc/amd/common/block/lpc/spi_dma.c | 6 ++++-- src/soc/amd/common/psp_verstage/boot_dev.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/soc/amd') diff --git a/src/soc/amd/common/block/lpc/spi_dma.c b/src/soc/amd/common/block/lpc/spi_dma.c index 97ba2be24435..8fbd9bd71027 100644 --- a/src/soc/amd/common/block/lpc/spi_dma.c +++ b/src/soc/amd/common/block/lpc/spi_dma.c @@ -26,7 +26,8 @@ struct spi_dma_transaction { size_t remaining; }; -static void *spi_dma_mmap(const struct region_device *rd, size_t offset, size_t size __unused) +static void *spi_dma_mmap(const struct region_device *rd, size_t offset, + size_t size __always_unused) { const struct mem_region_device *mdev; @@ -35,7 +36,8 @@ static void *spi_dma_mmap(const struct region_device *rd, size_t offset, size_t return &mdev->base[offset]; } -static int spi_dma_munmap(const struct region_device *rd __unused, void *mapping __unused) +static int spi_dma_munmap(const struct region_device *rd __always_unused, + void *mapping __always_unused) { return 0; } diff --git a/src/soc/amd/common/psp_verstage/boot_dev.c b/src/soc/amd/common/psp_verstage/boot_dev.c index 5b25d5962485..4ee78b834912 100644 --- a/src/soc/amd/common/psp_verstage/boot_dev.c +++ b/src/soc/amd/common/psp_verstage/boot_dev.c @@ -11,7 +11,8 @@ #define DEST_BUF_ALIGNMENT 16 -static void *boot_dev_mmap(const struct region_device *rd, size_t offset, size_t size __unused) +static void *boot_dev_mmap(const struct region_device *rd, size_t offset, + size_t size __always_unused) { const struct mem_region_device *mdev; @@ -20,7 +21,8 @@ static void *boot_dev_mmap(const struct region_device *rd, size_t offset, size_t return &(mdev->base[offset]); } -static int boot_dev_munmap(const struct region_device *rd __unused, void *mapping __unused) +static int boot_dev_munmap(const struct region_device *rd __always_unused, + void *mapping __always_unused) { return 0; } -- cgit v1.2.3