annotate lib/glthread/tls.h @ 16214:ec738d6aeef5

Talk about "native Windows API", not "Win32". * lib/classpath.c: Update comments to mention native Windows. * lib/csharpexec.c: Likewise. * lib/dup2.c: Likewise. * lib/error.c: Likewise. * lib/fcntl.c: Likewise. * lib/filename.h: Likewise. * lib/findprog.c: Likewise. * lib/get-rusage-as.c: Likewise. * lib/get-rusage-data.c: Likewise. * lib/getpagesize.c: Likewise. * lib/javaexec.c: Likewise. * lib/msvc-inval.c: Likewise. * lib/msvc-nothrow.c: Likewise. * lib/nanosleep.c: Likewise. * lib/nonblocking.c: Likewise. * lib/printf-parse.c: Likewise. * lib/setlocale.c: Likewise. * lib/sigaction.c: Likewise. * lib/strerror_r.c: Likewise. * lib/tmpdir.c: Likewise. * lib/vasnprintf.c: Likewise. * lib/w32spawn.h: Likewise. * lib/waitpid.c: Likewise. * lib/stdio.in.h (fdopen, fopen, freopen): Likewise. * m4/locale-ar.m4: Likewise. * m4/locale-fr.m4: Likewise. * m4/locale-ja.m4: Likewise. * m4/locale-tr.m4: Likewise. * m4/locale-zh.m4: Likewise. * m4/printf.m4: Likewise. * tests/test-cloexec.c: Likewise. * tests/test-copy-acl.sh: Likewise. * tests/test-copy-file.sh: Likewise. * tests/test-file-has-acl.sh: Likewise. * tests/test-set-mode-acl.sh: Likewise. * tests/test-dup-safer.c: Likewise. * tests/test-dup2.c: Likewise. * tests/test-dup3.c: Likewise. * tests/test-fcntl.c: Likewise. * tests/test-nonblocking-pipe.h: Likewise. * tests/test-nonblocking-socket.h: Likewise. * tests/test-pipe.c: Likewise. * tests/test-pipe2.c: Likewise. * tests/test-spawn-pipe-child.c: Likewise. * doc/acl-resources.txt: Likewise. * lib/getaddrinfo.c (WINDOWS_NATIVE): Renamed from WIN32_NATIVE. * tests/test-poll.c (WINDOWS_NATIVE): Likewise. * tests/test-select.h (WINDOWS_NATIVE): Likewise. * lib/localcharset.c: Update comments to mention native Windows. (WINDOWS_NATIVE): Renamed from WIN32_NATIVE. * lib/localename.c: Likewise. * lib/progreloc.c: Likewise. * lib/relocatable.c: Likewise. * lib/poll.c (WINDOWS_NATIVE): Renamed from WIN32_NATIVE. (windows_compute_revents): Renamed from win32_compute_revents. (windows_compute_revents_socket): Renamed from win32_compute_revents_socket. * lib/select.c: Update comments to mention native Windows. (windows_poll_handle): Renamed from win32_poll_handle. * m4/threadlib.m4: Update comments to mention native Windows. (gl_THREADLIB_EARLY_BODY, gl_THREADLIB_BODY): Expect --enable-threads=windows instead of --enable-threads=win32. Set USE_WINDOWS_THREADS, not USE_WIN32_THREADS. * lib/glthread/lock.h: Update comments to mention native Windows. (USE_WINDOWS_THREADS): Renamed from USE_WIN32_THREADS. * lib/glthread/lock.c (USE_WINDOWS_THREADS): Renamed from USE_WIN32_THREADS. * lib/glthread/cond.h (USE_WINDOWS_THREADS): Likewise. * lib/glthread/cond.c (USE_WINDOWS_THREADS): Likewise. * lib/glthread/thread.h (USE_WINDOWS_THREADS): Likewise. * lib/glthread/thread.c (USE_WINDOWS_THREADS): Likewise. * lib/glthread/tls.h (USE_WINDOWS_THREADS): Likewise. * lib/glthread/tls.c (USE_WINDOWS_THREADS): Likewise. * lib/glthread/yield.h (USE_WINDOWS_THREADS): Likewise. * tests/test-cond.c (USE_WINDOWS_THREADS): Likewise. * tests/test-thread_create.c (USE_WINDOWS_THREADS): Likewise. * tests/test-lock.c (USE_WINDOWS_THREADS): Likewise. (TEST_WINDOWS_THREADS): Renamed from TEST_WIN32_THREADS. * tests/test-tls.c: Likewise. Rationale: Microsoft renamed the "Win32 API" to "Windows API", as it is available on both 32-bit and 64-bit Windows systems. But in gnulib, we treat Cygwin like a Unix platform, therefore the main line of distinction is between "native Windows" on one side and Unix/ POSIX systems on the other side. More details in <https://lists.gnu.org/archive/html/bug-gnulib/2012-01/msg00027.html>. Suggested by Paul Eggert.
author Bruno Haible <bruno@clisp.org>
date Wed, 04 Jan 2012 14:31:33 +0100
parents 8250f2777afc
children e542fd46ad6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10318
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Thread-local storage in multithreaded situations.
16201
8250f2777afc maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents: 15816
diff changeset
2 Copyright (C) 2005, 2007-2012 Free Software Foundation, Inc.
10318
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2005. */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 /* This file contains thread-local storage primitives for use with a given
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 thread library. It does not contain primitives for creating threads or
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 for other multithreading primitives.
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 Type: gl_tls_key_t
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 Initialization: gl_tls_key_init (name, destructor);
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 Getting per-thread value: gl_tls_get (name)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 Setting per-thread value: gl_tls_set (name, pointer);
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 De-initialization: gl_tls_key_destroy (name);
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 Equivalent functions with control of error handling:
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 Initialization: err = glthread_tls_key_init (&name, destructor);
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 Setting per-thread value: err = glthread_tls_set (&name, pointer);
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 De-initialization: err = glthread_tls_key_destroy (&name);
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 A per-thread value is of type 'void *'.
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 A destructor is a function pointer of type 'void (*) (void *)', called
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 when a thread exits, and taking the last per-thread value as argument. It
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 is unspecified whether the destructor function is called when the last
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 per-thread value is NULL. On some platforms, the destructor function is
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 not called at all.
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 #ifndef _TLS_H
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 #define _TLS_H
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 #include <errno.h>
10326
9af9e0a74e40 Include <stdlib.h> always.
Bruno Haible <bruno@clisp.org>
parents: 10318
diff changeset
47 #include <stdlib.h>
10318
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 /* ========================================================================= */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 #if USE_POSIX_THREADS
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 /* Use the POSIX threads library. */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 # include <pthread.h>
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 # if PTHREAD_IN_USE_DETECTION_HARD
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 /* The pthread_in_use() detection needs to be done at runtime. */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 # define pthread_in_use() \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 glthread_in_use ()
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 extern int glthread_in_use (void);
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 # endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 # if USE_POSIX_THREADS_WEAK
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 /* Use weak references to the POSIX threads library. */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 # pragma weak pthread_key_create
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 # pragma weak pthread_getspecific
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 # pragma weak pthread_setspecific
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 # pragma weak pthread_key_delete
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 # ifndef pthread_self
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 # pragma weak pthread_self
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 # endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 # if !PTHREAD_IN_USE_DETECTION_HARD
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 # pragma weak pthread_cancel
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 # define pthread_in_use() (pthread_cancel != NULL)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 # endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 # else
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 # if !PTHREAD_IN_USE_DETECTION_HARD
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 # define pthread_in_use() 1
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 # endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 # endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 /* ------------------------- gl_tls_key_t datatype ------------------------- */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 typedef union
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 {
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 void *singlethread_value;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 pthread_key_t key;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 }
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 gl_tls_key_t;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 # define glthread_tls_key_init(KEY, DESTRUCTOR) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 (pthread_in_use () \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 ? pthread_key_create (&(KEY)->key, DESTRUCTOR) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 : ((KEY)->singlethread_value = NULL, 0))
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 # define gl_tls_get(NAME) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 (pthread_in_use () \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 ? pthread_getspecific ((NAME).key) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 : (NAME).singlethread_value)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 # define glthread_tls_set(KEY, POINTER) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 (pthread_in_use () \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 ? pthread_setspecific ((KEY)->key, (POINTER)) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 : ((KEY)->singlethread_value = (POINTER), 0))
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 # define glthread_tls_key_destroy(KEY) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112 (pthread_in_use () ? pthread_key_delete ((KEY)->key) : 0)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 #endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 /* ========================================================================= */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 #if USE_PTH_THREADS
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 /* Use the GNU Pth threads library. */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 # include <pth.h>
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 # if USE_PTH_THREADS_WEAK
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 /* Use weak references to the GNU Pth threads library. */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 # pragma weak pth_key_create
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 # pragma weak pth_key_getdata
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 # pragma weak pth_key_setdata
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 # pragma weak pth_key_delete
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 # pragma weak pth_cancel
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134 # define pth_in_use() (pth_cancel != NULL)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 # else
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138 # define pth_in_use() 1
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140 # endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
142 /* ------------------------- gl_tls_key_t datatype ------------------------- */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
143
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144 typedef union
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
145 {
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146 void *singlethread_value;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 pth_key_t key;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148 }
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149 gl_tls_key_t;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 # define glthread_tls_key_init(KEY, DESTRUCTOR) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151 (pth_in_use () \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152 ? (!pth_key_create (&(KEY)->key, DESTRUCTOR) ? errno : 0) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153 : ((KEY)->singlethread_value = NULL, 0))
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154 # define gl_tls_get(NAME) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 (pth_in_use () \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156 ? pth_key_getdata ((NAME).key) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 : (NAME).singlethread_value)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158 # define glthread_tls_set(KEY, POINTER) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 (pth_in_use () \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
160 ? (!pth_key_setdata ((KEY)->key, (POINTER)) ? errno : 0) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
161 : ((KEY)->singlethread_value = (POINTER), 0))
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
162 # define glthread_tls_key_destroy(KEY) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163 (pth_in_use () \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164 ? (!pth_key_delete ((KEY)->key) ? errno : 0) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165 : 0)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
166
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
167 #endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
168
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
169 /* ========================================================================= */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
170
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
171 #if USE_SOLARIS_THREADS
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
172
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
173 /* Use the old Solaris threads library. */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
174
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
175 # include <thread.h>
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
176
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
177 # if USE_SOLARIS_THREADS_WEAK
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
178
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
179 /* Use weak references to the old Solaris threads library. */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
180
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
181 # pragma weak thr_keycreate
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
182 # pragma weak thr_getspecific
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
183 # pragma weak thr_setspecific
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
184
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
185 # pragma weak thr_suspend
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
186 # define thread_in_use() (thr_suspend != NULL)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
187
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
188 # else
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
189
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
190 # define thread_in_use() 1
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
191
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
192 # endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
193
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
194 /* ------------------------- gl_tls_key_t datatype ------------------------- */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
195
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
196 typedef union
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
197 {
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
198 void *singlethread_value;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
199 thread_key_t key;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
200 }
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
201 gl_tls_key_t;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
202 # define glthread_tls_key_init(KEY, DESTRUCTOR) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
203 (thread_in_use () \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
204 ? thr_keycreate (&(KEY)->key, DESTRUCTOR) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
205 : ((KEY)->singlethread_value = NULL, 0))
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
206 # define gl_tls_get(NAME) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
207 (thread_in_use () \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
208 ? glthread_tls_get_multithreaded ((NAME).key) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
209 : (NAME).singlethread_value)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
210 extern void *glthread_tls_get_multithreaded (thread_key_t key);
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
211 # define glthread_tls_set(KEY, POINTER) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
212 (thread_in_use () \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
213 ? thr_setspecific ((KEY)->key, (POINTER)) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
214 : ((KEY)->singlethread_value = (POINTER), 0))
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
215 # define glthread_tls_key_destroy(KEY) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
216 /* Unsupported. */ \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
217 0
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
218
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
219 #endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
220
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
221 /* ========================================================================= */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
222
16214
ec738d6aeef5 Talk about "native Windows API", not "Win32".
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
223 #if USE_WINDOWS_THREADS
10318
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
224
15816
db340f34e324 glthread/*, strsignal: Support for MSVC.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
225 # define WIN32_LEAN_AND_MEAN /* avoid including junk */
10318
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
226 # include <windows.h>
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
227
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
228 /* ------------------------- gl_tls_key_t datatype ------------------------- */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
229
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
230 typedef DWORD gl_tls_key_t;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
231 # define glthread_tls_key_init(KEY, DESTRUCTOR) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
232 /* The destructor is unsupported. */ \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
233 ((*(KEY) = TlsAlloc ()) == (DWORD)-1 ? EAGAIN : ((void) (DESTRUCTOR), 0))
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
234 # define gl_tls_get(NAME) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
235 TlsGetValue (NAME)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
236 # define glthread_tls_set(KEY, POINTER) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
237 (!TlsSetValue (*(KEY), POINTER) ? EINVAL : 0)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
238 # define glthread_tls_key_destroy(KEY) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
239 (!TlsFree (*(KEY)) ? EINVAL : 0)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
240
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
241 #endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
242
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
243 /* ========================================================================= */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
244
16214
ec738d6aeef5 Talk about "native Windows API", not "Win32".
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
245 #if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS)
10318
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
246
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
247 /* Provide dummy implementation if threads are not supported. */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
248
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
249 /* ------------------------- gl_tls_key_t datatype ------------------------- */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
250
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
251 typedef struct
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
252 {
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
253 void *singlethread_value;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
254 }
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
255 gl_tls_key_t;
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
256 # define glthread_tls_key_init(KEY, DESTRUCTOR) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
257 ((KEY)->singlethread_value = NULL, \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
258 (void) (DESTRUCTOR), \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
259 0)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
260 # define gl_tls_get(NAME) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
261 (NAME).singlethread_value
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
262 # define glthread_tls_set(KEY, POINTER) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
263 ((KEY)->singlethread_value = (POINTER), 0)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
264 # define glthread_tls_key_destroy(KEY) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
265 0
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
266
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
267 #endif
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
268
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
269 /* ========================================================================= */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
270
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
271 /* Macros with built-in error handling. */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
272
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
273 /* ------------------------- gl_tls_key_t datatype ------------------------- */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
274
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
275 #define gl_tls_key_init(NAME, DESTRUCTOR) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
276 do \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277 { \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278 if (glthread_tls_key_init (&NAME, DESTRUCTOR)) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
279 abort (); \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
280 } \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
281 while (0)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
282 #define gl_tls_set(NAME, POINTER) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
283 do \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
284 { \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
285 if (glthread_tls_set (&NAME, POINTER)) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
286 abort (); \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
287 } \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
288 while (0)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
289 #define gl_tls_key_destroy(NAME) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
290 do \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
291 { \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
292 if (glthread_tls_key_destroy (&NAME)) \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
293 abort (); \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
294 } \
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
295 while (0)
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
296
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
297 /* ========================================================================= */
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
298
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
299 #endif /* _TLS_H */