7cabe9cc1b557d40f09869845dbf9d42a9793dce
[cacao.git] / src / threads / lock-common.h
1 /* src/threads/lock-common.h - common stuff of lock implementation
2
3    Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    $Id: threads.h 4866 2006-05-01 21:40:38Z edwin $
26
27 */
28
29
30 #ifndef _LOCK_COMMON_H
31 #define _LOCK_COMMON_H
32
33 #include "config.h"
34 #include "vm/types.h"
35
36 #include "vm/global.h"
37
38 /* ATTENTION: Don't include a threads header here, as it could include
39    java_lang_Thread.h and thus break the build (means, it recompiles
40    every time)!  Take care of that... */
41
42 #if defined(ENABLE_THREADS)
43 # include "threads/native/lock.h"
44 #else
45 # include "threads/none/lock.h"
46 #endif
47
48
49 /* only define the following stuff with thread enabled ************************/
50
51 #if defined(ENABLE_THREADS)
52
53 /* functions ******************************************************************/
54
55 void lock_init(void);
56
57 void lock_init_object_lock(java_object_t *);
58 lock_record_t *lock_get_initial_lock_word(void);
59
60 ptrint lock_pre_compute_thinlock(s4 index);
61
62 bool lock_monitor_enter(java_object_t *);
63 bool lock_monitor_exit(java_object_t *);
64
65 #define LOCK_monitor_enter    (functionptr) lock_monitor_enter
66 #define LOCK_monitor_exit     (functionptr) lock_monitor_exit
67
68 bool lock_is_held_by_current_thread(java_object_t *o);
69
70 void lock_wait_for_object(java_object_t *o, s8 millis, s4 nanos);
71 void lock_notify_object(java_object_t *o);
72 void lock_notify_all_object(java_object_t *o);
73
74 #endif /* ENABLE_THREADS */
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  */