* 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-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.
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) \
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);
}
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 =
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;
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);