From e3b3ba2d790871698d407f51d30ae201ca30761e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Tue, 15 Dec 1998 17:38:33 +0000 Subject: [PATCH] Wrap two macros into do { ... } while (0), and fix the way they're used in the kernel. Reviewed by: bde --- sys/kern/kern_threads.c | 4 ++-- sys/kern/vfs_aio.c | 4 ++-- sys/sys/time.h | 20 +++++++++++--------- sys/sys/timetc.h | 20 +++++++++++--------- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/sys/kern/kern_threads.c b/sys/kern/kern_threads.c index e2c245e9396e..57e8d96eb4f8 100644 --- a/sys/kern/kern_threads.c +++ b/sys/kern/kern_threads.c @@ -46,7 +46,7 @@ * in Germany will I accept domestic beer. This code may or may not work * and I certainly make no claims as to its fitness for *any* purpose. * - * $Id: kern_threads.c,v 1.8 1998/06/02 05:39:11 dyson Exp $ + * $Id: kern_threads.c,v 1.9 1998/10/25 17:44:51 phk Exp $ */ #include @@ -86,7 +86,7 @@ thr_sleep(struct proc *p, struct thr_sleep_args *uap) { p->p_wakeup = 0; return (EINVAL); } - TIMESPEC_TO_TIMEVAL(&atv, &ts) + TIMESPEC_TO_TIMEVAL(&atv, &ts); if (itimerfix(&atv)) { p->p_wakeup = 0; return (EINVAL); diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index 582eb9601bb8..c7c8aa9a5af0 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -13,7 +13,7 @@ * bad that happens because of using this software isn't the responsibility * of the author. This software is distributed AS-IS. * - * $Id: vfs_aio.c,v 1.34 1998/10/25 17:44:52 phk Exp $ + * $Id: vfs_aio.c,v 1.35 1998/11/27 01:14:21 tegge Exp $ */ /* @@ -1478,7 +1478,7 @@ aio_suspend(struct proc *p, struct aio_suspend_args *uap) if (ts.tv_nsec < 0 || ts.tv_nsec >= 1000000000) return (EINVAL); - TIMESPEC_TO_TIMEVAL(&atv, &ts) + TIMESPEC_TO_TIMEVAL(&atv, &ts); if (itimerfix(&atv)) return (EINVAL); timo = tvtohz(&atv); diff --git a/sys/sys/time.h b/sys/sys/time.h index 5a0cb5def4be..b6b7d288e8e9 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)time.h 8.5 (Berkeley) 5/4/95 - * $Id: time.h,v 1.33 1998/06/09 13:10:54 phk Exp $ + * $Id: time.h,v 1.34 1998/10/23 10:42:42 phk Exp $ */ #ifndef _SYS_TIME_H_ @@ -56,14 +56,16 @@ struct timespec { }; #endif -#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ - (ts)->tv_sec = (tv)->tv_sec; \ - (ts)->tv_nsec = (tv)->tv_usec * 1000; \ -} -#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ - (tv)->tv_sec = (ts)->tv_sec; \ - (tv)->tv_usec = (ts)->tv_nsec / 1000; \ -} +#define TIMEVAL_TO_TIMESPEC(tv, ts) \ + do { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ + } while (0) +#define TIMESPEC_TO_TIMEVAL(tv, ts) \ + do { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ + } while (0) struct timezone { int tz_minuteswest; /* minutes west of Greenwich */ diff --git a/sys/sys/timetc.h b/sys/sys/timetc.h index 5a0cb5def4be..b6b7d288e8e9 100644 --- a/sys/sys/timetc.h +++ b/sys/sys/timetc.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)time.h 8.5 (Berkeley) 5/4/95 - * $Id: time.h,v 1.33 1998/06/09 13:10:54 phk Exp $ + * $Id: time.h,v 1.34 1998/10/23 10:42:42 phk Exp $ */ #ifndef _SYS_TIME_H_ @@ -56,14 +56,16 @@ struct timespec { }; #endif -#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ - (ts)->tv_sec = (tv)->tv_sec; \ - (ts)->tv_nsec = (tv)->tv_usec * 1000; \ -} -#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ - (tv)->tv_sec = (ts)->tv_sec; \ - (tv)->tv_usec = (ts)->tv_nsec / 1000; \ -} +#define TIMEVAL_TO_TIMESPEC(tv, ts) \ + do { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ + } while (0) +#define TIMESPEC_TO_TIMEVAL(tv, ts) \ + do { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ + } while (0) struct timezone { int tz_minuteswest; /* minutes west of Greenwich */