Add program api to tinyrt

This commit is contained in:
flysand7 2023-07-25 16:24:19 +11:00
parent 8a93fa68ff
commit 1007f634fb
5 changed files with 20 additions and 2 deletions

View File

@ -3,6 +3,7 @@
// Pre-C23 keyword macros and stddef
#define static_assert _Static_assert
#define noreturn _Noreturn
#define NULL ((void *)0)
// Platform macros

View File

@ -167,8 +167,9 @@ static inline i64 syscall_close(u32 fd) {
return __syscall1(SYS_close, fd);
}
static inline i64 syscall_exit(int code) {
return __syscall1(SYS_exit, (i64)code);
static inline noreturn void syscall_exit(int code) {
__syscall1(SYS_exit, (i64)code);
__builtin_unreachable();
}
static inline i64 syscall_arch_prctl_set(int code, u64 value) {

View File

@ -55,3 +55,7 @@ static RT_Status rt_file_close(RT_File *file) {
}
return RT_STATUS_OK;
}
static noreturn void rt_program_exit(int code) {
syscall_exit(code);
}

View File

@ -11,3 +11,5 @@
# #define RT_API_FILE
file = 1
program = 1
shell = 0

View File

@ -41,6 +41,16 @@ static bool _rt_api_tmpfile;
static RT_Status rt_init();
static RT_Status rt_deinit();
// Program API
#if RT_API_PROGRAM == 1
static noreturn void rt_program_exit(int code);
#endif
#if RT_API_ENVIRONMENT == 1
static RT_Status rt_shell_exec(char const *cmd);
static RT_Status rt_env_get(char const *name);
#endif
// File API
#if RT_API_FILE == 1
struct RT_File typedef RT_File;