]> Savannah Git Hosting - gnulib.git/commitdiff
windows-thread: Add support for creating a thread in detached state.
authorBruno Haible <bruno@clisp.org>
Mon, 15 Jul 2019 00:35:58 +0000 (02:35 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 15 Jul 2019 00:35:58 +0000 (02:35 +0200)
* lib/windows-thread.h (GLWTHREAD_ATTR_DETACHED): New macro.
(glwthread_thread_create): Add attr argument.
* lib/windows-thread.c (glwthread_thread_create): Likewise.
* lib/glthread/thread.h (glthread_create): Update.
* lib/thrd.c (thrd_create): Update.

ChangeLog
lib/glthread/thread.h
lib/thrd.c
lib/windows-thread.c
lib/windows-thread.h

index ea541d50ffe8bfbfe9fe8954567bf1558b22caa0..316ae110e5d28ad789119285f1e0a238fc923153 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2019-07-14  Bruno Haible  <bruno@clisp.org>
+
+       windows-thread: Add support for creating a thread in detached state.
+       * lib/windows-thread.h (GLWTHREAD_ATTR_DETACHED): New macro.
+       (glwthread_thread_create): Add attr argument.
+       * lib/windows-thread.c (glwthread_thread_create): Likewise.
+       * lib/glthread/thread.h (glthread_create): Update.
+       * lib/thrd.c (thrd_create): Update.
+
 2019-07-14  Bruno Haible  <bruno@clisp.org>
 
        windows-*: Rename glwthread_spinlock_t to glwthread_initguard_t.
index eef9a46affcc015e4b34e6f556c504b09d2b0033..2c72cc5cdb2ea6e7b0a9f75902e7473f486e07af 100644 (file)
@@ -237,7 +237,7 @@ extern "C" {
 
 typedef glwthread_thread_t gl_thread_t;
 # define glthread_create(THREADP, FUNC, ARG) \
-    glwthread_thread_create (THREADP, FUNC, ARG)
+    glwthread_thread_create (THREADP, 0, FUNC, ARG)
 # define glthread_sigmask(HOW, SET, OSET) \
     /* unsupported */ 0
 # define glthread_join(THREAD, RETVALP) \
index f3f69496b00f1a1a3ea7d0d0c095da06ee439084..cb64185a9918d79153371f71c9df37f28a674453 100644 (file)
@@ -289,7 +289,7 @@ thrd_create (thrd_t *threadp, thrd_start_t mainfunc, void *arg)
   pthread_main_arg->arg = arg;
 
   {
-    int err = glwthread_thread_create (threadp,
+    int err = glwthread_thread_create (threadp, 0,
                                        pthread_main_func, pthread_main_arg);
     if (err != 0)
       free (pthread_main_arg);
index b42bd32baf89d5ff1bc72fc24178c907cccb5a5b..56723db7f733db6e585b8666e87d7b45732e2e03 100644 (file)
@@ -152,7 +152,7 @@ wrapper_func (void *varg)
 }
 
 int
-glwthread_thread_create (glwthread_thread_t *threadp,
+glwthread_thread_create (glwthread_thread_t *threadp, unsigned int attr,
                          void * (*func) (void *), void *arg)
 {
   struct glwthread_thread_struct *thread =
@@ -162,7 +162,7 @@ glwthread_thread_create (glwthread_thread_t *threadp,
     return ENOMEM;
   thread->handle = NULL;
   InitializeCriticalSection (&thread->handle_lock);
-  thread->detached = FALSE;
+  thread->detached = (attr & GLWTHREAD_ATTR_DETACHED ? TRUE : FALSE);
   thread->result = NULL; /* just to be deterministic */
   thread->func = func;
   thread->arg = arg;
index 8bf98fbf4629f329d8704c842465f098c5d327d2..70e5d004194e29b4bbfe513c2080e090b862530a 100644 (file)
@@ -38,7 +38,10 @@ typedef struct glwthread_thread_struct *glwthread_thread_t;
 extern "C" {
 #endif
 
+/* attr is a bit mask, consisting of the following bits: */
+#define GLWTHREAD_ATTR_DETACHED 1
 extern int glwthread_thread_create (glwthread_thread_t *threadp,
+                                    unsigned int attr,
                                     void * (*func) (void *), void *arg);
 extern int glwthread_thread_join (glwthread_thread_t thread, void **retvalp);
 extern int glwthread_thread_detach (glwthread_thread_t thread);