1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:47:35 +00:00

LibC: Implement various things to get GNU bc building and running.

Looks like that's all we needed, and bc now runs. :^)
This commit is contained in:
Andreas Kling 2019-02-03 04:32:31 +01:00
parent 3a9c01619f
commit c2adfd0e2d
9 changed files with 51 additions and 2 deletions

View file

@ -9,6 +9,7 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <Kernel/Syscall.h>
#include <AK/Vector.h>
extern "C" {
@ -26,9 +27,28 @@ int execve(const char* filename, char* const argv[], char* const envp[])
int execvp(const char* filename, char* const argv[])
{
// FIXME: This should do some sort of shell-like path resolution!
return execve(filename, argv, nullptr);
}
int execl(const char* filename, const char* arg0, ...)
{
Vector<const char*> args;
args.append(arg0);
va_list ap;
va_start(ap, arg0);
for (;;) {
const char* arg = va_arg(ap, const char*);
if (!arg)
break;
args.append(arg);
}
va_end(ap);
return execve(filename, (char* const *)args.data(), nullptr);
}
uid_t getuid()
{
return syscall(SC_getuid);