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]

fixincludes/3195 PTHREAD_MUTEX_INITIALIZER on Solaris



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}";
};


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