Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern "C"
- {
- #include "caml/alloc.h"
- #include "caml/custom.h"
- #include "caml/memory.h"
- #include "caml/fail.h"
- #include "caml/callback.h"
- #include "caml/mlvalues.h"
- }
- #include <assert.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include "nr3.h"
- #include "ran.h"
- #if DEBUG
- #define DBG(X...) fprintf(stderr, __FILE__ ":%i:", __LINE__ ), fprintf( stderr, X ), fprintf( stderr, "\n" ), fflush( stderr )
- #else
- #define DBG(X...)
- #endif
- extern "C"
- {
- static Ran ran( time( NULL) ) ;
- /* int -> void */
- CAMLprim void nr_random_seek( value v_seek )
- {
- CAMLparam1( v_seek );
- int seek = Int_val( v_seek );
- ran = Ran( seek );
- CAMLreturn0;
- }
- /* -> int */
- CAMLprim value nr_random_int64()
- {
- CAMLparam0();
- CAMLlocal1( ml_data );
- ml_data = caml_copy_int64( ran.int64() ) ;
- CAMLreturn( ml_data );
- }
- /* -> float */
- CAMLprim value nr_random_float()
- {
- CAMLparam0();
- CAMLlocal1( ml_data );
- ml_data = caml_copy_double( ran.doub() ) ;
- CAMLreturn( ml_data );
- }
- }
Add Comment
Please, Sign In to add comment