From 4f69fb67ee229c7b59ced5db64142b527d74ce7b Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 3 Sep 2024 11:53:15 +0200 Subject: Provide an improved example on early boot stage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also implied a renaming arch/riscv/bios -> arch/riscv/machine. Signed-off-by: Miquel Sabaté Solà --- arch/riscv/usr/basics.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'arch/riscv/usr/basics.c') diff --git a/arch/riscv/usr/basics.c b/arch/riscv/usr/basics.c index 4fa7df3..9194565 100644 --- a/arch/riscv/usr/basics.c +++ b/arch/riscv/usr/basics.c @@ -28,12 +28,12 @@ void test_factorial(void) * * Implemented in string.S */ -char * reverse_string(char *str); +char *reverse_string(char *str); void test_reverse_string(void) { assert(reverse_string(NULL) == NULL); - assert(reverse_string("") == ""); + assert(strlen(reverse_string("")) == 0); char s1[] = "This is a string."; assert(strcmp(reverse_string(s1), ".gnirts a si sihT") == 0); @@ -75,13 +75,13 @@ bool greater_than_ten(double a, uint64_t b); void test_greater_than_ten(void) { assert(!greater_than_ten(2.3, 1)); // 4.3 - assert(greater_than_ten(2.3, 2)); // 10.6 + assert(greater_than_ten(2.3, 2)); // 10.6 printf("greater_than_ten:\tOK\n"); } /* - * Atomically add the integer pointed by `a` with the given `value`. Although + * Atomically add the integer pointed by `a` with the given `value`. * this is a function, I've checked that the assembly produced by GCC on a * decent optimization level actually inlines this. */ @@ -111,11 +111,11 @@ static inline void atomic_add(uint64_t *a, uint64_t value) * * See: https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html. */ - asm volatile(".Latomic_add_retry:\n\t" + asm volatile(".Latomic_add_retry:\n\t" "amoadd.d t0, %1, %0\n\t" "beqz t0, .Latomic_add_retry" - : "+A" (*a) - : "r" (value) + : "+A"(*a) + : "r"(value) : "memory"); } -- cgit v1.2.3