* src/native/vm/sun_misc_Unsafe.cpp (getDouble): 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:    objectFieldOffset
485  * Signature: (Ljava/lang/reflect/Field;)J
486  */
487 JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, jobject _this, jobject field)
488 {
489 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
490
491         java_lang_reflect_Field rf(field);
492         java_lang_reflect_VMField rvmf(rf.get_f());
493         fieldinfo* f = rvmf.get_field();
494
495 #elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
496
497         java_lang_reflect_Field rf(field);
498         fieldinfo* f = rf.get_field();
499
500 #else
501 # error unknown configuration
502 #endif
503
504         return (jlong) f->offset;
505 }
506
507
508 /*
509  * Class:     sun/misc/Unsafe
510  * Method:    allocateMemory
511  * Signature: (J)J
512  */
513 JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_allocateMemory(JNIEnv *env, jobject _this, jlong bytes)
514 {
515         size_t  length;
516         void   *p;
517
518         length = (size_t) bytes;
519
520         if ((length != (uint64_t) bytes) || (bytes < 0)) {
521                 exceptions_throw_illegalargumentexception();
522                 return 0;
523         }
524
525         p = MNEW(uint8_t, length);
526
527         return (int64_t) (intptr_t) p;
528 }
529
530
531 #if 0
532 /* OpenJDK 7 */
533
534 /*
535  * Class:     sun/misc/Unsafe
536  * Method:    setMemory
537  * Signature: (Ljava/lang/Object;JJB)V
538  */
539 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong bytes, jbyte value)
540 {
541         size_t  length;
542         void   *p;
543
544         length = (size_t) bytes;
545
546         if ((length != (uint64_t) bytes) || (bytes < 0)) {
547                 exceptions_throw_illegalargumentexception();
548                 return;
549         }
550
551         /* XXX Missing LLNI: we need to unwrap _this object. */
552
553         p = (void *) (((uint8_t *) o) + offset);
554
555         /* XXX Not sure this is correct. */
556
557         os::memset(p, value, length);
558 }
559
560
561 /*
562  * Class:     sun/misc/Unsafe
563  * Method:    copyMemory
564  * Signature: (Ljava/lang/Object;JLjava/lang/Object;JJ)V
565  */
566 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, jobject _this, jobject srcBase, jlong srcOffset, jobject destBase, jlong destOffset, jlong bytes)
567 {
568         size_t  length;
569         void   *src;
570         void   *dest;
571
572         if (bytes == 0)
573                 return;
574
575         length = (size_t) bytes;
576
577         if ((length != (uint64_t) bytes) || (bytes < 0)) {
578                 exceptions_throw_illegalargumentexception();
579                 return;
580         }
581
582         /* XXX Missing LLNI: We need to unwrap these objects. */
583
584         src  = (void *) (((uint8_t *) srcBase) + srcOffset);
585         dest = (void *) (((uint8_t *) destBase) + destOffset);
586
587         os::memcpy(dest, src, length);
588 }
589 #else
590 /*
591  * Class:     sun/misc/Unsafe
592  * Method:    setMemory
593  * Signature: (JJB)V
594  */
595 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, jobject _this, jlong address, jlong bytes, jbyte value)
596 {
597         size_t  length;
598         void   *p;
599
600         length = (size_t) bytes;
601
602         if ((length != (uint64_t) bytes) || (bytes < 0)) {
603                 exceptions_throw_illegalargumentexception();
604                 return;
605         }
606
607         p = (void *) (intptr_t) address;
608
609         /* XXX Not sure this is correct. */
610
611         os::memset(p, value, length);
612 }
613
614
615 /*
616  * Class:     sun/misc/Unsafe
617  * Method:    copyMemory
618  * Signature: (JJJ)V
619  */
620 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, jobject _this, jlong srcAddress, jlong destAddress, jlong bytes)
621 {
622         size_t  length;
623         void   *src;
624         void   *dest;
625
626         if (bytes == 0)
627                 return;
628
629         length = (size_t) bytes;
630
631         if ((length != (uint64_t) bytes) || (bytes < 0)) {
632                 exceptions_throw_illegalargumentexception();
633                 return;
634         }
635
636         src  = (void *) (intptr_t) srcAddress;
637         dest = (void *) (intptr_t) destAddress;
638
639         os::memcpy(dest, src, length);
640 }
641 #endif
642
643
644 /*
645  * Class:     sun/misc/Unsafe
646  * Method:    freeMemory
647  * Signature: (J)V
648  */
649 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_freeMemory(JNIEnv *env, jobject _this, jlong address)
650 {
651         void *p;
652
653         p = (void *) (intptr_t) address;
654
655         if (p == NULL)
656                 return;
657
658         /* we pass length 1 to trick the free function */
659
660         MFREE(p, uint8_t, 1);
661 }
662
663
664 /*
665  * Class:     sun/misc/Unsafe
666  * Method:    staticFieldOffset
667  * Signature: (Ljava/lang/reflect/Field;)J
668  */
669 JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_staticFieldOffset(JNIEnv *env, jobject _this, jobject f)
670 {
671         /* The offset of static fields is 0. */
672
673         return 0;
674 }
675
676
677 /*
678  * Class:     sun/misc/Unsafe
679  * Method:    staticFieldBase
680  * Signature: (Ljava/lang/reflect/Field;)Ljava/lang/Object;
681  */
682 JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_staticFieldBase(JNIEnv *env, jobject _this, jobject field)
683 {
684 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
685
686         java_lang_reflect_Field rf(field);
687         java_lang_reflect_VMField rvmf(rf.get_f());
688         fieldinfo* f = rvmf.get_field();
689
690 #elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
691
692         java_lang_reflect_Field rf(field);
693         fieldinfo* f = rf.get_field();
694
695 #else
696 # error unknown configuration
697 #endif
698
699         return (jobject) (f->value);
700 }
701
702
703 /*
704  * Class:     sun/misc/Unsafe
705  * Method:    ensureClassInitialized
706  * Signature: (Ljava/lang/Class;)V
707  */
708 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_ensureClassInitialized(JNIEnv *env, jobject _this, jclass clazz)
709 {
710         classinfo *c;
711
712         c = LLNI_classinfo_unwrap(clazz);
713
714         if (!(c->state & CLASS_INITIALIZED))
715                 initialize_class(c);
716 }
717
718
719 /*
720  * Class:     sun/misc/Unsafe
721  * Method:    arrayBaseOffset
722  * Signature: (Ljava/lang/Class;)I
723  */
724 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, jobject _this, jclass arrayClass)
725 {
726         classinfo       *c;
727         arraydescriptor *ad;
728
729         c  = LLNI_classinfo_unwrap(arrayClass);
730         ad = c->vftbl->arraydesc;
731
732         if (ad == NULL) {
733                 /* XXX does that exception exist? */
734                 exceptions_throw_internalerror("java/lang/InvalidClassException");
735                 return 0;
736         }
737
738         return ad->dataoffset;
739 }
740
741
742 /*
743  * Class:     sun/misc/Unsafe
744  * Method:    arrayIndexScale
745  * Signature: (Ljava/lang/Class;)I
746  */
747 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, jobject _this, jclass arrayClass)
748 {
749         classinfo       *c;
750         arraydescriptor *ad;
751
752         c  = LLNI_classinfo_unwrap(arrayClass);
753         ad = c->vftbl->arraydesc;
754
755         if (ad == NULL) {
756                 /* XXX does that exception exist? */
757                 exceptions_throw_internalerror("java/lang/InvalidClassException");
758                 return 0;
759         }
760
761         return ad->componentsize;
762 }
763
764
765 /*
766  * Class:     sun/misc/Unsafe
767  * Method:    addressSize
768  * Signature: ()I
769  */
770 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv *env, jobject _this)
771 {
772         return SIZEOF_VOID_P;
773 }
774
775
776 /*
777  * Class:     sun/misc/Unsafe
778  * Method:    pageSize
779  * Signature: ()I
780  */
781 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_pageSize(JNIEnv *env, jobject _this)
782 {
783         int sz;
784
785         sz = getpagesize();
786
787         return sz;
788 }
789
790
791 /*
792  * Class:     sun/misc/Unsafe
793  * Method:    defineClass
794  * Signature: (Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;
795  */
796 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)
797 {
798         classloader_t   *cl;
799         utf             *utfname;
800         classinfo       *c;
801
802         cl = loader_hashtable_classloader_add((java_handle_t *) loader);
803
804         /* check if data was passed */
805
806         if (b == NULL) {
807                 exceptions_throw_nullpointerexception();
808                 return NULL;
809         }
810
811         /* check the indexes passed */
812
813         if ((off < 0) || (len < 0) || ((off + len) > LLNI_array_size(b))) {
814                 exceptions_throw_arrayindexoutofboundsexception();
815                 return NULL;
816         }
817
818         if (name != NULL) {
819                 /* convert '.' to '/' in java string */
820
821                 utfname = javastring_toutf((java_handle_t *) name, true);
822         } 
823         else {
824                 utfname = NULL;
825         }
826
827         /* define the class */
828
829         c = class_define(utfname, cl, len, (uint8_t *) &(LLNI_array_direct((java_handle_bytearray_t*) b, off)),
830                                          (java_handle_t *) protectionDomain);
831
832         if (c == NULL)
833                 return NULL;
834
835         java_handle_t* h = LLNI_classinfo_wrap(c);
836
837 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
838         // Set ProtectionDomain.
839         java_lang_Class jlc(h);
840         jlc.set_pd(protectionDomain);
841 #endif
842
843         return (jclass) h;
844 }
845
846
847 /*
848  * Class:     sun/misc/Unsafe
849  * Method:    allocateInstance
850  * Signature: (Ljava/lang/Class;)Ljava/lang/Object;
851  */
852 JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_allocateInstance(JNIEnv *env, jobject _this, jclass cls)
853 {
854         classinfo     *c;
855         java_handle_t *o;
856
857         c = LLNI_classinfo_unwrap(cls);
858
859         o = builtin_new(c);
860
861         return (jobject ) o;
862 }
863
864
865 /*
866  * Class:     sun/misc/Unsafe
867  * Method:    throwException
868  * Signature: (Ljava/lang/Throwable;)V
869  */
870 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_throwException(JNIEnv *env, jobject _this, jobject ee)
871 {
872         java_handle_t *o;
873
874         o = (java_handle_t *) ee;
875
876         exceptions_set_exception(o);
877 }
878
879
880 /*
881  * Class:     sun/misc/Unsafe
882  * Method:    compareAndSwapObject
883  * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z
884  */
885 JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject expected, jobject x)
886 {
887         volatile void **p;
888         void           *result;
889
890         /* XXX Use LLNI */
891
892         p = (volatile void **) (((uint8_t *) o) + offset);
893
894         result = Atomic::compare_and_swap(p, expected, x);
895
896         if (result == expected)
897                 return true;
898
899         return false;
900 }
901
902
903 /*
904  * Class:     sun/misc/Unsafe
905  * Method:    compareAndSwapInt
906  * Signature: (Ljava/lang/Object;JII)Z
907  */
908 JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, jobject _this, jobject o, jlong offset, jint expected, jint x)
909 {
910         uint32_t *p;
911         uint32_t  result;
912
913         /* XXX Use LLNI */
914
915         p = (uint32_t *) (((uint8_t *) o) + offset);
916
917         result = Atomic::compare_and_swap(p, expected, x);
918
919         if (result == (uint32_t) expected)
920                 return true;
921
922         return false;
923 }
924
925
926 /*
927  * Class:     sun/misc/Unsafe
928  * Method:    compareAndSwapLong
929  * Signature: (Ljava/lang/Object;JJJ)Z
930  */
931 JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong expected, jlong x)
932 {
933         uint64_t *p;
934         uint64_t  result;
935
936         /* XXX Use LLNI */
937
938         p = (uint64_t *) (((uint8_t *) o) + offset);
939
940         result = Atomic::compare_and_swap(p, expected, x);
941
942         if (result == (uint64_t) expected)
943                 return true;
944
945         return false;
946 }
947
948
949 /*
950  * Class:     sun/misc/Unsafe
951  * Method:    getObjectVolatile
952  * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
953  */
954 JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
955 {
956         return FieldAccess::get_volatile<jobject>(o, offset);
957 }
958
959
960 /*
961  * Class:     sun/misc/Unsafe
962  * Method:    putObjectVolatile
963  * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
964  */
965 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x)
966 {
967         FieldAccess::set_volatile(o, offset, x);
968 }
969
970
971 /*
972  * Class:     sun/misc/Unsafe
973  * Method:    getByteVolatile
974  * Signature: (Ljava/lang/Object;J)B
975  */
976 JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByteVolatile(JNIEnv* env, jobject _this, jobject o, jlong offset)
977 {
978         return FieldAccess::get_volatile<int32_t>(o, offset);
979 }
980
981
982 /*
983  * Class:     sun/misc/Unsafe
984  * Method:    getIntVolatile
985  * Signature: (Ljava/lang/Object;J)I
986  */
987 JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
988 {
989         return FieldAccess::get_volatile<int32_t>(o, offset);
990 }
991
992
993 /*
994  * Class:     sun/misc/Unsafe
995  * Method:    putIntVolatile
996  * Signature: (Ljava/lang/Object;JI)V
997  */
998 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x)
999 {
1000         FieldAccess::set_volatile(o, offset, x);
1001 }
1002
1003
1004 /*
1005  * Class:     sun/misc/Unsafe
1006  * Method:    getLongVolatile
1007  * Signature: (Ljava/lang/Object;J)J
1008  */
1009 JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
1010 {
1011         return FieldAccess::get_volatile<int64_t>(o, offset);
1012 }
1013
1014
1015 /*
1016  * Class:     sun/misc/Unsafe
1017  * Method:    putLongVolatile
1018  * Signature: (Ljava/lang/Object;JJ)V
1019  */
1020 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x)
1021 {
1022         FieldAccess::set_volatile(o, offset, x);
1023 }
1024
1025
1026 /*
1027  * Class:     sun/misc/Unsafe
1028  * Method:    getFloatVolatile
1029  * Signature: (Ljava/lang/Object;J)F
1030  */
1031 JNIEXPORT jfloat JNICALL Java_sun_misc_Unsafe_getFloatVolatile(JNIEnv* env, jobject _this, jobject o, jlong offset)
1032 {
1033         return FieldAccess::get_volatile<float>(o, offset);
1034 }
1035
1036
1037 /*
1038  * Class:     sun/misc/Unsafe
1039  * Method:    getDoubleVolatile
1040  * Signature: (Ljava/lang/Object;J)D
1041  */
1042 JNIEXPORT jdouble JNICALL Java_sun_misc_Unsafe_getDoubleVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
1043 {
1044         return FieldAccess::get_volatile<double>(o, offset);
1045 }
1046
1047
1048 /*
1049  * Class:     sun/misc/Unsafe
1050  * Method:    putOrderedObject
1051  * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
1052  */
1053 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x)
1054 {
1055         FieldAccess::set_volatile(o, offset, x);
1056 }
1057
1058
1059 /*
1060  * Class:     sun/misc/Unsafe
1061  * Method:    putOrderedInt
1062  * Signature: (Ljava/lang/Object;JI)V
1063  */
1064 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x)
1065 {
1066         FieldAccess::set_volatile(o, offset, x);
1067 }
1068
1069
1070 /*
1071  * Class:     sun/misc/Unsafe
1072  * Method:    putOrderedLong
1073  * Signature: (Ljava/lang/Object;JJ)V
1074  */
1075 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x)
1076 {
1077         FieldAccess::set_volatile(o, offset, x);
1078 }
1079
1080
1081 /*
1082  * Class:     sun/misc/Unsafe
1083  * Method:    unpark
1084  * Signature: (Ljava/lang/Object;)V
1085  */
1086 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, jobject _this, jobject thread)
1087 {
1088         java_handle_t *h = (java_handle_t *) thread;
1089         threadobject *t;
1090
1091 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
1092         h = java_lang_Thread(h).get_vmThread();
1093 #endif
1094         t = thread_get_thread(h);
1095
1096         threads_unpark(t);
1097 }
1098
1099
1100 /*
1101  * Class:     sun/misc/Unsafe
1102  * Method:    park
1103  * Signature: (ZJ)V
1104  */
1105 JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, jobject _this, jboolean isAbsolute, jlong time)
1106 {
1107         threads_park(isAbsolute, time);
1108 }
1109
1110 } // extern "C"
1111
1112
1113 /* native methods implemented by this file ************************************/
1114
1115 static JNINativeMethod methods[] = {
1116         { (char*) "registerNatives",        (char*) "()V",                                                        (void*) (uintptr_t) &Java_sun_misc_Unsafe_registerNatives                  },
1117         { (char*) "getInt",                 (char*) "(Ljava/lang/Object;J)I",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J     },
1118         { (char*) "putInt",                 (char*) "(Ljava/lang/Object;JI)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI    },
1119         { (char*) "getObject",              (char*) "(Ljava/lang/Object;J)Ljava/lang/Object;",                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_getObject                        },
1120         { (char*) "putObject",              (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_putObject                        },
1121         { (char*) "getBoolean",             (char*) "(Ljava/lang/Object;J)Z",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getBoolean                       },
1122         { (char*) "putBoolean",             (char*) "(Ljava/lang/Object;JZ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putBoolean                       },
1123         { (char*) "getByte",                (char*) "(Ljava/lang/Object;J)B",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J    },
1124         { (char*) "putByte",                (char*) "(Ljava/lang/Object;JB)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB   },
1125         { (char*) "getShort",               (char*) "(Ljava/lang/Object;J)S",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J   },
1126         { (char*) "putShort",               (char*) "(Ljava/lang/Object;JS)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS  },
1127         { (char*) "getChar",                (char*) "(Ljava/lang/Object;J)C",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J    },
1128         { (char*) "putChar",                (char*) "(Ljava/lang/Object;JC)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC   },
1129         { (char*) "getLong",                (char*) "(Ljava/lang/Object;J)J",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J    },
1130         { (char*) "putLong",                (char*) "(Ljava/lang/Object;JJ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ   },
1131         { (char*) "getFloat",               (char*) "(Ljava/lang/Object;J)F",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J   },
1132         { (char*) "putFloat",               (char*) "(Ljava/lang/Object;JF)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF  },
1133         { (char*) "getDouble",              (char*) "(Ljava/lang/Object;J)D",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J  },
1134         { (char*) "putDouble",              (char*) "(Ljava/lang/Object;JD)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD },
1135         { (char*) "getByte",                (char*) "(J)B",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByte__J                       },
1136         { (char*) "putByte",                (char*) "(JB)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putByte__JB                      },
1137         { (char*) "getShort",               (char*) "(J)S",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getShort__J                      },
1138         { (char*) "putShort",               (char*) "(JS)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putShort__JS                     },
1139         { (char*) "getChar",                (char*) "(J)C",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getChar__J                       },
1140         { (char*) "putChar",                (char*) "(JC)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putChar__JC                      },
1141         { (char*) "getInt",                 (char*) "(J)I",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getInt__J                        },
1142         { (char*) "putInt",                 (char*) "(JI)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putInt__JI                       },
1143         { (char*) "getLong",                (char*) "(J)J",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLong__J                       },
1144         { (char*) "putLong",                (char*) "(JJ)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLong__JJ                      },
1145         { (char*) "getFloat",               (char*) "(J)F",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloat__J                      },
1146         { (char*) "putFloat",               (char*) "(JF)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_putFloat__JF                     },
1147         { (char*) "getDouble",              (char*) "(J)D",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_getDouble__J                     },
1148         { (char*) "objectFieldOffset",      (char*) "(Ljava/lang/reflect/Field;)J",                               (void*) (uintptr_t) &Java_sun_misc_Unsafe_objectFieldOffset                },
1149         { (char*) "allocateMemory",         (char*) "(J)J",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_allocateMemory                   },
1150 #if 0
1151         // OpenJDK 7
1152         { (char*) "setMemory",              (char*) "(Ljava/lang/Object;JJB)V",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_setMemory                        },
1153         { (char*) "copyMemory",             (char*) "(Ljava/lang/Object;JLjava/lang/Object;JJ)V",                 (void*) (uintptr_t) &Java_sun_misc_Unsafe_copyMemory                       },
1154 #else
1155         { (char*) "setMemory",              (char*) "(JJB)V",                                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_setMemory                        },
1156         { (char*) "copyMemory",             (char*) "(JJJ)V",                                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_copyMemory                       },
1157 #endif
1158         { (char*) "freeMemory",             (char*) "(J)V",                                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_freeMemory                       },
1159         { (char*) "staticFieldOffset",      (char*) "(Ljava/lang/reflect/Field;)J",                               (void*) (uintptr_t) &Java_sun_misc_Unsafe_staticFieldOffset                },
1160         { (char*) "staticFieldBase",        (char*) "(Ljava/lang/reflect/Field;)Ljava/lang/Object;",              (void*) (uintptr_t) &Java_sun_misc_Unsafe_staticFieldBase                  },
1161         { (char*) "ensureClassInitialized", (char*) "(Ljava/lang/Class;)V",                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_ensureClassInitialized           },
1162         { (char*) "arrayBaseOffset",        (char*) "(Ljava/lang/Class;)I",                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_arrayBaseOffset                  },
1163         { (char*) "arrayIndexScale",        (char*) "(Ljava/lang/Class;)I",                                       (void*) (uintptr_t) &Java_sun_misc_Unsafe_arrayIndexScale                  },
1164         { (char*) "addressSize",            (char*) "()I",                                                        (void*) (uintptr_t) &Java_sun_misc_Unsafe_addressSize                      },
1165         { (char*) "pageSize",               (char*) "()I",                                                        (void*) (uintptr_t) &Java_sun_misc_Unsafe_pageSize                         },
1166         { (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 },
1167         { (char*) "allocateInstance",       (char*) "(Ljava/lang/Class;)Ljava/lang/Object;",                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_allocateInstance                 },
1168         { (char*) "throwException",         (char*) "(Ljava/lang/Throwable;)V",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_throwException                   },
1169         { (char*) "compareAndSwapObject",   (char*) "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapObject             },
1170         { (char*) "compareAndSwapInt",      (char*) "(Ljava/lang/Object;JII)Z",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapInt                },
1171         { (char*) "compareAndSwapLong",     (char*) "(Ljava/lang/Object;JJJ)Z",                                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapLong               },
1172         { (char*) "getObjectVolatile",      (char*) "(Ljava/lang/Object;J)Ljava/lang/Object;",                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_getObjectVolatile                },
1173         { (char*) "putObjectVolatile",      (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_putObjectVolatile                },
1174         { (char*) "getByteVolatile",        (char*) "(Ljava/lang/Object;J)B",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByteVolatile                  },
1175         { (char*) "getIntVolatile",         (char*) "(Ljava/lang/Object;J)I",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getIntVolatile                   },
1176         { (char*) "putIntVolatile",         (char*) "(Ljava/lang/Object;JI)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putIntVolatile                   },
1177         { (char*) "getLongVolatile",        (char*) "(Ljava/lang/Object;J)J",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLongVolatile                  },
1178         { (char*) "putLongVolatile",        (char*) "(Ljava/lang/Object;JJ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLongVolatile                  },
1179         { (char*) "getFloatVolatile",       (char*) "(Ljava/lang/Object;J)F",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloatVolatile                 },
1180         { (char*) "getDoubleVolatile",      (char*) "(Ljava/lang/Object;J)D",                                     (void*) (uintptr_t) &Java_sun_misc_Unsafe_getDoubleVolatile                },
1181         { (char*) "putOrderedObject",       (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedObject                 },
1182         { (char*) "putOrderedInt",          (char*) "(Ljava/lang/Object;JI)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedInt                    },
1183         { (char*) "putOrderedLong",         (char*) "(Ljava/lang/Object;JJ)V",                                    (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedLong                   },
1184         { (char*) "unpark",                 (char*) "(Ljava/lang/Object;)V",                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_unpark                           },
1185         { (char*) "park",                   (char*) "(ZJ)V",                                                      (void*) (uintptr_t) &Java_sun_misc_Unsafe_park                             },
1186 };
1187
1188
1189 /* _Jv_sun_misc_Unsafe_init ****************************************************
1190
1191    Register native functions.
1192
1193 *******************************************************************************/
1194
1195 void _Jv_sun_misc_Unsafe_init(void)
1196 {
1197         utf* u = utf_new_char("sun/misc/Unsafe");
1198
1199         NativeMethods& nm = VM::get_current()->get_nativemethods();
1200         nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
1201 }
1202
1203
1204 /*
1205  * These are local overrides for various environment variables in Emacs.
1206  * Please do not remove this and leave it at the end of the file, where
1207  * Emacs will automagically detect them.
1208  * ---------------------------------------------------------------------
1209  * Local variables:
1210  * mode: c++
1211  * indent-tabs-mode: t
1212  * c-basic-offset: 4
1213  * tab-width: 4
1214  * End:
1215  * vim:noexpandtab:sw=4:ts=4:
1216  */