First phase of switch to LibFixPOSIX: add LFP bindings and remove CFFI wrappers
[iolib.git] / src / syscalls / pkgdcl.lisp
blobb932224725cad2d5e3c09928ed31e300e2725af5
1 ;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; --- Package definition.
4 ;;;
6 (in-package :common-lisp-user)
8 (defpackage :iolib.syscalls
9 (:nicknames #:isys)
10 (:use :iolib.base :cffi)
11 (:shadow #:open #:close #:read #:write #:listen
12 #:truncate #:ftruncate #:time)
13 (:import-from
14 :libfixposix
16 ;;;----------------------------------------------------------------------
17 ;;; C Types
18 ;;;----------------------------------------------------------------------
20 ;; Primitive type sizes
21 #:size-of-char
22 #:size-of-short
23 #:size-of-int
24 #:size-of-long
25 #:size-of-long-long
26 #:size-of-pointer
28 ;; POSIX Types
29 #:size-t #:size-of-size-t
30 #:ssize-t #:size-of-ssize-t
31 #:off-t #:size-of-off-t
34 ;;;----------------------------------------------------------------------
35 ;;; C Constants
36 ;;;----------------------------------------------------------------------
38 ;; Syscall error codes
39 #:errno-values
40 #:e2big #:eacces #:eaddrinuse #:eaddrnotavail
41 #:eafnosupport #:ealready #:ebadf #:ebadmsg #:ebusy #:ecanceled
42 #:echild #:econnaborted #:econnrefused #:econnreset #:edeadlk
43 #:edestaddrreq #:edom #:edquot #:eexist #:efault #:efbig
44 #:ehostunreach #:eidrm #:eilseq #:einprogress #:eintr #:einval #:eio
45 #:eisconn #:eisdir #:eloop #:emfile #:emlink #:emsgsize #:emultihop
46 #:enametoolong #:enetdown #:enetreset #:enetunreach #:enfile
47 #:enobufs #:enodata #:enodev #:enoent #:enoexec #:enolck #:enolink
48 #:enomem #:enomsg #:enoprotoopt #:enospc #:enosr #:enostr #:enosys
49 #:enotconn #:enotdir #:enotempty #:enotsock #:enotsup #:enotty
50 #:enxio #:eopnotsupp #:eoverflow #:eperm #:epipe #:eproto
51 #:eprotonosupport #:eprototype #:erange #:erofs #:espipe #:esrch
52 #:estale #:etime #:etimedout #:etxtbsy #:ewouldblock #:exdev
53 #:ebug
55 ;; Waitpid()
56 #:wnohang
57 #:wuntraced
58 #:wcontinued
61 ;;;----------------------------------------------------------------------
62 ;;; Syscalls
63 ;;;----------------------------------------------------------------------
65 ;; Errno-related functions
66 #:errno
68 ;; Signals
69 #:wifexited
70 #:wexitstatus
71 #:wifsignaled
72 #:wtermsig
73 #:wcoredump
74 #:wifstopped
75 #:wstopsig
76 #:wifcontinued
78 ;; CMSG readers
79 #:cmsg.firsthdr
80 #:cmsg.nxthdr
81 #:cmsg.align
82 #:cmsg.space
83 #:cmsg.len
84 #:cmsg.data
87 (:export
89 ;;;----------------------------------------------------------------------
90 ;;; C Types
91 ;;;----------------------------------------------------------------------
93 ;; Primitive type sizes
94 #:size-of-char
95 #:size-of-short
96 #:size-of-int
97 #:size-of-long
98 #:size-of-long-long
99 #:size-of-pointer
101 ;; POSIX Types
102 #:size-t #:size-of-size-t
103 #:ssize-t #:size-of-ssize-t
104 #:pid-t #:size-of-pid-t
105 #:gid-t #:size-of-gid-t
106 #:uid-t #:size-of-uid-t
107 #:off-t #:size-of-off-t
108 #:mode-t #:size-of-mode-t
109 #:time-t #:size-of-time-t
110 #:useconds-t #:size-of-useconds-t
111 #:suseconds-t #:size-of-suseconds-t
112 #:dev-t #:size-of-dev-t
113 #:ino-t #:size-of-ino-t
114 #:nlink-t #:size-of-nlink-t
115 #:blksize-t #:size-of-blksize-t
116 #:blkcnt-t #:size-of-blkcnt-t
117 #:nfds-t #:size-of-nfds-t
120 ;;;----------------------------------------------------------------------
121 ;;; C Constants
122 ;;;----------------------------------------------------------------------
124 ;; Open()
125 #:o-rdonly
126 #:o-wronly
127 #:o-rdwr
128 #:o-creat
129 #:o-excl
130 #:o-trunc
131 #:o-append
132 #:o-noctty
133 #:o-nonblock
134 #:o-ndelay
135 #:o-sync
136 #:o-nofollow
137 #:o-async
138 #+linux #:o-cloexec
140 ;; Lseek()
141 #:seek-set
142 #:seek-cur
143 #:seek-end
145 ;; Access()
146 #:r-ok
147 #:w-ok
148 #:x-ok
149 #:f-ok
151 ;; Stat()
152 #:s-irwxu
153 #:s-irusr
154 #:s-iwusr
155 #:s-ixusr
156 #:s-ifmt
157 #:s-ififo
158 #:s-ifchr
159 #:s-ifdir
160 #:s-ifblk
161 #:s-ifreg
162 #:s-ifwht
163 #:s-iread
164 #:s-iwrite
165 #:s-iexec
166 #:s-irwxg
167 #:s-irgrp
168 #:s-iwgrp
169 #:s-ixgrp
170 #:s-irwxo
171 #:s-iroth
172 #:s-iwoth
173 #:s-ixoth
174 #:s-isuid
175 #:s-isgid
176 #:s-isvtx
177 #:s-iflnk
178 #:s-ifsock
179 #:path-max
181 ;; Readdir()
182 #:dt-unknown
183 #:dt-fifo
184 #:dt-chr
185 #:dt-dir
186 #:dt-blk
187 #:dt-reg
188 #:dt-lnk
189 #:dt-sock
190 #:dt-wht
192 ;; Kill()
193 #:sighup
194 #:sigquit
195 #:sigtrap
196 #-linux #:sigemt
197 #:sigkill
198 #:sigbus
199 #:sigsys
200 #:sigpipe
201 #:sigalrm
202 #:sigurg
203 #:sigstop
204 #:sigtstp
205 #:sigcont
206 #:sigchld
207 #:sigcld
208 #:sigttin
209 #:sigttou
210 #:sigio
211 #:sigxcpu
212 #:sigxfsz
213 #:sigvtalrm
214 #:sigprof
215 #:sigwinch
216 #-linux #:siginfo
217 #:sigusr1
218 #:sigusr2
219 #+linux #:sigrtmin
220 #+linux #:sigrtmax
222 ;; Waitpid()
223 #:wnohang
224 #:wuntraced
225 #:wcontinued
227 ;; Sigaction()
228 #:sig-ign
229 #:sig-dfl
230 #:sa-nocldstop
231 #:sa-nocldwait
232 #:sa-nodefer
233 #:sa-onstack
234 #:sa-resethand
235 #:sa-restart
236 #:sa-siginfo
238 ;; Fcntl()
239 #:f-dupfd
240 #:f-getfd
241 #:f-setfd
242 #:f-getfl
243 #:f-setfl
244 #:f-getlk
245 #:f-setlk
246 #:f-setlkw
247 #:f-getown
248 #:f-setown
249 #:f-rdlck
250 #:f-wrlck
251 #:f-unlck
252 #+linux #:f-getsig
253 #+linux #:f-setsig
254 #+linux #:f-setlease
255 #+linux #:f-getlease
257 ;; Mmap()
258 #:prot-none
259 #:prot-read
260 #:prot-write
261 #:prot-exec
262 #:map-shared
263 #:map-private
264 #:map-fixed
265 #:map-failed
267 ;; Select()
268 #:fd-setsize
270 ;; Poll()
271 #:pollin
272 #:pollrdnorm
273 #:pollrdband
274 #:pollpri
275 #:pollout
276 #:pollwrnorm
277 #:pollwrband
278 #:pollerr
279 #:pollrdhup
280 #:pollhup
281 #:pollnval
283 ;; Epoll
284 #+linux #:epoll-ctl-add
285 #+linux #:epoll-ctl-del
286 #+linux #:epoll-ctl-mod
287 #+linux #:epollin
288 #+linux #:epollrdnorm
289 #+linux #:epollrdband
290 #+linux #:epollpri
291 #+linux #:epollout
292 #+linux #:epollwrnorm
293 #+linux #:epollwrband
294 #+linux #:epollerr
295 #+linux #:epollhup
296 #+linux #:epollmsg
297 #+linux #:epolloneshot
298 #+linux #:epollet
300 ;; Kevent
301 #+bsd #:ev-add
302 #+bsd #:ev-enable
303 #+bsd #:ev-disable
304 #+bsd #:ev-delete
305 #+bsd #:ev-oneshot
306 #+bsd #:ev-clear
307 #+bsd #:ev-eof
308 #+bsd #:ev-error
309 #+bsd #:evfilt-read
310 #+bsd #:evfilt-write
311 #+bsd #:evfilt-aio
312 #+bsd #:evfilt-vnode
313 #+bsd #:evfilt-proc
314 #+bsd #:evfilt-signal
315 #+bsd #:evfilt-timer
316 #+(and bsd (not darwin)) #:evfilt-netdev
317 #+bsd #:note-delete
318 #+bsd #:note-write
319 #+bsd #:note-extend
320 #+bsd #:note-attrib
321 #+bsd #:note-link
322 #+bsd #:note-rename
323 #+bsd #:note-revoke
324 #+bsd #:note-exit
325 #+bsd #:note-fork
326 #+bsd #:note-exec
327 #+bsd #:note-track
328 #+bsd #:note-trackerr
329 #+(and bsd (not darwin)) #:note-linkup
330 #+(and bsd (not darwin)) #:note-linkdown
331 #+(and bsd (not darwin)) #:note-linkinv
333 ;; Ioctl()
334 #:fionbio
335 #:fionread
337 ;; Getrlimit()
338 #:prio-process
339 #:prio-pgrp
340 #:prio-user
341 #:rlim-infinity
342 #:rusage-self
343 #:rusage-children
344 #:rlimit-as
345 #:rlimit-core
346 #:rlimit-cpu
347 #:rlimit-data
348 #:rlimit-fsize
349 #:rlimit-memlock
350 #:rlimit-nofile
351 #:rlimit-nproc
352 #:rlimit-rss
353 #:rlimit-stack
354 #+linux #:rlim-saved-max
355 #+linux #:rlim-saved-cur
356 #+linux #:rlimit-locks
357 #+linux #:rlimit-msgqueue
358 #+linux #:rlimit-nlimits
359 #+linux #:rlimit-nice
360 #+linux #:rlimit-rtprio
361 #+linux #:rlimit-sigpending
362 #+bsd #:rlimit-sbsize
364 ;; Syscall error codes
365 #:errno-values
366 #:e2big #:eacces #:eaddrinuse #:eaddrnotavail
367 #:eafnosupport #:ealready #:ebadf #:ebadmsg #:ebusy #:ecanceled
368 #:echild #:econnaborted #:econnrefused #:econnreset #:edeadlk
369 #:edestaddrreq #:edom #:edquot #:eexist #:efault #:efbig
370 #:ehostunreach #:eidrm #:eilseq #:einprogress #:eintr #:einval #:eio
371 #:eisconn #:eisdir #:eloop #:emfile #:emlink #:emsgsize #:emultihop
372 #:enametoolong #:enetdown #:enetreset #:enetunreach #:enfile
373 #:enobufs #:enodata #:enodev #:enoent #:enoexec #:enolck #:enolink
374 #:enomem #:enomsg #:enoprotoopt #:enospc #:enosr #:enostr #:enosys
375 #:enotconn #:enotdir #:enotempty #:enotsock #:enotsup #:enotty
376 #:enxio #:eopnotsupp #:eoverflow #:eperm #:epipe #:eproto
377 #:eprotonosupport #:eprototype #:erange #:erofs #:espipe #:esrch
378 #:estale #:etime #:etimedout #:etxtbsy #:ewouldblock #:exdev
379 #:ebug
382 ;;;----------------------------------------------------------------------
383 ;;; Syscalls
384 ;;;----------------------------------------------------------------------
386 ;; Specials
387 #:*default-open-mode*
388 #:*environ*
390 ;; Errno-related functions
391 #:strerror
392 #:errno
394 ;; Memory manipulation functions
395 #:memset
396 #:bzero
397 #:memcpy
398 #:memmove
400 ;; Files
401 #:read
402 #:write
403 #:readv
404 #:writev
405 #:pread
406 #:pwrite
407 #:open
408 #:creat
409 #:pipe
410 #:mkfifo
411 #:umask
412 #:lseek
413 #:access
414 #:truncate
415 #:ftruncate
416 #:rename
417 #:link
418 #:symlink
419 #:readlink
420 #:realpath
421 #:unlink
422 #:chown
423 #:fchown
424 #:lchown
425 #:chmod
426 #:fchmod
427 #:stat
428 #:fstat
429 #:lstat
430 #:sync
431 #:fsync
432 #:mkstemp
434 ;; Directories
435 #:mkdir
436 #:rmdir
437 #:chdir
438 #:fchdir
439 #:getcwd
440 #:mkdtemp
442 ;; File descriptors
443 #:close
444 #:dup
445 #:dup2
446 #:fcntl
447 #:fd-nonblock
448 #:ioctl
449 #:fd-open-p
451 ;; TTYs
452 #:posix-openpt
453 #:grantpt
454 #:unlockpt
455 #:ptsname
457 ;; I/O Polling
458 #:select
459 #:fd-zero
460 #:copy-fd-set
461 #:fd-isset
462 #:fd-clr
463 #:fd-set
464 #:poll
465 #+linux #:epoll-create
466 #+linux #:epoll-ctl
467 #+linux #:epoll-wait
468 #+bsd #:kqueue
469 #+bsd #:kevent
470 #+bsd #:ev-set
472 ;; Directory walking
473 #:opendir
474 #:closedir
475 #:readdir
476 #:rewinddir
477 #:seekdir
478 #:telldir
480 ;; Memory mapping
481 #:mmap
482 #:munmap
484 ;; Process creation and info
485 #:fork
486 #:execv
487 #:execvp
488 #:waitpid
489 #:getpid
490 #:getppid
491 #:gettid
492 #:getuid
493 #:setuid
494 #:geteuid
495 #:seteuid
496 #:getgid
497 #:setgid
498 #:getegid
499 #:setegid
500 #:setreuid
501 #:setregid
502 #:getpgid
503 #:setpgid
504 #:getpgrp
505 #:setpgrp
506 #:setsid
507 #:getrlimit
508 #:setrlimit
509 #:getrusage
510 #:getpriority
511 #:setpriority
512 #:nice
514 ;; Signals
515 #:kill
516 #:sigaction
517 #:wifexited
518 #:wexitstatus
519 #:wifsignaled
520 #:wtermsig
521 #:wcoredump
522 #:wifstopped
523 #:wstopsig
524 #:wifcontinued
526 ;; Time
527 #:usleep
528 #:time
529 #:gettimeofday
530 #:get-monotonic-time
532 ;; Environment
533 #:getenv
534 #:setenv
535 #:unsetenv
536 #:clearenv
538 ;; Local info
539 #:gethostname
540 #:getdomainname
541 #:uname
543 ;; User info
544 #:getpwnam
545 #:getpwuid
547 ;; Group info
548 #:getgrnam
549 #:getgrgid
551 ;; CMSG readers
552 #:cmsg.firsthdr
553 #:cmsg.nxthdr
554 #:cmsg.align
555 #:cmsg.space
556 #:cmsg.len
557 #:cmsg.data
560 ;;;----------------------------------------------------------------------
561 ;;; Error conditions, wrappers and definers
562 ;;;----------------------------------------------------------------------
564 #:iolib-condition #:iolib-error #:syscall-error
565 #:code-of #:identifier-of #:message-of #:handle-of #:handle2-of
566 #:make-syscall-error #:syscall-error-p #:get-syscall-error-condition
567 #:signal-syscall-error #:signal-syscall-error/restart
568 #:poll-error #:event-type-of #:poll-timeout
570 ;; Syscall return wrapper
571 #:syscall-wrapper
572 #:error-predicate-of
573 #:error-location-of
574 #:return-filter-of
575 #:error-generator-of
576 #:syscall-restart-p
577 #:base-type-of
578 #:never-fails
579 #:signal-syscall-error
580 #:signal-syscall-error-kw
581 #:signal-syscall-error/restart
583 ;; Syscall definers
584 #:defentrypoint
585 #:defcfun*
586 #:defsyscall
588 ;; CFFI Type Designators
589 #:pointer-or-nil
590 #:pointer-or-nil-designator
591 #:bool
592 #:bool-designator
594 ;; SSTRING <-> CSTRING
595 #:+cstring-path-max+
596 #:cstring-to-sstring
597 #:sstring-to-cstring
598 #:with-cstring-to-sstring
599 #:with-sstring-to-cstring
601 ;; Misc
602 #:repeat-upon-condition
603 #:repeat-upon-eintr
604 #:repeat-decreasing-timeout
605 #:repeat-upon-condition-decreasing-timeout
608 ;;;----------------------------------------------------------------------
609 ;;; Struct definitions, slots and accessors
610 ;;;----------------------------------------------------------------------
612 ;; timespec
613 #:timespec #:size-of-timespec
614 #:sec
615 #:nsec
617 ;; timeval
618 #:timeval #:size-of-timeval
619 #:sec
620 #:usec
622 ;; sigaction
623 #:sigaction #:size-of-sigaction
624 #:handler
626 ;; stat
627 #:stat #:size-of-stat
628 #:dev #:stat-dev
629 #:ino #:stat-ino
630 #:mode #:stat-mode
631 #:nlink #:stat-nlink
632 #:uid #:stat-uid
633 #:gid #:stat-gid
634 #:rdev #:stat-rdev
635 #:size #:stat-size
636 #:blksize #:stat-blksize
637 #:blocks #:stat-blocks
638 #:atime #:stat-atime
639 #:mtime #:stat-mtime
640 #:ctime #:stat-ctime
642 ;; fd_set
643 #:fd-set #:size-of-fd-set
645 ;; pollfd
646 #:pollfd #:size-of-pollfd
647 #:fd
648 #:events
649 #:revents
651 ;; epoll_data
652 #+linux #:epoll-data #+linux #:size-of-epoll-data
653 #+linux #:ptr
654 #+linux #:fd
655 #+linux #:u32
656 #+linux #:u64
658 ;; epoll_event
659 #+linux #:epoll-event #+linux #:size-of-epoll-event
660 #+linux #:events
661 #+linux #:data
663 ;; kevent
664 #+bsd #:kevent #+bsd #:size-of-kevent
665 #+bsd #:ident
666 #+bsd #:filter
667 #+bsd #:flags
668 #+bsd #:fflags
669 #+bsd #:data
670 #+bsd #:udata
672 ;; sysconf
673 #:sysconf
674 #:sc-arg-max #:sc-child-max #:sc-host-name-max #:sc-login-name-max
675 #:sc-clk-tck #:sc-open-max #:sc-pagesize #:sc-re-dup-max
676 #:sc-stream-max #:sc-symloop-max #:sc-tty-name-max #:sc-tzname-max
677 #:sc-version #:sc-phys-pages #:sc-avphys-pages #:sc-nprocessors-conf
678 #:sc-nprocessors-onln