libffi-types.lisp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
  2. ;;;
  3. ;;; libffi-types.lisp -- CFFI-Grovel definitions for libffi
  4. ;;;
  5. ;;; Copyright (C) 2009, 2010, 2011, 2017 Liam M. Healy <lhealy@common-lisp.net>
  6. ;;;
  7. ;;; Permission is hereby granted, free of charge, to any person
  8. ;;; obtaining a copy of this software and associated documentation
  9. ;;; files (the "Software"), to deal in the Software without
  10. ;;; restriction, including without limitation the rights to use, copy,
  11. ;;; modify, merge, publish, distribute, sublicense, and/or sell copies
  12. ;;; of the Software, and to permit persons to whom the Software is
  13. ;;; furnished to do so, subject to the following conditions:
  14. ;;;
  15. ;;; The above copyright notice and this permission notice shall be
  16. ;;; included in all copies or substantial portions of the Software.
  17. ;;;
  18. ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  22. ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  23. ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  25. ;;; DEALINGS IN THE SOFTWARE.
  26. ;;;
  27. (in-package #:cffi)
  28. #+linux
  29. (define "_GNU_SOURCE")
  30. ;; When installed through Mac Ports, libffi include files
  31. ;; will be found in /opt/local/include.
  32. #+darwin
  33. (cc-flags "-I/opt/local/include/")
  34. #+openbsd
  35. (cc-flags "-I/usr/local/include")
  36. #+freebsd
  37. (cc-flags "-I/usr/local/include")
  38. (pkg-config-cflags "libffi" :optional t)
  39. #+darwin
  40. (include "ffi/ffi.h")
  41. #-darwin
  42. (include "ffi.h")
  43. (cenum status
  44. ((:ok "FFI_OK"))
  45. ((:bad-typedef "FFI_BAD_TYPEDEF"))
  46. ((:bad-abi "FFI_BAD_ABI")))
  47. #+freebsd
  48. (cenum abi
  49. ((:default-abi "FFI_DEFAULT_ABI")))
  50. #+(and windows x86-64)
  51. (cenum abi
  52. ((:default-abi "FFI_DEFAULT_ABI"))
  53. ((:win64 "FFI_WIN64")))
  54. #+(and windows (not x86-64))
  55. (cenum abi
  56. ((:default-abi "FFI_DEFAULT_ABI"))
  57. ((:sysv "FFI_SYSV"))
  58. ((:stdcall "FFI_STDCALL")))
  59. #-(or freebsd windows)
  60. (cenum abi
  61. ((:default-abi "FFI_DEFAULT_ABI"))
  62. #-x86-64
  63. ((:sysv "FFI_SYSV"))
  64. ((:unix64 "FFI_UNIX64")))
  65. (ctype ffi-abi "ffi_abi")
  66. (ctype size-t "size_t")
  67. (cstruct ffi-type "struct _ffi_type"
  68. (size "size" :type size-t)
  69. (alignment "alignment" :type :unsigned-short)
  70. (type "type" :type :unsigned-short)
  71. (elements "elements" :type :pointer))
  72. (cstruct ffi-cif "ffi_cif"
  73. (abi "abi" :type ffi-abi)
  74. (argument-count "nargs" :type :unsigned-int)
  75. (argument-types "arg_types" :type :pointer)
  76. (return-type "rtype" :type :pointer)
  77. (bytes "bytes" :type :unsigned-int)
  78. (flags "flags" :type :unsigned-int))
  79. (constant (+type-void+ "FFI_TYPE_VOID"))
  80. (constant (+type-int+ "FFI_TYPE_INT"))
  81. (constant (+type-float+ "FFI_TYPE_FLOAT"))
  82. (constant (+type-double+ "FFI_TYPE_DOUBLE"))
  83. (constant (+type-longdouble+ "FFI_TYPE_LONGDOUBLE"))
  84. (constant (+type-uint8+ "FFI_TYPE_UINT8"))
  85. (constant (+type-sint8+ "FFI_TYPE_SINT8"))
  86. (constant (+type-uint16+ "FFI_TYPE_UINT16"))
  87. (constant (+type-sint16+ "FFI_TYPE_SINT16"))
  88. (constant (+type-uint32+ "FFI_TYPE_UINT32"))
  89. (constant (+type-sint32+ "FFI_TYPE_SINT32"))
  90. (constant (+type-uint64+ "FFI_TYPE_UINT64"))
  91. (constant (+type-sint64+ "FFI_TYPE_SINT64"))
  92. (constant (+type-struct+ "FFI_TYPE_STRUCT"))
  93. (constant (+type-pointer+ "FFI_TYPE_POINTER"))