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);
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)
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)
{