Foreign Function Interface

What is FFI?

Mosh provides a general Foreign Function Interface (FFI) methods.

With these methods, you can load shared library, call C-function in it and get a result of function call.

Example

(import (rnrs)
        (mosh ffi))

;; use mysql client library
(let* ([libmysqlclient (open-shared-library "libmysqlclient.so.15")]
       [mysql-init     (c-function libmysqlclient void* mysql_init void*)])
  (display (mysql-init pointer-null)))
;; generate png image with Cairo library.
(import (rnrs)
        (mosh ffi))

(let* ((libcairo (open-shared-library "libcairo.so"))
         (cairo-image-surface-create (c-function libcairo void* cairo_image_surface_create int int int))
         (cairo-surface-write-to-png (c-function libcairo int cairo_surface_write_to_png void* char*))
         (cairo-create (c-function libcairo void* cairo_create void*))
         (set-line-width (c-function libcairo void cairo_set_line_width void* double))
         (rgba (c-function libcairo void cairo_set_source_rgba void* double double double double))
         (move-to (c-function libcairo void cairo_move_to void* double double))
         (line-to (c-function libcairo void cairo_line_to void* double double))
         (TOY-show-text (c-function libcairo void cairo_show_text void* char*))
         (stroke (c-function libcairo void cairo_stroke void*)))

       (let* ((surface (cairo-image-surface-create 1 300 300))
              (ctx (cairo-create surface)))
         (rgba ctx 1.0 1.0 1.0 1.0)
         (set-line-width ctx 8.0)
         (move-to ctx 10.0 10.0)
         (line-to ctx 10.0 290.0)
         (line-to ctx 290.0 290.0)
         (line-to ctx 290.0 10.0)
         (line-to ctx 10.0 10.0)
         (move-to ctx 100.0 150.0)
         (TOY-show-text ctx "mosh")
         (stroke ctx)
         (display (cairo-surface-write-to-png surface "test.png"))))
;; callback example
(import
 (mosh)
 (mosh ffi)
 (rnrs))

(define array (u8-list->bytevector '(6 5 3 4 1 7 2)))

(let* ([libc (open-shared-library "libc.so.6")] ;; Ubuntu
       [qsort (c-function libc void qsort void* int int callback)]
       [compare (c-callback int (void* void*) (lambda (x y) (if (> (pointer-ref-c-uint8 x 0)
                                                                   (pointer-ref-c-uint8 y 0)) 1 0)))])
    (qsort array (bytevector-length array) 1 compare)
    (display array)
    (free-c-callback compare))
Summary
Foreign Function InterfaceMosh provides a general Foreign Function Interface (FFI) methods.
(mosh ffi)Foreign Function Interface Library
Functions
ffi-supported?Returns #t when ffi is supported, otherwise #f.
shared-errnoWhen invoked with no argument, returns errno (On Windows getLastError()).
pointer?Returns #t if obj is pointer, otherwise #f
pointer->integerconvert pointer to integer
pointer->stringReturns string value at which pointer points.
open-shared-libraryOpen shared library.
close-shared-libraryClose shared library.
shared-library-errorGet a description of the last error that occurred during loading a shared library.
c-functionMake foreign c-function closure.
make-c-callbackMake c-callback.
c-callbackMake c-callback
free-c-callbackFree c-callback object.
mallocAllocate n bytes of memory.
freeFrees the memory allocated by <<malloc>>.
pointer->c-functionMake foreign c-function closure from pointer.
make-c-functionMake foreign c-function closure by lookuping a function named “name” in “lib” library.
null-terminated-bytevector->stringReturns a newly allocated (unless empty) string whose character sequence is encoded by the given null(\0) terminated bytevector.
null-terminated-utf8->stringReturns a newly allocated (unless empty) string whose character sequence is encoded by the given null(\0) terminated bytevector.
pointer-ref-c-uint16Get a value from pointer + offset as uint16.
pointer-ref-c-uint32Get a value from pointer + offset as uint32.
pointer-ref-c-uint64Get a value from pointer + offset as uint64.
pointer-ref-c-int8Get a value from pointer + offset as int8.
pointer-ref-c-int16Get a value from pointer + offset as int16.
pointer-ref-c-int32Get a value from pointer + offset as int32.
pointer-ref-c-int64Get a value from pointer + offset as int64.
pointer-ref-c-signed-charGet a value from pointer + offset as signed-char.
pointer-ref-c-unsigned-charGet a value from pointer + offset as unsigned-char.
pointer-ref-c-signed-shortGet a value from pointer + offset as signed-short.
pointer-ref-c-unsigned-shortGet a value from pointer + offset as unsigned-short.
pointer-ref-c-signed-intGet a value from pointer + offset as signed-int.
pointer-ref-c-unsigned-intGet a value from pointer + offset as unsigned-int.
pointer-ref-c-signed-longGet a value from pointer + offset as signed-long.
pointer-ref-c-unsigned-longGet a value from pointer + offset as unsigned-long.
pointer-ref-c-signed-long-longGet a value from pointer + offset as signed-long-long.
pointer-ref-c-unsigned-long-longGet a value from pointer + offset as unsigned-long-long.
pointer-ref-c-floatGet a value from pointer + offset as float.
pointer-ref-c-doubleGet a value from pointer + offset as double.
pointer-ref-c-pointerGet a value from pointer + offset as pointer.
pointer-set-c-char!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-short!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-int!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-long!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-long-long!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-float!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-double!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-int8!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-int16!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-int32!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-int64!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-uint8!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-uint16!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-uint32!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-uint64!Returns #t when ffi is supported, otherwise #f.
Constants
size-of-boolsizeof(bool)
size-of-shortsizeof(short)
size-of-unsigned-shortsizeof(unsigned short)
size-of-intsizeof(int)
size-of-unsigned-intsizeof(unsigned int)
size-of-longsizeof(long)
size-of-unsigned-longsizeof(unsigned long)
size-of-unsigned-long-longsizeof(unsigned long long)
size-of-long-longsizeof(long long)
size-of-void*sizeof(void*)
size-of-pointeralias for sizeof(void*)
size-of-size_tsizeof(size_t)
size-of-floatsizeof(float)
size-of-doublesizeof(double)
align-of-boolstruct x { char y; bool z; };
align-of-shortstruct x { char y; short z; };
align-of-intstruct x { char y; int z; };
align-of-longstruct x { char y; long z; };
align-of-long-longstruct x { char y; long long z; };
align-of-unsigned-longstruct x { char y; unsigned long z; };
align-of-unsigned-long-longstruct x { char y; unsigned-long long z; };
align-of-void*struct x { char y; void* z; };
align-of-size_tstruct x { char y; size_t z; };
align-of-floatstruct x { char y; float z; };
align-of-doublestruct x { char y; double z; };
align-of-int8_tstruct x { char y; int8_t z; };
align-of-int16_tstruct x { char y; int16_t z; };
align-of-int32_tstruct x { char y; int32_t z; };
align-of-int64_tstruct x { char y; int64_t z; };
on-darwin
on-linux
on-freebsd
on-openbsd
on-windows

(mosh ffi)

Foreign Function Interface Library

Summary
Functions
ffi-supported?Returns #t when ffi is supported, otherwise #f.
shared-errnoWhen invoked with no argument, returns errno (On Windows getLastError()).
pointer?Returns #t if obj is pointer, otherwise #f
pointer->integerconvert pointer to integer
pointer->stringReturns string value at which pointer points.
open-shared-libraryOpen shared library.
close-shared-libraryClose shared library.
shared-library-errorGet a description of the last error that occurred during loading a shared library.
c-functionMake foreign c-function closure.
make-c-callbackMake c-callback.
c-callbackMake c-callback
free-c-callbackFree c-callback object.
mallocAllocate n bytes of memory.
freeFrees the memory allocated by <<malloc>>.
pointer->c-functionMake foreign c-function closure from pointer.
make-c-functionMake foreign c-function closure by lookuping a function named “name” in “lib” library.
null-terminated-bytevector->stringReturns a newly allocated (unless empty) string whose character sequence is encoded by the given null(\0) terminated bytevector.
null-terminated-utf8->stringReturns a newly allocated (unless empty) string whose character sequence is encoded by the given null(\0) terminated bytevector.
pointer-ref-c-uint16Get a value from pointer + offset as uint16.
pointer-ref-c-uint32Get a value from pointer + offset as uint32.
pointer-ref-c-uint64Get a value from pointer + offset as uint64.
pointer-ref-c-int8Get a value from pointer + offset as int8.
pointer-ref-c-int16Get a value from pointer + offset as int16.
pointer-ref-c-int32Get a value from pointer + offset as int32.
pointer-ref-c-int64Get a value from pointer + offset as int64.
pointer-ref-c-signed-charGet a value from pointer + offset as signed-char.
pointer-ref-c-unsigned-charGet a value from pointer + offset as unsigned-char.
pointer-ref-c-signed-shortGet a value from pointer + offset as signed-short.
pointer-ref-c-unsigned-shortGet a value from pointer + offset as unsigned-short.
pointer-ref-c-signed-intGet a value from pointer + offset as signed-int.
pointer-ref-c-unsigned-intGet a value from pointer + offset as unsigned-int.
pointer-ref-c-signed-longGet a value from pointer + offset as signed-long.
pointer-ref-c-unsigned-longGet a value from pointer + offset as unsigned-long.
pointer-ref-c-signed-long-longGet a value from pointer + offset as signed-long-long.
pointer-ref-c-unsigned-long-longGet a value from pointer + offset as unsigned-long-long.
pointer-ref-c-floatGet a value from pointer + offset as float.
pointer-ref-c-doubleGet a value from pointer + offset as double.
pointer-ref-c-pointerGet a value from pointer + offset as pointer.
pointer-set-c-char!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-short!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-int!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-long!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-long-long!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-float!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-double!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-int8!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-int16!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-int32!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-int64!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-uint8!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-uint16!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-uint32!Returns #t when ffi is supported, otherwise #f.
pointer-set-c-uint64!Returns #t when ffi is supported, otherwise #f.
Constants
size-of-boolsizeof(bool)
size-of-shortsizeof(short)
size-of-unsigned-shortsizeof(unsigned short)
size-of-intsizeof(int)
size-of-unsigned-intsizeof(unsigned int)
size-of-longsizeof(long)
size-of-unsigned-longsizeof(unsigned long)
size-of-unsigned-long-longsizeof(unsigned long long)
size-of-long-longsizeof(long long)
size-of-void*sizeof(void*)
size-of-pointeralias for sizeof(void*)
size-of-size_tsizeof(size_t)
size-of-floatsizeof(float)
size-of-doublesizeof(double)
align-of-boolstruct x { char y; bool z; };
align-of-shortstruct x { char y; short z; };
align-of-intstruct x { char y; int z; };
align-of-longstruct x { char y; long z; };
align-of-long-longstruct x { char y; long long z; };
align-of-unsigned-longstruct x { char y; unsigned long z; };
align-of-unsigned-long-longstruct x { char y; unsigned-long long z; };
align-of-void*struct x { char y; void* z; };
align-of-size_tstruct x { char y; size_t z; };
align-of-floatstruct x { char y; float z; };
align-of-doublestruct x { char y; double z; };
align-of-int8_tstruct x { char y; int8_t z; };
align-of-int16_tstruct x { char y; int16_t z; };
align-of-int32_tstruct x { char y; int32_t z; };
align-of-int64_tstruct x { char y; int64_t z; };
on-darwin
on-linux
on-freebsd
on-openbsd
on-windows

Functions

ffi-supported?

Returns #t when ffi is supported, otherwise #f.

Prototype

(ffi-supported?)

Returns

#t when ffi is supported, otherwise #f.

shared-errno

When invoked with no argument, returns errno (On Windows getLastError()).  Invoked with one argument, set value to errno.

Prototype

(shared-errno . value)

Returns

errno

pointer?

Returns #t if obj is pointer, otherwise #f

Prototype

(pointer? obj)

Returns

#t if obj is pointer, otherwise #f

pointer->integer

convert pointer to integer

Prototype

(pointer->integer pointer)

Returns

integer represention of pointer.

pointer->string

Returns string value at which pointer points.

Prototype

(pointer->string pointer)

Parameters

pointerinteger valued pointer.  When not-pointer integer is passed, it may cause crash.

Returns

string value at which pointer points.

open-shared-library

Open shared library.

Prototype

(open-shared-library library)

Parameters

libraryPath to library.

Returns

Loaded shared library object.

Errors

Raise error when can’t load library

close-shared-library

Close shared library.

Prototype

(close-shared-library library)

Parameters

libraryShared library pointer returned by open-shared-library.

Errors

Raises an error when unable to close library.

shared-library-error

Get a description of the last error that occurred during loading a shared library.

Prototype

(shared-library-error)

Returns

A platform-dependent string describing the error, or #f if one is not available.

c-function

Make foreign c-function closure.

Prototype

(c-function lib ret func . arg)

Parameters

liblibrary object returned by open-shared-library
retreturn type of c-function. bool, int, char, double, float, void, char*, long-long, long, unsigned-long-long, unsigned-long, unsigned-int, unsigned-short, short, size_t, uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t and void* are supported.
funcname of c-function as symbol
arglist of argument types. void*, int, double and char* are supported.

Returns

Foreign function closure

make-c-callback

Make c-callback. c-callback object should be free-ed with <<free-c-callback>>.

Prototype

(make-c-callback return-type arg-type* proc)

Parameters

return-tupereturn value type as symbol. bool, void, char, short, int, long, long-long, unsigned-short, unsigned-int, unsigned-long, unsigned-long-long, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, float, double, size_t and void* are supported.
arg-type*arguments type as list of symbols. bool, void, char, short, int, long, long-long, unsigned-short, unsigned-int, unsigned-long, unsigned-long-long, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, float, double, size_t and void* are supported.
procprocedure

Returns

A pointer of c-callback

c-callback

Make c-callback

Prototype

(c-callback return-type arg-type* proc)

Parameters

return-tupeSame as make-c-callback but should not be quoted.
arg-type*Same as make-c-callback but should not be quoted.
procprocedure

Returns

A pointer of c-callback

free-c-callback

Free c-callback object.

Prototype

(free-c-callback callback)

Parameters

callbackcallback object as pointer.

malloc

Allocate n bytes of memory.  Allocated memory will never collected by GC.  Use <<free>> procedure.

Prototype

(malloc n)

Parameters

nn bytes of memory to allocate.

Returns

A pointer to the allocated memory.

free

Frees the memory allocated by <<malloc>>.

Prototype

(free p)

Parameters

pthe pointer allocated by <<malloc>.

pointer->c-function

Make foreign c-function closure from pointer.

Prototype

(pointer->c-function pointer ret-type name arg-types)

Parameters

pointerpointer to c-function which is lookuped by <<lookup-shared-library>>.
ret-typereturn type of c-function. void*, char*, void, double and int are supported.
namename of c-function as symbol arg-types- list of argument types. bool, int, char, double, float, void, char*, long-long, long, unsigned-long-long, unsigned-long, unsigned-int, unsigned-short, short, size_t, uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t and void* are supported.

Returns

Foreign function closure

make-c-function

Make foreign c-function closure by lookuping a function named “name” in “lib” library.

Prototype

(make-c-function lib ret-type name arg-types)

Parameters

liblibrary
ret-typereturn type of c-function. bool, int, char, double, float, void, char*, long-long, long, unsigned-long-long, unsigned-long, unsigned-int, unsigned-short, short, size_t, uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t and void* are supported.
namename of c-function as symbol arg-types- list of argument types. bool, int, char, double, float, void, char*, long-long, long, unsigned-long-long, unsigned-long, unsigned-int, unsigned-short, short, size_t, uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t and void* are supported.

Returns

Foreign function closure

null-terminated-bytevector->string

Returns a newly allocated (unless empty) string whose character sequence is encoded by the given null(\0) terminated bytevector.  This is useful for converting “C” string to Scheme string.

(bytevector->string '#vu8(65 66 67 0 65 66 67) (native-transcoder)) => "ABC\x0;ABC"
(null-terminated-bytevector->string '#vu8(65 66 67 0 65 66 67)) (native-transcoder) => "ABC"

Prototype

(null-terminated-bytevector->string bv transcoder)

Parameters

bvnull(\0) terminated bytevector.
transcodertranscoder

Returns

decoded string.

null-terminated-utf8->string

Returns a newly allocated (unless empty) string whose character sequence is encoded by the given null(\0) terminated bytevector.  This is useful for converting “C” string to Scheme string.

(utf8->string '#vu8(65 66 67 0 65 66 67)) => "ABC\x0;ABC"
(null-terminated-utf8->string '#vu8(65 66 67 0 65 66 67)) => "ABC"

Prototype

(null-terminated-bytevector->string bv transcoder)

Parameters

bvnull(\0) terminated bytevector.
transcodertranscoder

Returns

decoded string.

pointer-ref-c-uint16

Get a value from pointer + offset as uint16.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as uint16.

pointer-ref-c-uint32

Get a value from pointer + offset as uint32.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as uint32.

pointer-ref-c-uint64

Get a value from pointer + offset as uint64.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as uint64.

pointer-ref-c-int8

Get a value from pointer + offset as int8.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as int8.

pointer-ref-c-int16

Get a value from pointer + offset as int16.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as int16.

pointer-ref-c-int32

Get a value from pointer + offset as int32.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as int32.

pointer-ref-c-int64

Get a value from pointer + offset as int64.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as int64.

pointer-ref-c-signed-char

Get a value from pointer + offset as signed-char.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as signed-char.

pointer-ref-c-unsigned-char

Get a value from pointer + offset as unsigned-char.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as unsigned-char.

pointer-ref-c-signed-short

Get a value from pointer + offset as signed-short.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as signed-short.

pointer-ref-c-unsigned-short

Get a value from pointer + offset as unsigned-short.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as unsigned-short.

pointer-ref-c-signed-int

Get a value from pointer + offset as signed-int.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as signed-int.

pointer-ref-c-unsigned-int

Get a value from pointer + offset as unsigned-int.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as unsigned-int.

pointer-ref-c-signed-long

Get a value from pointer + offset as signed-long.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as signed-long.

pointer-ref-c-unsigned-long

Get a value from pointer + offset as unsigned-long.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as unsigned-long.

pointer-ref-c-signed-long-long

Get a value from pointer + offset as signed-long-long.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as signed-long-long.

pointer-ref-c-unsigned-long-long

Get a value from pointer + offset as unsigned-long-long.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as unsigned-long-long.

pointer-ref-c-float

Get a value from pointer + offset as float.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as float.

pointer-ref-c-double

Get a value from pointer + offset as double.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as double.

pointer-ref-c-pointer

Get a value from pointer + offset as pointer.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.

Returns

A value from pointer + offset as pointer.

pointer-set-c-char!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-char! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-short!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-short! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-int!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-int! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-long!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-long! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-long-long!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-long-long! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-float!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-float! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-double!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-double! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-int8!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-int8! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-int16!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-int16! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-int32!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-int32! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-int64!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-int64! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-uint8!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-uint8! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-uint16!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-uint16! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-uint32!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-uint32! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

pointer-set-c-uint64!

Returns #t when ffi is supported, otherwise #f.

Prototype

(pointer-set-c-uint64! pointer offset value)

Parameters

pointerpointer.
offsetoffset from pointer.
valuevalue to set.

Constants

size-of-bool

sizeof(bool)

size-of-short

sizeof(short)

size-of-unsigned-short

sizeof(unsigned short)

size-of-int

sizeof(int)

size-of-unsigned-int

sizeof(unsigned int)

size-of-long

sizeof(long)

size-of-unsigned-long

sizeof(unsigned long)

size-of-unsigned-long-long

sizeof(unsigned long long)

size-of-long-long

sizeof(long long)

size-of-void*

sizeof(void*)

size-of-pointer

alias for sizeof(void*)

size-of-size_t

sizeof(size_t)

size-of-float

sizeof(float)

size-of-double

sizeof(double)

align-of-bool

struct x { char y; bool z; };

-offset-of(x, z)

align-of-short

struct x { char y; short z; };

-offset-of(x, z)

align-of-int

struct x { char y; int z; };

-offset-of(x, z)

align-of-long

struct x { char y; long z; };

-offset-of(x, z)

align-of-long-long

struct x { char y; long long z; };

-offset-of(x, z)

align-of-unsigned-long

struct x { char y; unsigned long z; };

-offset-of(x, z)

align-of-unsigned-long-long

struct x { char y; unsigned-long long z; };

-offset-of(x, z)

align-of-void*

struct x { char y; void* z; };

-offset-of(x, z)

align-of-size_t

struct x { char y; size_t z; };

-offset-of(x, z)

align-of-float

struct x { char y; float z; };

-offset-of(x, z)

align-of-double

struct x { char y; double z; };

-offset-of(x, z)

align-of-int8_t

struct x { char y; int8_t z; };

-offset-of(x, z)

align-of-int16_t

struct x { char y; int16_t z; };

-offset-of(x, z)

align-of-int32_t

struct x { char y; int32_t z; };

-offset-of(x, z)

align-of-int64_t

struct x { char y; int64_t z; };

-offset-of(x, z)

on-darwin

on-linux

on-freebsd

on-openbsd

on-windows

Open shared library.
Close