* src/native/vm/sun_misc_Unsafe.cpp (putDouble): Implemented.
[cacao.git] / src / native / vm / sun_misc_Unsafe.cpp
1 /* src/native/vm/sun_misc_Unsafe.cpp - sun/misc/Unsafe
2
3    Copyright (C) 2006, 2007, 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 <stdint.h>
29 #include <unistd.h>
30
31 #include "threads/atomic.hpp"
32
33 #include "mm/memory.h"
34
35 #include "native/jni.hpp"
36 #include "native/llni.h"
37 #include "native/native.hpp"
38
39 #if defined(ENABLE_JNI_HEADERS)
40 # include "native/include/sun_misc_Unsafe.h"
41 #endif
42
43 #include "vm/jit/builtin.hpp"
44 #include "vm/exceptions.hpp"
45 #include "vm/initialize.hpp"
46 #include "vm/javaobjects.hpp"
47 #include "vm/os.hpp"
48 #include "vm/string.hpp"
49 #include "vm/utf8.h"
50
51
52 // Native functions are exported as C functions.
53 extern "C" {
54
55 /*
56  * Class:     sun/misc/Unsafe
57  * Method:    registerNatives
58  * Signature: ()V
59  */
60 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_registerNatives(JNIEnv *env, jclass clazz)
61 {
62         /* The native methods of this function are already registered in
63            _Jv_sun_misc_Unsafe_init() which is called during VM
64            startup. */
65 }
66
67
68 /*
69  * Class:     sun/misc/Unsafe
70  * Method:    getInt
71  * Signature: (Ljava/lang/Object;J)I
72  */
73 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
74 {
75         return FieldAccess::get<int32_t>(o, offset);
76 }
77
78
79 /*
80  * Class:     sun/misc/Unsafe
81  * Method:    putInt
82  * Signature: (Ljava/lang/Object;JI)V
83  */
84 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x)
85 {
86         FieldAccess::set(o, offset, x);
87 }
88
89
90 /*
91  * Class:     sun/misc/Unsafe
92  * Method:    getObject
93  * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
94  */
95 JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_getObject(JNIEnv *env, jobject _this, jobject o, jlong offset)
96 {
97         return FieldAccess::get<jobject>(o, offset);
98 }
99
100
101 /*
102  * Class:     sun/misc/Unsafe
103  * Method:    putObject
104  * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
105  */
106 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x)
107 {
108         FieldAccess::set(o, offset, x);
109 }
110
111
112 /*
113  * Class:     sun/misc/Unsafe
114  * Method:    getBoolean
115  * Signature: (Ljava/lang/Object;J)Z
116  */
117 JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_getBoolean(JNIEnv *env, jobject _this, jobject o, jlong offset)
118 {
119         return FieldAccess::get<int32_t>(o, offset);
120 }
121
122
123 /*
124  * Class:     sun/misc/Unsafe
125  * Method:    putBoolean
126  * Signature: (Ljava/lang/Object;JZ)V
127  */
128 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putBoolean(JNIEnv *env, jobject _this, jobject o, jlong offset, jboolean x)
129 {
130         FieldAccess::set(o, offset, (int32_t) x);
131 }
132
133
134 /*
135  * Class:     sun/misc/Unsafe
136  * Method:    getByte
137  * Signature: (Ljava/lang/Object;J)B
138  */
139 JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
140 {
141         return FieldAccess::get<int32_t>(o, offset);
142 }
143
144
145 /*
146  * Class:     sun/misc/Unsafe
147  * Method:    putByte
148  * Signature: (Ljava/lang/Object;JB)V
149  */
150 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB(JNIEnv *env, jobject _this, jobject o, jlong offset, jbyte x)
151 {
152         FieldAccess::set(o, offset, (int32_t) x);
153 }
154
155
156 /*
157  * Class:     sun/misc/Unsafe
158  * Method:    getShort
159  * Signature: (Ljava/lang/Object;J)S
160  */
161 JNIEXPORT jshort JNICALL Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
162 {
163         return FieldAccess::get<int32_t>(o, offset);
164 }
165
166
167 /*
168  * Class:     sun/misc/Unsafe
169  * Method:    putShort
170  * Signature: (Ljava/lang/Object;JS)V
171  */
172 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS(JNIEnv *env, jobject _this, jobject o, jlong offset, jshort x)
173 {
174         FieldAccess::set(o, offset, (int32_t) x);
175 }
176
177
178 /*
179  * Class:     sun/misc/Unsafe
180  * Method:    getChar
181  * Signature: (Ljava/lang/Object;J)C
182  */
183 JNIEXPORT jchar JNICALL Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
184 {
185         return FieldAccess::get<int32_t>(o, offset);
186 }
187
188
189 /*
190  * Class:     sun/misc/Unsafe
191  * Method:    putChar
192  * Signature: (Ljava/lang/Object;JC)V
193  */
194 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC(JNIEnv *env, jobject _this, jobject o, jlong offset, jchar x)
195 {
196         FieldAccess::set(o, offset, (int32_t) x);
197 }
198
199
200 /*
201  * Class:     sun/misc/Unsafe
202  * Method:    getLong
203  * Signature: (Ljava/lang/Object;J)J
204  */
205 JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
206 {
207         return FieldAccess::get<int64_t>(o, offset);
208 }
209
210
211 /*
212  * Class:     sun/misc/Unsafe
213  * Method:    putLong
214  * Signature: (Ljava/lang/Object;JJ)V
215  */
216 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x)
217 {
218         FieldAccess::set(o, offset, x);
219 }
220
221
222 /*
223  * Class:     sun/misc/Unsafe
224  * Method:    getFloat
225  * Signature: (Ljava/lang/Object;J)F
226  */
227 JNIEXPORT jfloat JNICALL Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
228 {
229         return FieldAccess::get<float>(o, offset);
230 }
231
232
233 /*
234  * Class:     sun/misc/Unsafe
235  * Method:    putFloat
236  * Signature: (Ljava/lang/Object;JF)V
237  */
238 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF(JNIEnv *env, jobject _this, jobject o, jlong offset, jfloat x)
239 {
240         FieldAccess::set(o, offset, x);
241 }
242
243
244 /*
245  * Class:     sun/misc/Unsafe
246  * Method:    getDouble
247  * Signature: (Ljava/lang/Object;J)D
248  */
249 JNIEXPORT jdouble JNICALL Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
250 {
251         return FieldAccess::get<double>(o, offset);
252 }
253
254
255 /*
256  * Class:     sun/misc/Unsafe
257  * Method:    putDouble
258  * Signature: (Ljava/lang/Object;JD)V
259  */
260 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD(JNIEnv *env, jobject _this, jobject o, jlong offset, jdouble x)
261 {
262         FieldAccess::set(o, offset, x);
263 }
264
265
266 /*
267  * Class:     sun/misc/Unsafe
268  * Method:    getByte
269  * Signature: (J)B
270  */
271 JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByte__J(JNIEnv *env, jobject _this, jlong address)
272 {
273         int8_t *p;
274         int8_t  value;
275
276         p = (int8_t *) (intptr_t) address;
277
278         value = *p;
279
280         return (int32_t) value;
281 }
282
283
284 /*
285  * Class:     sun/misc/Unsafe
286  * Method:    putByte
287  * Signature: (JB)V
288  */
289 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__JB(JNIEnv *env, jobject _this, jlong address, jbyte value)
290 {
291         int8_t *p;
292
293         p = (int8_t *) (intptr_t) address;
294
295         *p = (int8_t) value;
296 }
297
298
299 /*
300  * Class:     sun/misc/Unsafe
301  * Method:    getShort
302  * Signature: (J)S
303  */
304 JNIEXPORT jshort JNICALL Java_sun_misc_Unsafe_getShort__J(JNIEnv *env, jobject _this, jlong address)
305 {
306         int16_t *p;
307         int16_t  value;
308
309         p = (int16_t *) (intptr_t) address;
310
311         value = *p;
312
313         return (int32_t) value;
314 }
315
316
317 /*
318  * Class:     sun/misc/Unsafe
319  * Method:    putShort
320  * Signature: (JS)V
321  */
322 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__JS(JNIEnv *env, jobject _this, jlong address, jshort value)
323 {
324         int16_t *p;
325
326         p = (int16_t *) (intptr_t) address;
327
328         *p = (int16_t) value;
329 }
330
331
332 /*
333  * Class:     sun/misc/Unsafe
334  * Method:    getChar
335  * Signature: (J)C
336  */
337 JNIEXPORT jchar JNICALL Java_sun_misc_Unsafe_getChar__J(JNIEnv *env, jobject _this, jlong address)
338 {
339         uint16_t *p;
340         uint16_t  value;
341
342         p = (uint16_t *) (intptr_t) address;
343
344         value = *p;
345
346         return (int32_t) value;
347 }
348
349
350 /*
351  * Class:     sun/misc/Unsafe
352  * Method:    putChar
353  * Signature: (JC)V
354  */
355 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__JC(JNIEnv *env, jobject _this, jlong address, jchar value)
356 {
357         uint16_t *p;
358
359         p = (uint16_t *) (intptr_t) address;
360
361         *p = (uint16_t) value;
362 }
363
364
365 /*
366  * Class:     sun/misc/Unsafe
367  * Method:    getInt
368  * Signature: (J)I
369  */
370 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getInt__J(JNIEnv *env, jobject _this, jlong address)
371 {
372         int32_t *p;
373         int32_t  value;
374
375         p = (int32_t *) (intptr_t) address;
376
377         value = *p;
378
379         return value;
380 }
381
382
383 /*
384  * Class:     sun/misc/Unsafe
385  * Method:    putInt
386  * Signature: (JI)V
387  */
388 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__JI(JNIEnv *env, jobject _this, jlong address, jint value)
389 {
390         int32_t *p;
391
392         p = (int32_t *) (intptr_t) address;
393
394         *p = value;
395 }
396
397
398 /*
399  * Class:     sun/misc/Unsafe
400  * Method:    getLong
401  * Signature: (J)J
402  */
403 JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLong__J(JNIEnv *env, jobject _this, jlong address)
404 {
405         int64_t *p;
406         int64_t  value;
407
408         p = (int64_t *) (intptr_t) address;
409
410         value = *p;
411
412         return value;
413 }
414
415
416 /*
417  * Class:     sun/misc/Unsafe
418  * Method:    putLong
419  * Signature: (JJ)V
420  */
421 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__JJ(JNIEnv *env, jobject _this, jlong address, jlong value)
422 {
423         int64_t *p;
424
425         p = (int64_t *) (intptr_t) address;
426
427         *p = value;
428 }
429
430
431 /*
432  * Class:     sun/misc/Unsafe
433  * Method:    getFloat
434  * Signature: (J)F
435  */
436 JNIEXPORT jfloat JNICALL Java_sun_misc_Unsafe_getFloat__J(JNIEnv *env, jobject _this, jlong address)
437 {
438         float *p;
439         float  value;
440
441         p = (float *) (intptr_t) address;
442
443         value = *p;
444
445         return value;
446 }
447
448
449 /*
450  * Class:     sun/misc/Unsafe
451  * Method:    putFloat
452  * Signature: (JF)V
453  */
454 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__JF(JNIEnv *env, jobject _this, jlong address, jfloat value)
455 {
456         float* p;
457
458         p = (float*) (intptr_t) address;
459
460         *p = value;
461 }
462
463
464 /*
465  * Class:     sun/misc/Unsafe
466  * Method:    getDouble
467  * Signature: (J)D
468  */
469 JNIEXPORT jdouble JNICALL Java_sun_misc_Unsafe_getDouble__J(JNIEnv *env, jobject _this, jlong address)
470 {
471         double *p;
472         double  value;
473
474         p = (double*) (intptr_t) address;
475
476         value = *p;
477
478         return value;
479 }
480
481
482 /*
483  * Class:     sun/misc/Unsafe
484  * Method:    putDouble
485  * Signature: (JD)V
486  */
487 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putDouble__JD(JNIEnv *env, jobject _this, jlong address, jdouble value)
488 {
489         double* p;
490
491         p = (double*) (intptr_t) address;
492
493         *p = value;
494 }
495
496
497 /*
498  * Class:     sun/misc/Unsafe
499  * Method:    objectFieldOffset
500  * Signature: (Ljava/lang/reflect/Field;)J
501  */
502 JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, jobject _this, jobject field)
503 {
504 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
505
506         java_lang_reflect_Field rf(field);
507         java_lang_reflect_VMField rvmf(rf.get_f());
508         fieldinfo* f = rvmf.get_field();
509
510 #elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
511
512         java_lang_reflect_Field rf(field);
513         fieldinfo* f = rf.get_field();
514
515 #else
516 # error unknown configuration
517 #endif
518
519         return (jlong) f->offset;
520 }
521
522
523 /*
524  * Class:     sun/misc/Unsafe
525  * Method:    allocateMemory
526  * Signature: (J)J
527  */
528 JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_allocateMemory(JNIEnv *env, jobject _this, jlong bytes)
529 {
530         size_t  length;
531         void   *p;
532
533         length = (size_t) bytes;
534
535         if ((length != (uint64_t) bytes) || (bytes < 0)) {
536                 exceptions_throw_illegalargumentexception();
537                 return 0;
538         }
539
540         p = MNEW(uint8_t, length);
541
542         return (int64_t) (intptr_t) p;
543 }
544
545
546 #if 0
547 /* OpenJDK 7 */
548
549 /*
550  * Class:     sun/misc/Unsafe
551  * Method:    setMemory
552  * Signature: (Ljava/lang/Object;JJB)V
553  */
554 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong bytes, jbyte value)
555 {
556         size_t  length;
557         void   *p;
558
559         length = (size_t) bytes;
560
561         if ((length != (uint64_t) bytes) || (bytes < 0)) {
562                 exceptions_throw_illegalargumentexception();
563                 return;
564         }
565
566         /* XXX Missing LLNI: we need to unwrap _this object. */
567
568         p = (void *) (((uint8_t *) o) + offset);
569
570         /* XXX Not sure this is correct. */
571
572         os::memset(p, value, length);
573 }
574
575
576 /*
577  * Class:     sun/misc/Unsafe
578  * Method:    copyMemory
579  * Signature: (Ljava/lang/Object;JLjava/lang/Object;JJ)V
580  */
581 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, jobject _this, jobject srcBase, jlong srcOffset, jobject destBase, jlong destOffset, jlong bytes)
582 {
583         size_t  length;
584         void   *src;
585         void   *dest;
586
587         if (bytes == 0)
588                 return;
589
590         length = (size_t) bytes;
591
592         if ((length != (uint64_t) bytes) || (bytes < 0)) {
593                 exceptions_throw_illegalargumentexception();
594                 return;
595         }
596
597         /* XXX Missing LLNI: We need to unwrap these objects. */
598
599         src  = (void *) (((uint8_t *) srcBase) + srcOffset);
600         dest = (void *) (((uint8_t *) destBase) + destOffset);
601
602         os::memcpy(dest, src, length);
603 }
604 #else
605 /*
606  * Class:     sun/misc/Unsafe
607  * Method:    setMemory
608  * Signature: (JJB)V
609  */
610 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, jobject _this, jlong address, jlong bytes, jbyte value)
611 {
612         size_t  length;
613         void   *p;
614
615         length = (size_t) bytes;
616
617         if ((length != (uint64_t) bytes) || (bytes < 0)) {
618                 exceptions_throw_illegalargumentexception();
619                 return;
620         }
621
622         p = (void *) (intptr_t) address;
623
624         /* XXX Not sure this is correct. */
625
626         os::memset(p, value, length);
627 }
628
629
630 /*
631  * Class:     sun/misc/Unsafe
632  * Method:    copyMemory
633  * Signature: (JJJ)V
634  */
635 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, jobject _this, jlong srcAddress, jlong destAddress, jlong bytes)
636 {
637         size_t  length;
638         void   *src;
639         void   *dest;
640
641         if (bytes == 0)
642                 return;
643
644         length = (size_t) bytes;
645
646         if ((length != (uint64_t) bytes) || (bytes < 0)) {
647                 exceptions_throw_illegalargumentexception();
648                 return;
649         }
650
651         src  = (void *) (intptr_t) srcAddress;
652         dest = (void *) (intptr_t) destAddress;
653
654         os::memcpy(dest, src, length);
655 }
656 #endif
657
658
659 /*
660  * Class:     sun/misc/Unsafe
661  * Method:    freeMemory
662  * Signature: (J)V
663  */
664 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_freeMemory(JNIEnv *env, jobject _this, jlong address)
665 {
666         void *p;
667
668         p = (void *) (intptr_t) address;
669
670         if (p == NULL)
671                 return;
672
673         /* we pass length 1 to trick the free function */
674
675         MFREE(p, uint8_t, 1);
676 }
677
678
679 /*
680  * Class:     sun/misc/Unsafe
681  * Method:    staticFieldOffset
682  * Signature: (Ljava/lang/reflect/Field;)J
683  */
684 JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_staticFieldOffset(JNIEnv *env, jobject _this, jobject f)
685 {
686         /* The offset of static fields is 0. */
687
688         return 0;
689 }
690
691
692 /*
693  * Class:     sun/misc/Unsafe
694  * Method:    staticFieldBase
695  * Signature: (Ljava/lang/reflect/Field;)Ljava/lang/Object;
696  */
697 JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_staticFieldBase(JNIEnv *env, jobject _this, jobject field)
698 {
699 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
700
701         java_lang_reflect_Field rf(field);
702         java_lang_reflect_VMField rvmf(rf.get_f());
703         fieldinfo* f = rvmf.get_field();
704
705 #elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
706
707         java_lang_reflect_Field rf(field);
708         fieldinfo* f = rf.get_field();
709
710 #else
711 # error unknown configuration
712 #endif
713
714         return (jobject) (f->value);
715 }
716
717
718 /*
719  * Class:     sun/misc/Unsafe
720  * Method:    ensureClassInitialized
721  * Signature: (Ljava/lang/Class;)V
722  */
723 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_ensureClassInitialized(JNIEnv *env, jobject _this, jclass clazz)
724 {
725         classinfo *c;
726
727         c = LLNI_classinfo_unwrap(clazz);
728
729         if (!(c->state & CLASS_INITIALIZED))
730                 initialize_class(c);
731 }
732
733
734 /*
735  * Class:     sun/misc/Unsafe
736  * Method:    arrayBaseOffset
737  * Signature: (Ljava/lang/Class;)I
738  */
739 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, jobject _this, jclass arrayClass)
740 {
741         classinfo       *c;
742         arraydescriptor *ad;
743
744         c  = LLNI_classinfo_unwrap(arrayClass);
745         ad = c->vftbl->arraydesc;
746
747         if (ad == NULL) {
748                 /* XXX does that exception exist? */
749                 exceptions_throw_internalerror("java/lang/InvalidClassException");
750                 return 0;
751         }
752
753         return ad->dataoffset;
754 }
755
756
757 /*
758  * Class:     sun/misc/Unsafe
759  * Method:    arrayIndexScale
760  * Signature: (Ljava/lang/Class;)I
761  */
762 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, jobject _this, jclass arrayClass)
763 {
764         classinfo       *c;
765         arraydescriptor *ad;
766
767         c  = LLNI_classinfo_unwrap(arrayClass);
768         ad = c->vftbl->arraydesc;
769
770         if (ad == NULL) {
771                 /* XXX does that exception exist? */
772                 exceptions_throw_internalerror("java/lang/InvalidClassException");
773                 return 0;
774         }
775
776         return ad->componentsize;
777 }
778
779
780 /*
781  * Class:     sun/misc/Unsafe
782  * Method:    addressSize
783  * Signature: ()I
784  */
785 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv *env, jobject _this)
786 {
787         return SIZEOF_VOID_P;
788 }
789
790
791 /*
792  * Class:     sun/misc/Unsafe
793  * Method:    pageSize
794  * Signature: ()I
795  */
796 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_pageSize(JNIEnv *env, jobject _this)
797 {
798         int sz;
799
800         sz = getpagesize();
801
802         return sz;
803 }
804
805
806 /*
807  * Class:     sun/misc/Unsafe
808  * Method:    defineClass
809  * Signature: (Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;
810  */
811 JNIEXPORT jclass JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2(JNIEnv *env, jobject _this, jstring name, jbyteArray b, jint off, jint len, jobject loader, jobject protectionDomain)
812 {
813         classloader_t   *cl;
814         utf             *utfname;
815         classinfo       *c;
816
817         cl = loader_hashtable_classloader_add((java_handle_t *) loader);
818
819         /* check if data was passed */
820
821         if (b == NULL) {
822                 exceptions_throw_nullpointerexception();
823                 return NULL;
824         }
825
826         /* check the indexes passed */
827
828         if ((off < 0) || (len < 0) || ((off + len) > LLNI_array_size(b))) {
829                 exceptions_throw_arrayindexoutofboundsexception();
830                 return NULL;
831         }
832
833         if (name != NULL) {
834                 /* convert '.' to '/' in java string */
835
836                 utfname = javastring_toutf((java_handle_t *) name, true);
837         } 
838         else {
839                 utfname = NULL;
840         }
841
842         /* define the class */
843
844         c = class_define(utfname, cl, len, (uint8_t *) &(LLNI_array_direct((java_handle_bytearray_t*) b, off)),
845                                          (java_handle_t *) protectionDomain);
846
847         if (c == NULL)
848                 return NULL;
849
850         java_handle_t* h = LLNI_classinfo_wrap(c);
851
852 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
853         // Set ProtectionDomain.
854         java_lang_Class jlc(h);
855         jlc.set_pd(protectionDomain);
856 #endif
857
858         return (jclass) h;
859 }
860
861
862 /*
863  * Class:     sun/misc/Unsafe
864  * Method:    allocateInstance
865  * Signature: (Ljava/lang/Class;)Ljava/lang/Object;
866  */
867 JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_allocateInstance(JNIEnv *env, jobject _this, jclass cls)
868 {
869         classinfo     *c;
870         java_handle_t *o;
871
872         c = LLNI_classinfo_unwrap(cls);
873
874         o = builtin_new(c);
875
876         return (jobject ) o;
877 }
878
879
880 /*
881  * Class:     sun/misc/Unsafe
882  * Method:    throwException
883  * Signature: (Ljava/lang/Throwable;)V
884  */
885 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_throwException(JNIEnv *env, jobject _this, jobject ee)
886 {
887         java_handle_t *o;
888
889         o = (java_handle_t *) ee;
890
891         exceptions_set_exception(o);
892 }
893
894
895 /*
896  * Class:     sun/misc/Unsafe
897  * Method:    compareAndSwapObject
898  * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z
899  */
900 JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject expected, jobject x)
901 {
902         volatile void **p;
903         void           *result;
904
905         /* XXX Use LLNI */
906
907         p = (volatile void **) (((uint8_t *) o) + offset);
908
909         result = Atomic::compare_and_swap(p, expected, x);
910
911         if (result == expected)
912                 return true;
913
914         return false;
915 }
916
917
918 /*
919  * Class:     sun/misc/Unsafe
920  * Method:    compareAndSwapInt
921  * Signature: (Ljava/lang/Object;JII)Z
922  */
923 JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, jobject _this, jobject o, jlong offset, jint expected, jint x)
924 {
925         uint32_t *p;
926         uint32_t  result;
927
928         /* XXX Use LLNI */
929
930         p = (uint32_t *) (((uint8_t *) o) + offset);
931
932         result = Atomic::compare_and_swap(p, expected, x);
933
934         if (result == (uint32_t) expected)
935                 return true;
936
937         return false;
938 }
939
940
941 /*
942  * Class:     sun/misc/Unsafe
943  * Method:    compareAndSwapLong
944  * Signature: (Ljava/lang/Object;JJJ)Z
945  */
946 JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong expected, jlong x)
947 {
948         uint64_t *p;
949         uint64_t  result;
950
951         /* XXX Use LLNI */
952
953         p = (uint64_t *) (((uint8_t *) o) + offset);
954
955         result = Atomic::compare_and_swap(p, expected, x);
956
957         if (result == (uint64_t) expected)
958                 return true;
959
960         return false;
961 }
962
963
964 /*
965  * Class:     sun/misc/Unsafe
966  * Method:    getObjectVolatile
967  * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
968  */
969 JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
970 {
971         return FieldAccess::get_volatile<jobject>(o, offset);
972 }
973
974
975 /*
976  * Class:     sun/misc/Unsafe
977  * Method:    putObjectVolatile
978  * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
979  */
980 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x)
981 {
982         FieldAccess::set_volatile(o, offset, x);
983 }
984
985
986 /*
987  * Class:     sun/misc/Unsafe
988  * Method:    getByteVolatile
989  * Signature: (Ljava/lang/Object;J)B
990  */
991 JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByteVolatile(JNIEnv* env, jobject _this, jobject o, jlong offset)
992 {
993         return FieldAccess::get_volatile<int32_t>(o, offset);
994 }
995
996
997 /*
998  * Class:     sun/misc/Unsafe
999  * Method:    getIntVolatile
1000  * Signature: (Ljava/lang/Object;J)I
1001  */
1002 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
1003 {
1004         return FieldAccess::get_volatile<int32_t>(o, offset);
1005 }
1006
1007
1008 /*
1009  * Class:     sun/misc/Unsafe
1010  * Method:    putIntVolatile
1011  * Signature: (Ljava/lang/Object;JI)V
1012  */
1013 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x)
1014 {
1015         FieldAccess::set_volatile(o, offset, x);
1016 }
1017
1018
1019 /*
1020  * Class:     sun/misc/Unsafe
1021  * Method:    getLongVolatile
1022  * Signature: (Ljava/lang/Object;J)J
1023  */
1024 JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
1025 {
1026         return FieldAccess::get_volatile<int64_t>(o, offset);
1027 }
1028
1029
1030 /*
1031  * Class:     sun/misc/Unsafe
1032  * Method:    putLongVolatile
1033  * Signature: (Ljava/lang/Object;JJ)V
1034  */
1035 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x)
1036 {
1037         FieldAccess::set_volatile(o, offset, x);
1038 }
1039
1040
1041 /*
1042  * Class:     sun/misc/Unsafe
1043  * Method:    getFloatVolatile
1044  * Signature: (Ljava/lang/Object;J)F
1045  */
1046 JNIEXPORT jfloat JNICALL Java_sun_misc_Unsafe_getFloatVolatile(JNIEnv* env, jobject _this, jobject o, jlong offset)
1047 {
1048         return FieldAccess::get_volatile<float>(o, offset);
1049 }
1050
1051
1052 /*
1053  * Class:     sun/misc/Unsafe
1054  * Method:    getDoubleVolatile
1055  * Signature: (Ljava/lang/Object;J)D
1056  */
1057 JNIEXPORT jdouble JNICALL Java_sun_misc_Unsafe_getDoubleVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
1058 {
1059         return FieldAccess::get_volatile<double>(o, offset);
1060 }
1061
1062
1063 /*
1064  * Class:     sun/misc/Unsafe
1065  * Method:    putOrderedObject
1066  * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
1067  */
1068 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x)
1069 {
1070         FieldAccess::set_volatile(o, offset, x);
1071 }
1072
1073
1074 /*
1075  * Class:     sun/misc/Unsafe
1076  * Method:    putOrderedInt
1077  * Signature: (Ljava/lang/Object;JI)V
1078  */
1079 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x)
1080 {
1081         FieldAccess::set_volatile(o, offset, x);
1082 }
1083
1084
1085 /*
1086  * Class:     sun/misc/Unsafe
1087  * Method:    putOrderedLong
1088  * Signature: (Ljava/lang/Object;JJ)V
1089  */
1090 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x)
1091 {
1092         FieldAccess::set_volatile(o, offset, x);
1093 }
1094
1095
1096 /*
1097  * Class:     sun/misc/Unsafe
1098  * Method:    unpark
1099  * Signature: (Ljava/lang/Object;)V
1100  */
1101 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, jobject _this, jobject thread)
1102 {
1103         java_handle_t *h = (java_handle_t *) thread;
1104         threadobject *t;
1105
1106 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
1107         h = java_lang_Thread(h).get_vmThread();
1108 #endif
1109         t = thread_get_thread(h);
1110
1111         threads_unpark(t);
1112 }
1113
1114
1115 /*
1116  * Class:     sun/misc/Unsafe
1117  * Method:    park
1118  * Signature: (ZJ)V
1119  */
1120 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, jobject _this, jboolean isAbsolute, jlong time)
1121 {
1122         threads_park(isAbsolute, time);
1123 }
1124
1125 } // extern "C"
1126
1127
1128 /* native methods implemented by this file ************************************/
1129
1130 static JNINativeMethod methods[] = {
1131         { (char*) "registerNatives",        (char*) "()V",                                                        (void*) (uintptr_t) &Java_sun_misc_Unsafe_registerNatives                  },
1132         { (char*) "getInt",                 (char*) "(Ljava/lang/Object;J)I",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J     },
1133         { (char*) "putInt",                 (char*) "(Ljava/lang/Object;JI)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI    },
1134         { (char*) "getObject",              (char*) "(Ljava/lang/Object;J)Ljava/lang/Object;",                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_getObject                        },
1135         { (char*) "putObject",              (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_putObject                        },
1136         { (char*) "getBoolean",             (char*) "(Ljava/lang/Object;J)Z",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getBoolean                       },
1137         { (char*) "putBoolean",             (char*) "(Ljava/lang/Object;JZ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putBoolean                       },
1138         { (char*) "getByte",                (char*) "(Ljava/lang/Object;J)B",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J    },
1139         { (char*) "putByte",                (char*) "(Ljava/lang/Object;JB)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB   },
1140         { (char*) "getShort",               (char*) "(Ljava/lang/Object;J)S",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J   },
1141         { (char*) "putShort",               (char*) "(Ljava/lang/Object;JS)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS  },
1142         { (char*) "getChar",                (char*) "(Ljava/lang/Object;J)C",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J    },
1143         { (char*) "putChar",                (char*) "(Ljava/lang/Object;JC)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC   },
1144         { (char*) "getLong",                (char*) "(Ljava/lang/Object;J)J",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J    },
1145         { (char*) "putLong",                (char*) "(Ljava/lang/Object;JJ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ   },
1146         { (char*) "getFloat",               (char*) "(Ljava/lang/Object;J)F",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J   },
1147         { (char*) "putFloat",               (char*) "(Ljava/lang/Object;JF)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF  },
1148         { (char*) "getDouble",              (char*) "(Ljava/lang/Object;J)D",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J  },
1149         { (char*) "putDouble",              (char*) "(Ljava/lang/Object;JD)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD },
1150         { (char*) "getByte",                (char*) "(J)B",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByte__J                       },
1151         { (char*) "putByte",                (char*) "(JB)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putByte__JB                      },
1152         { (char*) "getShort",               (char*) "(J)S",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getShort__J                      },
1153         { (char*) "putShort",               (char*) "(JS)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putShort__JS                     },
1154         { (char*) "getChar",                (char*) "(J)C",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getChar__J                       },
1155         { (char*) "putChar",                (char*) "(JC)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putChar__JC                      },
1156         { (char*) "getInt",                 (char*) "(J)I",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getInt__J                        },
1157         { (char*) "putInt",                 (char*) "(JI)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putInt__JI                       },
1158         { (char*) "getLong",                (char*) "(J)J",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLong__J                       },
1159         { (char*) "putLong",                (char*) "(JJ)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLong__JJ                      },
1160         { (char*) "getFloat",               (char*) "(J)F",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloat__J                      },
1161         { (char*) "putFloat",               (char*) "(JF)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putFloat__JF                     },
1162         { (char*) "getDouble",              (char*) "(J)D",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getDouble__J                     },
1163         { (char*) "putDouble",              (char*) "(JD)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putDouble__JD                    },
1164         { (char*) "objectFieldOffset",      (char*) "(Ljava/lang/reflect/Field;)J",                               (void*) (uintptr_t) &Java_sun_misc_Unsafe_objectFieldOffset                },
1165         { (char*) "allocateMemory",         (char*) "(J)J",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_allocateMemory                   },
1166 #if 0
1167         // OpenJDK 7
1168         { (char*) "setMemory",              (char*) "(Ljava/lang/Object;JJB)V",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_setMemory                        },
1169         { (char*) "copyMemory",             (char*) "(Ljava/lang/Object;JLjava/lang/Object;JJ)V",                 (void*) (uintptr_t) &Java_sun_misc_Unsafe_copyMemory                       },
1170 #else
1171         { (char*) "setMemory",              (char*) "(JJB)V",                                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_setMemory                        },
1172         { (char*) "copyMemory",             (char*) "(JJJ)V",                                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_copyMemory                       },
1173 #endif
1174         { (char*) "freeMemory",             (char*) "(J)V",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_freeMemory                       },
1175         { (char*) "staticFieldOffset",      (char*) "(Ljava/lang/reflect/Field;)J",                               (void*) (uintptr_t) &Java_sun_misc_Unsafe_staticFieldOffset                },
1176         { (char*) "staticFieldBase",        (char*) "(Ljava/lang/reflect/Field;)Ljava/lang/Object;",              (void*) (uintptr_t) &Java_sun_misc_Unsafe_staticFieldBase                  },
1177         { (char*) "ensureClassInitialized", (char*) "(Ljava/lang/Class;)V",                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_ensureClassInitialized           },
1178         { (char*) "arrayBaseOffset",        (char*) "(Ljava/lang/Class;)I",                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_arrayBaseOffset                  },
1179         { (char*) "arrayIndexScale",        (char*) "(Ljava/lang/Class;)I",                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_arrayIndexScale                  },
1180         { (char*) "addressSize",            (char*) "()I",                                                        (void*) (uintptr_t) &Java_sun_misc_Unsafe_addressSize                      },
1181         { (char*) "pageSize",               (char*) "()I",                                                        (void*) (uintptr_t) &Java_sun_misc_Unsafe_pageSize                         },
1182         { (char*) "defineClass",            (char*) "(Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2 },
1183         { (char*) "allocateInstance",       (char*) "(Ljava/lang/Class;)Ljava/lang/Object;",                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_allocateInstance                 },
1184         { (char*) "throwException",         (char*) "(Ljava/lang/Throwable;)V",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_throwException                   },
1185         { (char*) "compareAndSwapObject",   (char*) "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapObject             },
1186         { (char*) "compareAndSwapInt",      (char*) "(Ljava/lang/Object;JII)Z",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapInt                },
1187         { (char*) "compareAndSwapLong",     (char*) "(Ljava/lang/Object;JJJ)Z",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapLong               },
1188         { (char*) "getObjectVolatile",      (char*) "(Ljava/lang/Object;J)Ljava/lang/Object;",                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_getObjectVolatile                },
1189         { (char*) "putObjectVolatile",      (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_putObjectVolatile                },
1190         { (char*) "getByteVolatile",        (char*) "(Ljava/lang/Object;J)B",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByteVolatile                  },
1191         { (char*) "getIntVolatile",         (char*) "(Ljava/lang/Object;J)I",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getIntVolatile                   },
1192         { (char*) "putIntVolatile",         (char*) "(Ljava/lang/Object;JI)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putIntVolatile                   },
1193         { (char*) "getLongVolatile",        (char*) "(Ljava/lang/Object;J)J",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLongVolatile                  },
1194         { (char*) "putLongVolatile",        (char*) "(Ljava/lang/Object;JJ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLongVolatile                  },
1195         { (char*) "getFloatVolatile",       (char*) "(Ljava/lang/Object;J)F",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloatVolatile                 },
1196         { (char*) "getDoubleVolatile",      (char*) "(Ljava/lang/Object;J)D",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getDoubleVolatile                },
1197         { (char*) "putOrderedObject",       (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedObject                 },
1198         { (char*) "putOrderedInt",          (char*) "(Ljava/lang/Object;JI)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedInt                    },
1199         { (char*) "putOrderedLong",         (char*) "(Ljava/lang/Object;JJ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedLong                   },
1200         { (char*) "unpark",                 (char*) "(Ljava/lang/Object;)V",                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_unpark                           },
1201         { (char*) "park",                   (char*) "(ZJ)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_park                             },
1202 };
1203
1204
1205 /* _Jv_sun_misc_Unsafe_init ****************************************************
1206
1207    Register native functions.
1208
1209 *******************************************************************************/
1210
1211 void _Jv_sun_misc_Unsafe_init(void)
1212 {
1213         utf* u = utf_new_char("sun/misc/Unsafe");
1214
1215         NativeMethods& nm = VM::get_current()->get_nativemethods();
1216         nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
1217 }
1218
1219
1220 /*
1221  * These are local overrides for various environment variables in Emacs.
1222  * Please do not remove this and leave it at the end of the file, where
1223  * Emacs will automagically detect them.
1224  * ---------------------------------------------------------------------
1225  * Local variables:
1226  * mode: c++
1227  * indent-tabs-mode: t
1228  * c-basic-offset: 4
1229  * tab-width: 4
1230  * End:
1231  * vim:noexpandtab:sw=4:ts=4:
1232  */