*** empty log message ***
[bpt/guile.git] / libguile / null-threads.h
1 /* classes: h_files */
2
3 #ifndef SCM_NULL_THREADS_H
4 #define SCM_NULL_THREADS_H
5
6 /* Copyright (C) 2002 Free Software Foundation, Inc.
7 *
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.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
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
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 \f
24
25 /* The null-threads implementation. We provide the standard API, but
26 no new threads can be created.
27 */
28
29 #error temporarily broken, compile with threads enabled (default option)
30
31 /* We can't switch so don't bother trying.
32 */
33 #undef SCM_THREAD_SWITCHING_CODE
34 #define SCM_THREAD_SWITCHING_CODE
35
36 #define scm_t_thread int
37
38 /* The "(void)(...)" constructs in the expansions are there to ensure
39 that the side effects of the argument expressions take place.
40 */
41
42 #define scm_thread_create(th,proc,data) ((void)(proc), (void)(data), ENOTSUP)
43 #define scm_thread_join(th) do { (void)(th); abort(); } while(0)
44 #define scm_thread_detach(th) do { (void)(th); abort(); } while(0)
45 #define scm_thread_self() 0
46
47 #define scm_t_mutex int
48
49 #define scm_mutex_init(mx) do { (void)(mx); } while(0)
50 #define scm_mutex_destroy(mx) do { (void)(mx); } while(0)
51 #define scm_mutex_lock(mx) do { (void)(mx); } while(0)
52 #define scm_mutex_trylock(mx) ((void)(mx), 1)
53 #define scm_mutex_unlock(mx) do { (void)(mx); } while(0)
54
55 #define scm_t_cond int
56
57 #define scm_cond_init(cv) do { (void)(cv); } while(0)
58 #define scm_cond_destroy(cv) do { (void)(cv); } while(0)
59 #define scm_cond_wait(cv,mx) ((void)(cv), (void)(mx), ENOTSUP)
60 #define scm_cond_timedwait(cv,mx,at) ((void)(cv), (void)(mx), (void)(at), \
61 ENOTSUP)
62 #define scm_cond_signal(cv) do { (void)(cv); } while(0)
63 #define scm_cond_broadcast(cv) do { (void)(cv); } while(0)
64
65 #define scm_thread_select select
66
67 typedef void **scm_t_key;
68
69 #define scm_key_create(keyp) do { *(keyp) = malloc(sizeof(void*)); \
70 } while(0)
71 #define scm_key_delete(key) do { free(key); } while(0)
72 #define scm_key_setspecific(key, value) do { *(key) = (value); } while(0)
73 #define scm_key_getspecific(key) *(key)
74
75 #if 0
76
77 /* These are the actual prototypes of the functions/macros defined
78 above. We list them here for reference. */
79
80 typedef int scm_t_thread;
81
82 SCM_API int scm_thread_create (scm_t_thread *th,
83 void (*proc) (void *), void *data);
84 SCM_API void scm_thread_join (scm_t_thread th);
85 SCM_API void scm_thread_detach (scm_t_thread th);
86 SCM_API scm_t_thread scm_thread_self (void);
87
88 typedef int scm_t_mutex;
89
90 SCM_API void scm_mutex_init (scm_t_mutex *mx);
91 SCM_API void scm_mutex_destroy (scm_t_mutex *mx);
92 SCM_API void scm_mutex_lock (scm_t_mutex *mx);
93 SCM_API int scm_mutex_trylock (scm_t_mutex *mx);
94 SCM_API void scm_mutex_unlock (scm_t_mutex *mx);
95
96 typedef int scm_t_cond;
97
98 SCM_API void scm_cond_init (scm_t_cond *cv);
99 SCM_API void scm_cond_destroy (scm_t_cond *cv);
100 SCM_API void scm_cond_wait (scm_t_cond *cv, scm_t_mutex *mx);
101 SCM_API int scm_cond_timedwait (scm_t_cond *cv, scm_t_mutex *mx,
102 scm_t_timespec *abstime);
103 SCM_API void scm_cond_signal (scm_t_cond *cv);
104 SCM_API void scm_cond_broadcast (scm_t_cond *cv);
105
106 typedef int scm_t_key;
107
108 SCM_API void scm_key_create (scm_t_key *keyp);
109 SCM_API void scm_key_delete (scm_t_key key);
110 SCM_API void scm_key_setspecific (scm_t_key key, const void *value);
111 SCM_API void *scm_key_getspecific (scm_t_key key);
112
113 SCM_API int scm_thread_select (int nfds,
114 SELECT_TYPE *readfds,
115 SELECT_TYPE *writefds,
116 SELECT_TYPE *exceptfds,
117 struct timeval *timeout);
118
119 #endif
120
121 #endif /* SCM_NULL_THREADS_H */
122
123 /*
124 Local Variables:
125 c-file-style: "gnu"
126 End:
127 */