Mercurial > emacs
changeset 27149:a3d16b780bb3
(EMACS_GET_TIME, EMACS_ADD_TIME, EMACS_SUB_TIME): Give
macros statement form.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 04 Jan 2000 17:13:58 +0000 |
parents | 929f111a6823 |
children | d8fd3814d591 |
files | src/systime.h |
diffstat | 1 files changed, 20 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/systime.h Tue Jan 04 14:52:06 2000 +0000 +++ b/src/systime.h Tue Jan 04 17:13:58 2000 +0000 @@ -95,33 +95,30 @@ /* On SVR4, the compiler may complain if given this extra BSD arg. */ #ifdef GETTIMEOFDAY_ONE_ARGUMENT -#define EMACS_GET_TIME(time) \ -{ \ - gettimeofday (&(time)); \ -} +#define EMACS_GET_TIME(time) gettimeofday (&(time)) #else /* not GETTIMEOFDAY_ONE_ARGUMENT */ -#define EMACS_GET_TIME(time) \ -{ \ - struct timezone dummy; \ - gettimeofday (&(time), &dummy); \ -} +#define EMACS_GET_TIME(time) \ + do { \ + struct timezone dummy; \ + gettimeofday (&(time), &dummy); \ + } while (0) #endif /* not GETTIMEOFDAY_ONE_ARGUMENT */ -#define EMACS_ADD_TIME(dest, src1, src2) \ -{ \ - (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \ - (dest).tv_usec = (src1).tv_usec + (src2).tv_usec; \ - if ((dest).tv_usec > 1000000) \ - (dest).tv_usec -= 1000000, (dest).tv_sec++; \ -} +#define EMACS_ADD_TIME(dest, src1, src2) \ + do { \ + (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \ + (dest).tv_usec = (src1).tv_usec + (src2).tv_usec; \ + if ((dest).tv_usec > 1000000) \ + (dest).tv_usec -= 1000000, (dest).tv_sec++; \ + } while (0) -#define EMACS_SUB_TIME(dest, src1, src2) \ -{ \ - (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \ - (dest).tv_usec = (src1).tv_usec - (src2).tv_usec; \ - if ((dest).tv_usec < 0) \ - (dest).tv_usec += 1000000, (dest).tv_sec--; \ -} +#define EMACS_SUB_TIME(dest, src1, src2) \ + do { \ + (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \ + (dest).tv_usec = (src1).tv_usec - (src2).tv_usec; \ + if ((dest).tv_usec < 0) \ + (dest).tv_usec += 1000000, (dest).tv_sec--; \ + } while (0) #define EMACS_TIME_NEG_P(time) \ ((long)(time).tv_sec < 0 \