Wrap WIFSIGNALED
[iolib.git] / src / syscalls / ffi-wrappers-unix.lisp
blobfbb690d3f05fd9ea3e74aced171800f09438bbd0
1 ;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; --- FFI wrappers.
4 ;;;
6 (in-package :iolib.syscalls)
8 (c "#if defined(__linux__)")
9 (c "#undef _GNU_SOURCE")
10 (define "_XOPEN_SOURCE" 600)
11 (define "_LARGEFILE_SOURCE")
12 (define "_LARGEFILE64_SOURCE")
13 (define "_FILE_OFFSET_BITS" 64)
14 (c "#endif")
17 ;;;-------------------------------------------------------------------------
18 ;;; ERRNO-related functions
19 ;;;-------------------------------------------------------------------------
21 (include "errno.h")
23 (declaim (inline errno %set-errno))
25 (defwrapper* ("iolib_get_errno" errno) :int
27 "return errno;")
29 (defwrapper* ("iolib_set_errno" %set-errno) :int
30 ((value :int))
31 "errno = value; return errno;")
34 ;;;-------------------------------------------------------------------------
35 ;;; waitpid status readers
36 ;;;-------------------------------------------------------------------------
37 (include "sys/types.h" "sys/wait.h")
39 (declaim (inline wifexited wexitstatus wtermsig wcoredump wifstopped
40 wstopsig wifcontinued))
42 (defwrapper ("WIFEXITED" wifexited) :int ;; boolean
43 (status :int))
45 (defwrapper ("WEXITSTATUS" wexitstatus) :int ;; unsigned-char
46 (status :int))
48 (defwrapper ("WIFSIGNALED" wifsignaled) :int
49 (status :int))
51 (defwrapper ("WTERMSIG" wtermsig) :int
52 (status :int))
54 (defwrapper* ("iolib_wcoredump" wcoredump) :int ;; boolean
55 ((status :int))
57 #ifdef WCOREDUMP
58 return WCOREDUMP(status);
59 #else
60 return 0;
61 #endif
64 (defwrapper ("WIFSTOPPED" wifstopped) :int ;; boolean
65 (status :int))
67 (defwrapper ("WSTOPSIG" wstopsig) :int
68 (status :int))
70 (defwrapper ("WIFCONTINUED" wifcontinued) :int ;; boolean
71 (status :int))
75 ;;;-------------------------------------------------------------------------
76 ;;; Socket message readers
77 ;;;-------------------------------------------------------------------------
79 (include "stdlib.h") ; needed on FreeBSD to define NULL
80 (include "sys/socket.h")
82 (declaim (inline cmsg.space cmsg.len cmsg.firsthdr cmsg.data))
84 (defwrapper ("CMSG_SPACE" cmsg.space) :unsigned-int
85 (data-size :unsigned-int))
87 (defwrapper ("CMSG_LEN" cmsg.len) :unsigned-int
88 (data-size :unsigned-int))
90 (defwrapper ("CMSG_FIRSTHDR" cmsg.firsthdr) :pointer
91 (msg ("struct msghdr*" :pointer)))
93 (defwrapper ("CMSG_DATA" cmsg.data) :pointer
94 (cmsg ("struct cmsghdr*" :pointer)))
97 ;;;-------------------------------------------------------------------------
98 ;;; Directory listing
99 ;;;-------------------------------------------------------------------------
101 (include "sys/types.h" "dirent.h")
103 (declaim (inline dirfd))
105 (defwrapper (dirfd "dirfd") :int
106 (dirp ("DIR*" :pointer)))