mescc: Support gcc-3.0: Implement alarm, setitimer.

This commit is contained in:
Jan Nieuwenhuizen 2018-06-07 18:03:51 +02:00
parent ef0a39547c
commit a70bc92857
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
3 changed files with 25 additions and 8 deletions

View File

@ -90,14 +90,6 @@ perror (char const *message)
fprintf (stderr, "%s: %s\n", strerror (errno), message);
}
int
setitimer (int which, struct itimerval const *new,
struct itimerval *old)
{
eputs ("setitimer stub\n");
return 0;
}
int
sigsetmask (int x)
{

View File

@ -22,6 +22,7 @@
#include <stdint.h>
#include <time.h>
#include <sys/times.h>
#include <sys/time.h>
FILE *
freopen (char const *file_name, char const *opentype, FILE *stream)
@ -88,3 +89,19 @@ atexit (void (*function) (void))
__call_at_exit = function;
}
unsigned int
alarm (unsigned int seconds)
{
#if !__MESC__
struct itimerval old;
struct itimerval new;
new.it_interval.tv_usec = 0;
new.it_interval.tv_sec = 0;
new.it_value.tv_usec = 0;
new.it_value.tv_sec = (long int) seconds;
if (setitimer (ITIMER_REAL, &new, &old) < 0)
return 0;
return old.it_value.tv_sec;
#endif
}

View File

@ -32,6 +32,7 @@
#define SYS_dup2 0x3f
#define SYS_getrusage 0x4d
#define SYS_lstat 0x6b
#define SYS_setitimer 0x68
#define SYS_fstat 0x6c
#define SYS_nanosleep 0xa2
@ -137,6 +138,13 @@ nanosleep (const struct timespec *requested_time,
return _sys_call2 (SYS_nanosleep, (int)requested_time, (int)remaining);
}
int
setitimer (int which, struct itimerval const *new,
struct itimerval *old)
{
return _sys_call3 (SYS_setitimer, (int)which, (int)new, (int)old);
}
int
fstat (int fd, struct stat *statbuf)
{