mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-21 14:49:17 +02:00
Initial file
This commit is contained in:
parent
9c54c01e44
commit
a0b0580d01
2 changed files with 26 additions and 0 deletions
9
examples/ffi/sub-bignums.h
Normal file
9
examples/ffi/sub-bignums.h
Normal 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);
|
||||||
|
}
|
17
examples/ffi/sub-bignums.scm
Normal file
17
examples/ffi/sub-bignums.scm
Normal 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
|
||||||
|
))
|
Loading…
Add table
Reference in a new issue