summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2022-11-13 18:49:55 -0500
committerBen Sima <ben@bsima.me>2022-11-13 18:49:55 -0500
commita6bb0f7d19677939f023aadb9ca7b49cc325a347 (patch)
treeec2b124b2a12430f0cd4edf065b68eeb03d9a2dd
parent8e27b7dbad41ef63bb42d1bf783be7ff6af5c045 (diff)
Add test for building guile extensions
Guile linking was first implemented in d8fe6f7ac54f155fe5a3c33509249a70d0c816c5. This test remained uncommitted since then because I wanted a better way to test it, but I couldn't figure out another way to test it, so here we are.
-rw-r--r--Biz/Bild/Bessel.c19
-rw-r--r--Biz/Bild/Bessel.scm10
2 files changed, 29 insertions, 0 deletions
diff --git a/Biz/Bild/Bessel.c b/Biz/Bild/Bessel.c
new file mode 100644
index 0000000..524956c
--- /dev/null
+++ b/Biz/Bild/Bessel.c
@@ -0,0 +1,19 @@
+// : dep guile-3.0
+// : lib libbessel-guile
+// : arg -shared
+// : arg -fPIC
+
+#include <math.h>
+#include <libguile.h>
+
+SCM
+j0_wrapper(SCM x)
+{
+ return scm_from_double(j0(scm_to_double(x)));
+}
+
+void
+init_bessel()
+{
+ scm_c_define_gsubr("j0", 1, 0, 0, j0_wrapper);
+}
diff --git a/Biz/Bild/Bessel.scm b/Biz/Bild/Bessel.scm
new file mode 100644
index 0000000..ad40834
--- /dev/null
+++ b/Biz/Bild/Bessel.scm
@@ -0,0 +1,10 @@
+;; : out bessel.exe
+(import (only (rnrs base) assert))
+(load-extension "libguile-bessel" "init_bessel")
+(define (main args)
+ (let ((result (j0 2)))
+ (display "testing")
+ (newline)
+ (display result)
+ (newline)
+ (assert (= (j0 2) 0.22389077914123567))))