From: Marco Schlumpp Date: Fri, 25 Mar 2022 15:40:15 +0000 (+0100) Subject: lib/nolibc: Implement exit function X-Git-Tag: RELEASE-0.13.0~83 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2188d8dcd394cca547de25e82905c200e5971a22;p=unikraft%2Funikraft.git lib/nolibc: Implement exit function The behaviour is similar to returning a value from main. Checkpatch-Ignore: EMBEDDED_FUNCTION_NAME Signed-off-by: Marco Schlumpp Reviewed-by: Razvan Deaconescu Reviewed-by: Marc Rittinghaus Approved-by: Marc Rittinghaus Tested-by: Unikraft CI GitHub-Closes: #627 --- diff --git a/lib/nolibc/exportsyms.uk b/lib/nolibc/exportsyms.uk index 5a8ce8384..852a431f0 100644 --- a/lib/nolibc/exportsyms.uk +++ b/lib/nolibc/exportsyms.uk @@ -43,6 +43,7 @@ putchar # stdlib abort +exit strtol strtoul strtoll diff --git a/lib/nolibc/include/stdlib.h b/lib/nolibc/include/stdlib.h index eb434e660..b06b4bbba 100644 --- a/lib/nolibc/include/stdlib.h +++ b/lib/nolibc/include/stdlib.h @@ -117,6 +117,8 @@ static inline void *memalign(size_t align, size_t size) void abort(void) __noreturn; +void exit(int status) __noreturn; + void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); diff --git a/lib/nolibc/stdlib.c b/lib/nolibc/stdlib.c index a2779bda1..30963f659 100644 --- a/lib/nolibc/stdlib.c +++ b/lib/nolibc/stdlib.c @@ -431,3 +431,11 @@ void abort(void) uk_pr_crit("Abnormal termination!\n"); ukplat_crash(); } + +#ifndef CONFIG_LIBPOSIX_PROCESS +void exit(int status) +{ + uk_pr_info("exit called with status %d, halting system\n", status); + ukplat_terminate(status); +} +#endif /* !CONFIG_LIBPOSIX_PROCESS */