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]

fixinc for PTHREAD_MUTEX_INITIALIZER



On mulling this over some more and looking at this:

/*
 * Sun Solaris 2.6 & 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
 */

I have to wonder if the current fix for 2.7 is even the right one.
It seems to me that this might be "more correct":

fix = {
  hackname = solaris_mutex_init;
  select = '@\(#\)pthread.h' "[ \t]+1.[12]6[ \t]+9[0-9/]+ SMI";
  files = pthread.h;
  c_fix = format;
  c_fix_arg = "#ifdef __STDC__\n"
              "%1, {0}}\n"
              "#else\n"
              "%0\n"
              "#endif";
  c_fix_arg = "(#define[ \t]+PTHREAD_MUTEX_INITIALIZER.*),[ \t]*0}$";
  test_text =
  '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
  "#define PTHREAD_MUTEX_INITIALIZER {{{0},0}, {{{0}}}, 0}";
};

for those not interested in following the funny formatting,
it would change the single line:

  #define PTHREAD_MUTEX_INITIALIZER {{{0},0}, {{{0}}}, 0}

into this (approximately):

  #if defined( __STDC__ ) && words-are-32-bits-too?
  #define PTHREAD_MUTEX_INITIALIZER {{{0},0}, {{{0}}}, {0}}
  #else
  #define PTHREAD_MUTEX_INITIALIZER {{{0},0}, {{{0}}}, 0}
  #endif

Portmeisters?


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