diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-07-27 20:29:28 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-07-27 20:29:28 +0300 |
| commit | 3212707a9ab549119ad0ad6441a07fe774c99f3b (patch) | |
| tree | 9df1e69c92dabfea37202008f77f8a100c0a7de4 /arch/riscv64/kernel | |
| parent | a26fb216729ba7a7d0fbfc97c2082c9db512aa36 (diff) | |
| download | kmi-3212707a9ab549119ad0ad6441a07fe774c99f3b.tar.gz kmi-3212707a9ab549119ad0ad6441a07fe774c99f3b.zip | |
use nifty variable argument count trick
+ Found it in newlib. This allows the compiler to more effectively
optimize away unnecessary register operations. Applied to both kernel
and init.c for a slight speed increase.
I really should move init.c to some other repository though, the
binary files are starting to get annoying
Diffstat (limited to 'arch/riscv64/kernel')
| -rw-r--r-- | arch/riscv64/kernel/proc.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/arch/riscv64/kernel/proc.c b/arch/riscv64/kernel/proc.c index 2cc3f36..a7721e2 100644 --- a/arch/riscv64/kernel/proc.c +++ b/arch/riscv64/kernel/proc.c @@ -35,15 +35,15 @@ void run_init(struct tcb *t, void *fdt) unreachable(); } -void set_args(struct tcb *t, struct sys_ret a) +void set_args(struct tcb *t, size_t n, struct sys_ret a) { struct riscv_regs *r = (struct riscv_regs *)(t->regs) - 1; - r->a0 = a.s; - r->a1 = a.ar0; - r->a2 = a.ar1; - r->a3 = a.ar2; - r->a4 = a.ar3; - r->a5 = a.ar4; + if (n >= 1) r->a0 = a.s; + if (n >= 2) r->a1 = a.ar0; + if (n >= 3) r->a2 = a.ar1; + if (n >= 4) r->a3 = a.ar2; + if (n >= 5) r->a4 = a.ar3; + if (n >= 6) r->a5 = a.ar4; } struct sys_ret get_args(struct tcb *t) |
