diff --git a/definitions/objects/process.def b/definitions/objects/process.def index 787e8f3..3a4ec9f 100644 --- a/definitions/objects/process.def +++ b/definitions/objects/process.def @@ -18,7 +18,7 @@ object process : object { method kill [destructor cap:kill] # Stop all threads and exit the current process - method exit [static] { + method exit [static noreturn] { param result int32 # The result to retrun to the parent process } diff --git a/src/kernel/syscall_verify.cpp.cog b/src/kernel/syscall_verify.cpp.cog index 80cecd8..78cb60b 100644 --- a/src/kernel/syscall_verify.cpp.cog +++ b/src/kernel/syscall_verify.cpp.cog @@ -147,8 +147,12 @@ for id, scope, method in syscalls.methods: if extra_argdefs: first_args += ", uint64_t *sp" - cog.outl(f"""j6_status_t {name} ({", ".join(cxxargdefs)});""") - cog.outl(f"""j6_status_t _syscall_verify_{name} ({first_args}) {{""") + attr = "" + if "noreturn" in method.options: + attr = "[[noreturn]] " + + cog.outl(f"""{attr}j6_status_t {name} ({", ".join(cxxargdefs)});""") + cog.outl(f"""{attr}j6_status_t _syscall_verify_{name} ({first_args}) {{""") for type, arg in extra_argdefs: cog.outl(f" {type} {arg} = pop_from<{type}>(sp);") @@ -178,7 +182,10 @@ for id, scope, method in syscalls.methods: cog.outl(f" if (!{arg}_obj) return j6_err_invalid_arg;") cog.outl() - cog.outl(f""" return {name}({", ".join(args)});""") + if "noreturn" in method.options: + cog.outl(f""" {name}({", ".join(args)});""") + else: + cog.outl(f""" return {name}({", ".join(args)});""") cog.outl("}") cog.outl("\n") ]]]*/ diff --git a/src/libraries/j6/j6/syscalls.h.cog b/src/libraries/j6/j6/syscalls.h.cog index c8ade0b..de181e5 100644 --- a/src/libraries/j6/j6/syscalls.h.cog +++ b/src/libraries/j6/j6/syscalls.h.cog @@ -39,7 +39,11 @@ for id, scope, method in syscalls.methods: for type, suffix in param.type.c_names(param.options): args.append(f"{type} {param.name}{suffix}") - cog.outl(f"""j6_status_t j6_{name} ({", ".join(args)});""") + attr = "" + if "noreturn" in method.options: + attr += "_Noreturn " + + cog.outl(f"""{attr}j6_status_t j6_{name} ({", ".join(args)});""") ]]]*/ /// [[[end]]]