1 /*
2    Copyright (c) 2010, 2021, Oracle and/or its affiliates.
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 #include <jni.h>
26 
27 #include "utils_HrtStopwatch.h"
28 #include "hrt_gstopwatch.h"
29 
30 JNIEXPORT void JNICALL
Java_utils_HrtStopwatch_init(JNIEnv * env,jclass cls,jint cap)31 Java_utils_HrtStopwatch_init(JNIEnv *env, jclass cls,
32                                         jint cap)
33 {
34     hrt_gsw_init(cap);
35 }
36 
37 JNIEXPORT void JNICALL
Java_utils_HrtStopwatch_close(JNIEnv * env,jclass cls)38 Java_utils_HrtStopwatch_close(JNIEnv *env, jclass cls)
39 {
40     hrt_gsw_close();
41 }
42 
43 JNIEXPORT jint JNICALL
Java_utils_HrtStopwatch_top(JNIEnv * env,jclass cls)44 Java_utils_HrtStopwatch_top(JNIEnv *env, jclass cls)
45 {
46     return hrt_gsw_top();
47 }
48 
49 JNIEXPORT jint JNICALL
Java_utils_HrtStopwatch_capacity(JNIEnv * env,jclass cls)50 Java_utils_HrtStopwatch_capacity(JNIEnv *env, jclass cls)
51 {
52     return hrt_gsw_capacity();
53 }
54 
55 JNIEXPORT jint JNICALL
Java_utils_HrtStopwatch_pushmark(JNIEnv * env,jclass cls)56 Java_utils_HrtStopwatch_pushmark(JNIEnv *env, jclass cls)
57 {
58     return hrt_gsw_pushmark();
59 }
60 
61 JNIEXPORT void JNICALL
Java_utils_HrtStopwatch_popmark(JNIEnv * env,jclass cls)62 Java_utils_HrtStopwatch_popmark(JNIEnv * env, jclass cls)
63 {
64     hrt_gsw_popmark();
65 }
66 
67 JNIEXPORT jdouble JNICALL
Java_utils_HrtStopwatch_rtmicros(JNIEnv * env,jclass cls,jint y,jint x)68 Java_utils_HrtStopwatch_rtmicros(JNIEnv *env, jclass cls,
69                                             jint y, jint x)
70 {
71     return hrt_gsw_rtmicros(y, x);
72 }
73 
74 JNIEXPORT jdouble JNICALL
Java_utils_HrtStopwatch_ctmicros(JNIEnv * env,jclass cls,jint y,jint x)75 Java_utils_HrtStopwatch_ctmicros(JNIEnv *env, jclass cls,
76                                             jint y, jint x)
77 {
78     return hrt_gsw_ctmicros(y, x);
79 }
80 
81 JNIEXPORT void JNICALL
Java_utils_HrtStopwatch_clear(JNIEnv * env,jclass cls)82 Java_utils_HrtStopwatch_clear(JNIEnv *env, jclass cls)
83 {
84     hrt_gsw_clear();
85 }
86