aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/riscv64/kernel/arch.c2
-rw-r--r--include/kmi/attrs.h4
-rw-r--r--scripts/makefile2
-rw-r--r--src/string.c3
-rw-r--r--src/uapi/ipc.c3
-rw-r--r--src/uapi/proc.c5
6 files changed, 13 insertions, 6 deletions
diff --git a/arch/riscv64/kernel/arch.c b/arch/riscv64/kernel/arch.c
index c4009e7..ff2c04c 100644
--- a/arch/riscv64/kernel/arch.c
+++ b/arch/riscv64/kernel/arch.c
@@ -19,7 +19,7 @@ id_t hartid_to_cpuid(id_t hart)
if (cpuid_to_hartid(i) == hart)
return i;
- error("failed to match hart id %d to cpu id\n", hart);
+ error("failed to match hart id %ld to cpu id\n", hart);
/* default to zero, though this should maybe be a panic? */
return 0;
}
diff --git a/include/kmi/attrs.h b/include/kmi/attrs.h
index 5c15201..f789310 100644
--- a/include/kmi/attrs.h
+++ b/include/kmi/attrs.h
@@ -59,6 +59,10 @@
/** Weak linkage. */
#define __weak __attribute__((weak))
+/** Tell optimizer something is used, even though it might not seem like it.
+ * Special functions like memcpy() may need it. */
+#define __used __attribute__((used))
+
/** Main entry point of kernel proper. */
#define __main __section(".kernel.start") __noinline
diff --git a/scripts/makefile b/scripts/makefile
index 762c5c9..8c0b5a4 100644
--- a/scripts/makefile
+++ b/scripts/makefile
@@ -1,7 +1,7 @@
# this could be done better
RELEASE ?= 0
OPTFLAGS != [ "$(RELEASE)" != "0" ] \
- && echo "-O3 -flto" \
+ && echo "-O2 -flto=auto" \
|| echo "-O0"
DEBUG ?= 1
diff --git a/src/string.c b/src/string.c
index 8c88e65..4eaaf68 100644
--- a/src/string.c
+++ b/src/string.c
@@ -287,7 +287,8 @@ __weak void *memchr(const void *ptr, int val, size_t num)
}
#undef memcpy
-__weak void *memcpy(void * restrict dst, const void * restrict src, size_t num)
+__weak __used void *memcpy(void * restrict dst, const void * restrict src,
+ size_t num)
{
const char *m1 = (const char *)src;
char *m2 = (char *)dst;
diff --git a/src/uapi/ipc.c b/src/uapi/ipc.c
index ddc7242..3c24f1c 100644
--- a/src/uapi/ipc.c
+++ b/src/uapi/ipc.c
@@ -153,7 +153,8 @@ static __noreturn void __run_notify(struct tcb *t, struct tcb *r)
/* if we're in the root process, we can safely handle signals and
* becoming orphaned */
if (!is_rpc(t))
- set_bits(flags, t->notify_flags & (NOTIFY_SIGNAL | NOTIFY_ORPHANED));
+ set_bits(flags,
+ t->notify_flags & (NOTIFY_SIGNAL | NOTIFY_ORPHANED));
/* handle critical notifications with special care */
if (is_set(t->notify_flags, NOTIFY_IRQ | NOTIFY_TIMER)) {
diff --git a/src/uapi/proc.c b/src/uapi/proc.c
index 5b64dce..85acb29 100644
--- a/src/uapi/proc.c
+++ b/src/uapi/proc.c
@@ -97,7 +97,7 @@ SYSCALL_DEFINE2(exec)(struct tcb *t, sys_arg_t bin, sys_arg_t interp)
/* exec is only allowed if we own all our own resources */
if (t->refcount)
- return_args1(t, ERR_INVAL)
+ return_args1(t, ERR_INVAL);
/* mark binary to be kept */
struct mem_region *b = find_used_region(&t->sp_r, bin);
@@ -267,7 +267,8 @@ SYSCALL_DEFINE1(detach)(struct tcb *t, sys_arg_t tid)
orphanize(o);
/* generally the thread shouldn't do anything with this information, but
- * it fits really nicely into the notification framework so just do it */
+ * it fits really nicely into the notification framework so just do it
+ */
notify(o, NOTIFY_ORPHANED);
return_args1(t, OK);