lkml.org 
[lkml]   [2002]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] Important per-cpu fix.
From
   From: Rusty Russell <rusty@rustcorp.com.au>
Date: Mon, 09 Sep 2002 13:45:02 +1000

/* FIXME: Initializer required so gcc 2.96 doesn't put in BSS */
DEFINE_PER_CPU(int, xxx) = 0;
everywhere, which can be deleted later

Why everywhere? If you do it in the macro, then when you want
to delete the initializer remove the macro arg. Then you cover
both in-kernel and cases in external sources because the build
will break for them so they'll know to fixup their macro invocation.

I hate when things change silently, and if you don't put it in
the macro, someone will get it wrong and we'll find out only
when someone with an older compiler uses that feature on an SMP
machine.

Read as: This is bad programming practice Rusty, regardless of
your personal views about this particular GCC bug or
what you think is a legitimate initializer.

See spinlock_t's declaration for older GCC versions, that is how we
traditionally deal with compiler bugs like this, explicitly so that it
is impossible to "miss" something and get it wrong.

Everytime I asked Linus to rearrange some piece of code that used
spinlock_t initializers to workaround the "empty initializer at
end of struct" GCC bug he always told me "someone will get it
wrong if we do it that way" And I think he's right.
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:28    [from the cache]
©2003-2011 Jasper Spaans