X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f3b82f616359ba02069f0e0f70391a691b9ba91c..a6c64d74cc84ef31accb835f570f990f5c45ecf8:/src/bindings/java/jmsg_rngstream.cpp diff --git a/src/bindings/java/jmsg_rngstream.cpp b/src/bindings/java/jmsg_rngstream.cpp index 2dda4cad9a..aa1a05013f 100644 --- a/src/bindings/java/jmsg_rngstream.cpp +++ b/src/bindings/java/jmsg_rngstream.cpp @@ -1,16 +1,17 @@ -/* Functions related to the RngStream Java port */ +/* Java binding of the RngStream library */ -/* Copyright (c) 2007-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include +#include "xbt/sysdep.h" #include "jmsg_rngstream.h" #include "jxbt_utilities.h" +SG_BEGIN_DECL() + jfieldID jrngstream_bind; RngStream jrngstream_to_native(JNIEnv *env, jobject jrngstream) { @@ -110,7 +111,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; } @@ -138,3 +145,5 @@ JNIEXPORT jint JNICALL Java_org_simgrid_msg_RngStream_randInt(JNIEnv *env, jobje return (jint)RngStream_RandInt(rngstream, (int)i, (int)j); } + +SG_END_DECL()