public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/6] tst_timer.h: add tst_timespect_rem_us() function
Date: Thu, 24 Jan 2019 16:06:33 +0100	[thread overview]
Message-ID: <20190124150632.GA16804@rei.lan> (raw)
In-Reply-To: <20181212203723.18810-1-rafael.tinoco@linaro.org>

Hi!
> Expand tst_timer.h functionality by having a function to also remove
> given microseconds from a given timespec.
> 
> Signed-off-by: Rafael David Tinoco <rafael.tinoco@linaro.org>
> ---
>  include/tst_timer.h | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/include/tst_timer.h b/include/tst_timer.h
> index 577bc88ef..b1c9ceeba 100644
> --- a/include/tst_timer.h
> +++ b/include/tst_timer.h
> @@ -151,6 +151,23 @@ static inline struct timespec tst_timespec_add_us(struct timespec t,
>  	return t;
>  }
>  
> +/*
> + * Removes us microseconds to t.
> + */
> +static inline struct timespec tst_timespec_rem_us(struct timespec t,
> +                                                  long long us)
                                               ^
					       This is very minor but
					       better name would be sub
					       as in substract

> +{
> +	t.tv_sec -= us / 1000000;
> +	t.tv_nsec -= (us % 1000000) * 1000;
> +
> +	if (t.tv_nsec < 0) {
> +		t.tv_sec--;
> +		t.tv_nsec += 1000000000;
> +	}
> +
> +	return t;
> +}
> +
>  /*
>   * Returns difference between two timespec structures.
>   */

-- 
Cyril Hrubis
chrubis@suse.cz

      parent reply	other threads:[~2019-01-24 15:06 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05 19:30 [LTP] [PATCH 1/2] syscalls/clock_settime01.c: create syscall clock_settime test Rafael David Tinoco
2018-12-05 19:30 ` [LTP] [PATCH 2/2] timers/clock_settime: remove clock_settime tests Rafael David Tinoco
2018-12-06 13:03 ` [LTP] [PATCH 1/2] syscalls/clock_settime01.c: create syscall clock_settime test Cyril Hrubis
2018-12-06 14:49   ` Rafael David Tinoco
2018-12-06 19:07   ` [LTP] [PATCH v2 1/2] syscalls/clock_settime01.c: create syscall clock_settime Rafael David Tinoco
2018-12-06 19:07     ` [LTP] [PATCH v2 2/2] timers/clock_settime: remove clock_settime tests Rafael David Tinoco
2018-12-06 19:11     ` [LTP] [PATCH v2 1/2] syscalls/clock_settime01.c: create syscall clock_settime Rafael David Tinoco
2018-12-11 14:27     ` Cyril Hrubis
2018-12-11 16:05       ` Rafael David Tinoco
2018-12-12 20:37       ` [LTP] [PATCH v3 1/6] tst_timer.h: add tst_timespect_rem_us() function Rafael David Tinoco
2018-12-12 20:37         ` [LTP] [PATCH v3 2/6] lib: add tst_clock_settime() to tst_clocks.h Rafael David Tinoco
2018-12-12 20:37         ` [LTP] [PATCH v3 3/6] lib: include SAFE_CLOCK_SETTIME() macro Rafael David Tinoco
2018-12-12 20:37         ` [LTP] [PATCH v3 4/6] lib: new restore_wallclock field to restore realtime clock Rafael David Tinoco
2019-01-24 15:12           ` Cyril Hrubis
2018-12-12 20:37         ` [LTP] [PATCH v3 5/6] syscalls/clock_settime: create syscall clock_settime tests Rafael David Tinoco
2018-12-12 20:46           ` Rafael David Tinoco
2019-01-24 16:11           ` Cyril Hrubis
2019-01-29 17:36             ` [LTP] [PATCH v4 1/8] lib: add tst_clock_settime() to tst_clocks.h Rafael David Tinoco
2019-01-29 17:36               ` [LTP] [PATCH v4 2/8] lib: include SAFE_CLOCK_SETTIME() macro Rafael David Tinoco
2019-01-29 17:36               ` [LTP] [PATCH v4 3/8] tst_timer: Add tst_timespec_add() Rafael David Tinoco
2019-01-29 17:36               ` [LTP] [PATCH v4 4/8] lib: new restore_wallclock field to restore realtime clock Rafael David Tinoco
2019-01-30 13:53                 ` Cyril Hrubis
2019-01-29 17:36               ` [LTP] [PATCH v4 5/8] tst_timer: Add tst_timespec_sub_us() Rafael David Tinoco
2019-01-29 17:36               ` [LTP] [PATCH v4 6/8] tst_timer: Turn clock_name() function public Rafael David Tinoco
2019-01-30 13:54                 ` Cyril Hrubis
2019-01-29 17:36               ` [LTP] [PATCH v4 7/8] syscalls/clock_settime: create syscall clock_settime tests Rafael David Tinoco
2019-01-30 13:56                 ` Cyril Hrubis
2019-01-29 17:36               ` [LTP] [PATCH v4 8/8] timers/clock_settime: remove " Rafael David Tinoco
2019-01-30 13:50               ` [LTP] [PATCH v4 1/8] lib: add tst_clock_settime() to tst_clocks.h Cyril Hrubis
2019-01-30 14:50                 ` Rafael David Tinoco
2018-12-12 20:37         ` [LTP] [PATCH v3 6/6] timers/clock_settime: remove clock_settime tests Rafael David Tinoco
2019-01-08 12:04           ` Rafael David Tinoco
2019-01-08 12:42             ` Cyril Hrubis
2019-01-08 12:46               ` Rafael David Tinoco
2019-01-24 12:58             ` Rafael David Tinoco
2019-01-24 13:18               ` Cyril Hrubis
2019-01-24 15:06         ` Cyril Hrubis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190124150632.GA16804@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox