| 1 |
#ifndef footimevalhfoo |
| 2 |
#define footimevalhfoo |
| 3 |
|
| 4 |
/*** |
| 5 |
This file is part of avahi. |
| 6 |
|
| 7 |
avahi is free software; you can redistribute it and/or modify it |
| 8 |
under the terms of the GNU Lesser General Public License as |
| 9 |
published by the Free Software Foundation; either version 2.1 of the |
| 10 |
License, or (at your option) any later version. |
| 11 |
|
| 12 |
avahi is distributed in the hope that it will be useful, but WITHOUT |
| 13 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 14 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General |
| 15 |
Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU Lesser General Public |
| 18 |
License along with avahi; if not, write to the Free Software |
| 19 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 20 |
USA. |
| 21 |
***/ |
| 22 |
|
| 23 |
/** \file timeval.h Functions to facilitate timeval handling */ |
| 24 |
|
| 25 |
#include <inttypes.h> |
| 26 |
#include <sys/time.h> |
| 27 |
|
| 28 |
#include "cdecl.h" |
| 29 |
|
| 30 |
AVAHI_C_DECL_BEGIN |
| 31 |
|
| 32 |
/** A numeric data type for storing microsecond values. (signed 64bit integer) */ |
| 33 |
typedef int64_t AvahiUsec; |
| 34 |
|
| 35 |
/** Compare two timeval structures and return a negative value when a < b, 0 when a == b and a positive value otherwise */ |
| 36 |
int avahi_timeval_compare(const struct timeval *a, const struct timeval *b); |
| 37 |
|
| 38 |
/** Calculate the difference between two timeval structures as microsecond value */ |
| 39 |
AvahiUsec avahi_timeval_diff(const struct timeval *a, const struct timeval *b); |
| 40 |
|
| 41 |
/** Add a number of microseconds to the specified timeval structure and return it. *a is modified. */ |
| 42 |
struct timeval* avahi_timeval_add(struct timeval *a, AvahiUsec usec); |
| 43 |
|
| 44 |
/** Return the difference between the current time and *a. Positive if *a was earlier */ |
| 45 |
AvahiUsec avahi_age(const struct timeval *a); |
| 46 |
|
| 47 |
/** Fill *tv with the current time plus "ms" milliseconds plus an |
| 48 |
* extra jitter of "j" milliseconds. Pass 0 for j if you don't want |
| 49 |
* the jitter */ |
| 50 |
struct timeval *avahi_elapse_time(struct timeval *tv, unsigned ms, unsigned j); |
| 51 |
|
| 52 |
AVAHI_C_DECL_END |
| 53 |
|
| 54 |
#endif |