Add jenkins link to readme
This commit is contained in:
parent
089bc7641e
commit
b776994b36
23
README.md
23
README.md
|
|
@ -13,6 +13,8 @@ to being portable by conforming to some specification.
|
|||
|
||||
[Maling lists](https://sr.ht/~retropikzel/foreign-c/lists)
|
||||
|
||||
[Jenkins](https://jenkins.scheme.org/job/foreign_c/job/foreign-c/)
|
||||
|
||||
- [Installation](#installation)
|
||||
- [Documentation](#documentation)
|
||||
- [Types](#types)
|
||||
|
|
@ -295,21 +297,21 @@ Example:
|
|||
(define-c-procedure qsort libc-stdlib 'qsort 'void '(pointer int int callback))
|
||||
|
||||
; Define our callback
|
||||
(pffi-define-callback compare
|
||||
(define-c-callback compare
|
||||
'int
|
||||
'(pointer pointer)
|
||||
(lambda (pointer-a pointer-b)
|
||||
(let ((a (pffi-pointer-get pointer-a 'int 0))
|
||||
(b (pffi-pointer-get pointer-b 'int 0)))
|
||||
(let ((a (c-bytevector-sint-get pointer-a (native-endianness) 0))
|
||||
(b (c-bytevector-sint-get pointer-b (native-endianness) 0)))
|
||||
(cond ((> a b) 1)
|
||||
((= a b) 0)
|
||||
((< a b) -1)))))
|
||||
|
||||
; Create new array of ints to be sorted
|
||||
(define array (make-c-bytevector (* (c-type-size 'int) 3)))
|
||||
(pffi-pointer-set! array 'int (* (c-type-size 'int) 0) 3)
|
||||
(pffi-pointer-set! array 'int (* (c-type-size 'int) 1) 2)
|
||||
(pffi-pointer-set! array 'int (* (c-type-size 'int) 2) 1)
|
||||
(c-bytevector-s32-native-set! array (* (c-type-size 'int) 0) 3)
|
||||
(c-bytevector-s32-native-set! array (* (c-type-size 'int) 1) 2)
|
||||
(c-bytevector-s32-native-set! array (* (c-type-size 'int) 2) 1)
|
||||
|
||||
(display array)
|
||||
(newline)
|
||||
|
|
@ -564,10 +566,11 @@ encoded by the given c-bytevector.
|
|||
|
||||
Setting environment variables like this on Windows works for this library:
|
||||
|
||||
set "PFFI_LOAD_PATH=C:\Program Files (x86)/foo/bar"
|
||||
set "FOREIGN_C_LOAD_PATH=C:\Program Files (x86)/foo/bar"
|
||||
|
||||
#### PFFI\_LOAD\_PATH
|
||||
#### FOREIGN_C_\_LOAD\_PATH
|
||||
|
||||
To add more paths to where pffi looks for libraries set PFFI\_LOAD\_PATH to
|
||||
paths separated by ; on windows, and : on other operating systems.
|
||||
To add more paths to where foreign c looks for libraries set
|
||||
FOREIGN_C\_LOAD\_PATH to paths separated by ; on windows, and : on other
|
||||
operating systems.
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ Schemes - 0.10.0</title>
|
|||
<thead>
|
||||
<tr class="header">
|
||||
<th></th>
|
||||
<th style="text-align: center;">c-size-of</th>
|
||||
<th style="text-align: center;">c-type-size</th>
|
||||
<th style="text-align: center;">c-bytevector-u8-set!</th>
|
||||
<th style="text-align: center;">c-bytevector-u8-ref</th>
|
||||
<th style="text-align: center;">define-c-library</th>
|
||||
|
|
@ -338,7 +338,7 @@ Schemes - 0.10.0</title>
|
|||
</tbody>
|
||||
</table>
|
||||
<h2 id="installation">Installation</h2>
|
||||
<p>Either download the latest release from <a
|
||||
<p>Eithe download the latest release from <a
|
||||
href="https://git.sr.ht/~retropikzel/foreign-c/refs">https://git.sr.ht/~retropikzel/foreign-c/refs</a>
|
||||
or git clone, preferably with a tag, and copy the
|
||||
<em>foreign</em> directory to your library directory.</p>
|
||||
|
|
@ -503,36 +503,36 @@ make -C snow/foreign/c SCHEME_IMPLEMENTATION_NAME</code></pre>
|
|||
(define-c-procedure qsort libc-stdlib 'qsort 'void '(pointer int int callback))
|
||||
|
||||
; Define our callback
|
||||
(pffi-define-callback compare
|
||||
(define-c-callback compare
|
||||
'int
|
||||
'(pointer pointer)
|
||||
(lambda (pointer-a pointer-b)
|
||||
(let ((a (pffi-pointer-get pointer-a 'int 0))
|
||||
(b (pffi-pointer-get pointer-b 'int 0)))
|
||||
(let ((a (c-bytevector-sint-get pointer-a (native-endianness) 0))
|
||||
(b (c-bytevector-sint-get pointer-b (native-endianness) 0)))
|
||||
(cond ((> a b) 1)
|
||||
((= a b) 0)
|
||||
((< a b) -1)))))
|
||||
|
||||
; Create new array of ints to be sorted
|
||||
(define array (make-c-bytevector (* (c-size-of 'int) 3)))
|
||||
(pffi-pointer-set! array 'int (* (c-size-of 'int) 0) 3)
|
||||
(pffi-pointer-set! array 'int (* (c-size-of 'int) 1) 2)
|
||||
(pffi-pointer-set! array 'int (* (c-size-of 'int) 2) 1)
|
||||
(define array (make-c-bytevector (* (c-type-size 'int) 3)))
|
||||
(c-bytevector-s32-native-set! array (* (c-type-size 'int) 0) 3)
|
||||
(c-bytevector-s32-native-set! array (* (c-type-size 'int) 1) 2)
|
||||
(c-bytevector-s32-native-set! array (* (c-type-size 'int) 2) 1)
|
||||
|
||||
(display array)
|
||||
(newline)
|
||||
;> (3 2 1)
|
||||
|
||||
; Sort the array
|
||||
(qsort array 3 (c-size-of 'int) compare)
|
||||
(qsort array 3 (c-type-size 'int) compare)
|
||||
|
||||
(display array)
|
||||
(newline)
|
||||
;> (1 2 3)</code></pre>
|
||||
<h3 id="c-bytevector">c-bytevector</h3>
|
||||
<p>Foreign-c c-bytevector interface is copied from R6RS
|
||||
bytevectors, with some added functionality for C null
|
||||
pointers.</p>
|
||||
bytevectors, with some added functionality for C null pointers
|
||||
and manual memory management.</p>
|
||||
<p>(<strong>make-c-null</strong>)</p>
|
||||
<p>Returns a null C pointer.</p>
|
||||
<p>(<strong>c-null?</strong> <em>obj</em>)</p>
|
||||
|
|
@ -545,8 +545,8 @@ make -C snow/foreign/c SCHEME_IMPLEMENTATION_NAME</code></pre>
|
|||
<p>Calls <em>thunk</em> with address pointer of
|
||||
<em>c-bytevector</em>.</p>
|
||||
<p>Since the support for calling C functions taking pointer
|
||||
address arguments, the ones you would prefix with &, varies,
|
||||
some additional ceremony is needed on the Scheme side.</p>
|
||||
address arguments, ones prefixrd with & in C, varies, some
|
||||
additional ceremony is needed on the Scheme side.</p>
|
||||
<p>Example:</p>
|
||||
<p>Calling from C:</p>
|
||||
<pre><code>//void func(int** i);
|
||||
|
|
@ -585,14 +585,16 @@ func(&i);</code></pre>
|
|||
the bytes of the c-bytevector</p>
|
||||
<p>(<strong>c-bytevector-s8-set!</strong> <em>c-bytevector</em>
|
||||
<em>k</em> <em>byte</em>)</p>
|
||||
<p>If K is not a valid index of c-bytevector the behaviour is
|
||||
undefined.</p>
|
||||
<p>Stores the byte in element k of c-bytevector.</p>
|
||||
<p>If <em>k</em> is not a valid index of c-bytevector the
|
||||
behaviour is undefined.</p>
|
||||
<p>Stores the <em>byte</em> in element <em>k</em> of
|
||||
<em>c-bytevector</em>.</p>
|
||||
<p>(<strong>c-bytevector-s8-ref</strong> <em>c-bytevector</em>
|
||||
<em>k</em> <em>byte</em>)</p>
|
||||
<p>If K is not a valid index of c-bytevector the behaviour is
|
||||
undefined.</p>
|
||||
<p>Returns the byte at index k of c-bytevector.</p>
|
||||
<em>k</em>)</p>
|
||||
<p>If <em>k</em> is not a valid index of c-bytevector the
|
||||
behaviour is undefined.</p>
|
||||
<p>Returns the byte at index <em>k</em> of
|
||||
<em>c-bytevector</em>.</p>
|
||||
<p>(<strong>c-bytevector-uint-ref</strong> <em>c-bytevector</em>
|
||||
<em>k</em> <em>endianness</em> <em>size</em>)</br>
|
||||
(<strong>c-bytevector-sint-ref</strong> <em>c-bytevector</em>
|
||||
|
|
@ -763,10 +765,10 @@ func(&i);</code></pre>
|
|||
<h3 id="environment-variables">Environment variables</h3>
|
||||
<p>Setting environment variables like this on Windows works for
|
||||
this library:</p>
|
||||
<pre><code>set "PFFI_LOAD_PATH=C:\Program Files (x86)/foo/bar"</code></pre>
|
||||
<h4 id="pffi_load_path">PFFI_LOAD_PATH</h4>
|
||||
<p>To add more paths to where pffi looks for libraries set
|
||||
PFFI_LOAD_PATH to paths separated by ; on windows, and : on
|
||||
<pre><code>set "FOREIGN_C_LOAD_PATH=C:\Program Files (x86)/foo/bar"</code></pre>
|
||||
<h4 id="foreign_c__load_path">FOREIGN_C__LOAD_PATH</h4>
|
||||
<p>To add more paths to where foreign c looks for libraries set
|
||||
FOREIGN_C_LOAD_PATH to paths separated by ; on windows, and : on
|
||||
other operating systems.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue