Guest User

Untitled

a guest
Dec 29th, 2015
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. extern "C"
  2. {
  3. #include "caml/alloc.h"
  4. #include "caml/custom.h"
  5. #include "caml/memory.h"
  6. #include "caml/fail.h"
  7. #include "caml/callback.h"
  8. #include "caml/mlvalues.h"
  9. }
  10. #include <assert.h>
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include "nr3.h"
  14. #include "ran.h"
  15.  
  16. #if DEBUG
  17. #define DBG(X...) fprintf(stderr, __FILE__ ":%i:", __LINE__ ), fprintf( stderr, X ), fprintf( stderr, "\n" ), fflush( stderr )
  18. #else
  19. #define DBG(X...)
  20. #endif
  21.  
  22. extern "C"
  23. {
  24.     static Ran ran( time( NULL) ) ;
  25.     /* int -> void */
  26.     CAMLprim void nr_random_seek( value v_seek )
  27.     {
  28.         CAMLparam1( v_seek );
  29.         int seek = Int_val( v_seek );
  30.         ran = Ran( seek );
  31.         CAMLreturn0;
  32.     }
  33.     /* -> int */
  34.     CAMLprim value nr_random_int64()
  35.     {
  36.         CAMLparam0();
  37.         CAMLlocal1( ml_data );
  38.         ml_data = caml_copy_int64( ran.int64() ) ;
  39.         CAMLreturn( ml_data );
  40.     }
  41.     /* -> float */
  42.     CAMLprim value nr_random_float()
  43.     {
  44.         CAMLparam0();
  45.         CAMLlocal1( ml_data );
  46.         ml_data = caml_copy_double( ran.doub() ) ;
  47.         CAMLreturn( ml_data );
  48.     }
  49. }
Add Comment
Please, Sign In to add comment