This repository has been archived by the owner on May 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibc-grovel.lisp
124 lines (97 loc) · 3.1 KB
/
libc-grovel.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
(in-package :net.mwatters.libc-misc)
(include "sys/types.h")
;; fixme; are some of these cffi builtins?
(ctype mode-t "mode_t")
(ctype uintptr-t "uintptr_t")
(ctype intptr-t "intptr_t")
(ctype time-t "time_t")
(ctype size-t "size_t")
(ctype ssize-t "ssize_t")
(ctype off-t "off_t")
(include "errno.h")
(constant (+resource-not-available+ "EAGAIN"))
(constant (+too-many-open-files+ "EMFILE"))
(constant (+system-call-interrupted+ "EINTR"))
(constant (+bad-file-descriptor+ "EBADF"))
(constant (+connection-reset+ "ECONNRESET"))
(constant (+operation-in-progress+ "EINPROGRESS"))
;; fixme; either use friendly names for all errors, or use unfriendly
;; names for everything to be more consistent
(constant (+e-exist+ "EEXIST"))
(constant (+e-no-space+ "ENOSPC"))
(constant (+e-pipe+ "EPIPE"))
(constant (+e-perm+ "EPERM"))
(constant (+e-io+ "EIO"))
(constant (+e-invalid+ "EINVAL"))
(constant (+e-not-socket+ "ENOTSOCK"))
(constant (+e-access+ "EACCES"))
(constant (+e-not-connected+ "ENOTCONN"))
#-(or freebsd) (cvar ("errno" *errno*) :int)
(include "time.h")
#+(or freebsd) (include "sys/timespec.h")
(cstruct timespec "struct timespec"
(seconds "tv_sec" :type time-t)
(nanoseconds "tv_nsec" :type :long))
(include "sys/stat.h")
(bitfield file-mode-flags
((:owner-rwx "S_IRWXU"))
((:owner-r "S_IRUSR"))
((:owner-w "S_IWUSR"))
((:owner-x "S_IXUSR"))
((:group-rwx "S_IRWXG"))
((:group-r "S_IRGRP"))
((:group-w "S_IWGRP"))
((:group-x "S_IXGRP"))
((:world-rwx "S_IRWXO"))
((:world-r "S_IROTH"))
((:world-w "S_IWOTH"))
((:world-x "S_IXOTH")))
(include "stdio.h")
(constantenum seek-whence
((:start "SEEK_SET"))
((:current "SEEK_CUR"))
((:end "SEEK_END")))
(include "sys/uio.h")
(cstruct iovec "struct iovec"
(base "iov_base" :type (:pointer :void))
(len "iov_len" :type size-t))
(include "fcntl.h")
(bitfield file-open-flags
((:read+write "O_RDWR"))
((:read "O_RDONLY"))
((:write "O_WRONLY"))
((:non-blocking "O_NONBLOCK"))
((:exclusive "O_EXCL"))
((:no-follow "O_NOFOLLOW"))
((:create "O_CREAT"))
#+(or freebsd) ((:locked-exclusive "O_EXLOCK"))
#+(or freebsd) ((:locked-shared "O_SHLOCK")))
(constantenum fcntl-command
((:set-flags "F_SETFL"))
((:get-flags "F_GETFL"))
((:set-lock "F_SETLK"))
((:get-lock "F_GETLK")))
(constantenum flock-lock-type
((:locked-shared "F_RDLCK"))
((:locked-exclusive "F_WRLCK"))
((:unlock "F_UNLCK")))
(cstruct flock "struct flock"
(lock-type "l_type" :type :short) ;flock-lock-type
(whence "l_whence" :type :short) ;seek-whence
(start "l_start" :type off-t)
(len "l_len" :type off-t)) ; 0 means lock entire file
(include "sys/resource.h")
(ctype rlim-t "rlim_t")
(cstruct rlimit "struct rlimit"
(soft "rlim_cur" :type rlim-t)
(hard "rlim_max" :type rlim-t))
(constantenum rlimit-resource-type
((:address-space "RLIMIT_AS"))
((:core-file-size "RLIMIT_CORE"))
((:cpu-time "RLIMIT_CPU"))
((:data-size "RLIMIT_DATA"))
((:resident-size "RLIMIT_RSS"))
((:stack-size "RLIMIT_STACK"))
((:file-size "RLIMIT_FSIZE"))
((:file-descriptors "RLIMIT_NOFILE")))
(constant (+rlimit-infinity+ "RLIM_INFINITY") :type integer)