* readline.scm: moved to ./ice-9/
[bpt/guile.git] / libguile / pthread-threads.h
1 /* classes: h_files */
2
3 #ifndef SCM_THREADS_PTHREADS_H
4 #define SCM_THREADS_PTHREADS_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 pthreads-threads implementation. This is a direct mapping.
26 */
27
28 /* This is an interface between Guile and the pthreads thread package. */
29
30 #include <pthread.h>
31 #include <sched.h>
32
33 #include "libguile/threads-plugin.h"
34
35 /* MDJ 021209 <djurfeldt@nada.kth.se>:
36 The separation of the plugin interface and the low-level C API
37 (currently in threads.h) needs to be completed in a sensible way.
38 */
39
40 /* The scm_t_ types are temporarily used both in plugin and low-level API */
41 #define scm_t_thread pthread_t
42
43 #define scm_i_plugin_thread_create pthread_create
44
45 #define scm_i_plugin_thread_join pthread_join
46 #define scm_i_plugin_thread_detach pthread_detach
47 #define scm_i_plugin_thread_self pthread_self
48 #define scm_i_plugin_thread_yield sched_yield
49
50 extern scm_t_mutexattr scm_i_plugin_mutex; /* The "fast" mutex. */
51
52 #define scm_i_plugin_mutex_destroy(m) \
53 pthread_mutex_destroy ((pthread_mutex_t *) (m))
54 #define scm_i_plugin_mutex_trylock(m) \
55 pthread_mutex_trylock ((pthread_mutex_t *) (m))
56
57 extern scm_t_mutexattr scm_i_plugin_rec_mutex;
58
59 #define scm_i_plugin_cond_init pthread_cond_init
60 #define scm_i_plugin_cond_destroy pthread_cond_destroy
61 #define scm_i_plugin_cond_signal pthread_cond_signal
62 #define scm_i_plugin_cond_broadcast pthread_cond_broadcast
63
64 #define scm_t_key pthread_key_t
65
66 #define scm_i_plugin_key_create pthread_key_create
67 #define scm_i_plugin_key_delete pthread_key_delete
68 #define scm_i_plugin_setspecific pthread_setspecific
69 #define scm_i_plugin_getspecific pthread_getspecific
70
71 #define scm_i_plugin_select select
72
73 #ifdef SCM_DEBUG_THREADS
74 void scm_i_assert_heap_locked (void);
75 #endif
76
77 void scm_init_pthread_threads (void);
78
79 #endif /* SCM_THREADS_PTHREADS_H */
80
81 /*
82 Local Variables:
83 c-file-style: "gnu"
84 End:
85 */