more timeval-related lossage. fixed some fns, added settimeofday & utimes

This commit is contained in:
cgd 1999-04-28 05:09:47 +00:00
parent c6e4495eeb
commit d3708a1699
2 changed files with 128 additions and 15 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_misc.c,v 1.30 1999/04/28 02:34:25 cgd Exp $ */
/* $NetBSD: osf1_misc.c,v 1.31 1999/04/28 05:09:48 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -383,12 +383,15 @@ osf1_sys_usleep_thread(p, v, retval)
register_t *retval;
{
struct osf1_sys_usleep_thread_args *uap = v;
struct osf1_timeval otv, endotv;
struct timeval tv, endtv;
u_long ticks;
int error, s;
if ((error = copyin(SCARG(uap, sleep), &tv, sizeof tv)))
if ((error = copyin(SCARG(uap, sleep), &otv, sizeof otv)))
return (error);
tv.tv_sec = otv.tv_sec;
tv.tv_usec = otv.tv_usec;
ticks = ((u_long)tv.tv_sec * 1000000 + tv.tv_usec) / tick;
s = splclock();
@ -401,10 +404,12 @@ osf1_sys_usleep_thread(p, v, retval)
s = splclock();
timersub(&time, &tv, &endtv);
splx(s);
if (tv.tv_sec < 0 || tv.tv_usec < 0)
tv.tv_sec = tv.tv_usec = 0;
if (endtv.tv_sec < 0 || endtv.tv_usec < 0)
endtv.tv_sec = endtv.tv_usec = 0;
error = copyout(&endtv, SCARG(uap, slept), sizeof endtv);
endotv.tv_sec = endtv.tv_sec;
endotv.tv_usec = endtv.tv_usec;
error = copyout(&endotv, SCARG(uap, slept), sizeof endotv);
}
return (error);
}
@ -1278,7 +1283,7 @@ osf1_sys_select(p, v, retval)
(caddr_t)&otv, sizeof otv);
if (error == 0) {
/* fill in and copy out the BSD timeval argument */
/* fill in and copy out the NetBSD timeval */
memset(&tv, 0, sizeof tv);
tv.tv_sec = otv.tv_sec;
tv.tv_usec = otv.tv_usec;
@ -1293,3 +1298,110 @@ osf1_sys_select(p, v, retval)
return (error);
}
int
osf1_sys_utimes(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_utimes_args *uap = v;
struct sys_utimes_args a;
struct osf1_timeval otv;
struct timeval tv;
caddr_t sg;
int error;
sg = stackgap_init(p->p_emul);
OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
SCARG(&a, path) = SCARG(uap, path);
error = 0;
if (SCARG(uap, tptr) == NULL)
SCARG(&a, tptr) = NULL;
else {
SCARG(&a, tptr) = stackgap_alloc(&sg, sizeof tv);
/* get the OSF/1 timeval argument */
error = copyin((caddr_t)SCARG(uap, tptr),
(caddr_t)&otv, sizeof otv);
if (error == 0) {
/* fill in and copy out the NetBSD timeval */
memset(&tv, 0, sizeof tv);
tv.tv_sec = otv.tv_sec;
tv.tv_usec = otv.tv_usec;
error = copyout((caddr_t)&tv,
(caddr_t)SCARG(&a, tptr), sizeof tv);
}
}
if (error == 0)
error = sys_utimes(p, &a, retval);
return (error);
}
int
osf1_sys_settimeofday(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_settimeofday_args *uap = v;
struct sys_settimeofday_args a;
struct osf1_timeval otv;
struct osf1_timezone otz;
struct timeval tv;
struct timezone tz;
int error;
caddr_t sg;
sg = stackgap_init(p->p_emul);
if (SCARG(uap, tv) == NULL)
SCARG(&a, tv) = NULL;
else {
SCARG(&a, tv) = stackgap_alloc(&sg, sizeof tv);
/* get the OSF/1 timeval argument */
error = copyin((caddr_t)SCARG(uap, tv),
(caddr_t)&otv, sizeof otv);
if (error == 0) {
/* fill in and copy out the NetBSD timeval */
memset(&tv, 0, sizeof tv);
tv.tv_sec = otv.tv_sec;
tv.tv_usec = otv.tv_usec;
error = copyout((caddr_t)&tv,
(caddr_t)SCARG(&a, tv), sizeof tv);
}
}
if (SCARG(uap, tzp) == NULL)
SCARG(&a, tzp) = NULL;
else {
SCARG(&a, tzp) = stackgap_alloc(&sg, sizeof tz);
/* get the OSF/1 timeval argument */
error = copyin((caddr_t)SCARG(uap, tzp),
(caddr_t)&otz, sizeof otz);
if (error == 0) {
/* fill in and copy out the NetBSD timezone */
memset(&tz, 0, sizeof tz);
tz.tz_minuteswest = otz.tz_minuteswest;
tz.tz_dsttime = otz.tz_dsttime;
error = copyout((caddr_t)&tz,
(caddr_t)SCARG(&a, tzp), sizeof tz);
}
}
if (error == 0)
error = sys_settimeofday(p, &a, retval);
return (error);
}

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.18 1999/04/28 02:34:25 cgd Exp $
$NetBSD: syscalls.master,v 1.19 1999/04/28 05:09:47 cgd Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -156,7 +156,7 @@
91 STD { int osf1_sys_fstat(int fd, void *sb); }
92 STD { int osf1_sys_fcntl(int fd, int cmd, void *arg); }
93 STD { int osf1_sys_select(u_int nd, fd_set *in, \
fd_set *ou, fd_set *ex, struct timeval *tv); }
fd_set *ou, fd_set *ex, struct osf1_timeval *tv); }
94 NOARGS { int sys_poll(struct pollfd *fds, u_int nfds, \
int timeout); }
95 NOARGS { int sys_fsync(int fd); }
@ -187,7 +187,7 @@
114 UNIMPL old sendmsg
115 OBSOL vtrace
116 STD { int osf1_sys_gettimeofday(struct osf1_timeval *tp, \
struct osf1_timezeon *tzp); }
struct osf1_timezone *tzp); }
117 STD { int osf1_sys_getrusage(int who, \
struct osf1_rusage *rusage); }
118 NOARGS { int sys_getsockopt(int s, int level, int name, \
@ -197,8 +197,8 @@
struct osf1_iovec *iovp, u_int iovcnt); }
121 STD { int osf1_sys_writev(int fd, \
struct osf1_iovec *iovp, u_int iovcnt); }
122 NOARGS { int sys_settimeofday(struct timeval *tv, \
struct timezone *tzp); }
122 STD { int osf1_sys_settimeofday(struct osf1_timeval *tv, \
struct osf1_timezone *tzp); }
123 NOARGS { int sys___posix_fchown(int fd, int uid, int gid); }
124 NOARGS { int sys_fchmod(int fd, int mode); }
125 NOARGS { int compat_43_sys_recvfrom(int s, caddr_t buf, \
@ -219,8 +219,8 @@
135 UNIMPL socketpair
136 NOARGS { int sys_mkdir(const char *path, int mode); }
137 NOARGS { int sys_rmdir(const char *path); }
138 NOARGS { int sys_utimes(const char *path, \
struct timeval *tptr); }
138 STD { int osf1_sys_utimes(const char *path, \
const struct osf1_timeval *tptr); }
139 OBSOL 4.2 sigreturn
140 UNIMPL adjtime
141 UNIMPL old getpeername
@ -343,8 +343,9 @@
248 UNIMPL fpathconf
249 UNIMPL
250 UNIMPL uswitch
251 STD { int osf1_sys_usleep_thread(struct timeval *sleep, \
struct timeval *slept); }
251 STD { int osf1_sys_usleep_thread( \
struct osf1_timeval *sleep, \
struct osf1_timeval *slept); }
252 UNIMPL audcntl
253 UNIMPL audgen
254 UNIMPL sysfs