forked from Mirrors/opensbi
treewide: Make carray arrays const and NULL-terminated
This allows the compiler to generate significantly better code, because it does not have to maintain either the loop counter or loop limit. Plus there are half as many symbols to relocate. This also simplifies passing carray arrays to helper functions. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:

committed by
Anup Patel

parent
23ef9c5f00
commit
df1c100001
@@ -13,8 +13,7 @@
|
||||
#include <sbi/sbi_error.h>
|
||||
#include <sbi/sbi_trap.h>
|
||||
|
||||
extern struct sbi_ecall_extension *sbi_ecall_exts[];
|
||||
extern unsigned long sbi_ecall_exts_size;
|
||||
extern struct sbi_ecall_extension *const sbi_ecall_exts[];
|
||||
|
||||
u16 sbi_ecall_version_major(void)
|
||||
{
|
||||
@@ -148,7 +147,7 @@ int sbi_ecall_init(void)
|
||||
struct sbi_ecall_extension *ext;
|
||||
unsigned long i;
|
||||
|
||||
for (i = 0; i < sbi_ecall_exts_size; i++) {
|
||||
for (i = 0; sbi_ecall_exts[i]; i++) {
|
||||
ext = sbi_ecall_exts[i];
|
||||
ret = SBI_ENODEV;
|
||||
|
||||
|
@@ -11,8 +11,7 @@
|
||||
#define ANSI_COLOR_RED "\x1b[31m"
|
||||
#define ANSI_COLOR_RESET "\x1b[0m"
|
||||
|
||||
extern struct sbiunit_test_suite *sbi_unit_tests[];
|
||||
extern unsigned long sbi_unit_tests_size;
|
||||
extern struct sbiunit_test_suite *const sbi_unit_tests[];
|
||||
|
||||
static void run_test_suite(struct sbiunit_test_suite *suite)
|
||||
{
|
||||
@@ -48,6 +47,6 @@ void run_all_tests(void)
|
||||
|
||||
sbi_printf("\n# Running SBIUNIT tests #\n");
|
||||
|
||||
for (i = 0; i < sbi_unit_tests_size; i++)
|
||||
for (i = 0; sbi_unit_tests[i]; i++)
|
||||
run_test_suite(sbi_unit_tests[i]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user