This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Build error with Re: ping [PATCH] Fix a deadlock bug in static variable initialization in libsupc++
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: =?big5?b?RG91ZyBLd2FuICjD9q62vHcp?= <dougkwan at google dot com>
- Cc: Jason Merrill <jason at redhat dot com>, gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Fri, 5 Oct 2007 17:18:17 -0400 (EDT)
- Subject: Build error with Re: ping [PATCH] Fix a deadlock bug in static variable initialization in libsupc++
- References: <498552560708021356k5206cebbmc070c183694700e3@mail.gmail.com> <46C37623.1010308@redhat.com> <498552560709171557g2d8b0d76vf1e40483b63612d9@mail.gmail.com>
On Mon, 17 Sep 2007, Doug Kwan (Ãö®¶¼w) wrote:
Hi Jason,
Here is the patch without the skip-list.
-Doug
-----
2007-09-13 Doug Kwan <dougkwan@google.com>
* gcc/gthr-posix.h (__gthread_cond_broadcast, __gthread_cond_wait,
__gthread_cond_wait_recursive, __gthread_self, __gthread_equal):
Add to extend interface for POSIX conditional variables.
(__GTHREAD_HAS_COND): Macro defined to signify support of
conditional variables.
Likewise
* gcc/gthr-single.h (__gthread_cond_broadcast, __gthread_cond_wait,
__gthread_cond_wait_recursive, __gthread_self, __gthread_equal):
Add to extend interface for POSIX conditional variables.
...
A patch in the range 129024:129030, i.e. this one, caused the
following build failure for cris-elf (cutnpasted with wrap):
In file included from
/tmp/hpautotest-gcc1/gcc/libgcc/../gcc/gthr.h:136,
from
/tmp/hpautotest-gcc1/gcc/libgcc/../gcc/unwind-dw2.c:42:
/tmp/hpautotest-gcc1/gcc/libgcc/../gcc/gthr-single.h:255: error:
expected ')' before 'cond'
/tmp/hpautotest-gcc1/gcc/libgcc/../gcc/gthr-single.h:261: error:
expected ')' before 'cond'
/tmp/hpautotest-gcc1/gcc/libgcc/../gcc/gthr-single.h:267: error:
expected ')' before 'cond'
coming from:
Index: gcc/gthr-single.h
===================================================================
--- gcc/gthr-single.h (revision 129024)
+++ gcc/gthr-single.h (revision 129030)
@@ -251,6 +251,25 @@ __gthread_recursive_mutex_unlock (__gthr
return __gthread_mutex_unlock (mutex);
}
+static inline int
+__gthread_cond_broadcast (__gthread_cond_t cond)
+{
+ return 0;
+}
+
+static inline int
+__gthread_cond_wait (__gthread_cond_t cond, __gthread_mutex_t *mutex)
+{
+ return 0;
+}
+
+static inline int
+__gthread_cond_wait_recursive (__gthread_cond_t cond,
+ __gthread_recursive_mutex_t *mutex)
+{
+ return 0;
+}
+
#endif /* _LIBOBJC */
#undef UNUSED
(Immediate cause being lack of __gthread_cond_t type. Tsk tsk,
totally untested.)
At first I thought the correct change would be to add "typedef
int __gthread_cond_t;" to gthr-single.h, but when I looked
deeper, reading gthr.h and the patch, it seemed like these
functions and the __gthread_cond_t type would be unused without
a "#define __GTHREAD_HAS_COND 1". Inspection of the
libstdc++-v3 users of the macro (libsupc++/guard.cc and
include/ext/concurrence.h) support the documentation.
Now, I argue that reverting the part of the patch above (to
gthr-single.h) is the obviously correct choice (it solves the
problem with no regressions from 129024 for cris-elf), but David
Edelsohn disagrees, being on the typedef side. Hence, I can't
safely argue that reverting the patch is the obvious choice.
I mean, having unused, uncalled stubs, does seem wrong. Those
functions and the type are optional, and gthr-single.h doesn't
define the macro saying the option is active.
You might think, why not add the "#define __GTHREAD_HAS_COND 1"
to gthr-single.h too? Well, because then gthr-single.h would
say we have optional functionality that we just have stubs for.
It'd also mean that all users have the macro, and we could just
remove that macro. That doesn't seem to be what was intended.
Please advise.
brgds, H-P