Newer
Older
;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
Stelian Ionescu
committed
;;; --- Package definition
;;;
(in-package :common-lisp-user)
(defpackage :iolib.syscalls
(:nicknames :isys :iolib/syscalls)
(:shadow #:open #:close #:read #:write #:listen
#:truncate #:ftruncate #:time)
Stelian Ionescu
committed
;; Specials
(:export
;; Deprecated, to be removed. 2011-09-05
Stelian Ionescu
committed
#:*environ*)
;; Simple POSIX Types
(:export
#:bool
#:size-t
#:ssize-t
#:intptr-t
#:uintptr-t
#:pid-t
#:gid-t
#:uid-t
#:off-t
#:mode-t
#:time-t
#:useconds-t
#:suseconds-t
#:dev-t
#:ino-t
#:nlink-t
#:blksize-t
#:blkcnt-t
#:nfds-t
#:rlim-t
#:id-t
#:clockid-t)
Stelian Ionescu
committed
;;-----------------------------------------
;; Error conditions, wrappers and definers
;;-----------------------------------------
(:export
Stelian Ionescu
committed
#:iolib-condition #:iolib-error #:syscall-error
#:code-of #:identifier-of #:message-of #:handle-of #:handle2-of
#:make-syscall-error #:syscall-error-p #:get-syscall-error-condition
#:signal-syscall-error #:signal-syscall-error/restart
#:poll-error #:event-type-of #:poll-timeout
Stelian Ionescu
committed
;; Syscall return wrapper
#:syscall-wrapper
#:error-predicate-of
#:error-location-of
#:return-filter-of
#:error-generator-of
#:syscall-restart-p
#:base-type-of
#:never-fails
#:signal-syscall-error
#:signal-syscall-error-kw
#:signal-syscall-error/restart
Stelian Ionescu
committed
Stelian Ionescu
committed
;; Syscall definers
#:defentrypoint
#:defcfun*
#:defsyscall
Stelian Ionescu
committed
Stelian Ionescu
committed
;; CFFI Type Designators
#:pointer-or-nil
#:pointer-or-nil-designator
#:bool
#:bool-designator
Stelian Ionescu
committed
Stelian Ionescu
committed
;; SSTRING <-> CSTRING
#:+cstring-path-max+
#:cstring-to-sstring
#:sstring-to-cstring
#:with-cstring-to-sstring
#:with-sstring-to-cstring
;; Misc
#:repeat-upon-condition
#:repeat-upon-eintr
#:repeat-decreasing-timeout
#:repeat-upon-condition-decreasing-timeout)
;;--------------------------------
;; Structs, slots and C constants
;;--------------------------------
(:export ;; errno.h
Stelian Ionescu
committed
#:errno-values
#:e2big #:eacces #:eaddrinuse #:eaddrnotavail
#:eafnosupport #:ealready #:ebadf #:ebadmsg #:ebusy #:ecanceled
#:echild #:econnaborted #:econnrefused #:econnreset #:edeadlk
#:edestaddrreq #:edom #:edquot #:eexist #:efault #:efbig #:ehostdown
Stelian Ionescu
committed
#: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 #:enonet #:enoprotoopt #:enospc #:enosr #:enostr
#:enosys #:enotconn #:enotdir #:enotempty #:enotsock #:enotsup #:enotty
Stelian Ionescu
committed
#:enxio #:eopnotsupp #:eoverflow #:eperm #:epipe #:eproto
#:eprotonosupport #:eprototype #:erange #:erofs #:eshutdown #:espipe
#:esrch #:estale #:etime #:etimedout #:etxtbsy #:ewouldblock #:exdev
Stelian Ionescu
committed
#:ebug)
(:export ;; fcntl.h
;; Open()
#:o-rdonly
#:o-wronly
#:o-rdwr
#:o-creat
#:o-excl
#:o-trunc
#:o-append
#:o-noctty
#:o-nonblock
#:o-ndelay
#:o-sync
#:o-nofollow
#:o-async
Stelian Ionescu
committed
#:o-cloexec
;; Fcntl()
#:f-dupfd
#:f-getfd
#:f-setfd
#:f-getfl
#:f-setfl
#:f-getlk
#:f-setlk
#:f-setlkw
#:f-getown
#:f-setown
#:f-rdlck
#:f-wrlck
#:f-unlck
#+linux #:f-getsig
#+linux #:f-setsig
#+linux #:f-setlease
#+linux #:f-getlease)
(:export ;; unistd.h
;; Lseek()
;; Access()
Stelian Ionescu
committed
#:f-ok)
(:export ;; time.h
;; struct timespec
Stelian Ionescu
committed
#:sec #:nsec
;; Clock_gettime() et al.
#:clock-realtime
#:clock-monotonic)
(:export ;; sys/stat.h
#:path-max
;; struct stat
Stelian Ionescu
committed
#:dev #:stat-dev
#:ino #:stat-ino
#:mode #:stat-mode
#:nlink #:stat-nlink
#:uid #:stat-uid
#:gid #:stat-gid
#:rdev #:stat-rdev
#:size #:stat-size
#:blksize #:stat-blksize
#:blocks #:stat-blocks
#:atime #:stat-atime
#:mtime #:stat-mtime
#:ctime #:stat-ctime
;; Stat()
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#:s-irwxu
#:s-irusr
#:s-iwusr
#:s-ixusr
#:s-ifmt
#:s-ififo
#:s-ifchr
#:s-ifdir
#:s-ifblk
#:s-ifreg
#:s-ifwht
#:s-iread
#:s-iwrite
#:s-iexec
#:s-irwxg
#:s-irgrp
#:s-iwgrp
#:s-ixgrp
#:s-irwxo
#:s-iroth
#:s-iwoth
#:s-ixoth
#:s-isuid
#:s-isgid
#:s-isvtx
#:s-iflnk
Stelian Ionescu
committed
#:s-ifsock)
(:export ;; sys/ioctl.h
#:fionbio
#:fionread)
(:export ;; sys/wait.h
;; Waitpid()
#:wnohang
#:wuntraced
#:wcontinued)
(:export ;; signal.h
;; Kill()
#:sigterm
#:sigusr1
#:sigusr2
#:sigchld
#:sigcont
#:sigbus
#:sigpoll
#:sigprof
#:sigsys
#:sigtrap
#:sigurg
#:sigvtalrm
#:sigemt
#:sigio
#:sigcld
#:sigpwr
#:siginfo
#:siglost
Stelian Ionescu
committed
;; struct sigaction
Stelian Ionescu
committed
#:handler
;; Sigaction()
#:sa-nocldstop
#:sa-nocldwait
#:sa-nodefer
#:sa-onstack
#:sa-resethand
#:sa-restart
Stelian Ionescu
committed
#:sa-siginfo)
(:export ;; sys/mman.h
;; Mmap()
#:prot-none
#:prot-read
#:prot-write
#:prot-exec
#:map-shared
#:map-private
#:map-fixed
Stelian Ionescu
committed
#:map-failed)
(:export ;; sys/select.h
;; fd_set
Stelian Ionescu
committed
;; struct timeval
Stelian Ionescu
committed
#:sec #:usec)
(:export ;; sys/poll.h
;; struct pollfd
Stelian Ionescu
committed
#:fd #:events #:revents
;; Poll()
#:pollin
#:pollrdnorm
#:pollrdband
#:pollpri
#:pollout
#:pollwrnorm
#:pollwrband
#:pollerr
#:pollrdhup
#:pollhup
Stelian Ionescu
committed
#:pollnval)
(:export ;; dirent.h
;; struct dirent
Stelian Ionescu
committed
#:fileno #:type #:name
;; Readdir()
#:dt-unknown
#:dt-fifo
#:dt-chr
#:dt-dir
#:dt-blk
#:dt-reg
#:dt-lnk
#:dt-sock
#:dt-wht)
(:export ;; sys/resource.h
;; struct rlimit
Stelian Ionescu
committed
#:cur #:max
;; struct rusage
Stelian Ionescu
committed
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
#:utime #:stime #:maxrss #:ixrss #:idrss #:isrss
#:minflt #:majflt #:nswap #:inblock #:outblock
#:msgsnd #:msgrcv #:nsignals #:nvcsw #:nivcsw
;; Getrlimit()
#:prio-process
#:prio-pgrp
#:prio-user
#:rlim-infinity
#:rusage-self
#:rusage-children
#:rlimit-as
#:rlimit-core
#:rlimit-cpu
#:rlimit-data
#:rlimit-fsize
#:rlimit-memlock
#:rlimit-nofile
#:rlimit-nproc
#:rlimit-rss
#:rlimit-stack
#+linux #:rlim-saved-max
#+linux #:rlim-saved-cur
#+linux #:rlimit-locks
#+linux #:rlimit-msgqueue
#+linux #:rlimit-nlimits
#+linux #:rlimit-nice
#+linux #:rlimit-rtprio
#+linux #:rlimit-sigpending
#+bsd #:rlimit-sbsize)
(:export ;; sys/utsname.h
;; struct utsname
Stelian Ionescu
committed
#:sysname #:nodename #:release #:version #:machine)
(:export ;; pwd.h
;; struct passwd
Stelian Ionescu
committed
#:name #:passwd #:uid #:gid #:gecos #:dir #:shell)
(:export ;; grp.h
;; struct group
Stelian Ionescu
committed
#:name #:passwd #:gid #:mem)
#+linux
(:export ;; sys/epoll.h
;; union epoll_data_t
Stelian Ionescu
committed
#:ptr #:fd #:u32 #:u64
;; struct epoll_event
Stelian Ionescu
committed
#:events #:data
;; Epoll_ctl()
#:epoll-ctl-add
#:epoll-ctl-del
#:epoll-ctl-mod
#:epollin
#:epollrdnorm
#:epollrdband
#:epollpri
#:epollout
#:epollwrnorm
#:epollwrband
#:epollerr
#:epollhup
#:epollmsg
#:epolloneshot
#:epollet)
#+bsd
(:export ;; sys/event.h
;; struct kevent
Stelian Ionescu
committed
#:ident #:filter #:flags #:fflags #:data #:udata
;; Kevent()
#+bsd #:ev-add
#+bsd #:ev-enable
#+bsd #:ev-disable
#+bsd #:ev-delete
#+bsd #:ev-oneshot
#+bsd #:ev-clear
#+bsd #:ev-eof
#+bsd #:ev-error
#+bsd #:evfilt-read
#+bsd #:evfilt-write
#+bsd #:evfilt-aio
#+bsd #:evfilt-vnode
#+bsd #:evfilt-proc
#+bsd #:evfilt-signal
#+bsd #:evfilt-timer
Stelian Ionescu
committed
#-darwin #:evfilt-netdev
#+bsd #:note-delete
#+bsd #:note-write
#+bsd #:note-extend
#+bsd #:note-attrib
#+bsd #:note-link
#+bsd #:note-rename
#+bsd #:note-revoke
#+bsd #:note-exit
#+bsd #:note-fork
#+bsd #:note-exec
#+bsd #:note-track
#+bsd #:note-trackerr
Stelian Ionescu
committed
#-darwin #:note-linkup
#-darwin #:note-linkdown
#-darwin #:note-linkinv)
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
(:export ;; syslog.h
;; Openlog() options
#:log-pid
#:log-cons
#:log-odelay
#:log-ndelay
#:log-nowait
#:log-perror
;; Syslog() facilities
#:log-kern
#:log-user
#:log-mail
#:log-daemon
#:log-auth
#:log-authpriv
#:log-syslog
#:log-lpr
#:log-news
#:log-uucp
#:log-cron
#:log-ftp
#+bsd #:log-security
#:log-local0
#:log-local1
#:log-local2
#:log-local3
#:log-local4
#:log-local5
#:log-local6
#:log-local7
;; Syslog() levels
#:log-emerg
#:log-alert
#:log-crit
#:log-err
#:log-warning
#:log-notice
#:log-info
#:log-debug)
Stelian Ionescu
committed
(:export ;; CFFI additions
#:sizeof)
Stelian Ionescu
committed
;;;----------
;;; Syscalls
;;;----------
(:export ;; Errno-related functions
Stelian Ionescu
committed
#:strerror)
(:export ;; Memory manipulation functions
Stelian Ionescu
committed
#:memmove)
(:export ;; Files
#:open
#:creat
#:pipe
#:mkfifo
#:umask
#:lseek
#:access
#:truncate
#:ftruncate
#:rename
#:link
#:symlink
#:readlink
#:realpath
#:unlink
#:chown
#:fchown
#:lchown
#:chmod
Stelian Ionescu
committed
#:fchmod)
(:export ;; I/O
#:read
#:write
#:readv
#:writev
#:pread
#:pwrite)
(:export ;; Stat
#:stat
#:fstat
#:lstat
#:sync
#:fsync
Stelian Ionescu
committed
(:export ;; Directories
#:mkdir
#:rmdir
#:chdir
#:fchdir
#:getcwd
Stelian Ionescu
committed
#:mkdtemp)
(:export ;; File descriptors
#:close
#:dup
#:dup2
#:fcntl
#:ioctl
Stelian Ionescu
committed
#:fd-cloexec-p
#:fd-nonblock-p
Stelian Ionescu
committed
(:export ;; TTYs
Stelian Ionescu
committed
#:openpt
Stelian Ionescu
committed
#:ptsname)
(:export ;; I/O Polling
#:select
#:copy-fd-set
#:fd-clr
Stelian Ionescu
committed
#:fd-isset
Stelian Ionescu
committed
#:fd-zero
#:poll
#+linux #:epoll-create
#+linux #:epoll-ctl
#+linux #:epoll-wait
#+bsd #:kqueue
#+bsd #:kevent
Stelian Ionescu
committed
#+bsd #:ev-set)
(:export ;; Socket message readers
#:cmsg.firsthdr
#:cmsg.nxthdr
#:cmsg.space
#:cmsg.len
#:cmsg.data)
(:export ;; Directory walking
#:opendir
#:closedir
#:readdir
#:rewinddir
#:seekdir
Stelian Ionescu
committed
#:telldir)
(:export ;; Memory mapping
Stelian Ionescu
committed
#:munmap)
(:export ;; Process creation and info
#:waitpid
#:getpid
#:getppid
Stelian Ionescu
committed
#+linux #:gettid
#:getuid
#:setuid
#:geteuid
#:seteuid
#:getgid
#:setgid
#:getegid
#:setegid
#:setreuid
#:setregid
#:getpgid
#:setpgid
#:getpgrp
#:setpgrp
#:setsid
#:getrlimit
#:setrlimit
#:getrusage
#:getpriority
#:setpriority
#:nice
Stelian Ionescu
committed
#:exit)
(:export ;; Signals
#:wifexited
#:wexitstatus
#:wcoredump
#:wifstopped
#:wstopsig
Stelian Ionescu
committed
#:wifcontinued)
(:export ;; Time
Stelian Ionescu
committed
#:clock-getres
#:clock-gettime
#:clock-settime
#:get-monotonic-time)
(:export ;; Environment
#:os-environ
#:getenv
#:setenv
#:unsetenv
Stelian Ionescu
committed
#:clearenv)
(:export ;; Hostname info
Stelian Ionescu
committed
#:getdonainname
#:uname)
(:export ;; User info
Stelian Ionescu
committed
#:getpwnam)
(:export ;; Group info