8fb75bb538811cc578f0b76eeb6686c9685575e9
[cacao.git] / src / native / vm / openjdk / sun_misc_Perf.cpp
1 /* src/native/vm/openjdk/sun_misc_Perf.cpp - sun/misc/Perf
2
3    Copyright (C) 2009
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5    Copyright (C) 2009 Theobroma Systems Ltd.
6
7    This file is part of CACAO.
8
9    This program is free software; you can redistribute it and/or
10    modify it under the terms of the GNU General Public License as
11    published by the Free Software Foundation; either version 2, or (at
12    your option) any later version.
13
14    This program is distributed in the hope that it will be useful, but
15    WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22    02110-1301, USA.
23
24 */
25
26
27 #include "config.h"
28
29 #include "native/jni.hpp"
30 #include "native/native.hpp"
31
32 #include "vm/utf8.h"
33 #include "vm/vm.hpp"
34
35
36 // Native functions are exported as C functions.
37 extern "C" {
38
39 /*
40  * Class:     sun/misc/Perf
41  * Method:    registerNatives
42  * Signature: ()V
43  */
44 JNIEXPORT void JNICALL Java_sun_misc_Perf_registerNatives(JNIEnv *env, jclass clazz)
45 {
46         /* The native methods of this function are already registered in
47            _Jv_sun_misc_Perf_init() which is called during VM
48            startup. */
49 }
50
51
52 /*
53  * Class:     sun/misc/Perf
54  * Method:    attach
55  * Signature: (Ljava/lang/String;II)Ljava/nio/ByteBuffer;
56  */
57 JNIEXPORT jobject JNICALL Java_sun_misc_Perf_attach(JNIEnv *env, jobject _this, jstring user, jint lvmid, jint mode)
58 {
59         log_println("Java_sun_misc_Perf_attach: Not supported!");
60         return NULL;
61 }
62
63
64 /*
65  * Class:     sun/misc/Perf
66  * Method:    createByteArray
67  * Signature: (Ljava/lang/String;II[BI)Ljava/nio/ByteBuffer;
68  */
69 JNIEXPORT jobject JNICALL Java_sun_misc_Perf_createByteArray(JNIEnv *env, jobject _this, jstring name, jint variability, jint units, jbyteArray value, jint max_length)
70 {
71         log_println("Java_sun_misc_Perf_createByteArray: Not supported!");
72         return NULL;
73 }
74
75
76 /*
77  * Class:     sun/misc/Perf
78  * Method:    createLong
79  * Signature: (Ljava/lang/String;IIJ)Ljava/nio/ByteBuffer;
80  */
81 JNIEXPORT jobject JNICALL Java_sun_misc_Perf_createLong(JNIEnv *env, jobject _this, jstring name, jint variability, jint units, jlong value)
82 {
83         log_println("Java_sun_misc_Perf_createLong: Not supported!");
84         return NULL;
85 }
86
87
88 /*
89  * Class:     sun/misc/Perf
90  * Method:    detach
91  * Signature: (Ljava/nio/ByteBuffer;)V
92  */
93 JNIEXPORT void JNICALL Java_sun_misc_Perf_detach(JNIEnv *env, jobject _this, jobject bb)
94 {
95         log_println("Java_sun_misc_Perf_detach: Not supported!");
96 }
97
98
99 /*
100  * Class:     sun/misc/Perf
101  * Method:    highResCounter
102  * Signature: ()J
103  */
104 JNIEXPORT jlong JNICALL Java_sun_misc_Perf_highResCounter(JNIEnv *env, jobject _this)
105 {
106         log_println("Java_sun_misc_Perf_highResCounter: IMPLEMENT ME!");
107         return 0;
108 }
109
110
111 /*
112  * Class:     sun/misc/Perf
113  * Method:    highResFrequency
114  * Signature: ()J
115  */
116 JNIEXPORT jlong JNICALL Java_sun_misc_Perf_highResFrequency(JNIEnv *env, jobject _this)
117 {
118         log_println("Java_sun_misc_Perf_highResFrequency: IMPLEMENT ME!");
119         return 0;
120 }
121
122 } // extern "C"
123
124
125 /* native methods implemented by this file ************************************/
126
127 static JNINativeMethod methods[] = {
128         { (char*) "registerNatives",  (char*) "()V",                                            (void*) (uintptr_t) &Java_sun_misc_Perf_registerNatives  },
129         { (char*) "attach",           (char*) "(Ljava/lang/String;II)Ljava/nio/ByteBuffer;",    (void*) (uintptr_t) &Java_sun_misc_Perf_attach           },
130         { (char*) "createByteArray",  (char*) "(Ljava/lang/String;II[BI)Ljava/nio/ByteBuffer;", (void*) (uintptr_t) &Java_sun_misc_Perf_createByteArray  },
131         { (char*) "createLong",       (char*) "(Ljava/lang/String;IIJ)Ljava/nio/ByteBuffer;",   (void*) (uintptr_t) &Java_sun_misc_Perf_createLong       },
132         { (char*) "detach",           (char*) "(Ljava/nio/ByteBuffer;)V",                       (void*) (uintptr_t) &Java_sun_misc_Perf_detach           },
133         { (char*) "highResCounter",   (char*) "()J",                                            (void*) (uintptr_t) &Java_sun_misc_Perf_highResCounter   },
134         { (char*) "highResFrequency", (char*) "()J",                                            (void*) (uintptr_t) &Java_sun_misc_Perf_highResFrequency },
135 };
136
137
138 /* _Jv_sun_misc_Perf_init ******************************************************
139
140    Register native functions.
141
142 *******************************************************************************/
143
144 void _Jv_sun_misc_Perf_init(void)
145 {
146         utf* u = utf_new_char("sun/misc/Perf");
147
148         NativeMethods& nm = VM::get_current()->get_nativemethods();
149         nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
150 }
151
152
153 /*
154  * These are local overrides for various environment variables in Emacs.
155  * Please do not remove this and leave it at the end of the file, where
156  * Emacs will automagically detect them.
157  * ---------------------------------------------------------------------
158  * Local variables:
159  * mode: c++
160  * indent-tabs-mode: t
161  * c-basic-offset: 4
162  * tab-width: 4
163  * End:
164  * vim:noexpandtab:sw=4:ts=4:
165  */