1 /* src/native/vm/gnu/sun_misc_Unsafe.c - sun/misc/Unsafe
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
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 $Id: java_lang_VMObject.c 5153 2006-07-18 08:19:24Z twisti $
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"
41 * Class: sun/misc/Unsafe
42 * Method: objectFieldOffset
43 * Signature: (Ljava/lang/reflect/Field;)J
45 JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, sun_misc_Unsafe* this, java_lang_reflect_Field* field)
50 c = (classinfo *) field->declaringClass;
51 f = &c->fields[field->slot];
53 return (s8) f->offset;
58 * Class: sun/misc/Unsafe
59 * Method: compareAndSwapInt
60 * Signature: (Ljava/lang/Object;JII)Z
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)
67 p = (s4 *) (((u1 *) obj) + offset);
69 /* XXX this should be atomic */
73 if (value == expect) {
85 * Class: sun/misc/Unsafe
86 * Method: compareAndSwapLong
87 * Signature: (Ljava/lang/Object;JJJ)Z
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)
95 * Class: sun/misc/Unsafe
96 * Method: compareAndSwapObject
97 * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z
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)
105 * Class: sun/misc/Unsafe
106 * Method: putOrderedInt
107 * Signature: (Ljava/lang/Object;JI)V
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)
115 * Class: sun/misc/Unsafe
116 * Method: putOrderedLong
117 * Signature: (Ljava/lang/Object;JJ)V
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)
125 * Class: sun/misc/Unsafe
126 * Method: putOrderedObject
127 * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
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)
135 * Class: sun/misc/Unsafe
136 * Method: putIntVolatile
137 * Signature: (Ljava/lang/Object;JI)V
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)
145 * Class: sun/misc/Unsafe
146 * Method: getIntVolatile
147 * Signature: (Ljava/lang/Object;J)I
149 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
155 * Class: sun/misc/Unsafe
156 * Method: putLongVolatile
157 * Signature: (Ljava/lang/Object;JJ)V
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)
165 * Class: sun/misc/Unsafe
167 * Signature: (Ljava/lang/Object;JJ)V
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)
175 * Class: sun/misc/Unsafe
176 * Method: getLongVolatile
177 * Signature: (Ljava/lang/Object;J)J
179 JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
185 * Class: sun/misc/Unsafe
187 * Signature: (Ljava/lang/Object;J)J
189 JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_getLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
195 * Class: sun/misc/Unsafe
196 * Method: putObjectVolatile
197 * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
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)
205 * Class: sun/misc/Unsafe
207 * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
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)
215 * Class: sun/misc/Unsafe
216 * Method: getObjectVolatile
217 * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
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)
225 * Class: sun/misc/Unsafe
226 * Method: arrayBaseOffset
227 * Signature: (Ljava/lang/Class;)I
229 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
235 * Class: sun/misc/Unsafe
236 * Method: arrayIndexScale
237 * Signature: (Ljava/lang/Class;)I
239 JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
245 * Class: sun/misc/Unsafe
247 * Signature: (Ljava/lang/Thread;)V
249 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Thread* par1)
255 * Class: sun/misc/Unsafe
259 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, struct sun_misc_Unsafe* this, s4 par1, s8 par2)
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 * ---------------------------------------------------------------------
272 * indent-tabs-mode: t