1 /* src/native/vm/sun_misc_Unsafe.c - sun/misc/Unsafe
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
8 This file is part of CACAO.
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.
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.
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
25 Contact: cacao@cacaojvm.org
27 Authors: Christian Thalinger
31 $Id: java_lang_VMObject.c 5153 2006-07-18 08:19:24Z twisti $
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"
47 * Class: sun/misc/Unsafe
48 * Method: objectFieldOffset
49 * Signature: (Ljava/lang/reflect/Field;)J
51 JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, sun_misc_Unsafe* this, java_lang_reflect_Field* field)
56 c = (classinfo *) field->declaringClass;
57 f = &c->fields[field->slot];
59 return (s8) f->offset;
64 * Class: sun/misc/Unsafe
65 * Method: compareAndSwapInt
66 * Signature: (Ljava/lang/Object;JII)Z
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)
73 p = (s4 *) (((u1 *) obj) + offset);
75 /* XXX this should be atomic */
79 if (value == expect) {
91 * Class: sun/misc/Unsafe
92 * Method: compareAndSwapLong
93 * Signature: (Ljava/lang/Object;JJJ)Z
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)
101 * Class: sun/misc/Unsafe
102 * Method: compareAndSwapObject
103 * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z
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)
111 * Class: sun/misc/Unsafe
112 * Method: putOrderedInt
113 * Signature: (Ljava/lang/Object;JI)V
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)
121 * Class: sun/misc/Unsafe
122 * Method: putOrderedLong
123 * Signature: (Ljava/lang/Object;JJ)V
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)
131 * Class: sun/misc/Unsafe
132 * Method: putOrderedObject
133 * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
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)
141 * Class: sun/misc/Unsafe
142 * Method: putIntVolatile
143 * Signature: (Ljava/lang/Object;JI)V
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)
151 * Class: sun/misc/Unsafe
152 * Method: getIntVolatile
153 * Signature: (Ljava/lang/Object;J)I
155 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
161 * Class: sun/misc/Unsafe
162 * Method: putLongVolatile
163 * Signature: (Ljava/lang/Object;JJ)V
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)
171 * Class: sun/misc/Unsafe
173 * Signature: (Ljava/lang/Object;JJ)V
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)
181 * Class: sun/misc/Unsafe
182 * Method: getLongVolatile
183 * Signature: (Ljava/lang/Object;J)J
185 JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
191 * Class: sun/misc/Unsafe
193 * Signature: (Ljava/lang/Object;J)J
195 JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_getLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
201 * Class: sun/misc/Unsafe
202 * Method: putObjectVolatile
203 * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
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)
211 * Class: sun/misc/Unsafe
213 * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
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)
221 * Class: sun/misc/Unsafe
222 * Method: getObjectVolatile
223 * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
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)
231 * Class: sun/misc/Unsafe
232 * Method: arrayBaseOffset
233 * Signature: (Ljava/lang/Class;)I
235 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
241 * Class: sun/misc/Unsafe
242 * Method: arrayIndexScale
243 * Signature: (Ljava/lang/Class;)I
245 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
251 * Class: sun/misc/Unsafe
253 * Signature: (Ljava/lang/Thread;)V
255 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Thread* par1)
261 * Class: sun/misc/Unsafe
265 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, struct sun_misc_Unsafe* this, s4 par1, s8 par2)
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 * ---------------------------------------------------------------------
278 * indent-tabs-mode: t