Initial file

This commit is contained in:
Justin Ethier 2021-01-25 21:17:57 -05:00
parent 9c54c01e44
commit a0b0580d01
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,9 @@
#include "cyclone/types.h"
// Some custom function to speed-up code
mp_int sub_big_nums(void *data, mp_int bnx, mp_int bny) {
alloc_bignum(data, bn);
BIGNUM_CALL(mp_sub(&bnx, &bny, &bignum_value(bn)));
return bignum_value(bn);
}

View file

@ -0,0 +1,17 @@
;; A basic example of subtracting 2 bignums using the FFI.
;;
;; This example is notable because we need to pass the
;; current thread's data object to C so that we can pass
;; it along to functions in the Cyclone runtime.
;;
(import (scheme base) (scheme write) (cyclone foreign) (srfi 18))
(include-c-header "sub-bignums.h")
(c-define sub-big-nums bignum "sub_big_nums" opaque bignum bignum)
(write
(sub-big-nums
(current-thread-data)
999999999999999999999999
222222222222222222222222
))