This is the mail archive of the gcc-patches@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]

Re: other/2764: Fixinclude should fix PTHREAD...Solaris2.7




> Meanwhile, attached is the fixincl.x with this fix added in:
> 
> > /*
> >  * Sun Solaris 2.7 defines PTHREAD_MUTEX_INITIALIZER with a trailing
> >  * "0" for the last field of the pthread_mutex_t structure, which is
> >  * of type upad64_t, which itself is typedef'd to int64_t, but with
> >  * __STDC__ defined (e.g. by -ansi) it is a union. So change the
> >  * initializer to "{0}" instead
> >  */
> > fix = {
> >   hackname = solaris27_mutex_init;
> >   select = '@\(#\)pthread.h' "[ \t]+1.26[ \t]+98/04/12 SMI";
> >   files = pthread.h;
> >   c_fix = format;
> >   c_fix_arg = "%1, {0}}";
> >   c_fix_arg = "(define[ \t]+PTHREAD_MUTEX_INITIALIZER.*),[ \t]*0}$";
> >   test_text = "#define PTHREAD_MUTEX_INITIALIZER {{{0},0}, {{{0}}}, 0}";
> > };

That seems to do the trick, the warning has disappeared.


> However, you may want to also consider what happens if the platform
> is a 64 bit platform.  In that event, the extra brace may be wrong.
> Perhaps we need some sort of #if-test that checks for a fundamental
> type for int64_t?

But solaris2.7's int_types.h typedefs uint64_t to

#ifdef	_LP64
typedef unsigned long		uint64_t;
#else	/* _ILP32 */
#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
typedef unsigned long long	uint64_t;
#endif
#endif

So it's a scalar in any case. Don't ask me why I can put the extra braces
around the scalar, but it seems consistent at least. The following does
not trigger a warning with or without the inner braces:
  struct A { int i; };
  A a = { {1} };

So I'd guess the fixincl hack is always good.

Regards
  Wolfgang

-------------------------------------------------------------------------
Wolfgang Bangerth          email: wolfgang.bangerth@iwr.uni-heidelberg.de
                             www: http://gaia.iwr.uni-heidelberg.de/~wolf




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