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:
Samuel Holland authored and Anup Patel committed 2024-11-28 17:09:17 +05:30
1 parent 23ef9c5f00
commit df1c100001
12 files changed
+26 -38

No files matched your search

+3 -4
View File
@@ -69,10 +69,9 @@ for VAR in ${VAR_LIST}; do
done
printf "\n"
printf "%s *%s[] = {\n" "${TYPE_NAME}" "${ARRAY_NAME}"
printf "%s *const %s[] = {\n" "${TYPE_NAME}" "${ARRAY_NAME}"
for VAR in ${VAR_LIST}; do
printf "\t&%s,\n" "${VAR}"
done
printf "};\n\n"
printf "unsigned long %s_size = sizeof(%s) / sizeof(%s *);\n" "${ARRAY_NAME}" "${ARRAY_NAME}" "${TYPE_NAME}"
printf "\tNULL\n"
printf "};\n"