jobject native_to_java_process(msg_process_t process)
{
- simgrid::java::JavaContext* context =
- (simgrid::java::JavaContext*) MSG_process_get_smx_ctx(process);
+ simgrid::java::JavaContext* context = (simgrid::java::JavaContext*) MSG_process_get_smx_ctx(process);
return context->jprocess;
}
void jprocess_join(jobject jprocess, JNIEnv * env)
{
- msg_process_t process = jprocess_to_native_process(jprocess,env);
- simgrid::java::JavaContext* context =
- (simgrid::java::JavaContext*) MSG_process_get_smx_ctx(process);
- xbt_os_thread_join(context->thread,NULL);
+ msg_process_t process = jprocess_to_native_process(jprocess,env);
+ simgrid::java::JavaContext* context = (simgrid::java::JavaContext*) MSG_process_get_smx_ctx(process);
+ xbt_os_thread_join(context->thread,NULL);
}
msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env)
{
- return
- (msg_process_t)(intptr_t)env->GetLongField(jprocess,
- jprocess_field_Process_bind);
+ return (msg_process_t)(intptr_t)env->GetLongField(jprocess, jprocess_field_Process_bind);
}
void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env)
{
- env->SetLongField(jprocess, jprocess_field_Process_bind,
- (intptr_t)process);
+ env->SetLongField(jprocess, jprocess_field_Process_bind, (intptr_t)process);
}
jlong jprocess_get_id(jobject jprocess, JNIEnv * env)
{
- return
- (intptr_t)env->GetLongField(jprocess, jprocess_field_Process_id);
+ return (intptr_t)env->GetLongField(jprocess, jprocess_field_Process_id);
}
jstring jprocess_get_name(jobject jprocess, JNIEnv * env)
return env->GetLongField(jprocess, id) ? JNI_TRUE : JNI_FALSE;
}
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls) {
+
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls) {
jclass jprocess_class_Process = env->FindClass("org/simgrid/msg/Process");
jprocess_field_Process_name = jxbt_get_jfield(env, jprocess_class_Process, "name", "Ljava/lang/String;");
jprocess_field_Process_ppid = jxbt_get_jfield(env, jprocess_class_Process, "ppid", "I");
jprocess_field_Process_host = jxbt_get_jfield(env, jprocess_class_Process, "host", "Lorg/simgrid/msg/Host;");
jprocess_field_Process_killTime = jxbt_get_jfield(env, jprocess_class_Process, "killTime", "D");
- if (!jprocess_class_Process || !jprocess_field_Process_id || !jprocess_field_Process_name || !jprocess_field_Process_pid ||
- !jprocess_field_Process_ppid || !jprocess_field_Process_host) {
+ if (!jprocess_class_Process || !jprocess_field_Process_id || !jprocess_field_Process_name ||
+ !jprocess_field_Process_pid || !jprocess_field_Process_ppid || !jprocess_field_Process_host) {
jxbt_throw_native(env,bprintf("Can't find some fields in Java class. You should report this bug."));
}
}
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_create(JNIEnv * env,
- jobject jprocess_arg,
- jobject jhostname)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv * env, jobject jprocess_arg, jobject jhostname)
{
-
-
jobject jprocess; /* the global reference to the java process instance */
jstring jname; /* the name of the java process instance */
const char *name; /* the C name of the process */
/* Retrieve the kill time from the process */
jdouble jkill = env->GetDoubleField(jprocess, jprocess_field_Process_killTime);
/* Actually build the MSG process */
- process = MSG_process_create_with_environment(name,
- [](int argc, char** argv) -> int {
+ process = MSG_process_create_with_environment(name, [](int argc, char** argv) -> int {
smx_process_t process = SIMIX_process_self();
// This is the jprocess passed as environment.
// It would be simplet if we could use a closure.
simgrid::java::java_main_jprocess(jprocess);
return 0;
}, jprocess,
- host,
- /*argc, argv, properties*/
- 0, NULL, NULL);
+ host,
+ /*argc, argv, properties*/
+ 0, NULL, NULL);
MSG_process_set_kill_time(process, (double)jkill);
/* bind the java process instance to the native process */
jprocess_bind(jprocess, process, env);
env->SetObjectField(jprocess, jprocess_field_Process_host, jhost);
}
-JNIEXPORT jint JNICALL
-Java_org_simgrid_msg_Process_killAll(JNIEnv * env, jclass cls,
- jint jresetPID)
+JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll(JNIEnv * env, jclass cls, jint jresetPID)
{
return (jint) MSG_process_killall((int) jresetPID);
}
-JNIEXPORT jobject JNICALL
-Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jclass cls,
- jint PID)
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jclass cls, jint PID)
{
msg_process_t process = MSG_process_from_PID(PID);
return jprocess;
}
-JNIEXPORT jobject JNICALL
-Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname) {
+
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname) {
msg_process_t process = jprocess_to_native_process(jprocess, env);
if (!process) {
return jproperty;
}
-JNIEXPORT jobject JNICALL
-Java_org_simgrid_msg_Process_getCurrentProcess(JNIEnv * env, jclass cls)
+
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess(JNIEnv * env, jclass cls)
{
msg_process_t process = MSG_process_self();
jobject jprocess;
return jprocess;
}
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_suspend(JNIEnv * env,
- jobject jprocess)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_suspend(JNIEnv * env, jobject jprocess)
{
msg_process_t process = jprocess_to_native_process(jprocess, env);
/* try to suspend the process */
msg_error_t rv = MSG_process_suspend(process);
- jxbt_check_res("MSG_process_suspend()", rv, MSG_OK,
- bprintf("unexpected error , please report this bug"));
-
+ jxbt_check_res("MSG_process_suspend()", rv, MSG_OK, bprintf("unexpected error , please report this bug"));
}
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_resume(JNIEnv * env,
- jobject jprocess)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume(JNIEnv * env, jobject jprocess)
{
msg_process_t process = jprocess_to_native_process(jprocess, env);
/* try to resume the process */
msg_error_t rv = MSG_process_resume(process);
- jxbt_check_res("MSG_process_resume()", rv, MSG_OK,
- bprintf("unexpected error , please report this bug"));
+ jxbt_check_res("MSG_process_resume()", rv, MSG_OK, bprintf("unexpected error , please report this bug"));
}
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_setAutoRestart
- (JNIEnv *env, jobject jprocess, jboolean jauto_restart) {
+JNIEXPORT void
+JNICALL Java_org_simgrid_msg_Process_setAutoRestart (JNIEnv *env, jobject jprocess, jboolean jauto_restart) {
msg_process_t process = jprocess_to_native_process(jprocess, env);
xbt_ex_t e;
xbt_ex_free(e);
}
}
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_restart
- (JNIEnv *env, jobject jprocess) {
+
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart (JNIEnv *env, jobject jprocess) {
msg_process_t process = jprocess_to_native_process(jprocess, env);
xbt_ex_t e;
}
}
-JNIEXPORT jboolean JNICALL
-Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env,
- jobject jprocess)
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env, jobject jprocess)
{
msg_process_t process = jprocess_to_native_process(jprocess, env);
return (jboolean) MSG_process_is_suspended(process);
}
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos)
{
double time = ((double)jmillis) / 1000 + ((double)jnanos) / 1000000000;
msg_error_t rv;
jxbt_throw_host_failure(env,NULL);
}
}
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_waitFor(JNIEnv * env, jobject jprocess,
- jdouble jseconds)
+
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor(JNIEnv * env, jobject jprocess, jdouble jseconds)
{
msg_error_t rv;
rv = MSG_process_sleep((double)jseconds);
}
}
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_kill(JNIEnv * env,
- jobject jprocess)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill(JNIEnv * env, jobject jprocess)
{
- /* get the native instances from the java ones */
+ /* get the native instances from the java ones */
msg_process_t process = jprocess_to_native_process(jprocess, env);
if (!process) {
jxbt_throw_notbound(env, "process", jprocess);
return;
}
- MSG_process_kill(process);
+ MSG_process_kill(process);
}
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_migrate(JNIEnv * env,
- jobject jprocess, jobject jhost)
+
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate(JNIEnv * env, jobject jprocess, jobject jhost)
{
msg_process_t process = jprocess_to_native_process(jprocess, env);
/* change the host java side */
env->SetObjectField(jprocess, jprocess_field_Process_host, jhost);
}
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Process_setKillTime (JNIEnv *env , jobject jprocess, jdouble jkilltime) {
- msg_process_t process = jprocess_to_native_process(jprocess, env);
- MSG_process_set_kill_time(process, (double)jkilltime);
+
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime (JNIEnv *env , jobject jprocess, jdouble jkilltime) {
+ msg_process_t process = jprocess_to_native_process(jprocess, env);
+ MSG_process_set_kill_time(process, (double)jkilltime);
}
-JNIEXPORT jint JNICALL
-Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls) {
+JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls) {
return (jint) MSG_process_get_number();
}