linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] linux/cpumask.h: add typechecking to cpumask_test_cpu
@ 2015-03-30 23:48 Rasmus Villemoes
  2015-03-31  3:25 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Rasmus Villemoes @ 2015-03-30 23:48 UTC (permalink / raw)
  To: Andrew Morton, Tejun Heo, Rasmus Villemoes, Rusty Russell; +Cc: linux-kernel

The Subtlety (1) referred to vanished with 6ba2ef7baac2 ("cpumask:
Move deprecated functions to end of header."). That used to mention
some suboptimal code generation by a, by now, rather ancient gcc. With
gcc 4.7, I don't see any change in the generated code by making it a
static inline, so let's add type checking and get rid of the ghost
reference.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/cpumask.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 086549a665e2..972c30e0714e 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -289,11 +289,11 @@ static inline void cpumask_clear_cpu(int cpu, struct cpumask *dstp)
  * @cpumask: the cpumask pointer
  *
  * Returns 1 if @cpu is set in @cpumask, else returns 0
- *
- * No static inline type checking - see Subtlety (1) above.
  */
-#define cpumask_test_cpu(cpu, cpumask) \
-	test_bit(cpumask_check(cpu), cpumask_bits((cpumask)))
+static inline int cpumask_test_cpu(int cpu, const struct cpumask *cpumask)
+{
+	return test_bit(cpumask_check(cpu), cpumask_bits((cpumask)));
+}
 
 /**
  * cpumask_test_and_set_cpu - atomically test and set a cpu in a cpumask
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] linux/cpumask.h: add typechecking to cpumask_test_cpu
  2015-03-30 23:48 [PATCH] linux/cpumask.h: add typechecking to cpumask_test_cpu Rasmus Villemoes
@ 2015-03-31  3:25 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2015-03-31  3:25 UTC (permalink / raw)
  To: Rasmus Villemoes, Andrew Morton, Tejun Heo, Rasmus Villemoes; +Cc: linux-kernel

Rasmus Villemoes <linux@rasmusvillemoes.dk> writes:
> The Subtlety (1) referred to vanished with 6ba2ef7baac2 ("cpumask:
> Move deprecated functions to end of header."). That used to mention
> some suboptimal code generation by a, by now, rather ancient gcc. With
> gcc 4.7, I don't see any change in the generated code by making it a
> static inline, so let's add type checking and get rid of the ghost
> reference.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Thanks, applied.

Cheers,
Rusty.

> ---
>  include/linux/cpumask.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> index 086549a665e2..972c30e0714e 100644
> --- a/include/linux/cpumask.h
> +++ b/include/linux/cpumask.h
> @@ -289,11 +289,11 @@ static inline void cpumask_clear_cpu(int cpu, struct cpumask *dstp)
>   * @cpumask: the cpumask pointer
>   *
>   * Returns 1 if @cpu is set in @cpumask, else returns 0
> - *
> - * No static inline type checking - see Subtlety (1) above.
>   */
> -#define cpumask_test_cpu(cpu, cpumask) \
> -	test_bit(cpumask_check(cpu), cpumask_bits((cpumask)))
> +static inline int cpumask_test_cpu(int cpu, const struct cpumask *cpumask)
> +{
> +	return test_bit(cpumask_check(cpu), cpumask_bits((cpumask)));
> +}
>  
>  /**
>   * cpumask_test_and_set_cpu - atomically test and set a cpu in a cpumask
> -- 
> 2.1.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-31  3:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-30 23:48 [PATCH] linux/cpumask.h: add typechecking to cpumask_test_cpu Rasmus Villemoes
2015-03-31  3:25 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).