aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv/usr
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-09-03 11:53:15 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-05 16:02:49 +0100
commit4f69fb67ee229c7b59ced5db64142b527d74ce7b (patch)
treed9aab519f0caa6086368c297d9849bbf7e4589b0 /arch/riscv/usr
parente94cc18273810ce9cc44d80608042c16eae4e6e4 (diff)
downloadfarga-4f69fb67ee229c7b59ced5db64142b527d74ce7b.tar.gz
farga-4f69fb67ee229c7b59ced5db64142b527d74ce7b.zip
Provide an improved example on early boot stage
This also implied a renaming arch/riscv/bios -> arch/riscv/machine. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'arch/riscv/usr')
-rw-r--r--arch/riscv/usr/basics.c14
1 files changed, 7 insertions, 7 deletions
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");
}