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