Merged r5526 from trunk:
[cacao.git] / src / native / vm / sun_misc_Unsafe.c
1 /* src/native/vm/sun_misc_Unsafe.c - sun/misc/Unsafe
2
3    Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    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    Contact: cacao@cacaojvm.org
26
27    Authors: Christian Thalinger
28
29    Changes:
30
31    $Id: java_lang_VMObject.c 5153 2006-07-18 08:19:24Z twisti $
32
33 */
34
35
36 #include "config.h"
37 #include "vm/types.h"
38
39 #include "native/jni.h"
40 #include "native/include/java_lang_Object.h"
41 #include "native/include/java_lang_reflect_Field.h"
42 #include "native/include/java_lang_Thread.h" /* required by sun_misc_Unsafe.h */
43 #include "native/include/sun_misc_Unsafe.h"
44
45
46 /*
47  * Class:     sun/misc/Unsafe
48  * Method:    objectFieldOffset
49  * Signature: (Ljava/lang/reflect/Field;)J
50  */
51 JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, sun_misc_Unsafe* this, java_lang_reflect_Field* field)
52 {
53         classinfo *c;
54         fieldinfo *f;
55
56         c = (classinfo *) field->declaringClass;
57         f = &c->fields[field->slot];
58
59         return (s8) f->offset;
60 }
61
62
63 /*
64  * Class:     sun/misc/Unsafe
65  * Method:    compareAndSwapInt
66  * Signature: (Ljava/lang/Object;JII)Z
67  */
68 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, sun_misc_Unsafe* this, java_lang_Object* obj, s8 offset, s4 expect, s4 update)
69 {
70         s4 *p;
71         s4  value;
72
73         p = (s4 *) (((u1 *) obj) + offset);
74
75         /* XXX this should be atomic */
76
77         value = *p;
78
79         if (value == expect) {
80                 *p = update;
81
82                 return true;
83         }
84
85         return false;
86 }
87
88
89 #if 0
90 /*
91  * Class:     sun/misc/Unsafe
92  * Method:    compareAndSwapLong
93  * Signature: (Ljava/lang/Object;JJJ)Z
94  */
95 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3, s8 par4)
96 {
97 }
98
99
100 /*
101  * Class:     sun/misc/Unsafe
102  * Method:    compareAndSwapObject
103  * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z
104  */
105 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3, struct java_lang_Object* par4)
106 {
107 }
108
109
110 /*
111  * Class:     sun/misc/Unsafe
112  * Method:    putOrderedInt
113  * Signature: (Ljava/lang/Object;JI)V
114  */
115 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s4 par3)
116 {
117 }
118
119
120 /*
121  * Class:     sun/misc/Unsafe
122  * Method:    putOrderedLong
123  * Signature: (Ljava/lang/Object;JJ)V
124  */
125 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3)
126 {
127 }
128
129
130 /*
131  * Class:     sun/misc/Unsafe
132  * Method:    putOrderedObject
133  * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
134  */
135 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3)
136 {
137 }
138
139
140 /*
141  * Class:     sun/misc/Unsafe
142  * Method:    putIntVolatile
143  * Signature: (Ljava/lang/Object;JI)V
144  */
145 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s4 par3)
146 {
147 }
148
149
150 /*
151  * Class:     sun/misc/Unsafe
152  * Method:    getIntVolatile
153  * Signature: (Ljava/lang/Object;J)I
154  */
155 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
156 {
157 }
158
159
160 /*
161  * Class:     sun/misc/Unsafe
162  * Method:    putLongVolatile
163  * Signature: (Ljava/lang/Object;JJ)V
164  */
165 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3)
166 {
167 }
168
169
170 /*
171  * Class:     sun/misc/Unsafe
172  * Method:    putLong
173  * Signature: (Ljava/lang/Object;JJ)V
174  */
175 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3)
176 {
177 }
178
179
180 /*
181  * Class:     sun/misc/Unsafe
182  * Method:    getLongVolatile
183  * Signature: (Ljava/lang/Object;J)J
184  */
185 JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
186 {
187 }
188
189
190 /*
191  * Class:     sun/misc/Unsafe
192  * Method:    getLong
193  * Signature: (Ljava/lang/Object;J)J
194  */
195 JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_getLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
196 {
197 }
198
199
200 /*
201  * Class:     sun/misc/Unsafe
202  * Method:    putObjectVolatile
203  * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
204  */
205 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3)
206 {
207 }
208
209
210 /*
211  * Class:     sun/misc/Unsafe
212  * Method:    putObject
213  * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
214  */
215 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3)
216 {
217 }
218
219
220 /*
221  * Class:     sun/misc/Unsafe
222  * Method:    getObjectVolatile
223  * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
224  */
225 JNIEXPORT struct java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
226 {
227 }
228
229
230 /*
231  * Class:     sun/misc/Unsafe
232  * Method:    arrayBaseOffset
233  * Signature: (Ljava/lang/Class;)I
234  */
235 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
236 {
237 }
238
239
240 /*
241  * Class:     sun/misc/Unsafe
242  * Method:    arrayIndexScale
243  * Signature: (Ljava/lang/Class;)I
244  */
245 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
246 {
247 }
248
249
250 /*
251  * Class:     sun/misc/Unsafe
252  * Method:    unpark
253  * Signature: (Ljava/lang/Thread;)V
254  */
255 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Thread* par1)
256 {
257 }
258
259
260 /*
261  * Class:     sun/misc/Unsafe
262  * Method:    park
263  * Signature: (ZJ)V
264  */
265 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, struct sun_misc_Unsafe* this, s4 par1, s8 par2)
266 {
267 }
268 #endif
269
270
271 /*
272  * These are local overrides for various environment variables in Emacs.
273  * Please do not remove this and leave it at the end of the file, where
274  * Emacs will automagically detect them.
275  * ---------------------------------------------------------------------
276  * Local variables:
277  * mode: c
278  * indent-tabs-mode: t
279  * c-basic-offset: 4
280  * tab-width: 4
281  * End:
282  */