Coverage report: /development/source/library/com/dydra/gitlab/dydra-cgi/ffi/lisp/spocq-ffi/package.lisp

KindCoveredAll%
expression411 36.4
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 (defpackage :spocq-ffi
2
   (:use :cl :cffi :cffi-sys)
3
   (:export ;; package.lisp:
4
            :load-library
5
            :unload-library)
6
   (:shadow))
7
 
8
 (in-package :spocq-ffi)
9
 
10
 (eval-when (:compile-toplevel :load-toplevel :execute)
11
   (pushnew #P"/opt/dydra/lib/" *foreign-library-directories* :test #'equal)
12
   (define-foreign-library libspocq
13
     (:unix (:or "libspocq.so.0" "libspocq.so"))
14
     (:darwin (:or "libspocq.0.dylib" "libspocq.dylib"))
15
     (t (:default "libspocq"))))
16
 
17
 (defun load-library (&key path version debug features)
18
   "Loads the libspocq native library.
19
    Must be called before invoking any foreign functions in the library."
20
   (declare (type boolean debug)
21
            (type list features))
22
   (load-foreign-library 'libspocq)
23
   #| 20171001: initialization returns from the load-foreign-library,
24
      but then segfaults---
25
   (let ((spocq-core-build-id (symbol-value (find-symbol "*BUILD-REVISION*" "SPOCQ.I"))))
26
     (when spocq-core-build-id
27
       (handler-case (cffi:foreign-funcall "spocq_load" :string spocq-core-build-id :void)
28
         (sb-kernel::undefined-alien-function-error () nil)))) |#
29
   (values)) ;;; no meaningful return value
30
 
31
 (defun unload-library ()
32
   "Unloads the libspocq native library."
33
   (close-foreign-library 'libspocq)
34
   (values)) ;;; no meaningful return value