Changes from arch/CVS synchronization
[bpt/guile.git] / libguile / null-threads.h
CommitLineData
3d527b27
MV
1/* classes: h_files */
2
d0350293
MV
3#ifndef SCM_NULL_THREADS_H
4#define SCM_NULL_THREADS_H
3d527b27 5
2b829bbb 6/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
3d527b27 7 *
73be1d9e
MV
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
3d527b27 12 *
73be1d9e 13 * This library is distributed in the hope that it will be useful,
3d527b27 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
73be1d9e
MV
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
3d527b27 17 *
73be1d9e
MV
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
92205699 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
73be1d9e 21 */
3d527b27
MV
22
23\f
24
9de87eea
MV
25/* The null-threads implementation. We provide the subset of the
26 standard pthread API that is used by Guile, but no new threads can
27 be created.
9bc4701c 28
9de87eea
MV
29 This file merely exits so that Guile can be compiled and run
30 without using pthreads. Improving performance via optimizations
31 that are possible in a single-threaded program is not a primary
32 goal.
d0350293 33*/
3d527b27 34
9de87eea 35#include <errno.h>
d0350293 36
9de87eea 37/* Threads
d0350293 38*/
9de87eea
MV
39#define scm_i_pthread_t int
40#define scm_i_pthread_self() 0
41#define scm_i_pthread_create(t,a,f,d) (*(t)=0, (void)(f), ENOSYS)
42#define scm_i_pthread_detach(t) do { } while (0)
43#define scm_i_pthread_exit(v) exit(0)
2e77f720
LC
44#define scm_i_pthread_cancel(t) 0
45#define scm_i_pthread_cleanup_push(t,v) 0
46#define scm_i_pthread_cleanup_pop(e) 0
9de87eea
MV
47#define scm_i_sched_yield() 0
48
49/* Signals
50 */
51#define scm_i_pthread_sigmask sigprocmask
d0350293 52
9de87eea
MV
53/* Mutexes
54 */
55#define SCM_I_PTHREAD_MUTEX_INITIALIZER 0
9de87eea
MV
56#define scm_i_pthread_mutex_t int
57#define scm_i_pthread_mutex_init(m,a) (*(m) = 0)
58#define scm_i_pthread_mutex_destroy(m) do { (void)(m); } while(0)
59#define scm_i_pthread_mutex_trylock(m) ((*(m))++)
60#define scm_i_pthread_mutex_lock(m) ((*(m))++)
61#define scm_i_pthread_mutex_unlock(m) ((*(m))--)
d1138028 62#define scm_i_pthread_mutexattr_recursive 0
9de87eea
MV
63
64/* Condition variables
65 */
66#define SCM_I_PTHREAD_COND_INITIALIZER 0
67#define scm_i_pthread_cond_t int
68#define scm_i_pthread_cond_init(c,a) (*(c) = 0)
69#define scm_i_pthread_cond_destroy(c) do { (void)(c); } while(0)
70#define scm_i_pthread_cond_signal(c) (*(c) = 1)
71#define scm_i_pthread_cond_broadcast(c) (*(c) = 1)
72#define scm_i_pthread_cond_wait(c,m) (abort(), 0)
73#define scm_i_pthread_cond_timedwait(c,m,t) (abort(), 0)
74
75/* Onces
76 */
77#define scm_i_pthread_once_t int
78#define SCM_I_PTHREAD_ONCE_INIT 0
79#define scm_i_pthread_once(o,f) do { \
80 if(!*(o)) { *(o)=1; f (); } \
81 } while(0)
d0350293 82
9de87eea
MV
83/* Thread specific storage
84 */
85typedef struct scm_i_pthread_key_t {
86 struct scm_i_pthread_key_t *next;
87 void *value;
88 void (*destr_func) (void *);
89} scm_i_pthread_key_t;
90
91SCM_API int scm_i_pthread_key_create (scm_i_pthread_key_t *key,
92 void (*destr_func) (void *));
93#define scm_i_pthread_setspecific(k,p) ((k).value = (p))
94#define scm_i_pthread_getspecific(k) ((k).value)
95
96/* Convenience functions
97 */
98#define scm_i_scm_pthread_mutex_lock scm_i_pthread_mutex_lock
661ae7ab 99#define scm_i_dynwind_pthread_mutex_lock scm_i_pthread_mutex_lock
9de87eea
MV
100#define scm_i_scm_pthread_cond_wait scm_i_pthread_cond_wait
101#define scm_i_scm_pthread_cond_timedwait scm_i_pthread_cond_timedwait
3d527b27 102
3d527b27 103
d0350293 104#endif /* SCM_NULL_THREADS_H */
3d527b27
MV
105
106/*
107 Local Variables:
108 c-file-style: "gnu"
109 End:
110*/