Re: per_cpu data question

From: Rusty Russell (rusty@rustcorp.com.au)
Date: Thu Aug 29 2002 - 20:59:20 EST


In message <20020829182431.A4936@in.ibm.com> you write:
> Hi Rusty,
>
> I can't do this -
>
> struct rcu_data *rdata;
> rdata = &get_cpu_var(rcu_data);
>
> Has this been deliberately made illegal ?

No, I suck. Lvalues continue to haunt me. This works for me.

BTW, I prefer to have bug reports cc'd to linux-kernel, so the
results are archived. Plus, public humiliation is good for the
soul.

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.32/include/linux/percpu.h working-2.5.32-percpu/include/linux/percpu.h
--- linux-2.5.32/include/linux/percpu.h 2002-08-28 09:29:53.000000000 +1000
+++ working-2.5.32-percpu/include/linux/percpu.h 2002-08-30 11:50:46.000000000 +1000
@@ -3,7 +3,8 @@
 #include <linux/spinlock.h> /* For preempt_disable() */
 #include <asm/percpu.h>
 
-#define get_cpu_var(var) ({ preempt_disable(); __get_cpu_var(var); })
+/* Must be an lvalue. */
+#define get_cpu_var(var) (*({ preempt_disable(); &__get_cpu_var(var); }))
 #define put_cpu_var(var) preempt_enable()
 
 #endif /* __LINUX_PERCPU_H */

--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Aug 31 2002 - 22:00:29 EST