exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / windows-thread.h
blob154bdfaef216c0c7bd83f6c194c018482fa208f2
1 /* Creating and controlling threads (native Windows implementation).
2 Copyright (C) 2005-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
20 #ifndef _WINDOWS_THREAD_H
21 #define _WINDOWS_THREAD_H
23 /* This file uses _Noreturn. */
24 #if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first."
26 #endif
28 #define WIN32_LEAN_AND_MEAN /* avoid including junk */
29 #include <windows.h>
31 /* The glwthread_thread_t is a pointer to a structure in memory.
32 Why not the thread handle? If it were the thread handle, it would be hard
33 to implement glwthread_thread_self() (since GetCurrentThread () returns a
34 pseudo-handle, DuplicateHandle (GetCurrentThread ()) returns a handle that
35 must be closed afterwards, and there is no function for quickly retrieving
36 a thread handle from its id).
37 Why not the thread id? I tried it. It did not work: Sometimes ids appeared
38 that did not belong to running threads, and glthread_join failed with ESRCH.
40 typedef struct glwthread_thread_struct *glwthread_thread_t;
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 /* attr is a bit mask, consisting of the following bits: */
47 #define GLWTHREAD_ATTR_DETACHED 1
48 extern int glwthread_thread_create (glwthread_thread_t *threadp,
49 unsigned int attr,
50 void * (*func) (void *), void *arg);
51 extern int glwthread_thread_join (glwthread_thread_t thread, void **retvalp);
52 extern int glwthread_thread_detach (glwthread_thread_t thread);
53 extern glwthread_thread_t glwthread_thread_self (void);
54 extern _Noreturn void glwthread_thread_exit (void *retval);
56 #ifdef __cplusplus
58 #endif
60 #endif /* _WINDOWS_THREAD_H */