Adding Haiku support
This commit is contained in:
parent
f037d22c40
commit
0af0378c0e
9
Makefile
9
Makefile
|
|
@ -27,6 +27,15 @@ package:
|
||||||
clean-package:
|
clean-package:
|
||||||
rm -rf *.tgz
|
rm -rf *.tgz
|
||||||
|
|
||||||
|
test-java: tmp/test/libtest.o tmp/test/libtest.so tmp/test/libtest.a
|
||||||
|
mkdir -p tmp/test
|
||||||
|
cp kawa.jar tmp/test/
|
||||||
|
cp -r foreign tmp/test/
|
||||||
|
cp tests/*.scm tmp/test/
|
||||||
|
cp tests/c-include/libtest.h tmp/test/
|
||||||
|
cd tmp/test \
|
||||||
|
&& ${JAVA_HOME}/bin/java --add-exports java.base/jdk.internal.foreign.abi=ALL-UNNAMED --add-exports java.base/jdk.internal.foreign.layout=ALL-UNNAMED --add-exports java.base/jdk.internal.foreign=ALL-UNNAMED --enable-native-access=ALL-UNNAMED --enable-preview -jar kawa.jar --r7rs --full-tailcalls -Dkawa.import.path=*.sld:./snow/*.sld:./snow/retropikzel/*.sld ${TESTNAME}.scm
|
||||||
|
|
||||||
test-compile-r7rs: tmp/test/libtest.o tmp/test/libtest.so tmp/test/libtest.a
|
test-compile-r7rs: tmp/test/libtest.o tmp/test/libtest.so tmp/test/libtest.a
|
||||||
make ${COMPILE_R7RS}
|
make ${COMPILE_R7RS}
|
||||||
cp -r foreign tmp/test/
|
cp -r foreign tmp/test/
|
||||||
|
|
|
||||||
42
README.md
42
README.md
|
|
@ -210,17 +210,13 @@ Options:
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
(cond-expand
|
(define-c-library libc
|
||||||
(windows (define-c-library libc-stdlib
|
(list "stdlib.h")
|
||||||
'("stdlib.h")
|
"c"
|
||||||
"ucrtbase"
|
'((additional-versions ("" "0" "6"))
|
||||||
'((additional-versions ("0" "6"))
|
(additional-paths ("."))))
|
||||||
(additiona-paths (".")))))
|
|
||||||
(else (define-c-library libc-stdlib
|
Note that libc is exported by this library so you might not need to load it.
|
||||||
(list "stdlib.h")
|
|
||||||
"c"
|
|
||||||
'((additional-versions ("0" "6"))
|
|
||||||
(additiona-paths ("."))))))
|
|
||||||
|
|
||||||
#### Notes
|
#### Notes
|
||||||
|
|
||||||
|
|
@ -245,9 +241,9 @@ Defines a new foreign function to be used from Scheme code.
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
(cond-expand
|
(cond-expand
|
||||||
(windows (define-c-library libc-stdlib '("stdlib.h") "ucrtbase" '()))
|
(windows (define-c-library libc '("stdlib.h") "ucrtbase" '()))
|
||||||
(else (define-c-library libc-stdlib '("stdlib.h") "c" '("6"))))
|
(else (define-c-library libc '("stdlib.h") "c" '("6"))))
|
||||||
(define-c-procedure c-puts libc-stdlib 'puts 'int '(pointer))
|
(define-c-procedure c-puts libc 'puts 'int '(pointer))
|
||||||
(c-puts "Message brought to you by foreign-c!")
|
(c-puts "Message brought to you by foreign-c!")
|
||||||
|
|
||||||
#### Notes
|
#### Notes
|
||||||
|
|
@ -591,6 +587,24 @@ UTF-8 encoding of the given string.
|
||||||
Returns a newly allocated (unless empty) string whose character sequence is
|
Returns a newly allocated (unless empty) string whose character sequence is
|
||||||
encoded by the given c-bytevector.
|
encoded by the given c-bytevector.
|
||||||
|
|
||||||
|
### Utilities
|
||||||
|
|
||||||
|
**libc**
|
||||||
|
|
||||||
|
Since the library uses C standard internally, and that is most likely library
|
||||||
|
to have different name on different operating systems. For example libc.so on
|
||||||
|
Linux, ucrtbase.dll on windows and libroot.so on Haiku. It makes sense to
|
||||||
|
export it, saving the users the trouble of figuring out which named shared
|
||||||
|
library they should load.
|
||||||
|
|
||||||
|
See foreign/c/libc.scm to see which headers are included and what shared
|
||||||
|
libraries are loaded.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
(define-c-procedure c-puts libc 'puts 'int '(pointer))
|
||||||
|
(c-puts "Message brought to you by foreign-c!")
|
||||||
|
|
||||||
### Environment variables
|
### Environment variables
|
||||||
|
|
||||||
Setting environment variables like this on Windows works for this library:
|
Setting environment variables like this on Windows works for this library:
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,9 @@
|
||||||
bytevector->c-bytevector
|
bytevector->c-bytevector
|
||||||
c-bytevector->bytevector
|
c-bytevector->bytevector
|
||||||
|
|
||||||
|
;;;; Utilities
|
||||||
|
libc
|
||||||
|
|
||||||
;; TODO endianness
|
;; TODO endianness
|
||||||
native-endianness
|
native-endianness
|
||||||
make-c-bytevector
|
make-c-bytevector
|
||||||
|
|
@ -317,12 +320,14 @@
|
||||||
(include "c/primitives/ypsilon.scm")))
|
(include "c/primitives/ypsilon.scm")))
|
||||||
(cond-expand
|
(cond-expand
|
||||||
(chicken-6 (include-relative "c/main.scm")
|
(chicken-6 (include-relative "c/main.scm")
|
||||||
|
(include-relative "c/libc.scm")
|
||||||
(include-relative "c/c-bytevectors.scm")
|
(include-relative "c/c-bytevectors.scm")
|
||||||
(include-relative "c/pointer.scm")
|
(include-relative "c/pointer.scm")
|
||||||
;(include-relative "c/array.scm")
|
;(include-relative "c/array.scm")
|
||||||
;(include-relative "c/struct.scm")
|
;(include-relative "c/struct.scm")
|
||||||
)
|
)
|
||||||
(else (include "c/main.scm")
|
(else (include "c/main.scm")
|
||||||
|
(include "c/libc.scm")
|
||||||
;(include "c/struct.scm")
|
;(include "c/struct.scm")
|
||||||
(include "c/c-bytevectors.scm")
|
(include "c/c-bytevectors.scm")
|
||||||
(include "c/pointer.scm")
|
(include "c/pointer.scm")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
(cond-expand
|
||||||
|
(windows (define-c-library libc
|
||||||
|
'("stdio.h" "string.h")
|
||||||
|
"ucrtbase"
|
||||||
|
'((additional-versions ("0" "6")))))
|
||||||
|
(else
|
||||||
|
(define c-library "c")
|
||||||
|
(when (get-environment-variable "BE_HOST_CPU")
|
||||||
|
(set! c-library "root"))
|
||||||
|
(define-c-library libc
|
||||||
|
'("stdio.h" "string.h")
|
||||||
|
c-library
|
||||||
|
'((additional-versions ("" "0" "6" "7"))))))
|
||||||
|
|
@ -103,7 +103,9 @@
|
||||||
"/usr/lib"
|
"/usr/lib"
|
||||||
"/usr/lib64"
|
"/usr/lib64"
|
||||||
; NetBSD
|
; NetBSD
|
||||||
"/usr/pkg/lib")))))
|
"/usr/pkg/lib"
|
||||||
|
; Haiku
|
||||||
|
"/boot/system/lib")))))
|
||||||
(auto-load-versions (list ""))
|
(auto-load-versions (list ""))
|
||||||
(paths (append auto-load-paths additional-paths))
|
(paths (append auto-load-paths additional-paths))
|
||||||
(versions (append additional-versions auto-load-versions))
|
(versions (append additional-versions auto-load-versions))
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,3 @@
|
||||||
(cond-expand
|
|
||||||
(windows (define-c-library libc
|
|
||||||
'("stdlib.h" "string.h")
|
|
||||||
"ucrtbase"
|
|
||||||
'((additional-versions ("0" "6")))))
|
|
||||||
(else (define-c-library libc
|
|
||||||
'("stdlib.h" "string.h")
|
|
||||||
"c"
|
|
||||||
'((additional-versions ("0" "6"))))))
|
|
||||||
|
|
||||||
(define-c-procedure c-calloc libc 'calloc 'pointer '(int int))
|
(define-c-procedure c-calloc libc 'calloc 'pointer '(int int))
|
||||||
(define-c-procedure c-memset-address->pointer libc 'memset 'pointer '(uint64 uint8 int))
|
(define-c-procedure c-memset-address->pointer libc 'memset 'pointer '(uint64 uint8 int))
|
||||||
(define-c-procedure c-memset-pointer->address libc 'memset 'uint64 '(pointer uint8 int))
|
(define-c-procedure c-memset-pointer->address libc 'memset 'uint64 '(pointer uint8 int))
|
||||||
|
|
|
||||||
|
|
@ -214,18 +214,6 @@
|
||||||
|
|
||||||
(print-header 'define-c-library)
|
(print-header 'define-c-library)
|
||||||
|
|
||||||
(cond-expand
|
|
||||||
(windows (define-c-library libc
|
|
||||||
'("stdio.h" "string.h")
|
|
||||||
"ucrtbase"
|
|
||||||
'((additional-versions ("0" "6")))))
|
|
||||||
(else (define-c-library libc
|
|
||||||
'("stdio.h" "string.h")
|
|
||||||
"c"
|
|
||||||
'((additional-versions ("0" "6"))))))
|
|
||||||
|
|
||||||
(debug libc)
|
|
||||||
|
|
||||||
(define-c-library c-testlib
|
(define-c-library c-testlib
|
||||||
'("libtest.h")
|
'("libtest.h")
|
||||||
"test"
|
"test"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue