(SCM_MUTEX_MAXSIZE): Increase to 12*sizeof(long),
[bpt/guile.git] / libguile / threads-plugin.h
1 /* classes: h_files */
2
3 #ifndef SCM_THREADS_PLUGIN_H
4 #define SCM_THREADS_PLUGIN_H
5
6 /* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004 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 #include <pthread.h> /* This file should *not* need to include pthread.h */
25
26 /* Size is checked in scm_init_threads_plugin.
27 For reference, sizes encountered include,
28 powerpc-apple-darwin5.5 pthread_mutex_t 44 bytes
29 */
30 #define SCM_MUTEX_MAXSIZE (12 * sizeof (long))
31 typedef struct { char _[SCM_MUTEX_MAXSIZE]; } scm_t_mutex;
32
33 /*fixme* Should be defined similarly to scm_t_mutex. */
34 #define scm_t_mutexattr pthread_mutexattr_t
35
36 extern int scm_i_plugin_mutex_size;
37 typedef int (*scm_t_mutex_init) (scm_t_mutex *, const scm_t_mutexattr *);
38 typedef int (*scm_t_mutex_lock) (scm_t_mutex *);
39 typedef int (*scm_t_mutex_unlock) (scm_t_mutex *);
40 extern scm_t_mutex_init scm_i_plugin_mutex_init;
41 extern scm_t_mutex_lock scm_i_plugin_mutex_lock;
42 extern scm_t_mutex_unlock scm_i_plugin_mutex_unlock;
43
44 /* Size is checked in scm_init_threads_plugin */
45 #define SCM_REC_MUTEX_MAXSIZE (SCM_MUTEX_MAXSIZE + 3 * sizeof (long))
46 typedef struct { char _[SCM_REC_MUTEX_MAXSIZE]; } scm_t_rec_mutex;
47
48 extern int scm_i_plugin_rec_mutex_size;
49 typedef int (*scm_t_rec_mutex_init) (scm_t_rec_mutex *,
50 const scm_t_mutexattr *);
51 typedef int (*scm_t_rec_mutex_destroy) (scm_t_rec_mutex *);
52 typedef int (*scm_t_rec_mutex_lock) (scm_t_rec_mutex *);
53 typedef int (*scm_t_rec_mutex_trylock) (scm_t_rec_mutex *);
54 typedef int (*scm_t_rec_mutex_unlock) (scm_t_rec_mutex *);
55 extern scm_t_rec_mutex_init scm_i_plugin_rec_mutex_init;
56 extern scm_t_rec_mutex_destroy scm_i_plugin_rec_mutex_destroy;
57 extern scm_t_rec_mutex_lock scm_i_plugin_rec_mutex_lock;
58 extern scm_t_rec_mutex_trylock scm_i_plugin_rec_mutex_trylock;
59 extern scm_t_rec_mutex_unlock scm_i_plugin_rec_mutex_unlock;
60
61 /*fixme*/
62 #define scm_t_cond pthread_cond_t
63
64 typedef int (*scm_t_cond_wait) (scm_t_cond *, scm_t_mutex *);
65 typedef int (*scm_t_cond_timedwait) (scm_t_cond *,
66 scm_t_mutex *,
67 const scm_t_timespec *);
68 extern scm_t_cond_wait scm_i_plugin_cond_wait;
69 extern scm_t_cond_timedwait scm_i_plugin_cond_timedwait;
70
71 extern void scm_init_threads_plugin (void);
72
73 #endif /* SCM_THREADS_PLUGIN_H */
74
75 /*
76 Local Variables:
77 c-file-style: "gnu"
78 End:
79 */