From 1a99961c0bf85b38409169ba3297901a11495ffc Mon Sep 17 00:00:00 2001 From: Stelian Ionescu Date: Tue, 7 Sep 2010 15:03:37 +0300 Subject: [PATCH] First phase of switch to LibFixPOSIX: add LFP bindings and remove CFFI wrappers --- src/iolib.syscalls.asd | 5 +- src/libfixposix.asd | 25 ++++++ src/libfixposix/constants.lisp | 17 +++++ src/libfixposix/ffi-functions.lisp | 45 +++++++++++ src/libfixposix/ffi-types.lisp | 116 ++++++++++++++++++++++++++++ src/libfixposix/pkgdcl.lisp | 84 ++++++++++++++++++++ src/syscalls/early.lisp | 12 --- src/syscalls/ffi-functions-unix.lisp | 4 - src/syscalls/ffi-types-unix.lisp | 144 ----------------------------------- src/syscalls/ffi-wrappers-unix.lisp | 106 -------------------------- src/syscalls/pkgdcl.lisp | 112 ++++++++++++++++++++++----- 11 files changed, 380 insertions(+), 290 deletions(-) create mode 100644 src/libfixposix.asd create mode 100644 src/libfixposix/constants.lisp create mode 100644 src/libfixposix/ffi-functions.lisp create mode 100644 src/libfixposix/ffi-types.lisp create mode 100644 src/libfixposix/pkgdcl.lisp delete mode 100644 src/syscalls/ffi-wrappers-unix.lisp diff --git a/src/iolib.syscalls.asd b/src/iolib.syscalls.asd index b195f59..93dec1b 100644 --- a/src/iolib.syscalls.asd +++ b/src/iolib.syscalls.asd @@ -14,7 +14,8 @@ *load-truename*))) (read f)) :licence "MIT" - :depends-on (:trivial-features :cffi :cffi-grovel :iolib.base) + :depends-on (:trivial-features :cffi :cffi-grovel :iolib.base + :libfixposix) :default-component-class iolib-source-file :pathname #-asdf2 (merge-pathnames "syscalls/" *load-truename*) #+asdf2 "syscalls/" @@ -28,7 +29,5 @@ (:file "os-conditions" :pathname #+unix "os-conditions-unix") (:file "designators") (:file "early") - (cffi-grovel:wrapper-file "ffi-wrappers" :pathname #+unix "ffi-wrappers-unix" - :soname "libiolib-syscalls") (:file "ffi-functions" :pathname #+unix "ffi-functions-unix")) :serial t) diff --git a/src/libfixposix.asd b/src/libfixposix.asd new file mode 100644 index 0000000..bc8b6ba --- /dev/null +++ b/src/libfixposix.asd @@ -0,0 +1,25 @@ +;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- + +(eval-when (:compile-toplevel :load-toplevel :execute) + (asdf:oos 'asdf:load-op :cffi-grovel) + (asdf:oos 'asdf:load-op :iolib.base)) + +(in-package :iolib.asdf) + +(defsystem :libfixposix + :description "Raw OS interface through LibFixPOSIX." + :maintainer "Stelian Ionescu " + :version #.(with-open-file (f (merge-pathnames "../version.lisp-expr" + (or *compile-file-pathname* + *load-truename*))) + (read f)) + :licence "Boost-1.0" + :depends-on (:cffi :cffi-grovel :iolib.base) + :default-component-class iolib-source-file + :pathname #-asdf2 (merge-pathnames "libfixposix/" *load-truename*) + #+asdf2 "libfixposix/" + :components + ((:file "pkgdcl") + (:file "constants" :depends-on ("pkgdcl")) + (cffi-grovel:grovel-file "ffi-types" :depends-on ("pkgdcl")) + (:file "ffi-functions" :depends-on ("pkgdcl" "ffi-types")))) diff --git a/src/libfixposix/constants.lisp b/src/libfixposix/constants.lisp new file mode 100644 index 0000000..56553d6 --- /dev/null +++ b/src/libfixposix/constants.lisp @@ -0,0 +1,17 @@ +;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- +;;; +;;; --- Misc. constants +;;; + +(in-package :libfixposix) + +;;;------------------------------------------------------------------------- +;;; Sizes of Standard Types +;;;------------------------------------------------------------------------- + +(defconstant size-of-char (foreign-type-size :char)) +(defconstant size-of-int (foreign-type-size :int)) +(defconstant size-of-long (foreign-type-size :long)) +(defconstant size-of-long-long (foreign-type-size :long-long)) +(defconstant size-of-pointer (foreign-type-size :pointer)) +(defconstant size-of-short (foreign-type-size :short)) diff --git a/src/libfixposix/ffi-functions.lisp b/src/libfixposix/ffi-functions.lisp new file mode 100644 index 0000000..f2c165d --- /dev/null +++ b/src/libfixposix/ffi-functions.lisp @@ -0,0 +1,45 @@ +;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- +;;; +;;; --- Foreign function definitions +;;; + +(in-package :libfixposix) + +(eval-when (:compile-toplevel :load-toplevel :execute) + (define-foreign-library libfixposix + (:unix "libfixposix.so")) + (use-foreign-library libfixposix)) + + +;;;------------------------------------------------------------------------- +;;; ERRNO-related functions +;;;------------------------------------------------------------------------- + +(defcfun (errno "lfp_errno") :int) + +(defun (setf errno) (value) + (foreign-funcall "lfp_set_errno" :int value :int)) + + +;;;------------------------------------------------------------------------- +;;; Socket message readers +;;;------------------------------------------------------------------------- + +(defcfun (cmsg.firsthdr "lfp_cmsg_firsthdr") :pointer + (msgh :pointer)) + +(defcfun (cmsg.nxthdr "lfp_cmsg_nxthdr") :pointer + (msgh :pointer) + (cmsg :pointer)) + +(defcfun (cmsg.align "lfp_cmsg_align") size-t + (length size-t)) + +(defcfun (cmsg.space "lfp_cmsg_space") size-t + (length size-t)) + +(defcfun (cmsg.len "lfp_cmsg_len") size-t + (length size-t)) + +(defcfun (cmsg.data "lfp_cmsg_data") :pointer + (cmsg :pointer)) diff --git a/src/libfixposix/ffi-types.lisp b/src/libfixposix/ffi-types.lisp new file mode 100644 index 0000000..5ff7cb0 --- /dev/null +++ b/src/libfixposix/ffi-types.lisp @@ -0,0 +1,116 @@ +;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- +;;; +;;; --- Foreign type definitions. +;;; + +(in-package :libfixposix) + +(include "libfixposix.h") + + + +;;;------------------------------------------------------------------------- +;;; Simple POSIX types +;;;------------------------------------------------------------------------- + +(ctype size-t "size_t") +(ctype ssize-t "ssize_t") +(ctype off-t "off_t") + + +;;;------------------------------------------------------------------------- +;;; errno.h +;;;------------------------------------------------------------------------- + +;; FIXME: :define-constants doesn't work when +;; the values arent' defined as macros too +(cenum (errno-values :define-constants t) + ((:e2big "E2BIG")) + ((:eacces "EACCES")) + ((:eaddrinuse "EADDRINUSE")) + ((:eaddrnotavail "EADDRNOTAVAIL")) + ((:eafnosupport "EAFNOSUPPORT")) + ((:ealready "EALREADY")) + ((:ebadf "EBADF")) + ((:ebadmsg "EBADMSG")) + ((:ebusy "EBUSY")) + ((:ecanceled "ECANCELED")) + ((:echild "ECHILD")) + ((:econnaborted "ECONNABORTED")) + ((:econnrefused "ECONNREFUSED")) + ((:econnreset "ECONNRESET")) + ((:edeadlk "EDEADLK")) + ((:edestaddrreq "EDESTADDRREQ")) + ((:edom "EDOM")) + ((:edquot "EDQUOT")) + ((:eexist "EEXIST")) + ((:efault "EFAULT")) + ((:efbig "EFBIG")) + ((:ehostunreach "EHOSTUNREACH")) + ((:eidrm "EIDRM")) + ((:eilseq "EILSEQ")) + ((:einprogress "EINPROGRESS")) + ((:eintr "EINTR")) + ((:einval "EINVAL")) + ((:eio "EIO")) + ((:eisconn "EISCONN")) + ((:eisdir "EISDIR")) + ((:eloop "ELOOP")) + ((:emfile "EMFILE")) + ((:emlink "EMLINK")) + ((:emsgsize "EMSGSIZE")) + ((:emultihop "EMULTIHOP")) + ((:enametoolong "ENAMETOOLONG")) + ((:enetdown "ENETDOWN")) + ((:enetreset "ENETRESET")) + ((:enetunreach "ENETUNREACH")) + ((:enfile "ENFILE")) + ((:enobufs "ENOBUFS")) + ((:enodata "ENODATA")) + ((:enodev "ENODEV")) + ((:enoent "ENOENT")) + ((:enoexec "ENOEXEC")) + ((:enolck "ENOLCK")) + ((:enolink "ENOLINK")) + ((:enomem "ENOMEM")) + ((:enomsg "ENOMSG")) + ((:enoprotoopt "ENOPROTOOPT")) + ((:enospc "ENOSPC")) + ((:enosr "ENOSR")) + ((:enostr "ENOSTR")) + ((:enosys "ENOSYS")) + ((:enotconn "ENOTCONN")) + ((:enotdir "ENOTDIR")) + ((:enotempty "ENOTEMPTY")) + ((:enotsock "ENOTSOCK")) + ((:enotsup "ENOTSUP")) + ((:enotty "ENOTTY")) + ((:enxio "ENXIO")) + ((:eopnotsupp "EOPNOTSUPP")) + ((:eoverflow "EOVERFLOW")) + ((:eperm "EPERM")) + ((:epipe "EPIPE")) + ((:eproto "EPROTO")) + ((:eprotonosupport "EPROTONOSUPPORT")) + ((:eprototype "EPROTOTYPE")) + ((:erange "ERANGE")) + ((:erofs "EROFS")) + ((:espipe "ESPIPE")) + ((:esrch "ESRCH")) + ((:estale "ESTALE")) + ((:etime "ETIME")) + ((:etimedout "ETIMEDOUT")) + ((:etxtbsy "ETXTBSY")) + ((:ewouldblock "EWOULDBLOCK")) + ((:exdev "EXDEV")) + ;; ((:ebug "LFP_EBUG")) + ) + + +;;;------------------------------------------------------------------------- +;;; sys/wait.h +;;;------------------------------------------------------------------------- + +(constant (wnohang "WNOHANG")) +(constant (wuntraced "WUNTRACED")) +(constant (wcontinued "WCONTINUED")) diff --git a/src/libfixposix/pkgdcl.lisp b/src/libfixposix/pkgdcl.lisp new file mode 100644 index 0000000..eeaa699 --- /dev/null +++ b/src/libfixposix/pkgdcl.lisp @@ -0,0 +1,84 @@ +;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- +;;; +;;; --- Package definition. +;;; + +(in-package :common-lisp-user) + +(defpackage :libfixposix + (:nicknames :lfp) + (:use :common-lisp :alexandria :cffi) + (:shadow #:open #:close #:read #:write #:listen + #:truncate #:ftruncate #:time) + (:export + + ;;;---------------------------------------------------------------------- + ;;; C Types + ;;;---------------------------------------------------------------------- + + ;; Primitive type sizes + #:size-of-char + #:size-of-short + #:size-of-int + #:size-of-long + #:size-of-long-long + #:size-of-pointer + + ;; POSIX Types + #:size-t #:size-of-size-t + #:ssize-t #:size-of-ssize-t + #:off-t #:size-of-off-t + + + ;;;---------------------------------------------------------------------- + ;;; C Constants + ;;;---------------------------------------------------------------------- + + ;; errno.h + #:errno-values + #:e2big #:eacces #:eaddrinuse #:eaddrnotavail + #:eafnosupport #:ealready #:ebadf #:ebadmsg #:ebusy #:ecanceled + #:echild #:econnaborted #:econnrefused #:econnreset #:edeadlk + #:edestaddrreq #:edom #:edquot #:eexist #:efault #:efbig + #:ehostunreach #:eidrm #:eilseq #:einprogress #:eintr #:einval #:eio + #:eisconn #:eisdir #:eloop #:emfile #:emlink #:emsgsize #:emultihop + #:enametoolong #:enetdown #:enetreset #:enetunreach #:enfile + #:enobufs #:enodata #:enodev #:enoent #:enoexec #:enolck #:enolink + #:enomem #:enomsg #:enoprotoopt #:enospc #:enosr #:enostr #:enosys + #:enotconn #:enotdir #:enotempty #:enotsock #:enotsup #:enotty + #:enxio #:eopnotsupp #:eoverflow #:eperm #:epipe #:eproto + #:eprotonosupport #:eprototype #:erange #:erofs #:espipe #:esrch + #:estale #:etime #:etimedout #:etxtbsy #:ewouldblock #:exdev + #:ebug + + ;; Waitpid() + #:wnohang + #:wuntraced + #:wcontinued + + + ;;;---------------------------------------------------------------------- + ;;; Syscalls + ;;;---------------------------------------------------------------------- + + ;; Errno-related functions + #:errno + + ;; Signals + #:wifexited + #:wexitstatus + #:wifsignaled + #:wtermsig + #:wcoredump + #:wifstopped + #:wstopsig + #:wifcontinued + + ;; CMSG readers + #:cmsg.firsthdr + #:cmsg.nxthdr + #:cmsg.align + #:cmsg.space + #:cmsg.len + #:cmsg.data + )) diff --git a/src/syscalls/early.lisp b/src/syscalls/early.lisp index f231da5..7d4bce6 100644 --- a/src/syscalls/early.lisp +++ b/src/syscalls/early.lisp @@ -6,18 +6,6 @@ (in-package :iolib.syscalls) ;;;------------------------------------------------------------------------- -;;; Sizes of Standard Types -;;;------------------------------------------------------------------------- - -(defconstant size-of-char (foreign-type-size :char)) -(defconstant size-of-int (foreign-type-size :int)) -(defconstant size-of-long (foreign-type-size :long)) -(defconstant size-of-long-long (foreign-type-size :long-long)) -(defconstant size-of-pointer (foreign-type-size :pointer)) -(defconstant size-of-short (foreign-type-size :short)) - - -;;;------------------------------------------------------------------------- ;;; Syscall return wrapper ;;;------------------------------------------------------------------------- diff --git a/src/syscalls/ffi-functions-unix.lisp b/src/syscalls/ffi-functions-unix.lisp index 07bae2e..42289f4 100644 --- a/src/syscalls/ffi-functions-unix.lisp +++ b/src/syscalls/ffi-functions-unix.lisp @@ -16,10 +16,6 @@ ;;; ERRNO-related functions ;;;------------------------------------------------------------------------- -(defentrypoint (setf errno) (value) - "Set errno value." - (%set-errno value)) - (defsyscall (%strerror-r (#+linux "__xpg_strerror_r" "strerror_r")) :int (errnum :int) diff --git a/src/syscalls/ffi-types-unix.lisp b/src/syscalls/ffi-types-unix.lisp index 6c79e7f..96e2f8f 100644 --- a/src/syscalls/ffi-types-unix.lisp +++ b/src/syscalls/ffi-types-unix.lisp @@ -562,150 +562,6 @@ ;;;------------------------------------------------------------------------- -;;; errno.h -;;;------------------------------------------------------------------------- - -(include "errno.h") - -(constantenum (errno-values :define-constants t) - ((:eperm "EPERM")) - ((:enoent "ENOENT")) - ((:esrch "ESRCH")) - ((:eintr "EINTR")) - ((:eio "EIO")) - ((:enxio "ENXIO")) - ((:e2big "E2BIG")) - ((:enoexec "ENOEXEC")) - ((:ebadf "EBADF")) - ((:echild "ECHILD")) - ((:enomem "ENOMEM")) - ((:eacces "EACCES")) - ((:efault "EFAULT")) - ((:ebusy "EBUSY")) - ((:eexist "EEXIST")) - ((:exdev "EXDEV")) - ((:enodev "ENODEV")) - ((:enotdir "ENOTDIR")) - ((:eisdir "EISDIR")) - ((:einval "EINVAL")) - ((:enfile "ENFILE")) - ((:emfile "EMFILE")) - ((:enotty "ENOTTY")) - ((:efbig "EFBIG")) - ((:enospc "ENOSPC")) - ((:espipe "ESPIPE")) - ((:erofs "EROFS")) - ((:emlink "EMLINK")) - ((:epipe "EPIPE")) - ((:edom "EDOM")) - ((:erange "ERANGE")) - ((:edeadlk "EDEADLK")) - ((:enametoolong "ENAMETOOLONG")) - ((:enolck "ENOLCK")) - ((:enosys "ENOSYS")) - ((:enotempty "ENOTEMPTY")) - ((:echrng "ECHRNG") :optional t) - ((:el2nsync "EL2NSYNC") :optional t) - ((:el3hlt "EL3HLT") :optional t) - ((:el3rst "EL3RST") :optional t) - ((:elnrng "ELNRNG") :optional t) - ((:eunatch "EUNATCH") :optional t) - ((:enocsi "ENOCSI") :optional t) - ((:el2hlt "EL2HLT") :optional t) - ((:ebade "EBADE") :optional t) - ((:ebadr "EBADR") :optional t) - ((:exfull "EXFULL") :optional t) - ((:enoano "ENOANO") :optional t) - ((:ebadrqc "EBADRQC") :optional t) - ((:ebadslt "EBADSLT") :optional t) - ((:edeadlock "EDEADLOCK") :optional t) - ((:ebfont "EBFONT") :optional t) - ((:enostr "ENOSTR") :optional t) - ((:enodata "ENODATA") :optional t) - ((:etime "ETIME") :optional t) - ((:enosr "ENOSR") :optional t) - ((:enopkg "ENOPKG") :optional t) - ((:eadv "EADV") :optional t) - ((:esrmnt "ESRMNT") :optional t) - ((:ecomm "ECOMM") :optional t) - ((:edotdot "EDOTDOT") :optional t) - ((:enotuniq "ENOTUNIQ") :optional t) - ((:ebadfd "EBADFD") :optional t) - ((:eremchg "EREMCHG") :optional t) - ((:elibacc "ELIBACC") :optional t) - ((:elibbad "ELIBBAD") :optional t) - ((:elibscn "ELIBSCN") :optional t) - ((:elibmax "ELIBMAX") :optional t) - ((:elibexec "ELIBEXEC") :optional t) - ((:eilseq "EILSEQ")) - ((:erestart "ERESTART") :optional t) - ((:estrpipe "ESTRPIPE") :optional t) - ((:euclean "EUCLEAN") :optional t) - ((:enotnam "ENOTNAM") :optional t) - ((:enavail "ENAVAIL") :optional t) - ((:eremoteio "EREMOTEIO") :optional t) - ((:enomedium "ENOMEDIUM") :optional t) - ((:emediumtype "EMEDIUMTYPE") :optional t) - ((:estale "ESTALE")) - ((:enotblk "ENOTBLK")) - ((:etxtbsy "ETXTBSY")) - ((:eusers "EUSERS")) - ((:eloop "ELOOP")) - ((:ewouldblock "EWOULDBLOCK")) - ((:enomsg "ENOMSG")) - ((:eidrm "EIDRM")) - ((:eproto "EPROTO")) - ((:emultihop "EMULTIHOP")) - ((:ebadmsg "EBADMSG")) - ((:eoverflow "EOVERFLOW")) - ((:edquot "EDQUOT")) - ((:einprogress "EINPROGRESS")) - ((:ealready "EALREADY")) - ;; TODO: These errors are related to sockets. However they - ;; might not be unique to them. Remove those that are unique - ;; and keep those that might be set elsewhere. - ((:eprotonosupport "EPROTONOSUPPORT")) - ((:esocktnosupport "ESOCKTNOSUPPORT")) - ((:enotsock "ENOTSOCK")) - ((:edestaddrreq "EDESTADDRREQ")) - ((:emsgsize "EMSGSIZE")) - ((:eprototype "EPROTOTYPE")) - ((:enoprotoopt "ENOPROTOOPT")) - ((:eremote "EREMOTE")) - ((:enolink "ENOLINK")) - ((:epfnosupport "EPFNOSUPPORT")) - ((:eafnosupport "EAFNOSUPPORT")) - ((:eaddrinuse "EADDRINUSE")) - ((:eaddrnotavail "EADDRNOTAVAIL")) - ((:enetdown "ENETDOWN")) - ((:enetunreach "ENETUNREACH")) - ((:enetreset "ENETRESET")) - ((:econnaborted "ECONNABORTED")) - ((:econnreset "ECONNRESET")) - ((:eisconn "EISCONN")) - ((:enotconn "ENOTCONN")) - ((:eshutdown "ESHUTDOWN")) - ((:etoomanyrefs "ETOOMANYREFS")) - ((:etimedout "ETIMEDOUT")) - ((:econnrefused "ECONNREFUSED")) - ((:ehostdown "EHOSTDOWN")) - ((:ehostunreach "EHOSTUNREACH")) - ((:enonet "ENONET") :optional t) - ((:enobufs "ENOBUFS")) - ((:enotsup "ENOTSUP")) - ((:eopnotsupp "EOPNOTSUPP"))) - - -;;;------------------------------------------------------------------------- -;;; sys/wait.h -;;;------------------------------------------------------------------------- - -(constant (wnohang "WNOHANG")) -(constant (wuntraced "WUNTRACED")) -(constant (wcontinued "WCONTINUED")) - - -;;;------------------------------------------------------------------------- ;;; sysconf(3) sys/unistd.h ;;;------------------------------------------------------------------------- diff --git a/src/syscalls/ffi-wrappers-unix.lisp b/src/syscalls/ffi-wrappers-unix.lisp deleted file mode 100644 index fbb690d..0000000 --- a/src/syscalls/ffi-wrappers-unix.lisp +++ /dev/null @@ -1,106 +0,0 @@ -;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- -;;; -;;; --- FFI wrappers. -;;; - -(in-package :iolib.syscalls) - -(c "#if defined(__linux__)") -(c "#undef _GNU_SOURCE") -(define "_XOPEN_SOURCE" 600) -(define "_LARGEFILE_SOURCE") -(define "_LARGEFILE64_SOURCE") -(define "_FILE_OFFSET_BITS" 64) -(c "#endif") - - -;;;------------------------------------------------------------------------- -;;; ERRNO-related functions -;;;------------------------------------------------------------------------- - -(include "errno.h") - -(declaim (inline errno %set-errno)) - -(defwrapper* ("iolib_get_errno" errno) :int - () - "return errno;") - -(defwrapper* ("iolib_set_errno" %set-errno) :int - ((value :int)) - "errno = value; return errno;") - - -;;;------------------------------------------------------------------------- -;;; waitpid status readers -;;;------------------------------------------------------------------------- -(include "sys/types.h" "sys/wait.h") - -(declaim (inline wifexited wexitstatus wtermsig wcoredump wifstopped - wstopsig wifcontinued)) - -(defwrapper ("WIFEXITED" wifexited) :int ;; boolean - (status :int)) - -(defwrapper ("WEXITSTATUS" wexitstatus) :int ;; unsigned-char - (status :int)) - -(defwrapper ("WIFSIGNALED" wifsignaled) :int - (status :int)) - -(defwrapper ("WTERMSIG" wtermsig) :int - (status :int)) - -(defwrapper* ("iolib_wcoredump" wcoredump) :int ;; boolean - ((status :int)) -" - #ifdef WCOREDUMP - return WCOREDUMP(status); - #else - return 0; - #endif -") - -(defwrapper ("WIFSTOPPED" wifstopped) :int ;; boolean - (status :int)) - -(defwrapper ("WSTOPSIG" wstopsig) :int - (status :int)) - -(defwrapper ("WIFCONTINUED" wifcontinued) :int ;; boolean - (status :int)) - - - -;;;------------------------------------------------------------------------- -;;; Socket message readers -;;;------------------------------------------------------------------------- - -(include "stdlib.h") ; needed on FreeBSD to define NULL -(include "sys/socket.h") - -(declaim (inline cmsg.space cmsg.len cmsg.firsthdr cmsg.data)) - -(defwrapper ("CMSG_SPACE" cmsg.space) :unsigned-int - (data-size :unsigned-int)) - -(defwrapper ("CMSG_LEN" cmsg.len) :unsigned-int - (data-size :unsigned-int)) - -(defwrapper ("CMSG_FIRSTHDR" cmsg.firsthdr) :pointer - (msg ("struct msghdr*" :pointer))) - -(defwrapper ("CMSG_DATA" cmsg.data) :pointer - (cmsg ("struct cmsghdr*" :pointer))) - - -;;;------------------------------------------------------------------------- -;;; Directory listing -;;;------------------------------------------------------------------------- - -(include "sys/types.h" "dirent.h") - -(declaim (inline dirfd)) - -(defwrapper (dirfd "dirfd") :int - (dirp ("DIR*" :pointer))) diff --git a/src/syscalls/pkgdcl.lisp b/src/syscalls/pkgdcl.lisp index 5d86f3e..b932224 100644 --- a/src/syscalls/pkgdcl.lisp +++ b/src/syscalls/pkgdcl.lisp @@ -10,6 +10,80 @@ (:use :iolib.base :cffi) (:shadow #:open #:close #:read #:write #:listen #:truncate #:ftruncate #:time) + (:import-from + :libfixposix + + ;;;---------------------------------------------------------------------- + ;;; C Types + ;;;---------------------------------------------------------------------- + + ;; Primitive type sizes + #:size-of-char + #:size-of-short + #:size-of-int + #:size-of-long + #:size-of-long-long + #:size-of-pointer + + ;; POSIX Types + #:size-t #:size-of-size-t + #:ssize-t #:size-of-ssize-t + #:off-t #:size-of-off-t + + + ;;;---------------------------------------------------------------------- + ;;; C Constants + ;;;---------------------------------------------------------------------- + + ;; Syscall error codes + #:errno-values + #:e2big #:eacces #:eaddrinuse #:eaddrnotavail + #:eafnosupport #:ealready #:ebadf #:ebadmsg #:ebusy #:ecanceled + #:echild #:econnaborted #:econnrefused #:econnreset #:edeadlk + #:edestaddrreq #:edom #:edquot #:eexist #:efault #:efbig + #:ehostunreach #:eidrm #:eilseq #:einprogress #:eintr #:einval #:eio + #:eisconn #:eisdir #:eloop #:emfile #:emlink #:emsgsize #:emultihop + #:enametoolong #:enetdown #:enetreset #:enetunreach #:enfile + #:enobufs #:enodata #:enodev #:enoent #:enoexec #:enolck #:enolink + #:enomem #:enomsg #:enoprotoopt #:enospc #:enosr #:enostr #:enosys + #:enotconn #:enotdir #:enotempty #:enotsock #:enotsup #:enotty + #:enxio #:eopnotsupp #:eoverflow #:eperm #:epipe #:eproto + #:eprotonosupport #:eprototype #:erange #:erofs #:espipe #:esrch + #:estale #:etime #:etimedout #:etxtbsy #:ewouldblock #:exdev + #:ebug + + ;; Waitpid() + #:wnohang + #:wuntraced + #:wcontinued + + + ;;;---------------------------------------------------------------------- + ;;; Syscalls + ;;;---------------------------------------------------------------------- + + ;; Errno-related functions + #:errno + + ;; Signals + #:wifexited + #:wexitstatus + #:wifsignaled + #:wtermsig + #:wcoredump + #:wifstopped + #:wstopsig + #:wifcontinued + + ;; CMSG readers + #:cmsg.firsthdr + #:cmsg.nxthdr + #:cmsg.align + #:cmsg.space + #:cmsg.len + #:cmsg.data + ) + (:export ;;;---------------------------------------------------------------------- @@ -289,26 +363,20 @@ ;; Syscall error codes #:errno-values - #:eperm #:enoent #:esrch #:eintr #:eio #:enxio #:e2big #:enoexec - #:ebadf #:echild #:enomem #:eacces #:efault #:ebusy #:eexist - #:exdev #:enodev #:enotdir #:eisdir #:einval #:enfile #:emfile - #:enotty #:efbig #:enospc #:espipe #:erofs #:emlink #:epipe #:edom - #:erange #:edeadlk #:enametoolong #:enolck #:enosys #:enotempty - #:echrng #:el2nsync #:el3hlt #:el3rst #:elnrng #:eunatch #:enocsi - #:el2hlt #:ebade #:ebadr #:exfull #:enoano #:ebadrqc #:ebadslt - #:edeadlock #:ebfont #:enostr #:enodata #:etime #:enosr #:enopkg - #:eadv #:esrmnt #:ecomm #:edotdot #:enotuniq #:ebadfd #:elibscn - #:elibmax #:elibexec #:eilseq #:erestart #:estrpipe #:euclean - #:enotnam #:enavail #:eremoteio #:enomedium #:emediumtype #:estale - #:enotblk #:etxtbsy #:eusers #:eloop #:ewouldblock #:enomsg #:eidrm - #:eproto #:emultihop #:ebadmsg #:eoverflow #:edquot #:einprogress - #:ealready #:eprotonosupport #:esocktnosupport #:enotsock - #:edestaddrreq #:emsgsize #:eprototype #:enoprotoopt #:eremote - #:enolink #:epfnosupport #:eafnosupport #:eaddrinuse #:eaddrnotavail - #:enetdown #:enetunreach #:enetreset #:econnaborted #:econnreset - #:eisconn #:enotconn #:eshutdown #:etoomanyrefs #:etimedout - #:econnrefused #:ehostdown #:ehostunreach #:enonet #:enobufs - #:eopnotsupp + #:e2big #:eacces #:eaddrinuse #:eaddrnotavail + #:eafnosupport #:ealready #:ebadf #:ebadmsg #:ebusy #:ecanceled + #:echild #:econnaborted #:econnrefused #:econnreset #:edeadlk + #:edestaddrreq #:edom #:edquot #:eexist #:efault #:efbig + #:ehostunreach #:eidrm #:eilseq #:einprogress #:eintr #:einval #:eio + #:eisconn #:eisdir #:eloop #:emfile #:emlink #:emsgsize #:emultihop + #:enametoolong #:enetdown #:enetreset #:enetunreach #:enfile + #:enobufs #:enodata #:enodev #:enoent #:enoexec #:enolck #:enolink + #:enomem #:enomsg #:enoprotoopt #:enospc #:enosr #:enostr #:enosys + #:enotconn #:enotdir #:enotempty #:enotsock #:enotsup #:enotty + #:enxio #:eopnotsupp #:eoverflow #:eperm #:epipe #:eproto + #:eprotonosupport #:eprototype #:erange #:erofs #:espipe #:esrch + #:estale #:etime #:etimedout #:etxtbsy #:ewouldblock #:exdev + #:ebug ;;;---------------------------------------------------------------------- @@ -481,9 +549,11 @@ #:getgrgid ;; CMSG readers + #:cmsg.firsthdr + #:cmsg.nxthdr + #:cmsg.align #:cmsg.space #:cmsg.len - #:cmsg.firsthdr #:cmsg.data -- 2.11.4.GIT