mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Mariusz Skamra <mariuszx.skamra@intel.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ktime: Simplify ktime_* comparison functions
Date: Fri, 26 May 2017 12:31:15 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1705261229330.1902@nanos> (raw)
In-Reply-To: <1495793358-4593-1-git-send-email-mariuszx.skamra@intel.com>

On Fri, 26 May 2017, Mariusz Skamra wrote:
> -static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2)
> -{
> -	if (cmp1 < cmp2)
> -		return -1;
> -	if (cmp1 > cmp2)
> -		return 1;
> -	return 0;
> -}
> +#define ktime_compare(cmp1, cmp2)	ktime_sub(cmp1, cmp2)

What's wrong with modifying the inline itself?

> -static inline bool ktime_after(const ktime_t cmp1, const ktime_t cmp2)
> -{
> -	return ktime_compare(cmp1, cmp2) > 0;
> -}
> +#define ktime_after(cmp1, cmp2)		(ktime_compare(cmp1, cmp2) > 0)

> -static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2)
> -{
> -	return ktime_compare(cmp1, cmp2) < 0;
> -}
> +#define ktime_before(cmp1, cmp2)	(ktime_compare(cmp1, cmp2) < 0)

Sorry, but those two are just crap. That inline compiles to exactly the
same code as the macro. If not, yell at your compiler people.

Thanks,

	tglx

      parent reply	other threads:[~2017-05-26 10:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 10:09 Mariusz Skamra
2017-05-26 10:20 ` Joe Perches
2017-05-26 10:31 ` Thomas Gleixner [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=alpine.DEB.2.20.1705261229330.1902@nanos \
    --to=tglx@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mariuszx.skamra@intel.com \
    /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

all inboxes | Powered by JetHome®