This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: other/2764: Fixinclude should fix PTHREAD...Solaris2.7
- To: Bruce Korb <bkorb at pacbell dot net>
- Subject: Re: other/2764: Fixinclude should fix PTHREAD...Solaris2.7
- From: Wolfgang Bangerth <wolfgang dot bangerth at iwr dot uni-heidelberg dot de>
- Date: Tue, 15 May 2001 13:07:40 +0200 (MET DST)
- cc: gcc-patches at gcc dot gnu dot org
> 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