Merged with tip.
[cacao.git] / src / threads / lock-common.h
1 /* src/threads/lock-common.h - common stuff of lock implementation
2
3    Copyright (C) 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23 */
24
25
26 #ifndef _LOCK_COMMON_H
27 #define _LOCK_COMMON_H
28
29 #include "config.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #include "vm/types.h"
36
37 #include "vm/global.h"
38
39 #if defined(ENABLE_THREADS)
40 # include "threads/posix/lock.h"
41 #else
42 # include "threads/none/lock.h"
43 #endif
44
45
46 /* only define the following stuff with thread enabled ************************/
47
48 #if defined(ENABLE_THREADS)
49
50 /* functions ******************************************************************/
51
52 void lock_init(void);
53
54 void lock_init_object_lock(java_object_t *);
55
56 ptrint lock_pre_compute_thinlock(s4 index);
57
58 bool lock_monitor_enter(java_handle_t *);
59 bool lock_monitor_exit(java_handle_t *);
60
61 #define LOCK_monitor_enter    (functionptr) lock_monitor_enter
62 #define LOCK_monitor_exit     (functionptr) lock_monitor_exit
63
64 bool lock_is_held_by_current_thread(java_handle_t *o);
65
66 void lock_wait_for_object(java_handle_t *o, s8 millis, s4 nanos);
67 void lock_notify_object(java_handle_t *o);
68 void lock_notify_all_object(java_handle_t *o);
69
70 #endif /* ENABLE_THREADS */
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #endif /* _LOCK_COMMON_H */
77
78
79 /*
80  * These are local overrides for various environment variables in Emacs.
81  * Please do not remove this and leave it at the end of the file, where
82  * Emacs will automagically detect them.
83  * ---------------------------------------------------------------------
84  * Local variables:
85  * mode: c
86  * indent-tabs-mode: t
87  * c-basic-offset: 4
88  * tab-width: 4
89  * End:
90  * vim:noexpandtab:sw=4:ts=4:
91  */