threads/180652: compat32 problem in clock_getcpuclockid2
Konstantin Belousov
kostikbel at gmail.com
Sat Jul 20 14:40:01 UTC 2013
The following reply was made to PR threads/180652; it has been noted by GNATS.
From: Konstantin Belousov <kostikbel at gmail.com>
To: Petr Salinger <Petr.Salinger at seznam.cz>
Cc: freebsd-gnats-submit at FreeBSD.org
Subject: Re: threads/180652: compat32 problem in clock_getcpuclockid2
Date: Sat, 20 Jul 2013 17:36:26 +0300
--ofoyOKZR33MYzbeX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Sat, Jul 20, 2013 at 03:26:06PM +0200, Petr Salinger wrote:
> It looks like the only remaining missing part of compat32 interfaces
> (covered by our eglibc testsuite) is ktimer_*() family, used for
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_gettime.h=
tml
Try this. Could you provide me with the isolated test case for timer_*
functions ?
commit 20bc0c0e4343307a4d24a1812c5cd546aa18b1da
Author: Konstantin Belousov <kib at freebsd.org>
Date: Sat Jul 20 17:31:39 2013 +0300
Implement compat32 for ktimer_*.
diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebs=
d32.h
index a95b0e5..9b04965 100644
--- a/sys/compat/freebsd32/freebsd32.h
+++ b/sys/compat/freebsd32/freebsd32.h
@@ -69,6 +69,15 @@ struct timespec32 {
CP((src).fld,(dst).fld,tv_nsec); \
} while (0)
=20
+struct itimerspec32 {
+ struct timespec32 it_interval;
+ struct timespec32 it_value;
+};
+#define ITS_CP(src, dst) do { \
+ TS_CP((src), (dst), it_interval); \
+ TS_CP((src), (dst), it_value); \
+} while (0)
+
struct rusage32 {
struct timeval32 ru_utime;
struct timeval32 ru_stime;
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/f=
reebsd32_misc.c
index cfcd83b..4136ba9 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -2332,6 +2332,43 @@ freebsd32_clock_getres(struct thread *td,
}
=20
int
+freebsd32_ktimer_settime(struct thread *td,
+ struct freebsd32_ktimer_settime_args *uap)
+{
+ struct itimerspec32 val32, oval32;
+ struct itimerspec val, oval, *ovalp;
+ int error;
+
+ error =3D copyin(uap->value, &val32, sizeof(val32));
+ if (error !=3D 0)
+ return (error);
+ ITS_CP(val32, val);
+ ovalp =3D uap->ovalue !=3D NULL ? &oval : NULL;
+ error =3D kern_ktimer_settime(td, uap->timerid, uap->flags, &val, ovalp);
+ if (error =3D=3D 0 && uap->ovalue !=3D NULL) {
+ ITS_CP(oval, oval32);
+ error =3D copyout(&oval32, uap->ovalue, sizeof(oval32));
+ }
+ return (error);
+}
+
+int
+freebsd32_ktimer_gettime(struct thread *td,
+ struct freebsd32_ktimer_gettime_args *uap)
+{
+ struct itimerspec32 val32;
+ struct itimerspec val;
+ int error;
+
+ error =3D kern_ktimer_gettime(td, uap->timerid, &val);
+ if (error =3D=3D 0) {
+ ITS_CP(val, val32);
+ error =3D copyout(&val32, uap->value, sizeof(val32));
+ }
+ return (error);
+}
+
+int
freebsd32_clock_getcpuclockid2(struct thread *td,
struct freebsd32_clock_getcpuclockid2_args *uap)
{
diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/sy=
scalls.master
index 6cb649f..6d3ea7c 100644
--- a/sys/compat/freebsd32/syscalls.master
+++ b/sys/compat/freebsd32/syscalls.master
@@ -441,11 +441,16 @@
const struct timespec32 *tp); }
234 AUE_NULL STD { int freebsd32_clock_getres(clockid_t clock_id, \
struct timespec32 *tp); }
-235 AUE_NULL UNIMPL timer_create
-236 AUE_NULL UNIMPL timer_delete
-237 AUE_NULL UNIMPL timer_settime
-238 AUE_NULL UNIMPL timer_gettime
-239 AUE_NULL UNIMPL timer_getoverrun
+235 AUE_NULL NOPROTO { int ktimer_create(clockid_t clock_id, \
+ struct sigevent *evp, int *timerid); }
+236 AUE_NULL NOPROTO { int ktimer_delete(int timerid); }
+237 AUE_NULL STD { int freebsd32_ktimer_settime(int timerid,\
+ int flags, \
+ const struct itimerspec32 *value, \
+ struct itimerspec32 *ovalue); }
+238 AUE_NULL STD { int freebsd32_ktimer_gettime(int timerid,\
+ struct itimerspec32 *value); }
+239 AUE_NULL NOPROTO { int ktimer_getoverrun(int timerid); }
240 AUE_NULL STD { int freebsd32_nanosleep( \
const struct timespec32 *rqtp, \
struct timespec32 *rmtp); }
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 6b908a0..8703a11 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1271,35 +1271,40 @@ struct ktimer_settime_args {
int
sys_ktimer_settime(struct thread *td, struct ktimer_settime_args *uap)
{
- struct proc *p =3D td->td_proc;
- struct itimer *it;
struct itimerspec val, oval, *ovalp;
int error;
=20
error =3D copyin(uap->value, &val, sizeof(val));
if (error !=3D 0)
return (error);
-=09
- if (uap->ovalue !=3D NULL)
- ovalp =3D &oval;
- else
- ovalp =3D NULL;
+ ovalp =3D uap->ovalue !=3D NULL ? &oval : NULL;
+ error =3D kern_ktimer_settime(td, uap->timerid, uap->flags, &val, ovalp);
+ if (error =3D=3D 0 && uap->ovalue !=3D NULL)
+ error =3D copyout(ovalp, uap->ovalue, sizeof(*ovalp));
+ return (error);
+}
+
+int
+kern_ktimer_settime(struct thread *td, int timer_id, int flags,
+ struct itimerspec *val, struct itimerspec *oval)
+{
+ struct proc *p;
+ struct itimer *it;
+ int error;
=20
+ p =3D td->td_proc;
PROC_LOCK(p);
- if (uap->timerid < 3 ||
- (it =3D itimer_find(p, uap->timerid)) =3D=3D NULL) {
+ if (timer_id < 3 || (it =3D itimer_find(p, timer_id)) =3D=3D NULL) {
PROC_UNLOCK(p);
error =3D EINVAL;
} else {
PROC_UNLOCK(p);
itimer_enter(it);
- error =3D CLOCK_CALL(it->it_clockid, timer_settime,
- (it, uap->flags, &val, ovalp));
+ error =3D CLOCK_CALL(it->it_clockid, timer_settime, (it,
+ flags, val, oval));
itimer_leave(it);
ITIMER_UNLOCK(it);
}
- if (error =3D=3D 0 && uap->ovalue !=3D NULL)
- error =3D copyout(ovalp, uap->ovalue, sizeof(*ovalp));
return (error);
}
=20
@@ -1312,26 +1317,34 @@ struct ktimer_gettime_args {
int
sys_ktimer_gettime(struct thread *td, struct ktimer_gettime_args *uap)
{
- struct proc *p =3D td->td_proc;
- struct itimer *it;
struct itimerspec val;
int error;
=20
+ error =3D kern_ktimer_gettime(td, uap->timerid, &val);
+ if (error =3D=3D 0)
+ error =3D copyout(&val, uap->value, sizeof(val));
+ return (error);
+}
+
+int
+kern_ktimer_gettime(struct thread *td, int timer_id, struct itimerspec *va=
l)
+{
+ struct proc *p;
+ struct itimer *it;
+ int error;
+
+ p =3D td->td_proc;
PROC_LOCK(p);
- if (uap->timerid < 3 ||
- (it =3D itimer_find(p, uap->timerid)) =3D=3D NULL) {
+ if (timer_id < 3 || (it =3D itimer_find(p, timer_id)) =3D=3D NULL) {
PROC_UNLOCK(p);
error =3D EINVAL;
} else {
PROC_UNLOCK(p);
itimer_enter(it);
- error =3D CLOCK_CALL(it->it_clockid, timer_gettime,
- (it, &val));
+ error =3D CLOCK_CALL(it->it_clockid, timer_gettime, (it, val));
itimer_leave(it);
ITIMER_UNLOCK(it);
}
- if (error =3D=3D 0)
- error =3D copyout(&val, uap->value, sizeof(val));
return (error);
}
=20
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 75278c3..4ed38b3 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -228,6 +228,10 @@ int kern_symlink(struct thread *td, char *path, char *=
link,
enum uio_seg segflg);
int kern_symlinkat(struct thread *td, char *path1, int fd, char *path2,
enum uio_seg segflg);
+int kern_ktimer_settime(struct thread *td, int timer_id, int flags,
+ struct itimerspec *val, struct itimerspec *oval);
+int kern_ktimer_gettime(struct thread *td, int timer_id,
+ struct itimerspec *val);
int kern_thr_new(struct thread *td, struct thr_param *param);
int kern_thr_suspend(struct thread *td, struct timespec *tsp);
int kern_truncate(struct thread *td, char *path, enum uio_seg pathseg,
--ofoyOKZR33MYzbeX
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (FreeBSD)
iQIcBAEBAgAGBQJR6qBqAAoJEJDCuSvBvK1BXIEP/2LMSizL9cYmu6TSo3dvTWqr
ICOuzscpUHr1gJSOLVNimN6vdJVRbKPaWE4xW7QjxFYJYmkOfshuBW6kswstONXS
Wctk8MmyICW1IhB48QFB3POGeo/qST1OQfXC9lNYcpsPmZT1B03zEKbJuZHDWUO7
MH7XLABc0+kR6aPIqhGQoEepn0okZLNvlbjG0rEBJ67SZjCMI6024pucn+J78I05
7vZOyTvWG8GRn9T/vCGsfKkkcYY6HnYwmEXTRhd5zR1HSufJIx2VCjuU6CRca1Uq
o8x4IC7PXOtfMzXIZrbnVUJXnJR3wTHRAOJSdi+KM2aHhP6BRFY64v22ui5ITcBo
yJ01k8aGQVn57WNh6rpnraYJ2gfJxyCxczSVBTk1y8eeNqRHli+56dUkvYld6+ZP
mggoCmTuAPF7Dd9SmwtUuA18h98Nkf5BNyBbsCmAqAA0oT71vyPjc9ZVem5zUM5k
tsorkrz/HyJWK5KiMFmdkD1l4cxJueIyb2e/QCMz3RraemfWPHaaO69FiERCVyeF
Txuhq5bZEgaLxB1MdxWRpuR9Xhu5gesgJNH3gxARehaS1+P5oASc5/tSdq2tdH6x
sMQ0rDhDMDuBfFO43HrXKDgHcmwfTEwmEIeCqiM+H1HCXIJ2w4DVWC+2MkHHR3Yt
hf/ZkZtPbEU5LWwzeZDc
=PNhX
-----END PGP SIGNATURE-----
--ofoyOKZR33MYzbeX--
More information about the freebsd-threads
mailing list