Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix build warnings on 32bits archs.
authorArnaud Giersch <arnaud.giersch@free.fr>
Tue, 12 Feb 2013 20:53:53 +0000 (21:53 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 12 Feb 2013 22:51:03 +0000 (23:51 +0100)
Use intermediate type intptr_t for conversions between pointer
types and jlong.

src/bindings/java/jmsg_file.c
src/bindings/java/jmsg_process.c
src/bindings/java/jmsg_rngstream.c
src/bindings/java/jmsg_vm.c
src/bindings/java/jxbt_utilities.h
src/bindings/java/smx_context_cojava.c
src/bindings/java/smx_context_java.c

index 1d45583..9266483 100644 (file)
@@ -6,12 +6,14 @@
   * under the terms of the license (GNU LGPL) which comes with this package. */
 #include "jmsg_file.h"
 #include "jxbt_utilities.h"
+
 void jfile_bind(JNIEnv *env, jobject jfile, msg_file_t stream) {
-  (*env)->SetLongField(env, jfile, jfile_field_bind, (jlong) (long) (stream));
+  (*env)->SetLongField(env, jfile, jfile_field_bind, (intptr_t)stream);
 }
 
 msg_file_t jfile_get_native(JNIEnv *env, jobject jfile) {
-  msg_file_t file = (msg_file_t)(*env)->GetLongField(env, jfile, jfile_field_bind);
+  msg_file_t file =
+    (msg_file_t)(intptr_t)(*env)->GetLongField(env, jfile, jfile_field_bind);
   return file;
 }
 
index 233a614..b78ba98 100644 (file)
@@ -56,17 +56,21 @@ void jprocess_join(jobject jprocess, JNIEnv * env)
 
 msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env)
 {
-  return (msg_process_t) (long) (*env)->GetLongField(env, jprocess, jprocess_field_Process_bind);
+  return
+    (msg_process_t)(intptr_t)(*env)->GetLongField(env, jprocess,
+                                                  jprocess_field_Process_bind);
 }
 
 void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env)
 {
-  (*env)->SetLongField(env, jprocess, jprocess_field_Process_bind, (jlong)(process));
+  (*env)->SetLongField(env, jprocess, jprocess_field_Process_bind,
+                       (intptr_t)process);
 }
 
 jlong jprocess_get_id(jobject jprocess, JNIEnv * env)
 {
-  return (*env)->GetLongField(env, jprocess, jprocess_field_Process_id);
+  return
+    (intptr_t)(*env)->GetLongField(env, jprocess, jprocess_field_Process_id);
 }
 
 jstring jprocess_get_name(jobject jprocess, JNIEnv * env)
index a51c4cc..6610b84 100644 (file)
@@ -13,7 +13,8 @@
 jfieldID jrngstream_bind;
 
 RngStream jrngstream_to_native(JNIEnv *env, jobject jrngstream) {
-  RngStream rngstream = (RngStream) (*env)->GetLongField(env, jrngstream, jrngstream_bind);
+  RngStream rngstream =
+    (RngStream)(intptr_t)(*env)->GetLongField(env, jrngstream, jrngstream_bind);
   if (!rngstream) {
     jxbt_throw_notbound(env, "rngstream", jrngstream);
     return NULL;
@@ -33,7 +34,7 @@ Java_org_simgrid_msg_RngStream_create(JNIEnv *env, jobject jrngstream, jstring j
   const char *name = (*env)->GetStringUTFChars(env, jname, 0);
   RngStream rngstream = RngStream_CreateStream(name);
   //Bind the RngStream object
-  (*env)->SetLongField(env, jrngstream, jrngstream_bind, (jlong)rngstream);
+  (*env)->SetLongField(env, jrngstream, jrngstream_bind, (intptr_t)rngstream);
 
   (*env)->ReleaseStringUTFChars(env, jname, name);
 }
@@ -41,7 +42,7 @@ JNIEXPORT void JNICALL
 Java_org_simgrid_msg_RngStream_destroy(JNIEnv *env, jobject jrngstream) {
   RngStream rngstream = jrngstream_to_native(env, jrngstream);
   RngStream_DeleteStream(&rngstream);
-  (*env)->SetLongField(env, jrngstream, jrngstream_bind, (jlong)NULL);
+  (*env)->SetLongField(env, jrngstream, jrngstream_bind, (intptr_t)NULL);
 }
 JNIEXPORT jboolean JNICALL
 Java_org_simgrid_msg_RngStream_setPackageSeed(JNIEnv *env, jobject jrngstream, jintArray jseed) {
index 7e98a81..bce9544 100644 (file)
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
 
 void jvm_bind(JNIEnv *env, jobject jvm, msg_vm_t vm) {
-  (*env)->SetLongField(env, jvm, jvm_field_bind, (jlong) (long) (vm));
+  (*env)->SetLongField(env, jvm, jvm_field_bind, (intptr_t)vm);
 }
 msg_vm_t jvm_get_native(JNIEnv *env, jobject jvm) {
-       msg_vm_t vm = (msg_vm_t)(*env)->GetLongField(env, jvm, jvm_field_bind);
-       return vm;
+  return (msg_vm_t)(intptr_t)(*env)->GetLongField(env, jvm, jvm_field_bind);
 }
 
 JNIEXPORT void JNICALL
index 4752c7c..8d5084c 100644 (file)
@@ -10,6 +10,7 @@
 #define JXBT_UTILITY_H
 
 #include <jni.h>
+#include <stdint.h>
 
 /* *********** */
 /* JNI GETTERS */
index 00fe9b5..4983f73 100644 (file)
@@ -210,7 +210,9 @@ static void smx_ctx_cojava_suspend(smx_context_t context)
     else if (!java_context->bound) {
       java_context->bound = 1;
       smx_process_t process = SIMIX_process_self();
-      (*global_env)->SetLongField(global_env, java_context->jprocess, jprocess_field_Process_bind, (jlong)process);
+      (*global_env)->SetLongField(global_env, java_context->jprocess,
+                                  jprocess_field_Process_bind,
+                                  (intptr_t)process);
     }
 
     next_coroutine = java_context->jcoroutine;
@@ -236,7 +238,8 @@ static void smx_ctx_cojava_resume(smx_context_t new_context) {
   else if (!java_context->bound) {
     java_context->bound = 1;
     smx_process_t process = SIMIX_process_self();
-    (*global_env)->SetLongField(global_env, java_context->jprocess, jprocess_field_Process_bind, (jlong)process);
+    (*global_env)->SetLongField(global_env, java_context->jprocess,
+                                jprocess_field_Process_bind, (intptr_t)process);
   }
   (*global_env)->CallStaticVoidMethod(global_env, coclass, coroutine_yieldTo, java_context->jcoroutine);
 }
index 02f6f7b..02406f2 100644 (file)
@@ -110,7 +110,8 @@ static void* smx_ctx_java_thread_run(void *data) {
   }
   else {
     smx_process_t process = SIMIX_process_self();
-    (*env)->SetLongField(env, context->jprocess, jprocess_field_Process_bind, (jlong)process);
+    (*env)->SetLongField(env, context->jprocess, jprocess_field_Process_bind,
+                         (intptr_t)process);
   }
   xbt_assert((context->jprocess != NULL), "Process not created...");
   //wait for the process to be able to begin