3 ;;;; cffiglue -- Interface to C library
5 ;;;; Copyright (c) 1991, by Luke Tierney.
6 ;;;; Copyright (c) 2007, by Carlos Ungil.
7 ;;;; Copyright (c) 2007, by AJ Rossini <blindglobe@gmail.com>.
8 ;;;; Permission is granted for unrestricted use.
10 ;;;; Tested (but the results have not been checked):
11 ;;;; Probability Distributions
12 ;;;; Internal Error Message Emulation
13 ;;;; Matrix Manipulation
16 ;;;; numgrad numhess minfo-maximize
18 (defpackage :lisp-stat-ffi-int
21 (:export ccl-store-integer ccl-store-double ccl-store-ptr
))
23 ;; are there any error message components that need to be exported?
24 ;; More importantly, should we factor them out into a logging package?
26 ;; This package initially loads the liblispstat library for access.
33 lu-decomp-front lu-solve-front
104 (in-package :lisp-stat-ffi-int
)
106 (cffi:load-foreign-library
108 (namestring cl-user
::*lispstat-home-dir
*)
113 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
115 ;;; Callback Support Functions
117 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
119 (cffi:defcfun
("ccl_store_integer" ccl-store-integer
)
121 (cffi:defcfun
("ccl_store_double" ccl-store-double
)
123 (cffi:defcfun
("ccl_store_ptr" ccl-store-ptr
)
127 ;;; Lisp-Managed Calloc/Free
130 ;;; this section is commented out in mclglue.lsp
131 ;;; and the relevant fragment in cffi-glue.c is not compiled (ifdef DODO)
135 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
137 ;;; XLISP Internal Error Message Emulation
139 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
141 (defvar *buf
* (make-string 1000))
143 (defun set-buf-char (i c
) (setf (elt *buf
* i
) (code-char c
)))
145 (defun get-buf (&optional
(n (position (code-char 0) *buf
*)))
148 (cffi:defcfun
("register_set_buf_char" register-set-buf-char
)
150 (cffi:defcallback ccl-set-buf-char
:void
((n :int
) (c :int
))
152 (register-set-buf-char (cffi:callback ccl-set-buf-char
))
154 (cffi:defcfun
("register_print_buffer" register-print-buffer
)
156 (cffi:defcallback ccl-print-buffer
:void
((n :int
) (type :int
))
158 (0 (princ (get-buf n
)))
159 (1 (error (get-buf n
))))
161 (register-print-buffer (cffi:callback ccl-print-buffer
))
163 (cffi:defcfun
("stdputstr" stdputstr
)
164 :void
(string :string
))
165 (cffi:defcfun
("xlfail" xlfail
)
166 :void
(string :string
))