Update README on using libraries in non-standard locations
[bpt/guile.git] / libguile / null-threads.c
CommitLineData
dbb605f5 1/* Copyright (C) 2002, 2006, 2008 Free Software Foundation, Inc.
3d527b27 2 *
73be1d9e
MV
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
3d527b27 7 *
73be1d9e
MV
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
3d527b27 12 *
73be1d9e
MV
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
92205699 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
73be1d9e 16 */
3d527b27 17
dbb605f5
LC
18#ifdef HAVE_CONFIG_H
19# include <config.h>
20#endif
21
9de87eea
MV
22#include <stdlib.h>
23#include "libguile/_scm.h"
3d527b27 24
9de87eea 25#if SCM_USE_NULL_THREADS
3d527b27 26
9de87eea 27#include "libguile/null-threads.h"
3d527b27 28
9de87eea 29static scm_i_pthread_key_t *all_keys = NULL;
3d527b27 30
9de87eea
MV
31static void
32destroy_keys (void)
3d527b27 33{
9de87eea
MV
34 scm_i_pthread_key_t *key;
35 int again;
4b9154e7 36
9de87eea
MV
37 do {
38 again = 0;
39 for (key = all_keys; key; key = key->next)
40 if (key->value && key->destr_func)
4b9154e7 41 {
9de87eea
MV
42 void *v = key->value;
43 key->value = NULL;
44 key->destr_func (v);
45 again = 1;
4b9154e7 46 }
9de87eea 47 } while (again);
3d527b27
MV
48}
49
9de87eea
MV
50int
51scm_i_pthread_key_create (scm_i_pthread_key_t *key,
52 void (*destr_func) (void *))
3d527b27 53{
9de87eea
MV
54 if (all_keys == NULL)
55 atexit (destroy_keys);
3d527b27 56
9de87eea
MV
57 key->next = all_keys;
58 all_keys = key;
59 key->value = NULL;
60 key->destr_func = destr_func;
4b9154e7 61
9de87eea 62 return 0;
3d527b27
MV
63}
64
9de87eea
MV
65#endif /* SCM_USE_NULL_THREADS */
66
3d527b27
MV
67
68/*
69 Local Variables:
70 c-file-style: "gnu"
71 End:
72*/