1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-
6 (in-package :iolib.syscalls
)
8 (define "_XOPEN_SOURCE" 600)
9 (c "#if defined(__linux__)")
10 (define "_LARGEFILE_SOURCE")
11 (define "_LARGEFILE64_SOURCE")
12 (define "_FILE_OFFSET_BITS" 64)
15 (include "string.h" "errno.h" "sys/types.h" "sys/stat.h"
16 "unistd.h" "sys/mman.h")
19 ;;;-----------------------------------------------------------------------------
20 ;;; Large-file support
21 ;;;-----------------------------------------------------------------------------
23 ;;; FIXME: this is only necessary on Linux right?
25 (declaim (inline %sys-lseek
))
26 (defwrapper ("lseek" %sys-lseek
)
27 ("off_t" (return-wrapper off-t
:error-generator signal-posix-error
))
32 (declaim (inline %sys-truncate
))
33 (defwrapper ("truncate" %sys-truncate
)
34 ("int" (return-wrapper :int
:error-generator signal-posix-error
/restart
))
35 (path ("const char*" filename-designator
))
38 (declaim (inline %sys-ftruncate
))
39 (defwrapper ("ftruncate" %sys-ftruncate
)
40 ("int" (return-wrapper :int
:error-generator signal-posix-error
/restart
))
44 (declaim (inline %sys-mmap
))
45 (defwrapper ("mmap" %sys-mmap
)
46 ("void*" (return-wrapper :pointer
:error-generator signal-posix-error
))
54 (declaim (inline %%sys-stat
))
55 (defwrapper ("stat" %%sys-stat
)
56 ("int" (return-wrapper :int
:error-generator signal-posix-error
))
57 (file-name ("const char*" filename-designator
))
58 (buf ("struct stat*" :pointer
)))
60 (declaim (inline %%sys-fstat
))
61 (defwrapper ("fstat" %%sys-fstat
)
62 ("int" (return-wrapper :int
:error-generator signal-posix-error
))
64 (buf ("struct stat*" :pointer
)))
66 (declaim (inline %%sys-lstat
))
67 (defwrapper ("lstat" %%sys-lstat
)
68 ("int" (return-wrapper :int
:error-generator signal-posix-error
))
69 (file-name ("const char*" filename-designator
))
70 (buf ("struct stat*" :pointer
)))
72 (declaim (inline %sys-pread
))
73 (defwrapper ("pread" %sys-pread
)
74 ("ssize_t" (return-wrapper ssize-t
:error-generator signal-posix-error
/restart
))
80 (declaim (inline %sys-pwrite
))
81 (defwrapper ("pwrite" %sys-pwrite
)
82 ("ssize_t" (return-wrapper ssize-t
:error-generator signal-posix-error
/restart
))
89 ;;;-----------------------------------------------------------------------------
90 ;;; ERRNO-related functions
91 ;;;-----------------------------------------------------------------------------
93 (declaim (inline %sys-errno
))
94 (defwrapper* ("iolib_get_errno" %sys-errno
) :int
98 (declaim (inline %%sys-set-errno
))
99 (defwrapper* ("iolib_set_errno" %%sys-set-errno
) :int
104 (declaim (inline %sys-strerror-r
))
105 (defwrapper ("strerror_r" %sys-strerror-r
)
106 ("int" (return-wrapper :int
:error-generator signal-posix-error
))