;;; -*- Mode: Scheme; scheme48-package: (config) -*- ;;;; C Stub Examples ;;;; Scheme48 Package Definitions ;;; Copyright (c) 2009, Taylor R. Campbell ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; * Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in ;;; the documentation and/or other materials provided with the ;;; distribution. ;;; ;;; * Neither the names of the authors nor the names of contributors ;;; may be used to endorse or promote products derived from this ;;; software without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (define-structures ((unix-file-descriptors unix-file-descriptors-interface) (unix-file-descriptor-stubs unix-file-descriptor-stubs-interface)) (open scheme finalization hash-maps receiving recursive-mutices srfi-9 ;define-record-type srfi-23 ;error stubber-syntax stubber-unix-syntax ) (optimize auto-integrate) (files unix-fd) (open (subset define-record-types (define-record-discloser))) (begin (define-record-discloser (lambda (file-descriptor) (list 'FILE-DESCRIPTOR (or (let ((alien (file-descriptor.alien file-descriptor))) (and alien (let ((integer (alien->integer alien))) (and (>= integer 0) integer)))) 'CLOSED)))))) (define-structures ((bsd-sockets bsd-sockets-interface) (bsd-socket-stubs bsd-socket-stubs-interface) (bsd-socket-addresses bsd-socket-addresses-interface) (bsd-socket-address-stubs bsd-socket-address-stubs-interface)) (open scheme byte-vectors finalization receiving srfi-9 ;define-record-type srfi-23 ;error stubber-syntax stubber-enumerations-syntax stubber-records-syntax stubber-unix-syntax unix-file-descriptor-stubs unix-file-descriptors ) (optimize auto-integrate) (files bsd-socket)) ;;; This is an interface to the BSD getifaddrs(3) library routine, ;;; which is unlikely to be available on non-BSDs. If you attempt to ;;; load this things will probably explode. (define-structure bsd-interface-addresses bsd-interface-addresses-interface (open scheme bsd-socket-address-stubs finalization receiving srfi-9 ;define-record-type stubber-syntax stubber-records-syntax stubber-unix-syntax ) (optimize auto-integrate) (files bsd-ifaddrs)) ;;; This requires adding `-lsqlite3' to the linker flags used by the ;;; stubber, or whatever else is necessary to link against the sqlite3 ;;; library. (define-structures ((sqlite3 sqlite3-interface) (sqlite3-stubs sqlite3-stubs-interface)) (open scheme finalization srfi-9 ;define-record-type srfi-23 ;error stubber-callback-syntax stubber-enumerations-syntax stubber-syntax ) (optimize auto-integrate) (files sqlite3)) (define-structure recursive-mutices recursive-mutices-interface (open scheme proposals queues receiving srfi-23 ;error threads threads-internal ) (optimize auto-integrate) (files s48-mutex)) (define-structure hash-maps hash-maps-interface (open scheme interrupts tables weak ) (optimize auto-integrate) (files s48-hash-map))