public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] setup_per_cpu_areas in 2.5.8pre3
@ 2002-04-14 21:15 Andries.Brouwer
  2002-04-16 12:48 ` Rusty Russell
  0 siblings, 1 reply; 4+ messages in thread
From: Andries.Brouwer @ 2002-04-14 21:15 UTC (permalink / raw)
  To: linux-kernel, torvalds


Now that I am writing anyway, one of the changes I needed
to compile 2.5.8pre3 is the following.

--- main.c~	Fri Apr 12 12:10:48 2002
+++ main.c	Sun Apr 14 16:11:33 2002
@@ -270,7 +270,9 @@
 #else
 #define smp_init()	do { } while (0)
 #endif
-
+static inline void setup_per_cpu_areas(void)
+{
+}
 #else
 
 #ifdef __GENERIC_PER_CPU

There is a nest of #ifdef's there, and in some branches
setup_per_cpu_areas() is not defined.

Of course the real fix is to remove the #ifdef's,
maybe using a weak symbol instead, or some other construction
that defines an empty default that can be replaced by an actual
routine.

Andries

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: [PATCH] setup_per_cpu_areas in 2.5.8pre3
@ 2002-04-17  8:24 Andries.Brouwer
  2002-04-17 15:11 ` Tom Rini
  0 siblings, 1 reply; 4+ messages in thread
From: Andries.Brouwer @ 2002-04-17  8:24 UTC (permalink / raw)
  To: Andries.Brouwer, rusty; +Cc: linux-kernel, torvalds

    > Now that I am writing anyway, one of the changes I needed
    > to compile 2.5.8pre3 is the following.

    Yeah, better patch below

Good.

    > Of course the real fix is to remove the #ifdef's,
    > maybe using a weak symbol instead, or some other construction
    > that defines an empty default that can be replaced by an actual
    > routine.

    Not unless you make it as readable as the current code.  Having magic
    appearing functions sounds cool, but beware that the cure might be
    worse than the disease.

But maybe I do not think that the current code is very readable.
Probably because just before fixing this compilation problem I had
to fix a different one where atomic_dec_and_lock was undefined,
and one finds a forest of #ifdef's in spinlock.h.

#ifdef's are evil. You have one, and there are two possible sources.
Easy and readable. You have two, and there are four. Already a small
effort to check that indeed all four combinations are OK. That was
what went wrong in the setup_per_cpu_areas case. You have three and
it is almost certain that someone forgets to check all possible
eight cases.

#ifdef's hide source from the compiler, so that when stuff compiles
for the developer it need not compile for the next person who comes
along. We have a kernel compilation project because of that.

So, if we can replace a certain type of #ifdef use by a different
formal construction, where all source is seen by the compiler,
that might well be progress.

Andries

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

end of thread, other threads:[~2002-04-17 15:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-14 21:15 [PATCH] setup_per_cpu_areas in 2.5.8pre3 Andries.Brouwer
2002-04-16 12:48 ` Rusty Russell
  -- strict thread matches above, loose matches on Subject: below --
2002-04-17  8:24 Andries.Brouwer
2002-04-17 15:11 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox