mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +00:00
Change syscall naming scheme.
This commit is contained in:
parent
46f0c28a4a
commit
3024167cbd
12 changed files with 156 additions and 148 deletions
|
@ -47,106 +47,106 @@ static DWORD handle(RegisterDump& regs, DWORD function, DWORD arg1, DWORD arg2,
|
||||||
{
|
{
|
||||||
ASSERT_INTERRUPTS_ENABLED();
|
ASSERT_INTERRUPTS_ENABLED();
|
||||||
switch (function) {
|
switch (function) {
|
||||||
case Syscall::Yield:
|
case Syscall::SC_yield:
|
||||||
yield();
|
yield();
|
||||||
break;
|
break;
|
||||||
case Syscall::PutCharacter:
|
case Syscall::SC_putch:
|
||||||
Console::the().putChar(arg1 & 0xff);
|
Console::the().putChar(arg1 & 0xff);
|
||||||
break;
|
break;
|
||||||
case Syscall::Sleep:
|
case Syscall::SC_sleep:
|
||||||
return current->sys$sleep(arg1);
|
return current->sys$sleep(arg1);
|
||||||
case Syscall::PosixGettimeofday:
|
case Syscall::SC_gettimeofday:
|
||||||
return current->sys$gettimeofday((timeval*)arg1);
|
return current->sys$gettimeofday((timeval*)arg1);
|
||||||
case Syscall::Spawn:
|
case Syscall::SC_spawn:
|
||||||
return current->sys$spawn((const char*)arg1, (const char**)arg2, (const char**)arg3);
|
return current->sys$spawn((const char*)arg1, (const char**)arg2, (const char**)arg3);
|
||||||
case Syscall::GetDirEntries:
|
case Syscall::SC_get_dir_entries:
|
||||||
return current->sys$get_dir_entries((int)arg1, (void*)arg2, (size_t)arg3);
|
return current->sys$get_dir_entries((int)arg1, (void*)arg2, (size_t)arg3);
|
||||||
case Syscall::PosixLstat:
|
case Syscall::SC_lstat:
|
||||||
return current->sys$lstat((const char*)arg1, (Unix::stat*)arg2);
|
return current->sys$lstat((const char*)arg1, (Unix::stat*)arg2);
|
||||||
case Syscall::PosixStat:
|
case Syscall::SC_stat:
|
||||||
return current->sys$stat((const char*)arg1, (Unix::stat*)arg2);
|
return current->sys$stat((const char*)arg1, (Unix::stat*)arg2);
|
||||||
case Syscall::PosixGetcwd:
|
case Syscall::SC_getcwd:
|
||||||
return current->sys$getcwd((char*)arg1, (size_t)arg2);
|
return current->sys$getcwd((char*)arg1, (size_t)arg2);
|
||||||
case Syscall::PosixOpen:
|
case Syscall::SC_open:
|
||||||
return current->sys$open((const char*)arg1, (int)arg2);
|
return current->sys$open((const char*)arg1, (int)arg2);
|
||||||
case Syscall::PosixWrite:
|
case Syscall::SC_write:
|
||||||
return current->sys$write((int)arg1, (const void*)arg2, (size_t)arg3);
|
return current->sys$write((int)arg1, (const void*)arg2, (size_t)arg3);
|
||||||
case Syscall::PosixClose:
|
case Syscall::SC_close:
|
||||||
//kprintf("syscall: close(%d)\n", arg1);
|
//kprintf("syscall: close(%d)\n", arg1);
|
||||||
return current->sys$close((int)arg1);
|
return current->sys$close((int)arg1);
|
||||||
case Syscall::PosixRead:
|
case Syscall::SC_read:
|
||||||
//kprintf("syscall: read(%d, %p, %u)\n", arg1, arg2, arg3);
|
//kprintf("syscall: read(%d, %p, %u)\n", arg1, arg2, arg3);
|
||||||
return current->sys$read((int)arg1, (void*)arg2, (size_t)arg3);
|
return current->sys$read((int)arg1, (void*)arg2, (size_t)arg3);
|
||||||
case Syscall::PosixLseek:
|
case Syscall::SC_lseek:
|
||||||
return current->sys$lseek((int)arg1, (off_t)arg2, (int)arg3);
|
return current->sys$lseek((int)arg1, (off_t)arg2, (int)arg3);
|
||||||
case Syscall::PosixKill:
|
case Syscall::SC_kill:
|
||||||
return current->sys$kill((pid_t)arg1, (int)arg2);
|
return current->sys$kill((pid_t)arg1, (int)arg2);
|
||||||
case Syscall::PosixGetuid:
|
case Syscall::SC_getuid:
|
||||||
return current->sys$getuid();
|
return current->sys$getuid();
|
||||||
case Syscall::PosixGetgid:
|
case Syscall::SC_getgid:
|
||||||
return current->sys$getgid();
|
return current->sys$getgid();
|
||||||
case Syscall::PosixGetpid:
|
case Syscall::SC_getpid:
|
||||||
return current->sys$getpid();
|
return current->sys$getpid();
|
||||||
case Syscall::PosixWaitpid:
|
case Syscall::SC_waitpid:
|
||||||
return current->sys$waitpid((pid_t)arg1, (int*)arg2, (int)arg3);
|
return current->sys$waitpid((pid_t)arg1, (int*)arg2, (int)arg3);
|
||||||
case Syscall::PosixMmap:
|
case Syscall::SC_mmap:
|
||||||
return (dword)current->sys$mmap((void*)arg1, (size_t)arg2);
|
return (dword)current->sys$mmap((void*)arg1, (size_t)arg2);
|
||||||
case Syscall::PosixMunmap:
|
case Syscall::SC_munmap:
|
||||||
return current->sys$munmap((void*)arg1, (size_t)arg2);
|
return current->sys$munmap((void*)arg1, (size_t)arg2);
|
||||||
case Syscall::PosixGethostname:
|
case Syscall::SC_gethostname:
|
||||||
return current->sys$gethostname((char*)arg1, (size_t)arg2);
|
return current->sys$gethostname((char*)arg1, (size_t)arg2);
|
||||||
case Syscall::PosixExit:
|
case Syscall::SC_exit:
|
||||||
cli();
|
cli();
|
||||||
current->sys$exit((int)arg1);
|
current->sys$exit((int)arg1);
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
return 0;
|
return 0;
|
||||||
case Syscall::GetArguments:
|
case Syscall::SC_get_arguments:
|
||||||
return current->sys$get_arguments((int*)arg1, (char***)arg2);
|
return current->sys$get_arguments((int*)arg1, (char***)arg2);
|
||||||
case Syscall::GetEnvironment:
|
case Syscall::SC_get_environment:
|
||||||
return current->sys$get_environment((char***)arg1);
|
return current->sys$get_environment((char***)arg1);
|
||||||
case Syscall::PosixChdir:
|
case Syscall::SC_chdir:
|
||||||
return current->sys$chdir((const char*)arg1);
|
return current->sys$chdir((const char*)arg1);
|
||||||
case Syscall::PosixUname:
|
case Syscall::SC_uname:
|
||||||
return current->sys$uname((utsname*)arg1);
|
return current->sys$uname((utsname*)arg1);
|
||||||
case Syscall::SetMmapName:
|
case Syscall::SC_set_mmap_name:
|
||||||
return current->sys$set_mmap_name((void*)arg1, (size_t)arg2, (const char*)arg3);
|
return current->sys$set_mmap_name((void*)arg1, (size_t)arg2, (const char*)arg3);
|
||||||
case Syscall::PosixReadlink:
|
case Syscall::SC_readlink:
|
||||||
return current->sys$readlink((const char*)arg1, (char*)arg2, (size_t)arg3);
|
return current->sys$readlink((const char*)arg1, (char*)arg2, (size_t)arg3);
|
||||||
case Syscall::PosixTtynameR:
|
case Syscall::SC_ttyname_r:
|
||||||
return current->sys$ttyname_r((int)arg1, (char*)arg2, (size_t)arg3);
|
return current->sys$ttyname_r((int)arg1, (char*)arg2, (size_t)arg3);
|
||||||
case Syscall::PosixSetsid:
|
case Syscall::SC_setsid:
|
||||||
return current->sys$setsid();
|
return current->sys$setsid();
|
||||||
case Syscall::PosixGetsid:
|
case Syscall::SC_getsid:
|
||||||
return current->sys$getsid((pid_t)arg1);
|
return current->sys$getsid((pid_t)arg1);
|
||||||
case Syscall::PosixSetpgid:
|
case Syscall::SC_setpgid:
|
||||||
return current->sys$setpgid((pid_t)arg1, (pid_t)arg2);
|
return current->sys$setpgid((pid_t)arg1, (pid_t)arg2);
|
||||||
case Syscall::PosixGetpgid:
|
case Syscall::SC_getpgid:
|
||||||
return current->sys$getpgid((pid_t)arg1);
|
return current->sys$getpgid((pid_t)arg1);
|
||||||
case Syscall::PosixGetpgrp:
|
case Syscall::SC_getpgrp:
|
||||||
return current->sys$getpgrp();
|
return current->sys$getpgrp();
|
||||||
case Syscall::PosixTcgetpgrp:
|
case Syscall::SC_tcgetpgrp:
|
||||||
return current->sys$tcgetpgrp((int)arg1);
|
return current->sys$tcgetpgrp((int)arg1);
|
||||||
case Syscall::PosixTcsetpgrp:
|
case Syscall::SC_tcsetpgrp:
|
||||||
return current->sys$tcsetpgrp((int)arg1, (pid_t)arg2);
|
return current->sys$tcsetpgrp((int)arg1, (pid_t)arg2);
|
||||||
case Syscall::PosixFork:
|
case Syscall::SC_fork:
|
||||||
return current->sys$fork(regs);
|
return current->sys$fork(regs);
|
||||||
case Syscall::PosixExecve:
|
case Syscall::SC_execve:
|
||||||
return current->sys$execve((const char*)arg1, (const char**)arg2, (const char**)arg3);
|
return current->sys$execve((const char*)arg1, (const char**)arg2, (const char**)arg3);
|
||||||
case Syscall::PosixGeteuid:
|
case Syscall::SC_geteuid:
|
||||||
return current->sys$geteuid();
|
return current->sys$geteuid();
|
||||||
case Syscall::PosixGetegid:
|
case Syscall::SC_getegid:
|
||||||
return current->sys$getegid();
|
return current->sys$getegid();
|
||||||
case Syscall::PosixSignal:
|
case Syscall::SC_signal:
|
||||||
return (dword)current->sys$signal((int)arg1, (Unix::sighandler_t)arg2);
|
return (dword)current->sys$signal((int)arg1, (Unix::sighandler_t)arg2);
|
||||||
case Syscall::PosixIsatty:
|
case Syscall::SC_isatty:
|
||||||
return current->sys$isatty((int)arg1);
|
return current->sys$isatty((int)arg1);
|
||||||
case Syscall::Getdtablesize:
|
case Syscall::SC_getdtablesize:
|
||||||
return current->sys$getdtablesize();
|
return current->sys$getdtablesize();
|
||||||
case Syscall::Dup:
|
case Syscall::SC_dup:
|
||||||
return current->sys$dup((int)arg1);
|
return current->sys$dup((int)arg1);
|
||||||
case Syscall::Dup2:
|
case Syscall::SC_dup2:
|
||||||
return current->sys$dup2((int)arg1, (int)arg2);
|
return current->sys$dup2((int)arg1, (int)arg2);
|
||||||
case Syscall::Sigaction:
|
case Syscall::SC_sigaction:
|
||||||
return current->sys$sigaction((int)arg1, (const Unix::sigaction*)arg2, (Unix::sigaction*)arg3);
|
return current->sys$sigaction((int)arg1, (const Unix::sigaction*)arg2, (Unix::sigaction*)arg3);
|
||||||
default:
|
default:
|
||||||
kprintf("<%u> int0x80: Unknown function %x requested {%x, %x, %x}\n", current->pid(), function, arg1, arg2, arg3);
|
kprintf("<%u> int0x80: Unknown function %x requested {%x, %x, %x}\n", current->pid(), function, arg1, arg2, arg3);
|
||||||
|
|
111
Kernel/Syscall.h
111
Kernel/Syscall.h
|
@ -2,6 +2,56 @@
|
||||||
|
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
#define ENUMERATE_SYSCALLS \
|
||||||
|
__ENUMERATE_SYSCALL(spawn) \
|
||||||
|
__ENUMERATE_SYSCALL(sleep) \
|
||||||
|
__ENUMERATE_SYSCALL(yield) \
|
||||||
|
__ENUMERATE_SYSCALL(putch) \
|
||||||
|
__ENUMERATE_SYSCALL(open) \
|
||||||
|
__ENUMERATE_SYSCALL(close) \
|
||||||
|
__ENUMERATE_SYSCALL(read) \
|
||||||
|
__ENUMERATE_SYSCALL(lseek) \
|
||||||
|
__ENUMERATE_SYSCALL(kill) \
|
||||||
|
__ENUMERATE_SYSCALL(getuid) \
|
||||||
|
__ENUMERATE_SYSCALL(exit) \
|
||||||
|
__ENUMERATE_SYSCALL(getgid) \
|
||||||
|
__ENUMERATE_SYSCALL(getpid) \
|
||||||
|
__ENUMERATE_SYSCALL(waitpid) \
|
||||||
|
__ENUMERATE_SYSCALL(mmap) \
|
||||||
|
__ENUMERATE_SYSCALL(munmap) \
|
||||||
|
__ENUMERATE_SYSCALL(get_dir_entries) \
|
||||||
|
__ENUMERATE_SYSCALL(lstat) \
|
||||||
|
__ENUMERATE_SYSCALL(getcwd) \
|
||||||
|
__ENUMERATE_SYSCALL(gettimeofday) \
|
||||||
|
__ENUMERATE_SYSCALL(gethostname) \
|
||||||
|
__ENUMERATE_SYSCALL(get_arguments) \
|
||||||
|
__ENUMERATE_SYSCALL(chdir) \
|
||||||
|
__ENUMERATE_SYSCALL(uname) \
|
||||||
|
__ENUMERATE_SYSCALL(set_mmap_name) \
|
||||||
|
__ENUMERATE_SYSCALL(readlink) \
|
||||||
|
__ENUMERATE_SYSCALL(write) \
|
||||||
|
__ENUMERATE_SYSCALL(ttyname_r) \
|
||||||
|
__ENUMERATE_SYSCALL(stat) \
|
||||||
|
__ENUMERATE_SYSCALL(get_environment) \
|
||||||
|
__ENUMERATE_SYSCALL(getsid) \
|
||||||
|
__ENUMERATE_SYSCALL(setsid) \
|
||||||
|
__ENUMERATE_SYSCALL(getpgid) \
|
||||||
|
__ENUMERATE_SYSCALL(setpgid) \
|
||||||
|
__ENUMERATE_SYSCALL(getpgrp) \
|
||||||
|
__ENUMERATE_SYSCALL(tcsetpgrp) \
|
||||||
|
__ENUMERATE_SYSCALL(tcgetpgrp) \
|
||||||
|
__ENUMERATE_SYSCALL(fork) \
|
||||||
|
__ENUMERATE_SYSCALL(execve) \
|
||||||
|
__ENUMERATE_SYSCALL(geteuid) \
|
||||||
|
__ENUMERATE_SYSCALL(getegid) \
|
||||||
|
__ENUMERATE_SYSCALL(signal) \
|
||||||
|
__ENUMERATE_SYSCALL(isatty) \
|
||||||
|
__ENUMERATE_SYSCALL(getdtablesize) \
|
||||||
|
__ENUMERATE_SYSCALL(dup) \
|
||||||
|
__ENUMERATE_SYSCALL(dup2) \
|
||||||
|
__ENUMERATE_SYSCALL(sigaction) \
|
||||||
|
|
||||||
|
|
||||||
#define DO_SYSCALL_A0(function) Syscall::invoke((dword)(function))
|
#define DO_SYSCALL_A0(function) Syscall::invoke((dword)(function))
|
||||||
#define DO_SYSCALL_A1(function, arg1) Syscall::invoke((dword)(function), (dword)(arg1))
|
#define DO_SYSCALL_A1(function, arg1) Syscall::invoke((dword)(function), (dword)(arg1))
|
||||||
#define DO_SYSCALL_A2(function, arg1, arg2) Syscall::invoke((dword)(function), (dword)(arg1), (dword)(arg2))
|
#define DO_SYSCALL_A2(function, arg1, arg2) Syscall::invoke((dword)(function), (dword)(arg1), (dword)(arg2))
|
||||||
|
@ -10,55 +60,22 @@
|
||||||
namespace Syscall {
|
namespace Syscall {
|
||||||
|
|
||||||
enum Function {
|
enum Function {
|
||||||
Spawn = 0x1981,
|
#undef __ENUMERATE_SYSCALL
|
||||||
Sleep = 0x1982,
|
#define __ENUMERATE_SYSCALL(x) SC_ ##x ,
|
||||||
Yield = 0x1983,
|
ENUMERATE_SYSCALLS
|
||||||
PutCharacter = 0x1984,
|
#undef __ENUMERATE_SYSCALL
|
||||||
PosixOpen = 0x1985,
|
|
||||||
PosixClose = 0x1986,
|
|
||||||
PosixRead = 0x1987,
|
|
||||||
PosixLseek = 0x1988,
|
|
||||||
PosixKill = 0x1989,
|
|
||||||
PosixGetuid = 0x1990,
|
|
||||||
PosixExit = 0x1991,
|
|
||||||
PosixGetgid = 0x1992,
|
|
||||||
PosixGetpid = 0x1993,
|
|
||||||
PosixWaitpid = 0x1994,
|
|
||||||
PosixMmap = 0x1995,
|
|
||||||
PosixMunmap = 0x1996,
|
|
||||||
GetDirEntries = 0x1997,
|
|
||||||
PosixLstat = 0x1998,
|
|
||||||
PosixGetcwd = 0x1999,
|
|
||||||
PosixGettimeofday = 0x2000,
|
|
||||||
PosixGethostname = 0x2001,
|
|
||||||
GetArguments = 0x2002,
|
|
||||||
PosixChdir = 0x2003,
|
|
||||||
PosixUname = 0x2004,
|
|
||||||
SetMmapName = 0x2005,
|
|
||||||
PosixReadlink = 0x2006,
|
|
||||||
PosixWrite = 0x2007,
|
|
||||||
PosixTtynameR = 0x2008,
|
|
||||||
PosixStat = 0x2009,
|
|
||||||
GetEnvironment = 0x2010,
|
|
||||||
PosixGetsid = 0x2011,
|
|
||||||
PosixSetsid = 0x2012,
|
|
||||||
PosixGetpgid = 0x2013,
|
|
||||||
PosixSetpgid = 0x2014,
|
|
||||||
PosixGetpgrp = 0x2015,
|
|
||||||
PosixTcsetpgrp = 0x2016,
|
|
||||||
PosixTcgetpgrp = 0x2017,
|
|
||||||
PosixFork = 0x2018,
|
|
||||||
PosixExecve = 0x2019,
|
|
||||||
PosixGeteuid = 0x2020,
|
|
||||||
PosixGetegid = 0x2021,
|
|
||||||
PosixSignal = 0x2022,
|
|
||||||
PosixIsatty = 0x2023,
|
|
||||||
Getdtablesize = 0x2024,
|
|
||||||
Dup = 0x2025,
|
|
||||||
Dup2 = 0x2026,
|
|
||||||
Sigaction = 0x2027,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline constexpr const char* toString(Function function)
|
||||||
|
{
|
||||||
|
switch (function) {
|
||||||
|
#undef __ENUMERATE_SYSCALL
|
||||||
|
#define __ENUMERATE_SYSCALL(x) case SC_ ##x: return #x;
|
||||||
|
ENUMERATE_SYSCALLS
|
||||||
|
#undef __ENUMERATE_SYSCALL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
inline dword invoke(dword function)
|
inline dword invoke(dword function)
|
||||||
|
|
|
@ -252,15 +252,6 @@ static void init_stage2()
|
||||||
Process::createKernelProcess(spawn_stress, "spawn_stress");
|
Process::createKernelProcess(spawn_stress, "spawn_stress");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
|
||||||
// It would be nice to exit this process, but right now it instantiates all kinds of things.
|
|
||||||
// At the very least it needs to be made sure those things stick around as appropriate.
|
|
||||||
DO_SYSCALL_A1(Syscall::PosixExit, 413);
|
|
||||||
|
|
||||||
kprintf("uh, we're still going after calling sys$exit...\n");
|
|
||||||
HANG;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
//sleep(3600 * TICKS_PER_SECOND);
|
//sleep(3600 * TICKS_PER_SECOND);
|
||||||
asm("hlt");
|
asm("hlt");
|
||||||
|
|
|
@ -52,7 +52,7 @@ dirent* readdir(DIR* dirp)
|
||||||
if (!dirp->buffer) {
|
if (!dirp->buffer) {
|
||||||
// FIXME: Figure out how much to actually allocate.
|
// FIXME: Figure out how much to actually allocate.
|
||||||
dirp->buffer = (char*)malloc(4096);
|
dirp->buffer = (char*)malloc(4096);
|
||||||
ssize_t nread = Syscall::invoke(Syscall::GetDirEntries, (dword)dirp->fd, (dword)dirp->buffer, 4096);
|
ssize_t nread = Syscall::invoke(Syscall::SC_get_dir_entries, (dword)dirp->fd, (dword)dirp->buffer, 4096);
|
||||||
dirp->buffer_size = nread;
|
dirp->buffer_size = nread;
|
||||||
dirp->nextptr = dirp->buffer;
|
dirp->nextptr = dirp->buffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,16 +34,16 @@ extern "C" int _start()
|
||||||
int status = 254;
|
int status = 254;
|
||||||
int argc;
|
int argc;
|
||||||
char** argv;
|
char** argv;
|
||||||
int rc = Syscall::invoke(Syscall::GetArguments, (dword)&argc, (dword)&argv);
|
int rc = Syscall::invoke(Syscall::SC_get_arguments, (dword)&argc, (dword)&argv);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto epilogue;
|
goto epilogue;
|
||||||
rc = Syscall::invoke(Syscall::GetEnvironment, (dword)&environ);
|
rc = Syscall::invoke(Syscall::SC_get_environment, (dword)&environ);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto epilogue;
|
goto epilogue;
|
||||||
status = main(argc, argv);
|
status = main(argc, argv);
|
||||||
|
|
||||||
epilogue:
|
epilogue:
|
||||||
Syscall::invoke(Syscall::PosixExit, status);
|
Syscall::invoke(Syscall::SC_exit, status);
|
||||||
|
|
||||||
// Birger's birthday <3
|
// Birger's birthday <3
|
||||||
return 20150614;
|
return 20150614;
|
||||||
|
|
|
@ -6,19 +6,19 @@ extern "C" {
|
||||||
|
|
||||||
void* mmap(void* addr, size_t size)
|
void* mmap(void* addr, size_t size)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixMmap, (dword)addr, (dword)size);
|
int rc = Syscall::invoke(Syscall::SC_mmap, (dword)addr, (dword)size);
|
||||||
__RETURN_WITH_ERRNO(rc, (void*)rc, (void*)-1);
|
__RETURN_WITH_ERRNO(rc, (void*)rc, (void*)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int munmap(void* addr, size_t size)
|
int munmap(void* addr, size_t size)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixMunmap, (dword)addr, (dword)size);
|
int rc = Syscall::invoke(Syscall::SC_munmap, (dword)addr, (dword)size);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_mmap_name(void* addr, size_t size, const char* name)
|
int set_mmap_name(void* addr, size_t size, const char* name)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::SetMmapName, (dword)addr, (dword)size, (dword)name);
|
int rc = Syscall::invoke(Syscall::SC_set_mmap_name, (dword)addr, (dword)size, (dword)name);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ extern "C" {
|
||||||
|
|
||||||
int spawn(const char* path, const char** args, const char** envp)
|
int spawn(const char* path, const char** args, const char** envp)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::Spawn, (dword)path, (dword)args, (dword)envp);
|
int rc = Syscall::invoke(Syscall::SC_spawn, (dword)path, (dword)args, (dword)envp);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,13 @@ extern "C" {
|
||||||
|
|
||||||
int kill(pid_t pid, int sig)
|
int kill(pid_t pid, int sig)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixKill, (dword)pid, (dword)sig);
|
int rc = Syscall::invoke(Syscall::SC_kill, (dword)pid, (dword)sig);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sighandler_t signal(int signum, sighandler_t handler)
|
sighandler_t signal(int signum, sighandler_t handler)
|
||||||
{
|
{
|
||||||
sighandler_t old_handler = (sighandler_t)Syscall::invoke(Syscall::PosixSignal, (dword)signum, (dword)handler);
|
sighandler_t old_handler = (sighandler_t)Syscall::invoke(Syscall::SC_signal, (dword)signum, (dword)handler);
|
||||||
if (old_handler == SIG_ERR) {
|
if (old_handler == SIG_ERR) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return SIG_ERR;
|
return SIG_ERR;
|
||||||
|
@ -24,7 +24,7 @@ sighandler_t signal(int signum, sighandler_t handler)
|
||||||
|
|
||||||
int sigaction(int signum, const struct sigaction* act, struct sigaction* old_act)
|
int sigaction(int signum, const struct sigaction* act, struct sigaction* old_act)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::Sigaction, (dword)signum, (dword)act, (dword)old_act);
|
int rc = Syscall::invoke(Syscall::SC_sigaction, (dword)signum, (dword)act, (dword)old_act);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ void* realloc(void *ptr, size_t)
|
||||||
|
|
||||||
void exit(int status)
|
void exit(int status)
|
||||||
{
|
{
|
||||||
Syscall::invoke(Syscall::PosixExit, (dword)status);
|
Syscall::invoke(Syscall::SC_exit, (dword)status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void abort()
|
void abort()
|
||||||
|
|
|
@ -15,7 +15,7 @@ time_t time(time_t* tloc)
|
||||||
|
|
||||||
int gettimeofday(struct timeval* tv, struct timezone*)
|
int gettimeofday(struct timeval* tv, struct timezone*)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixGettimeofday, (dword)tv);
|
int rc = Syscall::invoke(Syscall::SC_gettimeofday, (dword)tv);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,74 +9,74 @@ extern "C" {
|
||||||
|
|
||||||
pid_t fork()
|
pid_t fork()
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixFork);
|
int rc = Syscall::invoke(Syscall::SC_fork);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int execve(const char* filename, const char** argv, const char** envp)
|
int execve(const char* filename, const char** argv, const char** envp)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixExecve, (dword)filename, (dword)argv, (dword)envp);
|
int rc = Syscall::invoke(Syscall::SC_execve, (dword)filename, (dword)argv, (dword)envp);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
uid_t getuid()
|
uid_t getuid()
|
||||||
{
|
{
|
||||||
return Syscall::invoke(Syscall::PosixGetuid);
|
return Syscall::invoke(Syscall::SC_getuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
gid_t getgid()
|
gid_t getgid()
|
||||||
{
|
{
|
||||||
return Syscall::invoke(Syscall::PosixGetgid);
|
return Syscall::invoke(Syscall::SC_getgid);
|
||||||
}
|
}
|
||||||
|
|
||||||
uid_t geteuid()
|
uid_t geteuid()
|
||||||
{
|
{
|
||||||
return Syscall::invoke(Syscall::PosixGeteuid);
|
return Syscall::invoke(Syscall::SC_geteuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
gid_t getegid()
|
gid_t getegid()
|
||||||
{
|
{
|
||||||
return Syscall::invoke(Syscall::PosixGetegid);
|
return Syscall::invoke(Syscall::SC_getegid);
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t getpid()
|
pid_t getpid()
|
||||||
{
|
{
|
||||||
return Syscall::invoke(Syscall::PosixGetpid);
|
return Syscall::invoke(Syscall::SC_getpid);
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t setsid()
|
pid_t setsid()
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixSetsid);
|
int rc = Syscall::invoke(Syscall::SC_setsid);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t tcgetpgrp(int fd)
|
pid_t tcgetpgrp(int fd)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixTcgetpgrp, (dword)fd);
|
int rc = Syscall::invoke(Syscall::SC_tcgetpgrp, (dword)fd);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tcsetpgrp(int fd, pid_t pgid)
|
int tcsetpgrp(int fd, pid_t pgid)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixTcsetpgrp, (dword)fd, (dword)pgid);
|
int rc = Syscall::invoke(Syscall::SC_tcsetpgrp, (dword)fd, (dword)pgid);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int setpgid(pid_t pid, pid_t pgid)
|
int setpgid(pid_t pid, pid_t pgid)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixSetpgid, (dword)pid, (dword)pgid);
|
int rc = Syscall::invoke(Syscall::SC_setpgid, (dword)pid, (dword)pgid);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t getpgid(pid_t pid)
|
pid_t getpgid(pid_t pid)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixGetpgid, (dword)pid);
|
int rc = Syscall::invoke(Syscall::SC_getpgid, (dword)pid);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t getpgrp()
|
pid_t getpgrp()
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixGetpgrp);
|
int rc = Syscall::invoke(Syscall::SC_getpgrp);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,26 +84,26 @@ int open(const char* path, int options, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, options);
|
va_start(ap, options);
|
||||||
int rc = Syscall::invoke(Syscall::PosixOpen, (dword)path, (dword)options, (dword)ap);
|
int rc = Syscall::invoke(Syscall::SC_open, (dword)path, (dword)options, (dword)ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t read(int fd, void* buf, size_t count)
|
ssize_t read(int fd, void* buf, size_t count)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixRead, (dword)fd, (dword)buf, (dword)count);
|
int rc = Syscall::invoke(Syscall::SC_read, (dword)fd, (dword)buf, (dword)count);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t write(int fd, const void* buf, size_t count)
|
ssize_t write(int fd, const void* buf, size_t count)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixWrite, (dword)fd, (dword)buf, (dword)count);
|
int rc = Syscall::invoke(Syscall::SC_write, (dword)fd, (dword)buf, (dword)count);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ttyname_r(int fd, char* buffer, size_t size)
|
int ttyname_r(int fd, char* buffer, size_t size)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixTtynameR, (dword)fd, (dword)buffer, (dword)size);
|
int rc = Syscall::invoke(Syscall::SC_ttyname_r, (dword)fd, (dword)buffer, (dword)size);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,60 +117,60 @@ char* ttyname(int fd)
|
||||||
|
|
||||||
int close(int fd)
|
int close(int fd)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixClose, fd);
|
int rc = Syscall::invoke(Syscall::SC_close, fd);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t waitpid(pid_t waitee, int* wstatus, int options)
|
pid_t waitpid(pid_t waitee, int* wstatus, int options)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixWaitpid, waitee, (dword)wstatus);
|
int rc = Syscall::invoke(Syscall::SC_waitpid, waitee, (dword)wstatus);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lstat(const char* path, struct stat* statbuf)
|
int lstat(const char* path, struct stat* statbuf)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixLstat, (dword)path, (dword)statbuf);
|
int rc = Syscall::invoke(Syscall::SC_lstat, (dword)path, (dword)statbuf);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int stat(const char* path, struct stat* statbuf)
|
int stat(const char* path, struct stat* statbuf)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixStat, (dword)path, (dword)statbuf);
|
int rc = Syscall::invoke(Syscall::SC_stat, (dword)path, (dword)statbuf);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int chdir(const char* path)
|
int chdir(const char* path)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixChdir, (dword)path);
|
int rc = Syscall::invoke(Syscall::SC_chdir, (dword)path);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* getcwd(char* buffer, size_t size)
|
char* getcwd(char* buffer, size_t size)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixGetcwd, (dword)buffer, (dword)size);
|
int rc = Syscall::invoke(Syscall::SC_getcwd, (dword)buffer, (dword)size);
|
||||||
__RETURN_WITH_ERRNO(rc, buffer, nullptr);
|
__RETURN_WITH_ERRNO(rc, buffer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sleep(unsigned seconds)
|
int sleep(unsigned seconds)
|
||||||
{
|
{
|
||||||
return Syscall::invoke(Syscall::Sleep, (dword)seconds);
|
return Syscall::invoke(Syscall::SC_sleep, (dword)seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
int gethostname(char* buffer, size_t size)
|
int gethostname(char* buffer, size_t size)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixGethostname, (dword)buffer, (dword)size);
|
int rc = Syscall::invoke(Syscall::SC_gethostname, (dword)buffer, (dword)size);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t readlink(const char* path, char* buffer, size_t size)
|
ssize_t readlink(const char* path, char* buffer, size_t size)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixReadlink, (dword)path, (dword)buffer, (dword)size);
|
int rc = Syscall::invoke(Syscall::SC_readlink, (dword)path, (dword)buffer, (dword)size);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t lseek(int fd, off_t offset, int whence)
|
off_t lseek(int fd, off_t offset, int whence)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixLseek, (dword)fd, (dword)offset, (dword)whence);
|
int rc = Syscall::invoke(Syscall::SC_lseek, (dword)fd, (dword)offset, (dword)whence);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,25 +186,25 @@ int unlink(const char*)
|
||||||
|
|
||||||
int isatty(int fd)
|
int isatty(int fd)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixIsatty, (dword)fd);
|
int rc = Syscall::invoke(Syscall::SC_isatty, (dword)fd);
|
||||||
__RETURN_WITH_ERRNO(rc, 1, 0);
|
__RETURN_WITH_ERRNO(rc, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getdtablesize()
|
int getdtablesize()
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::Getdtablesize);
|
int rc = Syscall::invoke(Syscall::SC_getdtablesize);
|
||||||
__RETURN_WITH_ERRNO(rc, 1, 0);
|
__RETURN_WITH_ERRNO(rc, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dup(int old_fd)
|
int dup(int old_fd)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::Dup, (dword)old_fd);
|
int rc = Syscall::invoke(Syscall::SC_dup, (dword)old_fd);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dup2(int old_fd, int new_fd)
|
int dup2(int old_fd, int new_fd)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::Dup2, (dword)old_fd, (dword)new_fd);
|
int rc = Syscall::invoke(Syscall::SC_dup2, (dword)old_fd, (dword)new_fd);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ extern "C" {
|
||||||
|
|
||||||
int uname(struct utsname* buf)
|
int uname(struct utsname* buf)
|
||||||
{
|
{
|
||||||
int rc = Syscall::invoke(Syscall::PosixUname, (dword)buf);
|
int rc = Syscall::invoke(Syscall::SC_uname, (dword)buf);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue