This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
fixincludes/3195 PTHREAD_MUTEX_INITIALIZER on Solaris
- To: GCC-patches at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
- Subject: fixincludes/3195 PTHREAD_MUTEX_INITIALIZER on Solaris
- From: Bruce Korb <bkorb at veritas dot com>
- Date: Wed, 27 Jun 2001 08:28:28 -0700
- CC: Bruce Korb <bkorb at pacbell dot net>, "Loren J. Rittle" <ljrittle at acm dot org>, Sylvain dot Pion at sophia dot inria dot fr
Hi all,
I've done a little research now, and I believe that my analysis
here: http://gcc.gnu.org/ml/gcc-patches/2001-06/msg01683.html
is correct. Viz., we need to put brackets around the final zero
only when the final element is a union. It seems to be a union
when __STDC__ is defined.
compiling this thus `gcc -ansi -Wall -o XX.o -c XX.C`:
// Preprocessed source code is attached.
#include <memory>
int main()
{
std::allocator<int> a;
a.allocate(2);
return 0;
}
shows the problem, whereas `gcc -Wall -o XX.o -c XX.c` on:
#include <sys/types.h>
#include <pthread.h>
pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;
will yield a problem WITH the current change:
$ gcc -Wall -c -o XX.o XX.c
XX.c:3: warning: braces around scalar initializer
XX.c:3: warning: (near initialization for `x.__pthread_mutex_data')
This is under Solaris 2.8, too. Therefore, the text for ALL versions
of Solaris needs to be transmuted to:
#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
#define PTHREAD_MUTEX_INITIALIZER {<whatever>, 0}
#else
#define PTHREAD_MUTEX_INITIALIZER {<whatever>, {0}}
#endif
Perfect:
$ gcc -Wall -c -o XX.o XX.c
$ gcc -ansi -Wall -o XX.o -c XX.C
$
OK. Barring complaint before I get home tonight, the new fix is this.
Please examine upad64_t typedef in sys/types.h before complaining.
This should go in both mainline and branch.
fix = {
hackname = solaris_mutex_init;
select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
files = pthread.h;
c_fix = format;
c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
"%0\n"
"#else\n"
"%1, {0}}\n"
"#endif";
c_fix_arg = "(^#define[ \t]+PTHREAD_MUTEX_INITIALIZER[ \t]+{.*),[
\t]*0}$";
test_text =
'#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
"#define PTHREAD_MUTEX_INITIALIZER {{{0},0}, {{{0}}}, 0}";
};