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]
Other format: [Raw text]

[committed] jit.dg: fix issue with compilation of test-threads.c


DejaGnu's <dejagnu.h> provides decls of various inline functions,
of which the jit testsuite uses "pass", "fail" and "note".

The jit testcase test-threads.c jumps through some hoops to make
these functions threadsafe, using macros to rename the implementation
in dejagnu.h, giving them a "dejagnu_" prefix, then reimplementing
the names with wrappers that use a mutex.

The DejaGnu functions gained a "static" modifier in
ad36659ffa984a0541cfc2bd27f393e0d7d173a7, which appears to be in
DejaGnu 1.5.2 onwards.

Unfortunately, jit.dg/test-threads.c has forward decls of
"dejagnu_pass" etc, and these don't have "static", leading to conflicts
with later versions of DejaGnu for which "pass" etc have "static".

This patch fixes things by removing the forward decls of
"dejagnu_pass", moving the usage of them to a point at which dejagnu.h
has been included, which ought to work with both earlier and later
versions of DejaGnu.

Fixes compilation of test-threads.c in jit testsuite.

Committed to trunk as r244597.

gcc/testsuite/ChangeLog:
	* jit.dg/test-threads.c (dejagnu_pass): Remove decl.
	(dejagnu_fail): Likewise.
	(dejagnu_note): Likewise.
	(pass): Provide forward decl, moving true decl to after #include
	of harness.h.
	(fail): Likewise.
	(note): Likewise.
---
 gcc/testsuite/jit.dg/test-threads.c | 97 ++++++++++++++++++++-----------------
 1 file changed, 52 insertions(+), 45 deletions(-)

diff --git a/gcc/testsuite/jit.dg/test-threads.c b/gcc/testsuite/jit.dg/test-threads.c
index d4e53b2..03fea57 100644
--- a/gcc/testsuite/jit.dg/test-threads.c
+++ b/gcc/testsuite/jit.dg/test-threads.c
@@ -20,57 +20,16 @@ static pthread_mutex_t dg_mutex = PTHREAD_MUTEX_INITIALIZER;
    harness.h injects macros before including <dejagnu.h> so that the
    pass/fail functions become "dejagnu_pass"/"dejagnu_fail" etc.  */
 
-void dejagnu_pass (const char* fmt, ...);
-void dejagnu_fail (const char* fmt, ...);
-void dejagnu_note (const char* fmt, ...);
-
-/* We now provide our own implementations of "pass"/"fail"/"note", which
-   call the underlying dejagnu implementations, but with a mutex.  */
+/* Forward decls of our implementations of pass/fail/note.  */
 
 inline void
-pass (const char* fmt, ...)
-{
-  va_list ap;
-  char buffer[512];
-
-  va_start (ap, fmt);
-  vsnprintf (buffer, sizeof (buffer), fmt, ap);
-  va_end (ap);
-
-  pthread_mutex_lock (&dg_mutex);
-  dejagnu_pass (buffer);
-  pthread_mutex_unlock (&dg_mutex);
-}
+pass (const char* fmt, ...);
 
 inline void
-fail (const char* fmt, ...)
-{
-  va_list ap;
-  char buffer[512];
-
-  va_start (ap, fmt);
-  vsnprintf (buffer, sizeof (buffer), fmt, ap);
-  va_end (ap);
-
-  pthread_mutex_lock (&dg_mutex);
-  dejagnu_fail (buffer);
-  pthread_mutex_unlock (&dg_mutex);
-}
+fail (const char* fmt, ...);
 
 inline void
-note (const char* fmt, ...)
-{
-  va_list ap;
-  char buffer[512];
-
-  va_start (ap, fmt);
-  vsnprintf (buffer, sizeof (buffer), fmt, ap);
-  va_end (ap);
-
-  pthread_mutex_lock (&dg_mutex);
-  dejagnu_note (buffer);
-  pthread_mutex_unlock (&dg_mutex);
-}
+note (const char* fmt, ...);
 
 #define MAKE_DEJAGNU_H_THREADSAFE
 
@@ -91,6 +50,54 @@ note (const char* fmt, ...)
 #undef COMBINED_TEST
 #include "harness.h"
 
+/* We now provide our own implementations of "pass"/"fail"/"note", which
+   call the underlying dejagnu implementations, but with a mutex.  */
+
+inline void
+pass (const char* fmt, ...)
+{
+  va_list ap;
+  char buffer[512];
+
+  va_start (ap, fmt);
+  vsnprintf (buffer, sizeof (buffer), fmt, ap);
+  va_end (ap);
+
+  pthread_mutex_lock (&dg_mutex);
+  dejagnu_pass (buffer);
+  pthread_mutex_unlock (&dg_mutex);
+}
+
+inline void
+fail (const char* fmt, ...)
+{
+  va_list ap;
+  char buffer[512];
+
+  va_start (ap, fmt);
+  vsnprintf (buffer, sizeof (buffer), fmt, ap);
+  va_end (ap);
+
+  pthread_mutex_lock (&dg_mutex);
+  dejagnu_fail (buffer);
+  pthread_mutex_unlock (&dg_mutex);
+}
+
+inline void
+note (const char* fmt, ...)
+{
+  va_list ap;
+  char buffer[512];
+
+  va_start (ap, fmt);
+  vsnprintf (buffer, sizeof (buffer), fmt, ap);
+  va_end (ap);
+
+  pthread_mutex_lock (&dg_mutex);
+  dejagnu_note (buffer);
+  pthread_mutex_unlock (&dg_mutex);
+}
+
 struct thread_data
 {
   pthread_t m_tid;
-- 
1.8.5.3


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