Refactor core package definitions
[cffi.git] / libffi / libffi-types.lisp
blob7fe9e0db3ea72a1584cff9be52c3ca8b9eeaa99b
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 ;;;
28 (in-package #:cffi)
30 #+linux
31 (define "_GNU_SOURCE")
33 ;; When installed through Mac Ports, libffi include files
34 ;; will be found in /opt/local/include.
35 #+darwin
36 (cc-flags "-I/opt/local/include/")
38 #+openbsd
39 (cc-flags "-I/usr/local/include")
41 #+freebsd
42 (cc-flags "-I/usr/local/include")
44 (pkg-config-cflags "libffi" :optional t)
46 #+darwin
47 (include "ffi/ffi.h")
48 #-darwin
49 (include "ffi.h")
51 (cenum status
52 ((:ok "FFI_OK"))
53 ((:bad-typedef "FFI_BAD_TYPEDEF"))
54 ((:bad-abi "FFI_BAD_ABI")))
56 #+freebsd
57 (cenum abi
58 ((:default-abi "FFI_DEFAULT_ABI")))
60 #+(and windows x86-64)
61 (cenum abi
62 ((:default-abi "FFI_DEFAULT_ABI"))
63 ((:win64 "FFI_WIN64")))
65 #+(and windows (not x86-64))
66 (cenum abi
67 ((:default-abi "FFI_DEFAULT_ABI"))
68 ((:sysv "FFI_SYSV"))
69 ((:stdcall "FFI_STDCALL")))
71 #-(or freebsd windows)
72 (cenum abi
73 ((:default-abi "FFI_DEFAULT_ABI"))
74 #-x86-64
75 ((:sysv "FFI_SYSV"))
76 #+x86-64
77 ((:unix64 "FFI_UNIX64")))
79 (ctype ffi-abi "ffi_abi")
81 (ctype size-t "size_t")
83 (cstruct ffi-type "struct _ffi_type"
84 (size "size" :type size-t)
85 (alignment "alignment" :type :unsigned-short)
86 (type "type" :type :unsigned-short)
87 (elements "elements" :type :pointer))
89 (cstruct ffi-cif "ffi_cif"
90 (abi "abi" :type ffi-abi)
91 (argument-count "nargs" :type :unsigned-int)
92 (argument-types "arg_types" :type :pointer)
93 (return-type "rtype" :type :pointer)
94 (bytes "bytes" :type :unsigned-int)
95 (flags "flags" :type :unsigned-int))
97 (constant (+type-void+ "FFI_TYPE_VOID"))
98 (constant (+type-int+ "FFI_TYPE_INT"))
99 (constant (+type-float+ "FFI_TYPE_FLOAT"))
100 (constant (+type-double+ "FFI_TYPE_DOUBLE"))
101 (constant (+type-longdouble+ "FFI_TYPE_LONGDOUBLE"))
102 (constant (+type-uint8+ "FFI_TYPE_UINT8"))
103 (constant (+type-sint8+ "FFI_TYPE_SINT8"))
104 (constant (+type-uint16+ "FFI_TYPE_UINT16"))
105 (constant (+type-sint16+ "FFI_TYPE_SINT16"))
106 (constant (+type-uint32+ "FFI_TYPE_UINT32"))
107 (constant (+type-sint32+ "FFI_TYPE_SINT32"))
108 (constant (+type-uint64+ "FFI_TYPE_UINT64"))
109 (constant (+type-sint64+ "FFI_TYPE_SINT64"))
110 (constant (+type-struct+ "FFI_TYPE_STRUCT"))
111 (constant (+type-pointer+ "FFI_TYPE_POINTER"))