annotate lib/tls.c @ 9084:2932e92d6e31

* lib/version-etc.c (version_etc_va): Default to GPLv3+. * NEWS: Document this change.
author Eric Blake <ebb9@byu.net>
date Tue, 10 Jul 2007 12:22:36 +0000
parents 0b98a4edecb2
children bbbbbf4cd1c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6042
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Thread-local storage in multithreaded situations.
8682
0b98a4edecb2 Fix typo in return type.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
2 Copyright (C) 2005-2007 Free Software Foundation, Inc.
6042
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
7139
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 6042
diff changeset
4 This program is free software; you can redistribute it and/or modify
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 6042
diff changeset
5 it under the terms of the GNU General Public License as published by
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 6042
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
6042
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 any later version.
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
7139
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 6042
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 6042
diff changeset
12 GNU General Public License for more details.
6042
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
7139
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 6042
diff changeset
14 You should have received a copy of the GNU General Public License
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 6042
diff changeset
15 along with this program; if not, write to the Free Software Foundation,
adb21c293305 Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents: 6042
diff changeset
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
6042
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 /* Written by Bruno Haible <bruno@clisp.org>, 2005. */
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19
7304
1c4ed7637c24 Include <config.h> unconditionally.
Bruno Haible <bruno@clisp.org>
parents: 7139
diff changeset
20 #include <config.h>
6042
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include "tls.h"
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 /* ========================================================================= */
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #if USE_POSIX_THREADS
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #endif
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 /* ========================================================================= */
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 #if USE_PTH_THREADS
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #endif
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 /* ========================================================================= */
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 #if USE_SOLARIS_THREADS
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 /* Use the old Solaris threads library. */
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 /* ------------------------- gl_tls_key_t datatype ------------------------- */
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43
8682
0b98a4edecb2 Fix typo in return type.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
44 void *
6042
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 glthread_tls_get (thread_key_t key)
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 {
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 void *value;
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 if (thr_getspecific (key, &value) != 0)
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 abort ();
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 return value;
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 }
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 #endif
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 /* ========================================================================= */
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 #if USE_WIN32_THREADS
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 #endif
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61
ab97b105b804 New module 'tls'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 /* ========================================================================= */