Kernel/LibC: Implement alarm() and setitimer()
This makes vim able to start!
This commit is contained in:
@@ -86,6 +86,7 @@ __BEGIN_DECLS
|
||||
O(SYS_SIGACTION, sigaction) \
|
||||
O(SYS_SIGPENDING, sigpending) \
|
||||
O(SYS_SIGPROCMASK, sigprocmask) \
|
||||
O(SYS_SETITIMER, setitimer) \
|
||||
|
||||
enum Syscall
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int gettimeofday(struct timeval* __restrict tp, void* __restrict tzp)
|
||||
{
|
||||
@@ -13,3 +15,8 @@ int gettimeofday(struct timeval* __restrict tp, void* __restrict tzp)
|
||||
tp->tv_usec = ts.tv_nsec / 1000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setitimer(int which, const struct itimerval* __restrict value, struct itimerval* __restrict ovalue)
|
||||
{
|
||||
return syscall(SYS_SETITIMER, which, value, ovalue);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
char** environ;
|
||||
@@ -514,3 +515,14 @@ int access(const char* path, int amode)
|
||||
{
|
||||
return syscall(SYS_ACCESS, path, amode);
|
||||
}
|
||||
|
||||
unsigned alarm(unsigned seconds)
|
||||
{
|
||||
itimerval value, ovalue;
|
||||
value.it_value.tv_sec = seconds;
|
||||
value.it_value.tv_usec = 0;
|
||||
value.it_interval.tv_sec = 0;
|
||||
value.it_interval.tv_usec = 0;
|
||||
setitimer(ITIMER_REAL, &value, &ovalue);
|
||||
return ovalue.it_value.tv_sec;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user