"setuid",
"setgid",
"_time",
- "stime",
+ "_stime",
"ioctl",
"brk",
"sbrk",
#if defined(NO_64BIT)
typedef uint32_t time_t;
+/* For kernel struct alignment */
+typedef struct {
+ uint32_t time;
+ uint32_t pad;
+} __ktime_t;
#else
typedef int64_t time_t;
+typedef struct {
+ uint64_t time;
+} __ktime_t;
#endif
typedef int32_t clock_t;
#endif
extern int _stat(const char *path, struct _uzistat *s);
extern int _fstat(int fd, struct _uzistat *s);
extern int _getfsys(uint16_t dev, struct _uzifilesys *fs);
-extern int _time(time_t *t, uint16_t clock);
-extern int _stime(const time_t *t, uint16_t clock);
+extern int _time(__ktime_t *t, uint16_t clock);
+extern int _stime(const __ktime_t *t, uint16_t clock);
extern int _times(struct tms *t);
-extern int _utime(const char *file, time_t *buf);
+extern int _utime(const char *file, __ktime_t *buf);
extern int _uname(struct _uzisysinfoblk *uzib, int len);
extern int _profil(void *samples, uint16_t offset, uint16_t size, int16_t scale);
extern int _lseek(int fd, off_t *offset, int mode);
extern int fstat(int fd, struct stat *s);
extern int alarm(uint16_t seconds);
extern time_t time(time_t *t);
-extern int stime(time_t *t);
+extern int stime(const time_t *t);
extern int times(struct tms *tms);
extern int utime(const char *filename, const struct utimbuf *utim);
extern int uname(struct utsname *buf);
SRC_C += popen.c printf.c putenv.c putgetch.c putpwent.c pwent.c qsort.c
SRC_C += raise.c rand.c readdir.c readlink.c realloc.c regerror.c
SRC_C += regsub.c remove.c rewind.c rindex.c setbuffer.c setenv.c setjmp.c
-SRC_C += setlocale.c setvbuf.c settimeofday.c sleep.c sprintf.c stat.c stdio0.c
+SRC_C += setlocale.c setvbuf.c settimeofday.c sleep.c sprintf.c
+SRC_C += stat.c stdio0.c stime.c
SRC_C += strcasecmp.c strcasestr.c strdup.c stricmp.c strlcpy.c strncasecmp.c
SRC_C += strnlen.c strnicmp.c strsep.c strxfrm.c strcoll.c
SRC_C += strtod.c strtol.c system.c time.c tmpnam.c ttyname.c
SRC_C += popen.c printf.c putenv.c putgetch.c putpwent.c pwent.c qsort.c
SRC_C += raise.c rand.c readdir.c readlink.c realloc.c regerror.c
SRC_C += regsub.c remove.c rewind.c rindex.c setbuffer.c setenv.c setjmp.c
-SRC_C += setlocale.c setvbuf.c settimeofday.c sleep.c sprintf.c stat.c stdio0.c
+SRC_C += setlocale.c setvbuf.c settimeofday.c sleep.c sprintf.c
+SRC_C += stat.c stdio0.c stime.c
SRC_C += strcasecmp.c strcasestr.c strdup.c stricmp.c strlcpy.c strncasecmp.c
SRC_C += strnicmp.c strnlen.c strsep.c
SRC_C += system.c time.c tmpnam.c ttyname.c
{
int r;
unsigned long d;
+ __ktime_t tmp;
+
res->tv_nsec = 0;
switch(clk_id) {
case CLOCK_REALTIME:
- _time(&res->tv_sec, 0);
+ _time(&tmp, 0);
+ res->tv_sec = tmp.time;
return 0;
case CLOCK_MONOTONIC:
- _time(&res->tv_sec, 1);
+ _time(&tmp, 1);
+ res->tv_sec = tmp.time;
d = res->tv_sec;
/* We know that this wraps at 2^32 ticks which also means we know
it'll fit 32bits */
{
switch(clk_id) {
case CLOCK_REALTIME:
- _stime(&tp->tv_sec, 0);
+ stime(&tp->tv_sec);
return 0;
case CLOCK_MONOTONIC:
return -EPERM;
ASRCS += syscall_setuid.s
ASRCS += syscall_setgid.s
ASRCS += syscall__time.s
-ASRCS += syscall_stime.s
+ASRCS += syscall__stime.s
ASRCS += syscall_ioctl.s
ASRCS += syscall_brk.s
ASRCS += syscall_sbrk.s
ASRCS += syscall_nice.s
ASRCS += syscall__sigdisp.s
ASRCS += syscall_flock.s
+ASRCS += syscall_getpgrp.s
+ASRCS += syscall_yield.s
ASRCALL = $(ASRCS) $(ASYS)
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
if (tv) {
- _time(&tv->tv_sec, 0);
+ time(&tv->tv_sec);
tv->tv_usec = 0;
}
if (tz) {
{
int ret = 0;
if (tv) {
- ret = _stime(&tv->tv_sec, 0);
+ ret = stime(&tv->tv_sec);
}
return ret;
}
/* Divide by ten in shifts. Would be nice if the compiler did that for us 8)
FIXME: probably worth having a Z80 asm version of this */
-static div10quicki(unsigned int i)
+static unsigned int div10quicki(unsigned int i)
{
unsigned int q, r;
q = (i >> 1) + (i >> 2);
unsigned int sleep(unsigned int seconds)
{
- time_t end, now;
+ __ktime_t end, now;
_time(&end, 1); /* in 1/10ths */
- end += seconds * 10;
+ end.time += seconds * 10;
if (_pause(seconds * 10) == 0)
return 0;
_time(&now, 1);
- return div10quicki(end - now);
+ return div10quicki(end.time - now.time);
}
*/
time_t time(time_t *t)
{
- time_t tmp;
- if (t) {
- _time(t, 0);
- return *t;
- }
+ static time_t tr;
+ __ktime_t tmp;
_time(&tmp, 0);
- return tmp;
+ tr = tmp.time;
+ if (t)
+ *t = tr;
+ return tr;
}