[kernel] Add "noreturn" syscall option
The new "noreturn" option tag on syscall methods causes those methods to be generated with [[noreturn]] / _Noreturn to avoid clang complaining that other functions marked noreturn, like exit(), because it can't tell that the syscall never returns.
This commit is contained in:
@@ -18,7 +18,7 @@ object process : object {
|
|||||||
method kill [destructor cap:kill]
|
method kill [destructor cap:kill]
|
||||||
|
|
||||||
# Stop all threads and exit the current process
|
# 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
|
param result int32 # The result to retrun to the parent process
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,8 +147,12 @@ for id, scope, method in syscalls.methods:
|
|||||||
if extra_argdefs:
|
if extra_argdefs:
|
||||||
first_args += ", uint64_t *sp"
|
first_args += ", uint64_t *sp"
|
||||||
|
|
||||||
cog.outl(f"""j6_status_t {name} ({", ".join(cxxargdefs)});""")
|
attr = ""
|
||||||
cog.outl(f"""j6_status_t _syscall_verify_{name} ({first_args}) {{""")
|
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:
|
for type, arg in extra_argdefs:
|
||||||
cog.outl(f" {type} {arg} = pop_from<{type}>(sp);")
|
cog.outl(f" {type} {arg} = pop_from<{type}>(sp);")
|
||||||
@@ -178,6 +182,9 @@ for id, scope, method in syscalls.methods:
|
|||||||
cog.outl(f" if (!{arg}_obj) return j6_err_invalid_arg;")
|
cog.outl(f" if (!{arg}_obj) return j6_err_invalid_arg;")
|
||||||
cog.outl()
|
cog.outl()
|
||||||
|
|
||||||
|
if "noreturn" in method.options:
|
||||||
|
cog.outl(f""" {name}({", ".join(args)});""")
|
||||||
|
else:
|
||||||
cog.outl(f""" return {name}({", ".join(args)});""")
|
cog.outl(f""" return {name}({", ".join(args)});""")
|
||||||
cog.outl("}")
|
cog.outl("}")
|
||||||
cog.outl("\n")
|
cog.outl("\n")
|
||||||
|
|||||||
@@ -39,7 +39,11 @@ for id, scope, method in syscalls.methods:
|
|||||||
for type, suffix in param.type.c_names(param.options):
|
for type, suffix in param.type.c_names(param.options):
|
||||||
args.append(f"{type} {param.name}{suffix}")
|
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]]]
|
/// [[[end]]]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user