2023-01-22 14:00:20 +00:00
|
|
|
#include <bits/errno-return.h>
|
2023-01-06 12:31:14 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdint.h>
|
2023-01-22 14:00:20 +00:00
|
|
|
#include <sys/syscall.h>
|
2023-01-06 12:31:14 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
extern "C" long arch_invoke_syscall(long, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
long syscall(long num, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, num);
|
|
|
|
|
|
|
|
uintptr_t arg0 = va_arg(ap, uintptr_t);
|
|
|
|
uintptr_t arg1 = va_arg(ap, uintptr_t);
|
|
|
|
uintptr_t arg2 = va_arg(ap, uintptr_t);
|
|
|
|
uintptr_t arg3 = va_arg(ap, uintptr_t);
|
|
|
|
uintptr_t arg4 = va_arg(ap, uintptr_t);
|
|
|
|
|
|
|
|
long rc = arch_invoke_syscall(num, arg0, arg1, arg2, arg3, arg4);
|
|
|
|
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2023-01-22 14:00:20 +00:00
|
|
|
|
|
|
|
int usleep(useconds_t us)
|
|
|
|
{
|
|
|
|
long rc = syscall(SYS_usleep, us);
|
|
|
|
__errno_return(rc, int);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long sleep(unsigned long seconds)
|
|
|
|
{
|
|
|
|
syscall(SYS_usleep, seconds * 1000000);
|
|
|
|
return 0;
|
|
|
|
}
|
2023-01-06 12:31:14 +00:00
|
|
|
}
|