bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / code / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: thread: Fix test link error on DragonFly BSD 6.0
Date: Mon, 07 Jun 2021 21:31:05 +0200	[thread overview]
Message-ID: <2717359.GKeOqE04yk@omega> (raw)

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_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.
	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.  */
 #include "glthread/thread.h"
 #include <stdlib.h>
@@ -203,3 +202,15 @@ const gl_thread_t gl_null_thread /* = { .p = NULL } */;
 /* ========================================================================= */
+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
- #error "Please include config.h first."
 /* ========================================================================= */
@@ -314,17 +306,7 @@ typedef int gl_thread_t;
 extern "C" {
-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 /* _GLTHREAD_THREAD_H */

                 reply	other threads:[~2021-06-07 19:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2717359.GKeOqE04yk@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --subject='Re: thread: Fix test link error on DragonFly BSD 6.0' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).