Browse Source

Added method get_real_time to get real system time, via Java, from C.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@4335 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 14 years ago
parent
commit
720d47eb7d
  1. 1
      prism/include/prism.h
  2. 19
      prism/src/prism/prism.cc

1
prism/include/prism.h

@ -43,6 +43,7 @@ typedef struct FoxGlynnWeights
} FoxGlynnWeights; } FoxGlynnWeights;
// Function prototypes // Function prototypes
EXPORT long get_real_time(JNIEnv *env);
EXPORT void get_string_array_from_java(JNIEnv *env, jobject strings_list, jstring *&strings_jstrings, const char **&strings, int &size); EXPORT void get_string_array_from_java(JNIEnv *env, jobject strings_list, jstring *&strings_jstrings, const char **&strings, int &size);
EXPORT void release_string_array_from_java(JNIEnv *env, jstring *strings_jstrings, const char **strings, jint size); EXPORT void release_string_array_from_java(JNIEnv *env, jstring *strings_jstrings, const char **strings, jint size);
EXPORT FoxGlynnWeights fox_glynn(double q_tmax, double underflow, double overflow, double accuracy); EXPORT FoxGlynnWeights fox_glynn(double q_tmax, double underflow, double overflow, double accuracy);

19
prism/src/prism/prism.cc

@ -31,6 +31,25 @@
#include <math.h> #include <math.h>
#include <new> #include <new>
#include <vector> #include <vector>
#include "jnipointer.h"
//------------------------------------------------------------------------------
// Get the current time in milliseconds (via Java).
// Returns -1 in case of error obtaining the time.
long get_real_time(JNIEnv *env)
{
jlong ret = 0;
if (env) {
jclass cl = env->FindClass("java/lang/System");
jmethodID me = env->GetStaticMethodID(cl, "currentTimeMillis", "()J");
ret = env->CallLongMethod(cl, me);
} else {
ret = -1;
}
return ret;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

Loading…
Cancel
Save