[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
thread: Fix test link error on DragonFly BSD 6.0
From: |
Bruno Haible |
Subject: |
thread: Fix test link error on DragonFly BSD 6.0 |
Date: |
Mon, 07 Jun 2021 21:31:05 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) |
On DragonFly BSD 6.0, when compiling a testdir with CFLAGS=-g (no gcc
optimizations), I get a link error:
gcc -ggdb -o test-thread_self test-thread_self.o libtests.a
../gllib/libgnu.a libtests.a ../gllib/libgnu.a libtests.a -lm -lm -lm -lm -lm
-lm -lm -lm -lm -lm -lm
../../gltests/../gllib/glthread/thread.h:323: error: undefined reference to
'pthread_create'
collect2: error: ld returned 1 exit status
*** Error code 1 (continuing)
The reason is that glthread/thread.h contains a supposedly inline function
'gl_thread_create'. But on this platform, config.h defines
#define _GL_EXTERN_INLINE_STDHEADER_BUG
#define _GL_INLINE static _GL_UNUSED
#define _GL_EXTERN_INLINE static _GL_UNUSED
That is, no inlining is performed, and the reference to pthread_create
ends up in the file test-thread_self.o.
This patch fixes it, by moving the reference to pthread_create away from
the header file.
2021-06-07 Bruno Haible <bruno@clisp.org>
thread: Fix test link error on DragonFly BSD 6.0.
* lib/glthread/thread.c (gl_thread_create): Moved to here...
* lib/glthread/thread.h (gl_thread_create): ...from here.
(_GLTHREAD_THREAD_INLINE): Remove macro.
Remove _GL_INLINE_HEADER_BEGIN/END invocations.
diff --git a/lib/glthread/thread.c b/lib/glthread/thread.c
index 38ba85d..de44932 100644
--- a/lib/glthread/thread.c
+++ b/lib/glthread/thread.c
@@ -20,7 +20,6 @@
#include <config.h>
/* Specification. */
-# define _GLTHREAD_THREAD_INLINE _GL_EXTERN_INLINE
#include "glthread/thread.h"
#include <stdlib.h>
@@ -203,3 +202,15 @@ const gl_thread_t gl_null_thread /* = { .p = NULL } */;
#endif
/* ========================================================================= */
+
+gl_thread_t
+gl_thread_create (void *(*func) (void *arg), void *arg)
+{
+ gl_thread_t thread;
+ int ret;
+
+ ret = glthread_create (&thread, func, arg);
+ if (ret != 0)
+ abort ();
+ return thread;
+}
diff --git a/lib/glthread/thread.h b/lib/glthread/thread.h
index 1de9dcb..3e84599 100644
--- a/lib/glthread/thread.h
+++ b/lib/glthread/thread.h
@@ -83,14 +83,6 @@
# endif
#endif
-#ifndef _GL_INLINE_HEADER_BEGIN
- #error "Please include config.h first."
-#endif
-_GL_INLINE_HEADER_BEGIN
-#ifndef _GLTHREAD_THREAD_INLINE
-# define _GLTHREAD_THREAD_INLINE _GL_INLINE
-#endif
-
/* ========================================================================= */
#if USE_ISOC_THREADS
@@ -314,17 +306,7 @@ typedef int gl_thread_t;
extern "C" {
#endif
-_GLTHREAD_THREAD_INLINE gl_thread_t
-gl_thread_create (void *(*func) (void *arg), void *arg)
-{
- gl_thread_t thread;
- int ret;
-
- ret = glthread_create (&thread, func, arg);
- if (ret != 0)
- abort ();
- return thread;
-}
+extern gl_thread_t gl_thread_create (void *(*func) (void *arg), void *arg);
#define gl_thread_sigmask(HOW, SET, OSET) \
do \
{ \
@@ -351,6 +333,4 @@ gl_thread_create (void *(*func) (void *arg), void *arg)
}
#endif
-_GL_INLINE_HEADER_END
-
#endif /* _GLTHREAD_THREAD_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- thread: Fix test link error on DragonFly BSD 6.0,
Bruno Haible <=