|
Description
|
Compile:
#include <pthread.h>
pthread_once_t o = PTHREAD_ONCE_INIT;
$ gcc -Wall a.c
a.c:3: warning: missing braces around initializer
a.c:3: warning: (near initialization for `o.__pthread_once_pad')
PTHREAD_ONCE_INIT should be { { 0, 0, 0, 0 } } not { 0, 0, 0, 0 }
Note that this fix will break any code using the workaround:
#define PTHREAD_ONCE_INIT { {0, 0, 0, 0} }
/* workaround */
pthread_once_t o = { PTHREAD_ONCE_INIT };
I don't have a better idea though.
John Levon wrote:
> You observed:
> Note that this fix will break any code using the workaround.
> I don't have a better idea though.
>
> I'm OK with this risk, since the fix is correct
> according to standards (and the old code wasn't).
> Tell me what you think. How much open source pain will I cause?
We need to make this change. It will break our xVM build (where I found
the bug) but that's not a major problem. As for the rest of the pain,
see:
http://www.google.com/codesearch?hl=en&lr=&q={\s%3FPTHREAD_ONCE_INIT\s%3F}&sbtn=Search
It doesn't actually look too bad. It's probably worth a full SFW compile
though, and a flag day of course.
cheers,
john
I did a bringover and build of the SFW gate.
There were no problems with the change.
It turns out that there are no instances of either
'pthread_once_t' or PTHREAD_ONCE_INIT anywhere in the SFW gate.
|