PR123: LD_LIBRARY_PATH and java.library.path
[cacao.git] / src / threads / lockword.cpp
1 /* src/threads/lockword.cpp - lockword implementation
2
3    Copyright (C) 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 #include "config.h"
27
28 #include <assert.h>
29 #include <stdint.h>
30
31 #include "threads/lock.hpp"
32
33
34 /**
35  * Inflate the lock of the given object. This may only be called by
36  * the owner of the monitor of the object.
37  * 
38  * PRE-CONDITION: The current thread must be the owner of this
39  * object's monitor AND of the lock record's lock!
40  *
41  * @param lr The lock-record to install.  The current thread must own
42  *               the lock of this lock record!
43  */
44 void Lockword::inflate(lock_record_t* lr)
45 {
46         if (is_fat_lock()) {
47                 // Sanity check.
48                 assert(get_fat_lock() == lr);
49                 return;
50         }
51
52         // Sanity check.
53         assert(get_thin_lock_without_count() == thread_get_current()->thinlock);
54
55         // Copy the count from the thinlock.
56         lr->count = get_thin_lock_count();
57
58 //      DEBUGLOCKS(("[lock_inflate      : lr=%p, t=%p, o=%p, o->lockword=%lx, count=%d]",
59 //                              lr, thread_get_current(), o, get_thin_lock(), lr->count));
60
61         // Install the lock-record in the lockword.
62         set(lr);
63 }
64
65
66 /*
67  * These are local overrides for various environment variables in Emacs.
68  * Please do not remove this and leave it at the end of the file, where
69  * Emacs will automagically detect them.
70  * ---------------------------------------------------------------------
71  * Local variables:
72  * mode: c++
73  * indent-tabs-mode: t
74  * c-basic-offset: 4
75  * tab-width: 4
76  * End:
77  * vim:noexpandtab:sw=4:ts=4:
78  */