1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-
6 (in-package :iolib.syscalls
)
8 (c "#if defined(__linux__)")
9 (define "_XOPEN_SOURCE" 600)
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 (defwrapper ("lseek" %sys-lseek
)
28 (offset ("off_t" off-t
))
31 (defwrapper ("truncate" %sys-truncate
)
32 ("int" (return-wrapper :int
:error-generator return-posix-error
/restart
))
33 (path ("const char*" filename-designator
))
34 (length ("off_t" off-t
)))
36 (defwrapper ("ftruncate" %sys-ftruncate
)
37 ("int" (return-wrapper :int
:error-generator return-posix-error
/restart
))
39 (length ("off_t" off-t
)))
41 (defwrapper ("mmap" %sys-mmap
)
44 (length ("size_t" size-t
))
48 (offset ("off_t" off-t
)))
50 (defwrapper ("stat" %%sys-stat
)
52 (file-name ("const char*" filename-designator
))
53 (buf ("struct stat*" :pointer
)))
55 (defwrapper ("fstat" %%sys-fstat
)
57 (filedes ("int" :int
))
58 (buf ("struct stat*" :pointer
)))
60 (defwrapper ("lstat" %%sys-lstat
)
62 (file-name ("const char*" filename-designator
))
63 (buf ("struct stat*" :pointer
)))
65 (defwrapper ("pread" %sys-pread
)
66 ("ssize_t" (return-wrapper ssize-t
:error-generator return-posix-error
/restart
))
69 (count ("size_t" size-t
))
70 (offset ("off_t" off-t
)))
72 (defwrapper ("pwrite" %sys-pwrite
)
73 ("ssize_t" (return-wrapper ssize-t
:error-generator return-posix-error
/restart
))
76 (count ("size_t" size-t
))
77 (offset ("off_t" off-t
)))
80 ;;;-----------------------------------------------------------------------------
81 ;;; ERRNO-related functions
82 ;;;-----------------------------------------------------------------------------
84 (defwrapper* "get_errno" :int
()
87 (defwrapper* "set_errno" :int
((value :int
))
91 (defwrapper ("strerror_r" %sys-strerror-r
)
95 (buflen ("size_t" size-t
)))