summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2018-04-21 14:45:32 -0600
committerAaron Durbin <adurbin@chromium.org>2018-04-24 14:37:59 +0000
commit6403167d290da235a732bd2d6157aa2124fb403a (patch)
tree9c4805af37a31830934f91098d299e967df930c6 /src/lib
parent38fd6685e9da61daadc96a8d537e6966dfe3b219 (diff)
compiler.h: add __weak macro
Instead of writing out '__attribute__((weak))' use a shorter form. Change-Id: If418a1d55052780077febd2d8f2089021f414b91 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/25767 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Justin TerAvest <teravest@chromium.org>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/boot_device.c3
-rw-r--r--src/lib/bootblock.c9
-rw-r--r--src/lib/cbfs.c3
-rw-r--r--src/lib/cbmem_common.c3
-rw-r--r--src/lib/coreboot_table.c11
-rw-r--r--src/lib/fallback_boot.c3
-rw-r--r--src/lib/gpio.c5
-rw-r--r--src/lib/hardwaremain.c3
-rw-r--r--src/lib/imd_cbmem.c3
-rw-r--r--src/lib/prog_loaders.c7
-rw-r--r--src/lib/prog_ops.c7
-rw-r--r--src/lib/reset.c7
-rw-r--r--src/lib/timer.c3
-rw-r--r--src/lib/timestamp.c4
-rw-r--r--src/lib/wrdd.c3
15 files changed, 44 insertions, 30 deletions
diff --git a/src/lib/boot_device.c b/src/lib/boot_device.c
index e7968f4fa9..c5afce7161 100644
--- a/src/lib/boot_device.c
+++ b/src/lib/boot_device.c
@@ -14,8 +14,9 @@
*/
#include <boot_device.h>
+#include <compiler.h>
-void __attribute__((weak)) boot_device_init(void)
+void __weak boot_device_init(void)
{
/* Provide weak do-nothing init. */
}
diff --git a/src/lib/bootblock.c b/src/lib/bootblock.c
index 2e228c6d32..bee28459ef 100644
--- a/src/lib/bootblock.c
+++ b/src/lib/bootblock.c
@@ -16,6 +16,7 @@
#include <arch/exception.h>
#include <bootblock_common.h>
+#include <compiler.h>
#include <console/console.h>
#include <delay.h>
#include <pc80/mc146818rtc.h>
@@ -25,10 +26,10 @@
DECLARE_OPTIONAL_REGION(timestamp);
-__attribute__((weak)) void bootblock_mainboard_early_init(void) { /* no-op */ }
-__attribute__((weak)) void bootblock_soc_early_init(void) { /* do nothing */ }
-__attribute__((weak)) void bootblock_soc_init(void) { /* do nothing */ }
-__attribute__((weak)) void bootblock_mainboard_init(void) { /* do nothing */ }
+__weak void bootblock_mainboard_early_init(void) { /* no-op */ }
+__weak void bootblock_soc_early_init(void) { /* do nothing */ }
+__weak void bootblock_soc_init(void) { /* do nothing */ }
+__weak void bootblock_mainboard_init(void) { /* do nothing */ }
asmlinkage void bootblock_main_with_timestamp(uint64_t base_timestamp)
{
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index 9e81bd3a3a..2dcd429361 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -20,6 +20,7 @@
#include <boot_device.h>
#include <cbfs.h>
#include <commonlib/compression.h>
+#include <compiler.h>
#include <endian.h>
#include <lib.h>
#include <symbols.h>
@@ -308,7 +309,7 @@ static int cbfs_master_header_props(struct cbfs_props *props)
/* This struct is marked as weak to allow a particular platform to
* override the master header logic. This implementation should work for most
* devices. */
-const struct cbfs_locator __attribute__((weak)) cbfs_master_header_locator = {
+const struct cbfs_locator __weak cbfs_master_header_locator = {
.name = "Master Header Locator",
.locate = cbfs_master_header_props,
};
diff --git a/src/lib/cbmem_common.c b/src/lib/cbmem_common.c
index 166ec87013..2451fca8c7 100644
--- a/src/lib/cbmem_common.c
+++ b/src/lib/cbmem_common.c
@@ -14,6 +14,7 @@
*/
#include <console/console.h>
#include <cbmem.h>
+#include <compiler.h>
#include <bootstate.h>
#include <rules.h>
#include <symbols.h>
@@ -37,7 +38,7 @@ void cbmem_run_init_hooks(int is_recovery)
}
}
-void __attribute__((weak)) cbmem_fail_resume(void)
+void __weak cbmem_fail_resume(void)
{
}
diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c
index e786443cf6..2970215034 100644
--- a/src/lib/coreboot_table.c
+++ b/src/lib/coreboot_table.c
@@ -16,6 +16,7 @@
*/
#include <arch/cbconfig.h>
+#include <compiler.h>
#include <console/console.h>
#include <console/uart.h>
#include <ip_checksum.h>
@@ -244,9 +245,9 @@ static inline void lb_vboot_handoff(struct lb_header *header) {}
#endif /* CONFIG_VBOOT */
#endif /* CONFIG_CHROMEOS */
-__attribute__((weak)) uint32_t board_id(void) { return UNDEFINED_STRAPPING_ID; }
-__attribute__((weak)) uint32_t ram_code(void) { return UNDEFINED_STRAPPING_ID; }
-__attribute__((weak)) uint32_t sku_id(void) { return UNDEFINED_STRAPPING_ID; }
+__weak uint32_t board_id(void) { return UNDEFINED_STRAPPING_ID; }
+__weak uint32_t ram_code(void) { return UNDEFINED_STRAPPING_ID; }
+__weak uint32_t sku_id(void) { return UNDEFINED_STRAPPING_ID; }
static void lb_board_id(struct lb_header *header)
{
@@ -441,7 +442,7 @@ static void lb_record_version_timestamp(struct lb_header *header)
rec->timestamp = coreboot_version_timestamp;
}
-void __attribute__((weak)) lb_board(struct lb_header *header) { /* NOOP */ }
+void __weak lb_board(struct lb_header *header) { /* NOOP */ }
/*
* It's possible that the system is using a SPI flash as the boot device,
@@ -449,7 +450,7 @@ void __attribute__((weak)) lb_board(struct lb_header *header) { /* NOOP */ }
* case don't provide any information as the correct information is
* not known.
*/
-void __attribute__((weak)) lb_spi_flash(struct lb_header *header) { /* NOOP */ }
+void __weak lb_spi_flash(struct lb_header *header) { /* NOOP */ }
static struct lb_forward *lb_forward(struct lb_header *header,
struct lb_header *next_header)
diff --git a/src/lib/fallback_boot.c b/src/lib/fallback_boot.c
index 443f209b1d..a079910262 100644
--- a/src/lib/fallback_boot.c
+++ b/src/lib/fallback_boot.c
@@ -1,8 +1,9 @@
#include <fallback.h>
+#include <compiler.h>
#include <watchdog.h>
/* Implement platform specific override. */
-void __attribute__((weak)) set_boot_successful(void) { }
+void __weak set_boot_successful(void) { }
void boot_successful(void)
{
diff --git a/src/lib/gpio.c b/src/lib/gpio.c
index 48db262a11..b52d7b0c5f 100644
--- a/src/lib/gpio.c
+++ b/src/lib/gpio.c
@@ -15,6 +15,7 @@
#include <assert.h>
#include <base3.h>
+#include <compiler.h>
#include <console/console.h>
#include <delay.h>
#include <gpio.h>
@@ -168,13 +169,13 @@ int _gpio_base3_value(const gpio_t gpio[], int num_gpio, int binary_first)
}
/* Default handler for ACPI path is to return NULL */
-__attribute__((weak)) const char *gpio_acpi_path(gpio_t gpio)
+__weak const char *gpio_acpi_path(gpio_t gpio)
{
return NULL;
}
/* Default handler returns 0 because type of gpio_t is unknown */
-__attribute__((weak)) uint16_t gpio_acpi_pin(gpio_t gpio)
+__weak uint16_t gpio_acpi_pin(gpio_t gpio)
{
return 0;
}
diff --git a/src/lib/hardwaremain.c b/src/lib/hardwaremain.c
index 0deab4bd0b..6fd55d7758 100644
--- a/src/lib/hardwaremain.c
+++ b/src/lib/hardwaremain.c
@@ -21,6 +21,7 @@
#include <adainit.h>
#include <arch/exception.h>
#include <bootstate.h>
+#include <compiler.h>
#include <console/console.h>
#include <console/post_codes.h>
#include <cbmem.h>
@@ -115,7 +116,7 @@ static struct boot_state boot_states[] = {
BS_INIT_ENTRY(BS_PAYLOAD_BOOT, bs_payload_boot),
};
-void __attribute__((weak)) arch_bootstate_coreboot_exit(void) { }
+void __weak arch_bootstate_coreboot_exit(void) { }
static boot_state_t bs_pre_device(void *arg)
{
diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c
index 5713c2c328..cc1294f353 100644
--- a/src/lib/imd_cbmem.c
+++ b/src/lib/imd_cbmem.c
@@ -15,6 +15,7 @@
#include <bootstate.h>
#include <bootmem.h>
+#include <compiler.h>
#include <console/console.h>
#include <cbmem.h>
#include <imd.h>
@@ -109,7 +110,7 @@ void cbmem_initialize_empty(void)
cbmem_initialize_empty_id_size(0, 0);
}
-void __attribute__((weak)) cbmem_top_init(void)
+void __weak cbmem_top_init(void)
{
}
diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c
index 128869b2ba..8a6d6afafa 100644
--- a/src/lib/prog_loaders.c
+++ b/src/lib/prog_loaders.c
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <cbfs.h>
#include <cbmem.h>
+#include <compiler.h>
#include <console/console.h>
#include <fallback.h>
#include <halt.h>
@@ -71,9 +72,9 @@ fail:
halt();
}
-void __attribute__((weak)) stage_cache_add(int stage_id,
+void __weak stage_cache_add(int stage_id,
const struct prog *stage) {}
-void __attribute__((weak)) stage_cache_load_stage(int stage_id,
+void __weak stage_cache_load_stage(int stage_id,
struct prog *stage) {}
static void ramstage_cache_invalid(void)
@@ -164,7 +165,7 @@ fail:
static struct prog global_payload =
PROG_INIT(PROG_PAYLOAD, CONFIG_CBFS_PREFIX "/payload");
-void __attribute__((weak)) mirror_payload(struct prog *payload)
+void __weak mirror_payload(struct prog *payload)
{
}
diff --git a/src/lib/prog_ops.c b/src/lib/prog_ops.c
index 44a32d19bf..5e670d34c0 100644
--- a/src/lib/prog_ops.c
+++ b/src/lib/prog_ops.c
@@ -14,6 +14,7 @@
* GNU General Public License for more details.
*/
+#include <compiler.h>
#include <program_loading.h>
/* For each segment of a program loaded this function is called*/
@@ -23,13 +24,13 @@ void prog_segment_loaded(uintptr_t start, size_t size, int flags)
arch_segment_loaded(start, size, flags);
}
-void __attribute__((weak)) platform_segment_loaded(uintptr_t start,
+void __weak platform_segment_loaded(uintptr_t start,
size_t size, int flags)
{
/* do nothing */
}
-void __attribute__((weak)) arch_segment_loaded(uintptr_t start, size_t size,
+void __weak arch_segment_loaded(uintptr_t start, size_t size,
int flags)
{
/* do nothing */
@@ -41,7 +42,7 @@ void prog_run(struct prog *prog)
arch_prog_run(prog);
}
-void __attribute__((weak)) platform_prog_run(struct prog *prog)
+void __weak platform_prog_run(struct prog *prog)
{
/* do nothing */
}
diff --git a/src/lib/reset.c b/src/lib/reset.c
index 703118a6f5..2c9529277e 100644
--- a/src/lib/reset.c
+++ b/src/lib/reset.c
@@ -14,6 +14,7 @@
*/
#include <arch/cache.h>
+#include <compiler.h>
#include <console/console.h>
#include <halt.h>
#include <reset.h>
@@ -27,10 +28,10 @@ __attribute__((noreturn)) static void __hard_reset(void) {
}
/* Not all platforms implement all reset types. Fall back to hard_reset. */
-__attribute__((weak)) void do_global_reset(void) { __hard_reset(); }
-__attribute__((weak)) void do_soft_reset(void) { __hard_reset(); }
+__weak void do_global_reset(void) { __hard_reset(); }
+__weak void do_soft_reset(void) { __hard_reset(); }
-__attribute__((weak)) void soc_reset_prepare(enum reset_type rt) { /* no-op */ }
+__weak void soc_reset_prepare(enum reset_type rt) { /* no-op */ }
void global_reset(void)
{
diff --git a/src/lib/timer.c b/src/lib/timer.c
index adc0d07cef..625bfc0a77 100644
--- a/src/lib/timer.c
+++ b/src/lib/timer.c
@@ -13,12 +13,13 @@
* GNU General Public License for more details.
*/
+#include <compiler.h>
#include <console/console.h>
#include <timer.h>
#include <delay.h>
#include <thread.h>
-__attribute__((weak)) void init_timer(void) { /* do nothing */ }
+__weak void init_timer(void) { /* do nothing */ }
void udelay(unsigned int usec)
{
diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c
index 2ab725372b..bf49365c86 100644
--- a/src/lib/timestamp.c
+++ b/src/lib/timestamp.c
@@ -361,7 +361,7 @@ ROMSTAGE_CBMEM_INIT_HOOK(timestamp_sync_cache_to_cbmem)
RAMSTAGE_CBMEM_INIT_HOOK(timestamp_sync_cache_to_cbmem)
/* Provide default timestamp implementation using monotonic timer. */
-uint64_t __attribute__((weak)) timestamp_get(void)
+uint64_t __weak timestamp_get(void)
{
struct mono_time t1, t2;
@@ -375,7 +375,7 @@ uint64_t __attribute__((weak)) timestamp_get(void)
}
/* Like timestamp_get() above this matches up with microsecond granularity. */
-int __attribute__((weak)) timestamp_tick_freq_mhz(void)
+int __weak timestamp_tick_freq_mhz(void)
{
return 1;
}
diff --git a/src/lib/wrdd.c b/src/lib/wrdd.c
index da082f8163..a8390cf732 100644
--- a/src/lib/wrdd.c
+++ b/src/lib/wrdd.c
@@ -14,9 +14,10 @@
* GNU General Public License for more details.
*/
+#include <compiler.h>
#include <wrdd.h>
-uint16_t __attribute__((weak)) wifi_regulatory_domain(void)
+uint16_t __weak wifi_regulatory_domain(void)
{
return WRDD_DEFAULT_REGULATORY_DOMAIN;
}