Ruediger Pluem wrote:
[...]
threadproc/unix/thread.c: In function `apr_thread_once_init':
threadproc/unix/thread.c:306: warning: missing braces around initializer
threadproc/unix/thread.c:306: warning: (near initialization for
`once_init.__pthread_once_pad')
To me this seems to be a bug in the Solaris include files in the
definition of PTHREAD_ONCE_INIT.
It's an overly pedantic (and in this case useless) gcc
warning. There's nothing wrong with the Solaris definition:
typedef struct _once {
long long __pthread_once_pad [ 4 ] ;
} pthread_once_t ;
pthread_once_t once_init = { 0, 0, 0, 0 };
The following patch fixes this on Solaris, but breaks it on other
platforms:
Right. There's no way to portably silence the gcc warning.
Index: threadproc/unix/thread.c
===================================================================
--- threadproc/unix/thread.c (Revision 662580)
+++ threadproc/unix/thread.c (Arbeitskopie)
@@ -303,7 +303,7 @@
APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t
**control,
apr_pool_t *p)
{
- static const pthread_once_t once_init = PTHREAD_ONCE_INIT;
+ static const pthread_once_t once_init = {PTHREAD_ONCE_INIT};
^^^^^
I don't think I've ever seen a pthread_once_t object declared
const. Unless I'm missing something, it seems that on a system
where the once_init object is allocated in ROM, the first call
to pthread_once() with its address is liable to fail with
a signal.
Martin