This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/50982] AIX libstdc++ GTHREADS incompatibility


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50982

--- Comment #32 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-11-05 14:29:11 UTC ---
(In reply to comment #29)
> On AIX pthread_once_t is a struct containing an array:
> 
> typedef struct
> {
> #ifdef __64BIT__
>         long    __on_word[9];
> #else
>         int     __on_word[28];
> #endif /* __64BIT__ */
> }
> pthread_once_t;
> 
> and the initializer is an array:
> 
> #ifdef __64BIT__
> #define PTHREAD_ONCE_INIT \
> { \
>         0, \
>         0, \
>         0, \
>         0, \
>         0, \
>         _PTH_FLAGS_INIT64, \
>         0 \
> }
> #else
> #define PTHREAD_ONCE_INIT \
> { \
>         0, \
>         0, \
>         0, \
>         0, \
>         0, \
>         0, \
>         0, \
>         2, \
>         0 \
> }
> #endif /* __64BIT__ */
> 
> The initializer has few words than the array because the rest are zero, but
> matching the size does not solve the problem.

The initializer is missing a set of braces.

That could be fixed by changing mutex like so:

Index: include/std/mutex
===================================================================
--- include/std/mutex   (revision 181013)
+++ include/std/mutex   (working copy)
@@ -760,7 +760,7 @@
   {
   private:
     typedef __gthread_once_t __native_type;
-    __native_type  _M_once = __GTHREAD_ONCE_INIT;
+    __native_type  _M_once = { __GTHREAD_ONCE_INIT };

   public:
     /// Constructor

But that would be wrong for other platforms - I'll have to look into this bit,
but you could apply the patch locally for now to get past this problem.

Maybe we need to fixinclude the INIT macro to add extra braces on AIX.

> I also do not understand the conversion error:
> 
> extern int
> pthread_once (pthread_once_t *, void (*)(void))
>                    ;
> 
> static inline int
> __gthread_once (__gthread_once_t *__once, void (*__func) (void))
> {
>   if (__gthread_active_p ())
>     return pthread_once (__once, __func);
>   else
>     return -1;
> }
> 
>       int __e = __gthread_once(&(__once._M_once), &__once_proxy);

I don't understand that either.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]