Displaying 7 results from an estimated 7 matches for "subtract_timeval".
2019 Sep 28
2
[PATCH nbdkit 1/2] common/include: Add function for subtracting struct timeval.
...ine TEST_SUBTRACT(tv1, tv2, exp_sec, exp_usec) \
+ do { \
+ struct timeval z; \
+ \
+ subtract_timeval (&tv1, &tv2, &z); \
+ if (z.tv_sec != (exp_sec) || z.tv_usec != (exp_usec)) { \
+ fprintf (stderr, \
+ "%s: unexpected (%ld, %d), expecting (%ld, %d)\n", \...
2019 Sep 28
0
[PATCH nbdkit v2 1/4] common/include: Add function for subtracting struct timeval.
...ine TEST_SUBTRACT(tv1, tv2, exp_sec, exp_usec) \
+ do { \
+ struct timeval z; \
+ \
+ subtract_timeval (&tv1, &tv2, &z); \
+ if (z.tv_sec != (exp_sec) || z.tv_usec != (exp_usec)) { \
+ fprintf (stderr, \
+ "%s: unexpected (%ld, %d), expecting (%ld, %d)\n", \...
2019 Sep 28
0
[PATCH nbdkit 2/2] reflection: Add mode for reflecting server time.
...ection_can_cache (void *handle)
return NBDKIT_CACHE_NATIVE;
}
+static void
+update_time (struct handle *h)
+{
+ struct timeval tv;
+ int64_t secs;
+ int32_t usecs;
+ char *p;
+
+ gettimeofday (&tv, NULL);
+
+ switch (mode) {
+ case MODE_TIME:
+ break;
+
+ case MODE_UPTIME:
+ subtract_timeval (&load_t, &tv, &tv);
+ break;
+
+ case MODE_CONNTIME:
+ subtract_timeval (&h->conn_t, &tv, &tv);
+ break;
+
+ default:
+ abort ();
+ }
+
+ /* Pack the result into the output buffer. */
+ secs = tv.tv_sec;
+ usecs = tv.tv_usec;
+ secs = htobe64 (secs);
+...
2019 Sep 28
0
[PATCH nbdkit v2 3/4] info: Add mode for sending back server time.
...@ info_can_cache (void *handle)
return NBDKIT_CACHE_NATIVE;
}
+static void
+update_time (struct handle *h)
+{
+ struct timeval tv;
+ int64_t secs;
+ int32_t usecs;
+ char *p;
+
+ gettimeofday (&tv, NULL);
+
+ switch (mode) {
+ case MODE_TIME:
+ break;
+
+ case MODE_UPTIME:
+ subtract_timeval (&load_t, &tv, &tv);
+ break;
+
+ case MODE_CONNTIME:
+ subtract_timeval (&h->conn_t, &tv, &tv);
+ break;
+
+ default:
+ abort ();
+ }
+
+ /* Pack the result into the output buffer. */
+ secs = tv.tv_sec;
+ usecs = tv.tv_usec;
+ secs = htobe64 (secs);
+...
2020 Oct 17
0
[PATCH nbdkit] common/include/tvdiff.h: Add formal specification.
This commit adds a formal specification of tvdiff_usec and a partial
specification of subtract_timeval. These may be proved using Frama-C.
The existing functions ignored overflow, but it is possible to call
the functions with parameters that will cause overflow. So to create
a formal specification I had to modify the functions to signal
overflow. Luckily GCC and Clang have convenient __builtin*s...
2019 Sep 30
1
Re: [PATCH nbdkit v2 1/4] common/include: Add function for subtracting struct timeval.
...meval *x, const struct timeval *y)
> {
> int64_t usec;
> @@ -50,4 +50,15 @@ tvdiff_usec (const struct timeval *x, const struct timeval *y)
> return usec;
> }
>
> +/* Return timeval difference as another struct timeval. z = y - x. */
> +static inline void
> +subtract_timeval (const struct timeval *x, const struct timeval *y,
> + struct timeval *z)
> +{
> + int64_t usec = tvdiff_usec (x, y);
> +
> + z->tv_sec = usec / 1000000;
> + z->tv_usec = usec % 1000000;
> +}
> +
> #endif /* NBDKIT_TVDIFF_H */
>
--
Eric B...
2019 Sep 28
9
[PATCH nbdkit v2 0/4] info: Add mode for sending back server time.
v1 was:
https://www.redhat.com/archives/libguestfs/2019-September/thread.html#00361
v2:
- Adds a patch to rename the reflection plugin to the info plugin.
- Adds tests.
Rich.