forked from foreign-c/foreign-c
(foreign c) is a C foreign function interface (FFI) library for R6RS and R7RS Schemes. It is portable in the sense that it supports multiple implementations.
- Scheme 49.1%
- C 44.3%
- Tree-sitter Query 5.9%
- Makefile 0.7%
|
|
||
|---|---|---|
| foreign | Fix Kawa u64 handling | |
| tests | Clean up tests | |
| .gitignore | switch-to-test-r7rs ( #36 ) | |
| COPYING | Add license | |
| Dockerfile.jenkins | Fix jenkins tests | |
| Jenkinsfile | Add webhooks ( #37 ) | |
| LICENSE | Fix tests, add pffi-os-name | |
| Makefile | Fix Kawa u64 handling | |
| README.md | Fixes for Chicken 6 | |
| REFERENCE.md | types ( #34 ) | |
(foreign c) is a C foreign function interface (FFI) library for R6RS and R7RS Schemes
Documentation
See REFERENCE.md
Supported implementations
- Chez => 10.0.0
- R6RS
- Chibi > 0.11
- R7RS
- Chicken >= 6.0.0
- R7RS
- Guile >= 3
- R6RS
- R7RS
- Has include bug, might not work on all situations
- Ikarus >= 0.0.4-rc1+
- R6RS
- Ironscheme
- R6RS
- Kawa >= 3.11 and Java >= 22
- R7RS
- Needs arguments to enable FFI
- -J--add-exports=java.base/jdk.internal.foreign.abi=ALL-UNNAMED
- -J--add-exports=java.base/jdk.internal.foreign.layout=ALL-UNNAMED
- -J--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED
- -J--enable-native-access=ALL-UNNAMED
- -J--enable-preview
- All needed arguments on one line for copy pasting
- -J--add-exports=java.base/jdk.internal.foreign.abi=ALL-UNNAMED -J--add-exports=java.base/jdk.internal.foreign.layout=ALL-UNNAMED -J--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED -J--enable-native-access=ALL-UNNAMED -J--enable-preview
- So that snow-chibi installed library is found
- -Dkawa.import.path=/usr/local/share/kawa
- -Dkawa.import.path=/usr/local/share/kawa/lib
- Racket >= 8.16 [cs]
- R6RS
- Unable to run tests as Rackets SRFI-64 implementation does not work
- R7RS
- R6RS
- Sagittarius >= 0.9.13
- R6RS
- R7RS
- STklos > 2.10
- R7RS
- At the time only 2.10 is out so build from git
- Ypsilon >= 2.08
- R6RS
- R7RS
Work in progress
- Cyclone
- R7RS
- Gambit
- R7RS
- Gauche
- R7RS
- Waiting for Gauche to support dynamic FFI
- Gerbil
- R7RS
- Mit-Scheme
- R7RS
- Mosh
- R6RS
- R7RS
- Larceny
- R6RS
- R7RS
Dependencies
- Chibi
- libffi
Installation
R6RS - Akku
In your project directory run:
akku install "(foreign c)"
R6RS - Manual
Dowloand the latest release or clone from git and copy directory named
"foreign" into your project, then run:
akku install
R7RS - Snow-fort
snow-chibi --impls=IMPLEMENTATION install "(foreign c)"
You can test that library is found by your implementation like this:
cp tests/hello.scm /tmp/hello.scm
cd /tmp
IMPLEMENTATION hello.scm
R7RS Manual
Manual system wide installation requires snow-chibi.
Either download the latest release from https://git.sr.ht/~retropikzel/foreign-c/refs or git clone, tag, and copy the foreign directory to your library directory.
Example for how to install for Gauche:
apt-get install libffi-dev
git clone https://git.sr.ht/~retropikzel/foreign-c
cd foreign-c
make SCHEME=gauche
make SCHEME=gauche install
Adding support for new implementation
See from any foreign/c/SCHEME-primitives.sld what needs to be exported. Make the library files foreign/c/YOURSCHEME-primitives.sld foreign/c/YOURSCHEME-primitives.scm. Import it in cond expand in foreign/c.sld.
Run tests with:
make SCHEME=YOURSCHEME test-r6rs
or
make SCHEME=YOURSCHEME test-r6rs