Skip to content
  1. Feb 03, 2022
  2. Jan 31, 2022
  3. Jan 07, 2022
  4. Aug 19, 2021
    • stacksmith's avatar
      Allow local names in WITH-FOREIGN-SLOTS · 743a9025
      stacksmith authored
      It remains compatible with existing code, but accepts additional formats for bindings:
      1) (name slot-name) - just like WITH-SLOTS;
      2) (name :pointer slot-name) - a pointer version.
      743a9025
  5. May 15, 2021
    • jathd's avatar
      Signal an error when a foreign function is not found on ABCL · 6b1e0f45
      jathd authored
      When a foreign function is not found by find-foreign-function (either because
      the function doesn't exist, or because the library is not loaded), nil is
      returned, so %%foreign-funcall is called with nil as a function, which
      ultimately leads to a null-pointer exception.
      
      Better to signal an error on the lisp side.
      6b1e0f45
  6. Apr 14, 2021
  7. Feb 27, 2021
  8. Feb 01, 2021
    • Stuart Dilts's avatar
      Fix discard-docstring · 7c68cafa
      Stuart Dilts authored
      defun-like semantics were meant for defcallback, but it's no longer used there.
      
      This allows for empty structure/union definitions, e.g. (defcstruct foo "empty").
      7c68cafa
  9. Jan 21, 2021
  10. Jan 01, 2021
  11. Dec 30, 2020
  12. Oct 15, 2020
  13. Sep 20, 2020
    • Luís Oliveira's avatar
      Optimise CHECK-FOR-TYPEDEF-CYCLES · 7b3f5217
      Luís Oliveira authored
      Use a list rather than a hash-table to keep track of types
      seen. Although this pessimizes the time complexity of this algorithm
      from O(n) to O(n^2), using an hash-table only becomes faster once we
      reach n=250 and using a list reduces consing by an order of magnitude.
      
      For the common case where the typedef chain is only one or two types
      long, using a list is also one or two orders of magnitude faster.
      
      This makes slow code paths that call PARSE-TYPE at runtime a bit less
      painful.
      
      Benchmark:
      
      (defun make-typedef-chain (size)
        (if (zerop size)
            :int
            (eval `(cffi:defctype ,(make-symbol (format nil "TYPEDEF-~a" size))
                                  ,(make-typedef-chain (1- size))))))
      
      (let ((chain (cffi::parse-type (make-typedef-chain 2))))
        (funcall
         (compile nil (lambda ()
                        (time (loop repeat 100
                                    do (cffi::check-for-typedef-cycles chain)))))))
      7b3f5217
  14. Aug 10, 2020
    • Luís Oliveira's avatar
      sbcl: fix callback calling conventions · c3eba9ce
      Luís Oliveira authored
      Previously assumed the presence of the :ALIEN-CALLBACK-CONVENTIONS
      feature which was only ever present in the Anton Kovalenko's
      sbcl-win32-threads fork.
      
      Fixes lp issue #1890671 reported by Matthew Stickney.
      c3eba9ce
  15. Jun 02, 2020
    • Mark's avatar
      abcl: implement MAKE-SHAREABLE-BYTE-VECTOR · 47136ad9
      Mark authored
      In abcl-1.7.0, CL:MAKE-ARRAY is able create and share malloc()d memory
      for java.nio.ByteVector allocated by JNA via use of the :NIO-BUFFER
      argument. Whether this feature is present in the current
      implementation is conditionalized on the presence :NIO in
      CL:*FEATURES*.
      
      We retain the old behavior of copying memory for
      WITH-POINTER-TO-VECTOR-DATA when passed a non-shareable byte vector as
      a plausible fallback strategy.
      47136ad9
  16. May 18, 2020
    • Stelian Ionescu's avatar
      Detect statically linked libraries and avoid loading · fed34b0e
      Stelian Ionescu authored
      * add option :CANARY to DEFINE-FOREIGN-LIBRARY: a foreign symbol unique
      to the library
      
      If that symbol is found in the current image before
      the first attempt to load the library, the latter is assumed to be
      statically linked and LOAD-FOREIGN-LIBRARY only marks the load state
      as :STATIC before returning.
      
      * add new slot LOAD-STATE which, together with HANDLE, tracks the
      library
      
      | library state     | LOAD-STATE | HANDLE  |
      |-------------------|------------|---------|
      | not loaded        | NIL        | NIL     |
      | statically linked | :STATIC    | NIL     |
      | dlopen()'d        | :EXTERNAL  | non-NIL |
      fed34b0e
  17. May 17, 2020
  18. May 12, 2020
  19. May 11, 2020
  20. May 04, 2020
    • Shinmera's avatar
      Implement an enum flag that elides an error when translating an enum value that was not declared. · 2e945ea7
      Shinmera authored
      This is useful for very large enumerations of which we're only interested in a subset, or enumerations that allow for arbitrary client or vendor extensions that we cannot be aware of. Erroring on a value that we ostensibly do not care about in such a situation is not desirable, and instead simply passing through the integer allows handling the interesting cases easily in a CASE or something similar.
      2e945ea7
  21. Feb 26, 2020
    • Madhu's avatar
      fix translation of struct-typedefs · c5d140fe
      Madhu authored
      CFFI now always translates aggregate struct values to lisp property
      lists.  Earlier struct values which were defined by types introduced
      by defctype were translated as foreign pointers.
      
      One consequence of this change is that defcvar to a foreign struct
      will always produce an immutable lisp list.  To modify the struct the
      user first has to get at the pointer to the struct via
      FORIEGN-SYMBOL-VALUE or GET-VAR-POINTER.  To modify nested structs the
      user has to get at the pointer to the field via FORIEGN-SLOT-POINTER,
      - or use the the (:POINTER VAR) syntax of WITH-FOREIGN-SLOTS.
      
      * src/early-types.lisp: (defctype): use translatable-foreign-type
      instead of enhanced-foreign-type.
      
      * tests/structs.lisp: New tests: (misnamed) STRUCT-VALUES.FSBV.1
      STRUCT-VALUES.FSBV.1 Updated tests: STRUCT.ALIGNMENT.1
      STRUCT.ALIGNMENT.2 STRUCT.ALIGNMENT.3 STRUCT.ALIGNMENT.4
      STRUCT.ALIGNMENT.5 STRUCT.ALIGNMENT.6 STRUCT.ALIGNMENT.7
      STRUCT.NESTED-SETF STRUCT.ALIGNMENT.8
      c5d140fe
  22. Jan 24, 2020
  23. Jan 06, 2020
  24. Dec 19, 2019
  25. Dec 08, 2019
  26. Nov 17, 2019
  27. Sep 15, 2019
  28. Mar 01, 2019
  29. Dec 25, 2018
    • 3 b's avatar
      check for ENUM-KEY instead of KEYWORD in foreign enum translators · 78143fd6
      3 b authored
      KEYWORDP can't be constant folded, since a symbol could be uninterned
      after compilation, so using a more general type gets rid of some
      style warnings on SBCL. %FOREIGN-ENUM-VALUE has an explicit check for
      ENUM-KEY, so that is probably more correct than KEYWORD anyway.
      78143fd6
  30. Feb 03, 2018
  31. Feb 02, 2018
  32. Jan 30, 2018
  33. Jan 03, 2018
    • Michał Herda's avatar
      Add &REST MAKE-ARRAY-ARGS to FOREIGN-ARRAY-TO-LISP (#128) · 8a2bd255
      Michał Herda authored
      Rename test ARRAY.ROUND-TRIP to ARRAY.FOREIGN-TO-LISP.BASIC
      Add test ARRAY.FOREIGN-TO-LISP.ADJUSTABLE
      Add test ARRAY.FOREIGN-TO-LISP.DISPLACED
      Add test ARRAY.FOREIGN-TO-LISP.SPECIALIZED
      
      Implementation detail for test ARRAY.FOREIGN-TO-LISP.SPECIALIZED:
      
      15.1.2.2 of the Holy Standard states that the only truly portable array
      specializations are for bits (bit-vectors) and characters (strings). Since
      char-codes are implementation-dependent, it would be tricky to write a
      portable test for them without generating characters at runtime. So, for a
      truly portable test, we are only left with bits, which are luckily numeric,
      and equal to (UNSIGNED-BYTE 1).
      
      This is why this test is so terribly wasteful, spending a whole byte for a
      single bit - CFFI has no capabilities for dealing with single bits, and this
      test is only meant to check correctness of the :ELEMENT-TYPE argument to
      MAKE-ARRAY. In actual use cases of specialized FOREIGN-ARRAY-TO-LISP, capable
      implementations will be able to make specialized arrays of types that are
      commonly optimized for and/or representable in hardware, such as
      (UNSIGNED-BYTE 8) on x86 architectures.
      
      Implements lp bug #1740800.
      8a2bd255
  34. Oct 05, 2017
  35. Oct 03, 2017