1 ;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
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)
17 ;;;-------------------------------------------------------------------------
18 ;;; ERRNO-related functions
19 ;;;-------------------------------------------------------------------------
23 (declaim (inline errno %set-errno
))
25 (defwrapper* ("iolib_get_errno" errno
) :int
29 (defwrapper* ("iolib_set_errno" %set-errno
) :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
45 (defwrapper ("WEXITSTATUS" wexitstatus
) :int
;; unsigned-char
48 (defwrapper ("WIFSIGNALED" wifsignaled
) :int
51 (defwrapper ("WTERMSIG" wtermsig
) :int
54 (defwrapper* ("iolib_wcoredump" wcoredump
) :int
;; boolean
58 return WCOREDUMP(status);
64 (defwrapper ("WIFSTOPPED" wifstopped
) :int
;; boolean
67 (defwrapper ("WSTOPSIG" wstopsig
) :int
70 (defwrapper ("WIFCONTINUED" wifcontinued
) :int
;; boolean
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 ;;;-------------------------------------------------------------------------
99 ;;;-------------------------------------------------------------------------
101 (include "sys/types.h" "dirent.h")
103 (declaim (inline dirfd
))
105 (defwrapper (dirfd "dirfd") :int
106 (dirp ("DIR*" :pointer
)))