mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
libc now has exit() and abort() functions.
This commit is contained in:
parent
4bc2841ef0
commit
d3a7b18f69
5 changed files with 24 additions and 22 deletions
|
@ -18,7 +18,7 @@ endif
|
|||
|
||||
LIBMAXSIROOT=$(OSROOT)/libmaxsi
|
||||
|
||||
LIBC=$(LIBMAXSIROOT)/libc.a $(LIBMAXSIROOT)/start.o
|
||||
LIBC=$(LIBMAXSIROOT)/start.o $(LIBMAXSIROOT)/libc.a
|
||||
LIBS=$(LIBC)
|
||||
|
||||
CPPFLAGS=$(CPUDEFINES)
|
||||
|
|
|
@ -31,6 +31,8 @@ namespace Maxsi
|
|||
{
|
||||
int Execute(const char* filepath, int argc, const char** argv);
|
||||
void PrintPathFiles();
|
||||
void Abort();
|
||||
void Exit(int code);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,24 @@ namespace Maxsi
|
|||
{
|
||||
SysPrintPathFiles();
|
||||
}
|
||||
|
||||
void Abort()
|
||||
{
|
||||
// TODO: Send SIGABRT instead!
|
||||
Exit(128 + 6);
|
||||
}
|
||||
|
||||
extern "C" void abort() { return Abort(); }
|
||||
|
||||
void Exit(int code)
|
||||
{
|
||||
const char* sh = "sh";
|
||||
const char* argv[] = { sh };
|
||||
Execute("sh", 1, argv);
|
||||
while(true);
|
||||
}
|
||||
|
||||
extern "C" void exit(int code) { return Exit(code); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,18 +36,7 @@ _start:
|
|||
push $0 # argc
|
||||
call main
|
||||
|
||||
# HACK: Just restart the shell!
|
||||
mov $10, %eax
|
||||
mov $SH, %ebx
|
||||
int $0x80
|
||||
|
||||
# Now return mains result when exiting the process
|
||||
mov %eax, %ebx
|
||||
mov $1, %eax
|
||||
mov $0x0, %ebx # TODO: This syscall exits a thread, not a process!
|
||||
int $0x80
|
||||
|
||||
.section .data
|
||||
SH:
|
||||
.asciz "sh"
|
||||
# Terminate the process with main's exit code.
|
||||
push %eax
|
||||
call exit
|
||||
|
||||
|
|
|
@ -48,13 +48,6 @@ namespace Maxsi
|
|||
SysExit(Result);
|
||||
}
|
||||
|
||||
#ifdef LIBMAXSI_LIBC
|
||||
extern "C" void exit(int result)
|
||||
{
|
||||
SysExit(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
void ThreadStartup(size_t Id, Entry Start, void* Parameter)
|
||||
{
|
||||
Exit(Start(Parameter));
|
||||
|
|
Loading…
Reference in a new issue