Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[java] Fix binding for RngStream.setSeed on LP64
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 22 Jul 2016 10:38:49 +0000 (12:38 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 22 Jul 2016 10:44:55 +0000 (12:44 +0200)
This is the same bug I fixed earlier in setPackageSeed() but I did not
notice it was there as well :/

src/bindings/java/jmsg_rngstream.cpp

index 2dda4ca..a7e82b7 100644 (file)
@@ -110,7 +110,13 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_RngStream_setSeed(JNIEnv *env, j
   if (!rngstream)
     return JNI_FALSE;
 
-  int result = RngStream_SetSeed(rngstream, (unsigned long*)buffer);
+  // The C API expects unsigned long which are wider than int on LP64.
+  // We need to convert:
+  unsigned long seed[6];
+  for (int i = 0; i != 6; ++i)
+    seed[i] = buffer[i];
+
+  int result = RngStream_SetSeed(rngstream, seed);
 
   return result == -1 ? JNI_FALSE : JNI_TRUE;
 }