diff options
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: misc.c,v 1.67 2008/01/01 08:47:04 dtucker Exp $ */ | 1 | /* $OpenBSD: misc.c,v 1.68 2008/06/12 20:38:28 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. | 4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. |
@@ -832,3 +832,23 @@ put_u16(void *vp, u_int16_t v) | |||
832 | p[0] = (u_char)(v >> 8) & 0xff; | 832 | p[0] = (u_char)(v >> 8) & 0xff; |
833 | p[1] = (u_char)v & 0xff; | 833 | p[1] = (u_char)v & 0xff; |
834 | } | 834 | } |
835 | |||
836 | void | ||
837 | ms_subtract_diff(struct timeval *start, int *ms) | ||
838 | { | ||
839 | struct timeval diff, finish; | ||
840 | |||
841 | gettimeofday(&finish, NULL); | ||
842 | timersub(&finish, start, &diff); | ||
843 | *ms -= (diff.tv_sec * 1000) + (diff.tv_usec / 1000); | ||
844 | } | ||
845 | |||
846 | void | ||
847 | ms_to_timeval(struct timeval *tv, int ms) | ||
848 | { | ||
849 | if (ms < 0) | ||
850 | ms = 0; | ||
851 | tv->tv_sec = ms / 1000; | ||
852 | tv->tv_usec = (ms % 1000) * 1000; | ||
853 | } | ||
854 | |||