Commit | Line | Data |
---|---|---|
eac85310 MV |
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 program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2, or (at your option) | |
11 | * any later version. | |
12 | * | |
13 | * This program 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 | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this software; see the file COPYING. If not, write to | |
20 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |
21 | * Boston, MA 02111-1307 USA | |
22 | * | |
23 | * As a special exception, the Free Software Foundation gives permission | |
24 | * for additional uses of the text contained in its release of GUILE. | |
25 | * | |
26 | * The exception is that, if you link the GUILE library with other files | |
27 | * to produce an executable, this does not by itself cause the | |
28 | * resulting executable to be covered by the GNU General Public License. | |
29 | * Your use of that executable is in no way restricted on account of | |
30 | * linking the GUILE library code into it. | |
31 | * | |
32 | * This exception does not however invalidate any other reasons why | |
33 | * the executable file might be covered by the GNU General Public License. | |
34 | * | |
35 | * This exception applies only to the code released by the | |
36 | * Free Software Foundation under the name GUILE. If you copy | |
37 | * code from other Free Software Foundation releases into a copy of | |
38 | * GUILE, as the General Public License permits, the exception does | |
39 | * not apply to the code that you add in this way. To avoid misleading | |
40 | * anyone as to the status of such modified files, you must delete | |
41 | * this exception notice from them. | |
42 | * | |
43 | * If you write modifications of your own for GUILE, it is your choice | |
44 | * whether to permit this exception to apply to your modifications. | |
45 | * If you do not wish that, delete this exception notice. */ | |
46 | ||
47 | \f | |
48 | ||
9bc4701c | 49 | /* The pthreads-threads implementation. This is a direct mapping. |
eac85310 MV |
50 | */ |
51 | ||
9bc4701c MD |
52 | /* This is an interface between Guile and the pthreads thread package. */ |
53 | ||
eac85310 | 54 | #include <pthread.h> |
0b6843b1 | 55 | #include <sched.h> |
eac85310 | 56 | |
29717c89 MD |
57 | #include "libguile/threads-plugin.h" |
58 | ||
9bc4701c MD |
59 | /* MDJ 021209 <djurfeldt@nada.kth.se>: |
60 | The separation of the plugin interface and the low-level C API | |
61 | (currently in threads.h) needs to be completed in a sensible way. | |
62 | */ | |
63 | ||
64 | /* The scm_t_ types are temporarily used both in plugin and low-level API */ | |
65 | #define scm_t_thread pthread_t | |
eac85310 | 66 | |
9bc4701c | 67 | #define scm_i_plugin_thread_create pthread_create |
eac85310 | 68 | |
9bc4701c MD |
69 | #define scm_i_plugin_thread_join pthread_join |
70 | #define scm_i_plugin_thread_detach pthread_detach | |
0b6843b1 MD |
71 | #define scm_i_plugin_thread_self pthread_self |
72 | #define scm_i_plugin_thread_yield sched_yield | |
eac85310 | 73 | |
28d52ebb | 74 | extern scm_t_mutexattr scm_i_plugin_mutex; /* The "fast" mutex. */ |
eac85310 | 75 | |
0b6843b1 MD |
76 | #define scm_i_plugin_mutex_destroy(m) \ |
77 | pthread_mutex_destroy ((pthread_mutex_t *) (m)) | |
78 | #define scm_i_plugin_mutex_trylock(m) \ | |
79 | pthread_mutex_trylock ((pthread_mutex_t *) (m)) | |
eac85310 | 80 | |
28d52ebb MD |
81 | extern scm_t_mutexattr scm_i_plugin_rec_mutex; |
82 | ||
9bc4701c | 83 | #define scm_i_plugin_cond_init pthread_cond_init |
6da2dfc4 | 84 | #define scm_i_plugin_cond_destroy pthread_cond_destroy |
9bc4701c MD |
85 | #define scm_i_plugin_cond_signal pthread_cond_signal |
86 | #define scm_i_plugin_cond_broadcast pthread_cond_broadcast | |
eac85310 | 87 | |
9bc4701c | 88 | #define scm_t_key pthread_key_t |
eac85310 | 89 | |
9bc4701c MD |
90 | #define scm_i_plugin_key_create pthread_key_create |
91 | #define scm_i_plugin_key_delete pthread_key_delete | |
92 | #define scm_i_plugin_setspecific pthread_setspecific | |
93 | #define scm_i_plugin_getspecific pthread_getspecific | |
eac85310 | 94 | |
9bc4701c | 95 | #define scm_i_plugin_select select |
eac85310 | 96 | |
e29e0b09 MD |
97 | #ifdef SCM_DEBUG_THREADS |
98 | void scm_i_assert_heap_locked (void); | |
99 | #endif | |
100 | ||
28d52ebb MD |
101 | void scm_init_pthread_threads (void); |
102 | ||
93cd4dcd | 103 | #endif /* SCM_THREADS_PTHREADS_H */ |
eac85310 MV |
104 | |
105 | /* | |
106 | Local Variables: | |
107 | c-file-style: "gnu" | |
108 | End: | |
109 | */ |