util: Add the "sum" method to the java and lua m5 util wrappers.
Change-Id: Id55dec87af3e0fc89da6c5471a2aa02443063108 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28175 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Gabe Black <gabe.black@gmail.com> Reviewed-by: Pouya Fotouhi <pfotouhi@ucdavis.edu> Maintainer: Gabe Black <gabe.black@gmail.com>
This commit is contained in:
@@ -52,6 +52,7 @@ public class gem5Op {
|
||||
|
||||
public native void exit(long ns_delay);
|
||||
public native void fail(long ns_delay, long code);
|
||||
public native long sum(long a, long b, long c, long d, long e, long f);
|
||||
public native long init_param(long key_str1, long key_str2);
|
||||
public native void checkpoint(long ns_delay, long ns_period);
|
||||
public native void reset_stats(long ns_delay, long ns_period);
|
||||
|
||||
@@ -104,6 +104,16 @@ Java_jni_gem5Op_fail(JNIEnv *env, jobject obj, jlong j_ns_delay, jlong j_code)
|
||||
m5_fail(j_ns_delay, j_code);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_jni_gem5Op_sum(JNIEnv *env, jobject obj, jlong a, jlong b, jlong c,
|
||||
jlong d, jlong e, jlong f)
|
||||
{
|
||||
uint64_t result = m5_sum(a, b, c, d, e, f);
|
||||
if (result & 0x8000000000000000ULL)
|
||||
printf("Truncated return value from sum() to 63 bits\n");
|
||||
return (result & 0x7FFFFFFFFFFFFFFFULL);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_jni_gem5Op_init_1param(JNIEnv *env, jobject obj, jlong j_key_str1,
|
||||
jlong j_key_str2)
|
||||
|
||||
@@ -100,6 +100,20 @@ do_exit(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
do_sum(lua_State *L)
|
||||
{
|
||||
uint64_t a = lua_tointeger(L, 1);
|
||||
uint64_t b = lua_tointeger(L, 2);
|
||||
uint64_t c = lua_tointeger(L, 3);
|
||||
uint64_t d = lua_tointeger(L, 4);
|
||||
uint64_t e = lua_tointeger(L, 5);
|
||||
uint64_t f = lua_tointeger(L, 6);
|
||||
uint64_t sum = m5_sum(a, b, c, d, e, f);
|
||||
lua_pushinteger(L, sum);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
do_fail(lua_State *L)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user