uringmachine 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/dependabot.yml +12 -0
- data/.github/workflows/test.yml +35 -0
- data/.gitignore +59 -0
- data/.gitmodules +3 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +11 -0
- data/Rakefile +39 -0
- data/TODO.md +0 -0
- data/examples/echo_server.rb +52 -0
- data/examples/event_loop.rb +69 -0
- data/examples/fibers.rb +105 -0
- data/examples/http_server.rb +56 -0
- data/examples/http_server_multishot.rb +57 -0
- data/examples/http_server_simpler.rb +34 -0
- data/ext/um/extconf.rb +71 -0
- data/ext/um/iou.h +101 -0
- data/ext/um/op_ctx.c +138 -0
- data/ext/um/ring.c +755 -0
- data/ext/um/um.c +267 -0
- data/ext/um/um.h +97 -0
- data/ext/um/um_class.c +175 -0
- data/ext/um/um_ext.c +11 -0
- data/ext/um/um_op.c +87 -0
- data/ext/um/um_utils.c +23 -0
- data/lib/uringmachine/version.rb +3 -0
- data/lib/uringmachine.rb +8 -0
- data/test/helper.rb +70 -0
- data/test/test_iou.rb +876 -0
- data/test/test_um.rb +168 -0
- data/uringmachine.gemspec +27 -0
- data/vendor/liburing/.github/actions/codespell/stopwords +7 -0
- data/vendor/liburing/.github/pull_request_template.md +86 -0
- data/vendor/liburing/.github/workflows/build.yml +137 -0
- data/vendor/liburing/.github/workflows/codespell.yml +25 -0
- data/vendor/liburing/.github/workflows/shellcheck.yml +20 -0
- data/vendor/liburing/.gitignore +41 -0
- data/vendor/liburing/CHANGELOG +111 -0
- data/vendor/liburing/CITATION.cff +11 -0
- data/vendor/liburing/COPYING +502 -0
- data/vendor/liburing/COPYING.GPL +339 -0
- data/vendor/liburing/LICENSE +20 -0
- data/vendor/liburing/Makefile +96 -0
- data/vendor/liburing/Makefile.common +7 -0
- data/vendor/liburing/Makefile.quiet +11 -0
- data/vendor/liburing/README +106 -0
- data/vendor/liburing/SECURITY.md +6 -0
- data/vendor/liburing/configure +624 -0
- data/vendor/liburing/debian/README.Debian +7 -0
- data/vendor/liburing/debian/changelog +38 -0
- data/vendor/liburing/debian/control +39 -0
- data/vendor/liburing/debian/copyright +49 -0
- data/vendor/liburing/debian/liburing-dev.install +4 -0
- data/vendor/liburing/debian/liburing-dev.manpages +5 -0
- data/vendor/liburing/debian/liburing2.install +1 -0
- data/vendor/liburing/debian/liburing2.symbols +56 -0
- data/vendor/liburing/debian/patches/series +1 -0
- data/vendor/liburing/debian/rules +29 -0
- data/vendor/liburing/debian/source/format +1 -0
- data/vendor/liburing/debian/source/local-options +2 -0
- data/vendor/liburing/debian/source/options +1 -0
- data/vendor/liburing/debian/watch +3 -0
- data/vendor/liburing/examples/Makefile +53 -0
- data/vendor/liburing/examples/helpers.c +62 -0
- data/vendor/liburing/examples/helpers.h +7 -0
- data/vendor/liburing/examples/io_uring-close-test.c +123 -0
- data/vendor/liburing/examples/io_uring-cp.c +282 -0
- data/vendor/liburing/examples/io_uring-test.c +112 -0
- data/vendor/liburing/examples/io_uring-udp.c +403 -0
- data/vendor/liburing/examples/link-cp.c +193 -0
- data/vendor/liburing/examples/napi-busy-poll-client.c +509 -0
- data/vendor/liburing/examples/napi-busy-poll-server.c +450 -0
- data/vendor/liburing/examples/poll-bench.c +101 -0
- data/vendor/liburing/examples/proxy.c +2461 -0
- data/vendor/liburing/examples/proxy.h +102 -0
- data/vendor/liburing/examples/rsrc-update-bench.c +100 -0
- data/vendor/liburing/examples/send-zerocopy.c +658 -0
- data/vendor/liburing/examples/ucontext-cp.c +258 -0
- data/vendor/liburing/liburing-ffi.pc.in +12 -0
- data/vendor/liburing/liburing.pc.in +12 -0
- data/vendor/liburing/liburing.spec +66 -0
- data/vendor/liburing/make-debs.sh +55 -0
- data/vendor/liburing/src/Makefile +129 -0
- data/vendor/liburing/src/arch/aarch64/lib.h +47 -0
- data/vendor/liburing/src/arch/aarch64/syscall.h +91 -0
- data/vendor/liburing/src/arch/generic/lib.h +17 -0
- data/vendor/liburing/src/arch/generic/syscall.h +100 -0
- data/vendor/liburing/src/arch/riscv64/lib.h +48 -0
- data/vendor/liburing/src/arch/riscv64/syscall.h +100 -0
- data/vendor/liburing/src/arch/syscall-defs.h +94 -0
- data/vendor/liburing/src/arch/x86/lib.h +11 -0
- data/vendor/liburing/src/arch/x86/syscall.h +296 -0
- data/vendor/liburing/src/ffi.c +15 -0
- data/vendor/liburing/src/include/liburing/barrier.h +81 -0
- data/vendor/liburing/src/include/liburing/io_uring.h +818 -0
- data/vendor/liburing/src/include/liburing.h +1602 -0
- data/vendor/liburing/src/int_flags.h +11 -0
- data/vendor/liburing/src/lib.h +52 -0
- data/vendor/liburing/src/liburing-ffi.map +211 -0
- data/vendor/liburing/src/liburing.map +104 -0
- data/vendor/liburing/src/nolibc.c +55 -0
- data/vendor/liburing/src/queue.c +468 -0
- data/vendor/liburing/src/register.c +374 -0
- data/vendor/liburing/src/setup.c +689 -0
- data/vendor/liburing/src/setup.h +9 -0
- data/vendor/liburing/src/syscall.c +29 -0
- data/vendor/liburing/src/syscall.h +53 -0
- data/vendor/liburing/src/version.c +21 -0
- data/vendor/liburing/test/232c93d07b74.c +305 -0
- data/vendor/liburing/test/35fa71a030ca.c +329 -0
- data/vendor/liburing/test/500f9fbadef8.c +91 -0
- data/vendor/liburing/test/7ad0e4b2f83c.c +94 -0
- data/vendor/liburing/test/8a9973408177.c +107 -0
- data/vendor/liburing/test/917257daa0fe.c +54 -0
- data/vendor/liburing/test/Makefile +297 -0
- data/vendor/liburing/test/a0908ae19763.c +59 -0
- data/vendor/liburing/test/a4c0b3decb33.c +181 -0
- data/vendor/liburing/test/accept-link.c +255 -0
- data/vendor/liburing/test/accept-non-empty.c +256 -0
- data/vendor/liburing/test/accept-reuse.c +163 -0
- data/vendor/liburing/test/accept-test.c +83 -0
- data/vendor/liburing/test/accept.c +919 -0
- data/vendor/liburing/test/across-fork.c +284 -0
- data/vendor/liburing/test/b19062a56726.c +54 -0
- data/vendor/liburing/test/b5837bd5311d.c +78 -0
- data/vendor/liburing/test/bind-listen.c +408 -0
- data/vendor/liburing/test/buf-ring-nommap.c +123 -0
- data/vendor/liburing/test/buf-ring-put.c +83 -0
- data/vendor/liburing/test/buf-ring.c +473 -0
- data/vendor/liburing/test/ce593a6c480a.c +139 -0
- data/vendor/liburing/test/close-opath.c +123 -0
- data/vendor/liburing/test/config +14 -0
- data/vendor/liburing/test/connect-rep.c +204 -0
- data/vendor/liburing/test/connect.c +442 -0
- data/vendor/liburing/test/coredump.c +60 -0
- data/vendor/liburing/test/cq-full.c +97 -0
- data/vendor/liburing/test/cq-overflow.c +530 -0
- data/vendor/liburing/test/cq-peek-batch.c +103 -0
- data/vendor/liburing/test/cq-ready.c +95 -0
- data/vendor/liburing/test/cq-size.c +65 -0
- data/vendor/liburing/test/d4ae271dfaae.c +96 -0
- data/vendor/liburing/test/d77a67ed5f27.c +65 -0
- data/vendor/liburing/test/defer-taskrun.c +391 -0
- data/vendor/liburing/test/defer-tw-timeout.c +173 -0
- data/vendor/liburing/test/defer.c +319 -0
- data/vendor/liburing/test/double-poll-crash.c +195 -0
- data/vendor/liburing/test/drop-submit.c +94 -0
- data/vendor/liburing/test/eeed8b54e0df.c +120 -0
- data/vendor/liburing/test/empty-eownerdead.c +45 -0
- data/vendor/liburing/test/eploop.c +74 -0
- data/vendor/liburing/test/eventfd-disable.c +179 -0
- data/vendor/liburing/test/eventfd-reg.c +77 -0
- data/vendor/liburing/test/eventfd-ring.c +98 -0
- data/vendor/liburing/test/eventfd.c +113 -0
- data/vendor/liburing/test/evloop.c +73 -0
- data/vendor/liburing/test/exec-target.c +6 -0
- data/vendor/liburing/test/exit-no-cleanup.c +117 -0
- data/vendor/liburing/test/fadvise.c +202 -0
- data/vendor/liburing/test/fallocate.c +265 -0
- data/vendor/liburing/test/fc2a85cb02ef.c +132 -0
- data/vendor/liburing/test/fd-install.c +500 -0
- data/vendor/liburing/test/fd-pass.c +237 -0
- data/vendor/liburing/test/fdinfo.c +419 -0
- data/vendor/liburing/test/file-register.c +1189 -0
- data/vendor/liburing/test/file-update.c +231 -0
- data/vendor/liburing/test/file-verify.c +654 -0
- data/vendor/liburing/test/files-exit-hang-poll.c +114 -0
- data/vendor/liburing/test/files-exit-hang-timeout.c +137 -0
- data/vendor/liburing/test/fixed-buf-iter.c +115 -0
- data/vendor/liburing/test/fixed-buf-merge.c +101 -0
- data/vendor/liburing/test/fixed-hugepage.c +411 -0
- data/vendor/liburing/test/fixed-link.c +90 -0
- data/vendor/liburing/test/fixed-reuse.c +160 -0
- data/vendor/liburing/test/fpos.c +255 -0
- data/vendor/liburing/test/fsnotify.c +118 -0
- data/vendor/liburing/test/fsync.c +224 -0
- data/vendor/liburing/test/futex.c +571 -0
- data/vendor/liburing/test/hardlink.c +170 -0
- data/vendor/liburing/test/helpers.c +318 -0
- data/vendor/liburing/test/helpers.h +108 -0
- data/vendor/liburing/test/ignore-single-mmap.c +48 -0
- data/vendor/liburing/test/init-mem.c +164 -0
- data/vendor/liburing/test/io-cancel.c +561 -0
- data/vendor/liburing/test/io_uring_enter.c +264 -0
- data/vendor/liburing/test/io_uring_passthrough.c +482 -0
- data/vendor/liburing/test/io_uring_register.c +503 -0
- data/vendor/liburing/test/io_uring_setup.c +110 -0
- data/vendor/liburing/test/iopoll-leak.c +85 -0
- data/vendor/liburing/test/iopoll-overflow.c +118 -0
- data/vendor/liburing/test/iopoll.c +465 -0
- data/vendor/liburing/test/lfs-openat-write.c +119 -0
- data/vendor/liburing/test/lfs-openat.c +273 -0
- data/vendor/liburing/test/link-timeout.c +1108 -0
- data/vendor/liburing/test/link.c +497 -0
- data/vendor/liburing/test/link_drain.c +255 -0
- data/vendor/liburing/test/madvise.c +195 -0
- data/vendor/liburing/test/min-timeout-wait.c +354 -0
- data/vendor/liburing/test/min-timeout.c +233 -0
- data/vendor/liburing/test/mkdir.c +112 -0
- data/vendor/liburing/test/msg-ring-fd.c +331 -0
- data/vendor/liburing/test/msg-ring-flags.c +212 -0
- data/vendor/liburing/test/msg-ring-overflow.c +159 -0
- data/vendor/liburing/test/msg-ring.c +467 -0
- data/vendor/liburing/test/multicqes_drain.c +429 -0
- data/vendor/liburing/test/napi-test.c +215 -0
- data/vendor/liburing/test/napi-test.sh +48 -0
- data/vendor/liburing/test/no-mmap-inval.c +42 -0
- data/vendor/liburing/test/nolibc.c +62 -0
- data/vendor/liburing/test/nop-all-sizes.c +99 -0
- data/vendor/liburing/test/nop.c +177 -0
- data/vendor/liburing/test/nvme.h +169 -0
- data/vendor/liburing/test/ooo-file-unreg.c +82 -0
- data/vendor/liburing/test/open-close.c +261 -0
- data/vendor/liburing/test/open-direct-link.c +188 -0
- data/vendor/liburing/test/open-direct-pick.c +180 -0
- data/vendor/liburing/test/openat2.c +312 -0
- data/vendor/liburing/test/personality.c +204 -0
- data/vendor/liburing/test/pipe-bug.c +95 -0
- data/vendor/liburing/test/pipe-eof.c +83 -0
- data/vendor/liburing/test/pipe-reuse.c +105 -0
- data/vendor/liburing/test/poll-cancel-all.c +496 -0
- data/vendor/liburing/test/poll-cancel-ton.c +135 -0
- data/vendor/liburing/test/poll-cancel.c +228 -0
- data/vendor/liburing/test/poll-link.c +221 -0
- data/vendor/liburing/test/poll-many.c +230 -0
- data/vendor/liburing/test/poll-mshot-overflow.c +265 -0
- data/vendor/liburing/test/poll-mshot-update.c +323 -0
- data/vendor/liburing/test/poll-race-mshot.c +276 -0
- data/vendor/liburing/test/poll-race.c +105 -0
- data/vendor/liburing/test/poll-ring.c +48 -0
- data/vendor/liburing/test/poll-v-poll.c +353 -0
- data/vendor/liburing/test/poll.c +327 -0
- data/vendor/liburing/test/probe.c +135 -0
- data/vendor/liburing/test/read-before-exit.c +129 -0
- data/vendor/liburing/test/read-mshot-empty.c +153 -0
- data/vendor/liburing/test/read-mshot.c +404 -0
- data/vendor/liburing/test/read-write.c +1013 -0
- data/vendor/liburing/test/recv-msgall-stream.c +398 -0
- data/vendor/liburing/test/recv-msgall.c +263 -0
- data/vendor/liburing/test/recv-multishot.c +602 -0
- data/vendor/liburing/test/recvsend_bundle.c +691 -0
- data/vendor/liburing/test/reg-fd-only.c +131 -0
- data/vendor/liburing/test/reg-hint.c +56 -0
- data/vendor/liburing/test/reg-reg-ring.c +90 -0
- data/vendor/liburing/test/regbuf-merge.c +91 -0
- data/vendor/liburing/test/register-restrictions.c +633 -0
- data/vendor/liburing/test/rename.c +132 -0
- data/vendor/liburing/test/ring-leak.c +283 -0
- data/vendor/liburing/test/ring-leak2.c +249 -0
- data/vendor/liburing/test/ringbuf-read.c +196 -0
- data/vendor/liburing/test/ringbuf-status.c +242 -0
- data/vendor/liburing/test/rsrc_tags.c +461 -0
- data/vendor/liburing/test/runtests-loop.sh +16 -0
- data/vendor/liburing/test/runtests-quiet.sh +11 -0
- data/vendor/liburing/test/runtests.sh +168 -0
- data/vendor/liburing/test/rw_merge_test.c +98 -0
- data/vendor/liburing/test/self.c +91 -0
- data/vendor/liburing/test/send-zerocopy.c +971 -0
- data/vendor/liburing/test/send_recv.c +412 -0
- data/vendor/liburing/test/send_recvmsg.c +444 -0
- data/vendor/liburing/test/shared-wq.c +84 -0
- data/vendor/liburing/test/short-read.c +75 -0
- data/vendor/liburing/test/shutdown.c +165 -0
- data/vendor/liburing/test/sigfd-deadlock.c +88 -0
- data/vendor/liburing/test/single-issuer.c +169 -0
- data/vendor/liburing/test/skip-cqe.c +428 -0
- data/vendor/liburing/test/socket-getsetsock-cmd.c +346 -0
- data/vendor/liburing/test/socket-io-cmd.c +237 -0
- data/vendor/liburing/test/socket-rw-eagain.c +149 -0
- data/vendor/liburing/test/socket-rw-offset.c +149 -0
- data/vendor/liburing/test/socket-rw.c +137 -0
- data/vendor/liburing/test/socket.c +408 -0
- data/vendor/liburing/test/splice.c +512 -0
- data/vendor/liburing/test/sq-full-cpp.cc +45 -0
- data/vendor/liburing/test/sq-full.c +45 -0
- data/vendor/liburing/test/sq-poll-dup.c +211 -0
- data/vendor/liburing/test/sq-poll-kthread.c +169 -0
- data/vendor/liburing/test/sq-poll-share.c +138 -0
- data/vendor/liburing/test/sq-space_left.c +159 -0
- data/vendor/liburing/test/sqpoll-disable-exit.c +196 -0
- data/vendor/liburing/test/sqpoll-exec.c +132 -0
- data/vendor/liburing/test/sqpoll-exit-hang.c +78 -0
- data/vendor/liburing/test/sqpoll-sleep.c +69 -0
- data/vendor/liburing/test/statx.c +172 -0
- data/vendor/liburing/test/stdout.c +232 -0
- data/vendor/liburing/test/submit-and-wait.c +108 -0
- data/vendor/liburing/test/submit-link-fail.c +156 -0
- data/vendor/liburing/test/submit-reuse.c +237 -0
- data/vendor/liburing/test/symlink.c +117 -0
- data/vendor/liburing/test/sync-cancel.c +235 -0
- data/vendor/liburing/test/teardowns.c +58 -0
- data/vendor/liburing/test/test.h +36 -0
- data/vendor/liburing/test/thread-exit.c +143 -0
- data/vendor/liburing/test/timeout-new.c +256 -0
- data/vendor/liburing/test/timeout.c +1798 -0
- data/vendor/liburing/test/truncate.c +186 -0
- data/vendor/liburing/test/tty-write-dpoll.c +60 -0
- data/vendor/liburing/test/unlink.c +112 -0
- data/vendor/liburing/test/version.c +25 -0
- data/vendor/liburing/test/wait-timeout.c +287 -0
- data/vendor/liburing/test/waitid.c +373 -0
- data/vendor/liburing/test/wakeup-hang.c +162 -0
- data/vendor/liburing/test/wq-aff.c +146 -0
- data/vendor/liburing/test/xattr.c +442 -0
- metadata +412 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
|
|
3
|
+
#ifndef LIBURING_ARCH_GENERIC_SYSCALL_H
|
|
4
|
+
#define LIBURING_ARCH_GENERIC_SYSCALL_H
|
|
5
|
+
|
|
6
|
+
#include <fcntl.h>
|
|
7
|
+
|
|
8
|
+
static inline int __sys_io_uring_register(unsigned int fd, unsigned int opcode,
|
|
9
|
+
const void *arg, unsigned int nr_args)
|
|
10
|
+
{
|
|
11
|
+
int ret;
|
|
12
|
+
ret = syscall(__NR_io_uring_register, fd, opcode, arg, nr_args);
|
|
13
|
+
return (ret < 0) ? -errno : ret;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static inline int __sys_io_uring_setup(unsigned int entries,
|
|
17
|
+
struct io_uring_params *p)
|
|
18
|
+
{
|
|
19
|
+
int ret;
|
|
20
|
+
ret = syscall(__NR_io_uring_setup, entries, p);
|
|
21
|
+
return (ret < 0) ? -errno : ret;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static inline int __sys_io_uring_enter2(unsigned int fd, unsigned int to_submit,
|
|
25
|
+
unsigned int min_complete,
|
|
26
|
+
unsigned int flags, sigset_t *sig,
|
|
27
|
+
size_t sz)
|
|
28
|
+
{
|
|
29
|
+
int ret;
|
|
30
|
+
ret = syscall(__NR_io_uring_enter, fd, to_submit, min_complete, flags,
|
|
31
|
+
sig, sz);
|
|
32
|
+
return (ret < 0) ? -errno : ret;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static inline int __sys_io_uring_enter(unsigned int fd, unsigned int to_submit,
|
|
36
|
+
unsigned int min_complete,
|
|
37
|
+
unsigned int flags, sigset_t *sig)
|
|
38
|
+
{
|
|
39
|
+
return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
|
|
40
|
+
_NSIG / 8);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static inline int __sys_open(const char *pathname, int flags, mode_t mode)
|
|
44
|
+
{
|
|
45
|
+
int ret;
|
|
46
|
+
ret = open(pathname, flags, mode);
|
|
47
|
+
return (ret < 0) ? -errno : ret;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static inline ssize_t __sys_read(int fd, void *buffer, size_t size)
|
|
51
|
+
{
|
|
52
|
+
ssize_t ret;
|
|
53
|
+
ret = read(fd, buffer, size);
|
|
54
|
+
return (ret < 0) ? -errno : ret;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
|
|
58
|
+
int fd, off_t offset)
|
|
59
|
+
{
|
|
60
|
+
void *ret;
|
|
61
|
+
ret = mmap(addr, length, prot, flags, fd, offset);
|
|
62
|
+
return (ret == MAP_FAILED) ? ERR_PTR(-errno) : ret;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static inline int __sys_munmap(void *addr, size_t length)
|
|
66
|
+
{
|
|
67
|
+
int ret;
|
|
68
|
+
ret = munmap(addr, length);
|
|
69
|
+
return (ret < 0) ? -errno : ret;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static inline int __sys_madvise(void *addr, size_t length, int advice)
|
|
73
|
+
{
|
|
74
|
+
int ret;
|
|
75
|
+
ret = madvise(addr, length, advice);
|
|
76
|
+
return (ret < 0) ? -errno : ret;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static inline int __sys_getrlimit(int resource, struct rlimit *rlim)
|
|
80
|
+
{
|
|
81
|
+
int ret;
|
|
82
|
+
ret = getrlimit(resource, rlim);
|
|
83
|
+
return (ret < 0) ? -errno : ret;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static inline int __sys_setrlimit(int resource, const struct rlimit *rlim)
|
|
87
|
+
{
|
|
88
|
+
int ret;
|
|
89
|
+
ret = setrlimit(resource, rlim);
|
|
90
|
+
return (ret < 0) ? -errno : ret;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static inline int __sys_close(int fd)
|
|
94
|
+
{
|
|
95
|
+
int ret;
|
|
96
|
+
ret = close(fd);
|
|
97
|
+
return (ret < 0) ? -errno : ret;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#endif /* #ifndef LIBURING_ARCH_GENERIC_SYSCALL_H */
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
|
|
3
|
+
#ifndef LIBURING_ARCH_RISCV64_LIB_H
|
|
4
|
+
#define LIBURING_ARCH_RISCV64_LIB_H
|
|
5
|
+
|
|
6
|
+
#include <elf.h>
|
|
7
|
+
#include <sys/auxv.h>
|
|
8
|
+
#include "../../syscall.h"
|
|
9
|
+
|
|
10
|
+
static inline long __get_page_size(void)
|
|
11
|
+
{
|
|
12
|
+
Elf64_Off buf[2];
|
|
13
|
+
long ret = 4096;
|
|
14
|
+
int fd;
|
|
15
|
+
|
|
16
|
+
fd = __sys_open("/proc/self/auxv", O_RDONLY, 0);
|
|
17
|
+
if (fd < 0)
|
|
18
|
+
return ret;
|
|
19
|
+
|
|
20
|
+
while (1) {
|
|
21
|
+
ssize_t x;
|
|
22
|
+
|
|
23
|
+
x = __sys_read(fd, buf, sizeof(buf));
|
|
24
|
+
if (x < (long) sizeof(buf))
|
|
25
|
+
break;
|
|
26
|
+
|
|
27
|
+
if (buf[0] == AT_PAGESZ) {
|
|
28
|
+
ret = buf[1];
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
__sys_close(fd);
|
|
34
|
+
return ret;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static inline long get_page_size(void)
|
|
38
|
+
{
|
|
39
|
+
static long cache_val;
|
|
40
|
+
|
|
41
|
+
if (cache_val)
|
|
42
|
+
return cache_val;
|
|
43
|
+
|
|
44
|
+
cache_val = __get_page_size();
|
|
45
|
+
return cache_val;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#endif /* #ifndef LIBURING_ARCH_RISCV64_LIB_H */
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
|
|
3
|
+
#ifndef LIBURING_ARCH_RISCV64_SYSCALL_H
|
|
4
|
+
#define LIBURING_ARCH_RISCV64_SYSCALL_H
|
|
5
|
+
|
|
6
|
+
#if defined(__riscv) && __riscv_xlen == 64
|
|
7
|
+
|
|
8
|
+
#define __do_syscallM(...) ({ \
|
|
9
|
+
__asm__ volatile ( \
|
|
10
|
+
"ecall" \
|
|
11
|
+
: "=r"(a0) \
|
|
12
|
+
: __VA_ARGS__ \
|
|
13
|
+
: "memory", "a1"); \
|
|
14
|
+
(long) a0; \
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
#define __do_syscallN(...) ({ \
|
|
18
|
+
__asm__ volatile ( \
|
|
19
|
+
"ecall" \
|
|
20
|
+
: "=r"(a0) \
|
|
21
|
+
: __VA_ARGS__ \
|
|
22
|
+
: "memory"); \
|
|
23
|
+
(long) a0; \
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
#define __do_syscall0(__n) ({ \
|
|
27
|
+
register long a7 __asm__("a7") = __n; \
|
|
28
|
+
register long a0 __asm__("a0"); \
|
|
29
|
+
\
|
|
30
|
+
__do_syscallM("r" (a7)); \
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
#define __do_syscall1(__n, __a) ({ \
|
|
34
|
+
register long a7 __asm__("a7") = __n; \
|
|
35
|
+
register __typeof__(__a) a0 __asm__("a0") = __a; \
|
|
36
|
+
\
|
|
37
|
+
__do_syscallM("r" (a7), "0" (a0)); \
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
#define __do_syscall2(__n, __a, __b) ({ \
|
|
41
|
+
register long a7 __asm__("a7") = __n; \
|
|
42
|
+
register __typeof__(__a) a0 __asm__("a0") = __a; \
|
|
43
|
+
register __typeof__(__b) a1 __asm__("a1") = __b; \
|
|
44
|
+
\
|
|
45
|
+
__do_syscallN("r" (a7), "0" (a0), "r" (a1)); \
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
#define __do_syscall3(__n, __a, __b, __c) ({ \
|
|
49
|
+
register long a7 __asm__("a7") = __n; \
|
|
50
|
+
register __typeof__(__a) a0 __asm__("a0") = __a; \
|
|
51
|
+
register __typeof__(__b) a1 __asm__("a1") = __b; \
|
|
52
|
+
register __typeof__(__c) a2 __asm__("a2") = __c; \
|
|
53
|
+
\
|
|
54
|
+
__do_syscallN("r" (a7), "0" (a0), "r" (a1), "r" (a2)); \
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
#define __do_syscall4(__n, __a, __b, __c, __d) ({ \
|
|
58
|
+
register long a7 __asm__("a7") = __n; \
|
|
59
|
+
register __typeof__(__a) a0 __asm__("a0") = __a; \
|
|
60
|
+
register __typeof__(__b) a1 __asm__("a1") = __b; \
|
|
61
|
+
register __typeof__(__c) a2 __asm__("a2") = __c; \
|
|
62
|
+
register __typeof__(__d) a3 __asm__("a3") = __d; \
|
|
63
|
+
\
|
|
64
|
+
__do_syscallN("r" (a7), "0" (a0), "r" (a1), "r" (a2), "r" (a3));\
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
#define __do_syscall5(__n, __a, __b, __c, __d, __e) ({ \
|
|
68
|
+
register long a7 __asm__("a7") = __n; \
|
|
69
|
+
register __typeof__(__a) a0 __asm__("a0") = __a; \
|
|
70
|
+
register __typeof__(__b) a1 __asm__("a1") = __b; \
|
|
71
|
+
register __typeof__(__c) a2 __asm__("a2") = __c; \
|
|
72
|
+
register __typeof__(__d) a3 __asm__("a3") = __d; \
|
|
73
|
+
register __typeof__(__e) a4 __asm__("a4") = __e; \
|
|
74
|
+
\
|
|
75
|
+
__do_syscallN("r" (a7), "0" (a0), "r" (a1), "r" (a2), "r" (a3), \
|
|
76
|
+
"r"(a4)); \
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
#define __do_syscall6(__n, __a, __b, __c, __d, __e, __f) ({ \
|
|
80
|
+
register long a7 __asm__("a7") = __n; \
|
|
81
|
+
register __typeof__(__a) a0 __asm__("a0") = __a; \
|
|
82
|
+
register __typeof__(__b) a1 __asm__("a1") = __b; \
|
|
83
|
+
register __typeof__(__c) a2 __asm__("a2") = __c; \
|
|
84
|
+
register __typeof__(__d) a3 __asm__("a3") = __d; \
|
|
85
|
+
register __typeof__(__e) a4 __asm__("a4") = __e; \
|
|
86
|
+
register __typeof__(__f) a5 __asm__("a5") = __f; \
|
|
87
|
+
\
|
|
88
|
+
__do_syscallN("r" (a7), "0" (a0), "r" (a1), "r" (a2), "r" (a3), \
|
|
89
|
+
"r" (a4), "r"(a5)); \
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
#include "../syscall-defs.h"
|
|
93
|
+
|
|
94
|
+
#else /* #if defined(__riscv) && __riscv_xlen == 64 */
|
|
95
|
+
|
|
96
|
+
#include "../generic/syscall.h"
|
|
97
|
+
|
|
98
|
+
#endif /* #if defined(__riscv) && __riscv_xlen == 64 */
|
|
99
|
+
|
|
100
|
+
#endif /* #ifndef LIBURING_ARCH_RISCV64_SYSCALL_H */
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
|
|
3
|
+
#ifndef LIBURING_ARCH_SYSCALL_DEFS_H
|
|
4
|
+
#define LIBURING_ARCH_SYSCALL_DEFS_H
|
|
5
|
+
|
|
6
|
+
#include <fcntl.h>
|
|
7
|
+
|
|
8
|
+
static inline int __sys_open(const char *pathname, int flags, mode_t mode)
|
|
9
|
+
{
|
|
10
|
+
/*
|
|
11
|
+
* Some architectures don't have __NR_open, but __NR_openat.
|
|
12
|
+
*/
|
|
13
|
+
#ifdef __NR_open
|
|
14
|
+
return (int) __do_syscall3(__NR_open, pathname, flags, mode);
|
|
15
|
+
#else
|
|
16
|
+
return (int) __do_syscall4(__NR_openat, AT_FDCWD, pathname, flags, mode);
|
|
17
|
+
#endif
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static inline ssize_t __sys_read(int fd, void *buffer, size_t size)
|
|
21
|
+
{
|
|
22
|
+
return (ssize_t) __do_syscall3(__NR_read, fd, buffer, size);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
|
|
26
|
+
int fd, off_t offset)
|
|
27
|
+
{
|
|
28
|
+
int nr;
|
|
29
|
+
|
|
30
|
+
#if defined(__NR_mmap2)
|
|
31
|
+
nr = __NR_mmap2;
|
|
32
|
+
offset >>= 12;
|
|
33
|
+
#else
|
|
34
|
+
nr = __NR_mmap;
|
|
35
|
+
#endif
|
|
36
|
+
return (void *) __do_syscall6(nr, addr, length, prot, flags, fd, offset);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static inline int __sys_munmap(void *addr, size_t length)
|
|
40
|
+
{
|
|
41
|
+
return (int) __do_syscall2(__NR_munmap, addr, length);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static inline int __sys_madvise(void *addr, size_t length, int advice)
|
|
45
|
+
{
|
|
46
|
+
return (int) __do_syscall3(__NR_madvise, addr, length, advice);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static inline int __sys_getrlimit(int resource, struct rlimit *rlim)
|
|
50
|
+
{
|
|
51
|
+
return (int) __do_syscall2(__NR_getrlimit, resource, rlim);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static inline int __sys_setrlimit(int resource, const struct rlimit *rlim)
|
|
55
|
+
{
|
|
56
|
+
return (int) __do_syscall2(__NR_setrlimit, resource, rlim);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static inline int __sys_close(int fd)
|
|
60
|
+
{
|
|
61
|
+
return (int) __do_syscall1(__NR_close, fd);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static inline int __sys_io_uring_register(unsigned int fd, unsigned int opcode,
|
|
65
|
+
const void *arg, unsigned int nr_args)
|
|
66
|
+
{
|
|
67
|
+
return (int) __do_syscall4(__NR_io_uring_register, fd, opcode, arg,
|
|
68
|
+
nr_args);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static inline int __sys_io_uring_setup(unsigned int entries,
|
|
72
|
+
struct io_uring_params *p)
|
|
73
|
+
{
|
|
74
|
+
return (int) __do_syscall2(__NR_io_uring_setup, entries, p);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static inline int __sys_io_uring_enter2(unsigned int fd, unsigned int to_submit,
|
|
78
|
+
unsigned int min_complete,
|
|
79
|
+
unsigned int flags, sigset_t *sig,
|
|
80
|
+
size_t sz)
|
|
81
|
+
{
|
|
82
|
+
return (int) __do_syscall6(__NR_io_uring_enter, fd, to_submit,
|
|
83
|
+
min_complete, flags, sig, sz);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static inline int __sys_io_uring_enter(unsigned int fd, unsigned int to_submit,
|
|
87
|
+
unsigned int min_complete,
|
|
88
|
+
unsigned int flags, sigset_t *sig)
|
|
89
|
+
{
|
|
90
|
+
return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
|
|
91
|
+
_NSIG / 8);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
#endif
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
|
|
3
|
+
#ifndef LIBURING_ARCH_X86_SYSCALL_H
|
|
4
|
+
#define LIBURING_ARCH_X86_SYSCALL_H
|
|
5
|
+
|
|
6
|
+
#if defined(__x86_64__)
|
|
7
|
+
/**
|
|
8
|
+
* Note for syscall registers usage (x86-64):
|
|
9
|
+
* - %rax is the syscall number.
|
|
10
|
+
* - %rax is also the return value.
|
|
11
|
+
* - %rdi is the 1st argument.
|
|
12
|
+
* - %rsi is the 2nd argument.
|
|
13
|
+
* - %rdx is the 3rd argument.
|
|
14
|
+
* - %r10 is the 4th argument (**yes it's %r10, not %rcx!**).
|
|
15
|
+
* - %r8 is the 5th argument.
|
|
16
|
+
* - %r9 is the 6th argument.
|
|
17
|
+
*
|
|
18
|
+
* `syscall` instruction will clobber %r11 and %rcx.
|
|
19
|
+
*
|
|
20
|
+
* After the syscall returns to userspace:
|
|
21
|
+
* - %r11 will contain %rflags.
|
|
22
|
+
* - %rcx will contain the return address.
|
|
23
|
+
*
|
|
24
|
+
* IOW, after the syscall returns to userspace:
|
|
25
|
+
* %r11 == %rflags and %rcx == %rip.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#define __do_syscall0(NUM) ({ \
|
|
29
|
+
intptr_t rax; \
|
|
30
|
+
\
|
|
31
|
+
__asm__ volatile( \
|
|
32
|
+
"syscall" \
|
|
33
|
+
: "=a"(rax) /* %rax */ \
|
|
34
|
+
: "a"(NUM) /* %rax */ \
|
|
35
|
+
: "rcx", "r11", "memory" \
|
|
36
|
+
); \
|
|
37
|
+
rax; \
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
#define __do_syscall1(NUM, ARG1) ({ \
|
|
41
|
+
intptr_t rax; \
|
|
42
|
+
\
|
|
43
|
+
__asm__ volatile( \
|
|
44
|
+
"syscall" \
|
|
45
|
+
: "=a"(rax) /* %rax */ \
|
|
46
|
+
: "a"((NUM)), /* %rax */ \
|
|
47
|
+
"D"((ARG1)) /* %rdi */ \
|
|
48
|
+
: "rcx", "r11", "memory" \
|
|
49
|
+
); \
|
|
50
|
+
rax; \
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
#define __do_syscall2(NUM, ARG1, ARG2) ({ \
|
|
54
|
+
intptr_t rax; \
|
|
55
|
+
\
|
|
56
|
+
__asm__ volatile( \
|
|
57
|
+
"syscall" \
|
|
58
|
+
: "=a"(rax) /* %rax */ \
|
|
59
|
+
: "a"((NUM)), /* %rax */ \
|
|
60
|
+
"D"((ARG1)), /* %rdi */ \
|
|
61
|
+
"S"((ARG2)) /* %rsi */ \
|
|
62
|
+
: "rcx", "r11", "memory" \
|
|
63
|
+
); \
|
|
64
|
+
rax; \
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
#define __do_syscall3(NUM, ARG1, ARG2, ARG3) ({ \
|
|
68
|
+
intptr_t rax; \
|
|
69
|
+
\
|
|
70
|
+
__asm__ volatile( \
|
|
71
|
+
"syscall" \
|
|
72
|
+
: "=a"(rax) /* %rax */ \
|
|
73
|
+
: "a"((NUM)), /* %rax */ \
|
|
74
|
+
"D"((ARG1)), /* %rdi */ \
|
|
75
|
+
"S"((ARG2)), /* %rsi */ \
|
|
76
|
+
"d"((ARG3)) /* %rdx */ \
|
|
77
|
+
: "rcx", "r11", "memory" \
|
|
78
|
+
); \
|
|
79
|
+
rax; \
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
#define __do_syscall4(NUM, ARG1, ARG2, ARG3, ARG4) ({ \
|
|
83
|
+
intptr_t rax; \
|
|
84
|
+
register __typeof__(ARG4) __r10 __asm__("r10") = (ARG4); \
|
|
85
|
+
\
|
|
86
|
+
__asm__ volatile( \
|
|
87
|
+
"syscall" \
|
|
88
|
+
: "=a"(rax) /* %rax */ \
|
|
89
|
+
: "a"((NUM)), /* %rax */ \
|
|
90
|
+
"D"((ARG1)), /* %rdi */ \
|
|
91
|
+
"S"((ARG2)), /* %rsi */ \
|
|
92
|
+
"d"((ARG3)), /* %rdx */ \
|
|
93
|
+
"r"(__r10) /* %r10 */ \
|
|
94
|
+
: "rcx", "r11", "memory" \
|
|
95
|
+
); \
|
|
96
|
+
rax; \
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
#define __do_syscall5(NUM, ARG1, ARG2, ARG3, ARG4, ARG5) ({ \
|
|
100
|
+
intptr_t rax; \
|
|
101
|
+
register __typeof__(ARG4) __r10 __asm__("r10") = (ARG4); \
|
|
102
|
+
register __typeof__(ARG5) __r8 __asm__("r8") = (ARG5); \
|
|
103
|
+
\
|
|
104
|
+
__asm__ volatile( \
|
|
105
|
+
"syscall" \
|
|
106
|
+
: "=a"(rax) /* %rax */ \
|
|
107
|
+
: "a"((NUM)), /* %rax */ \
|
|
108
|
+
"D"((ARG1)), /* %rdi */ \
|
|
109
|
+
"S"((ARG2)), /* %rsi */ \
|
|
110
|
+
"d"((ARG3)), /* %rdx */ \
|
|
111
|
+
"r"(__r10), /* %r10 */ \
|
|
112
|
+
"r"(__r8) /* %r8 */ \
|
|
113
|
+
: "rcx", "r11", "memory" \
|
|
114
|
+
); \
|
|
115
|
+
rax; \
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
#define __do_syscall6(NUM, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) ({ \
|
|
119
|
+
intptr_t rax; \
|
|
120
|
+
register __typeof__(ARG4) __r10 __asm__("r10") = (ARG4); \
|
|
121
|
+
register __typeof__(ARG5) __r8 __asm__("r8") = (ARG5); \
|
|
122
|
+
register __typeof__(ARG6) __r9 __asm__("r9") = (ARG6); \
|
|
123
|
+
\
|
|
124
|
+
__asm__ volatile( \
|
|
125
|
+
"syscall" \
|
|
126
|
+
: "=a"(rax) /* %rax */ \
|
|
127
|
+
: "a"((NUM)), /* %rax */ \
|
|
128
|
+
"D"((ARG1)), /* %rdi */ \
|
|
129
|
+
"S"((ARG2)), /* %rsi */ \
|
|
130
|
+
"d"((ARG3)), /* %rdx */ \
|
|
131
|
+
"r"(__r10), /* %r10 */ \
|
|
132
|
+
"r"(__r8), /* %r8 */ \
|
|
133
|
+
"r"(__r9) /* %r9 */ \
|
|
134
|
+
: "rcx", "r11", "memory" \
|
|
135
|
+
); \
|
|
136
|
+
rax; \
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
#include "../syscall-defs.h"
|
|
140
|
+
|
|
141
|
+
#else /* #if defined(__x86_64__) */
|
|
142
|
+
|
|
143
|
+
#ifdef CONFIG_NOLIBC
|
|
144
|
+
/**
|
|
145
|
+
* Note for syscall registers usage (x86, 32-bit):
|
|
146
|
+
* - %eax is the syscall number.
|
|
147
|
+
* - %eax is also the return value.
|
|
148
|
+
* - %ebx is the 1st argument.
|
|
149
|
+
* - %ecx is the 2nd argument.
|
|
150
|
+
* - %edx is the 3rd argument.
|
|
151
|
+
* - %esi is the 4th argument.
|
|
152
|
+
* - %edi is the 5th argument.
|
|
153
|
+
* - %ebp is the 6th argument.
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
#define __do_syscall0(NUM) ({ \
|
|
157
|
+
intptr_t eax; \
|
|
158
|
+
\
|
|
159
|
+
__asm__ volatile( \
|
|
160
|
+
"int $0x80" \
|
|
161
|
+
: "=a"(eax) /* %eax */ \
|
|
162
|
+
: "a"(NUM) /* %eax */ \
|
|
163
|
+
: "memory" \
|
|
164
|
+
); \
|
|
165
|
+
eax; \
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
#define __do_syscall1(NUM, ARG1) ({ \
|
|
169
|
+
intptr_t eax; \
|
|
170
|
+
\
|
|
171
|
+
__asm__ volatile( \
|
|
172
|
+
"int $0x80" \
|
|
173
|
+
: "=a"(eax) /* %eax */ \
|
|
174
|
+
: "a"(NUM), /* %eax */ \
|
|
175
|
+
"b"((ARG1)) /* %ebx */ \
|
|
176
|
+
: "memory" \
|
|
177
|
+
); \
|
|
178
|
+
eax; \
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
#define __do_syscall2(NUM, ARG1, ARG2) ({ \
|
|
182
|
+
intptr_t eax; \
|
|
183
|
+
\
|
|
184
|
+
__asm__ volatile( \
|
|
185
|
+
"int $0x80" \
|
|
186
|
+
: "=a" (eax) /* %eax */ \
|
|
187
|
+
: "a"(NUM), /* %eax */ \
|
|
188
|
+
"b"((ARG1)), /* %ebx */ \
|
|
189
|
+
"c"((ARG2)) /* %ecx */ \
|
|
190
|
+
: "memory" \
|
|
191
|
+
); \
|
|
192
|
+
eax; \
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
#define __do_syscall3(NUM, ARG1, ARG2, ARG3) ({ \
|
|
196
|
+
intptr_t eax; \
|
|
197
|
+
\
|
|
198
|
+
__asm__ volatile( \
|
|
199
|
+
"int $0x80" \
|
|
200
|
+
: "=a" (eax) /* %eax */ \
|
|
201
|
+
: "a"(NUM), /* %eax */ \
|
|
202
|
+
"b"((ARG1)), /* %ebx */ \
|
|
203
|
+
"c"((ARG2)), /* %ecx */ \
|
|
204
|
+
"d"((ARG3)) /* %edx */ \
|
|
205
|
+
: "memory" \
|
|
206
|
+
); \
|
|
207
|
+
eax; \
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
#define __do_syscall4(NUM, ARG1, ARG2, ARG3, ARG4) ({ \
|
|
211
|
+
intptr_t eax; \
|
|
212
|
+
\
|
|
213
|
+
__asm__ volatile( \
|
|
214
|
+
"int $0x80" \
|
|
215
|
+
: "=a" (eax) /* %eax */ \
|
|
216
|
+
: "a"(NUM), /* %eax */ \
|
|
217
|
+
"b"((ARG1)), /* %ebx */ \
|
|
218
|
+
"c"((ARG2)), /* %ecx */ \
|
|
219
|
+
"d"((ARG3)), /* %edx */ \
|
|
220
|
+
"S"((ARG4)) /* %esi */ \
|
|
221
|
+
: "memory" \
|
|
222
|
+
); \
|
|
223
|
+
eax; \
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
#define __do_syscall5(NUM, ARG1, ARG2, ARG3, ARG4, ARG5) ({ \
|
|
227
|
+
intptr_t eax; \
|
|
228
|
+
\
|
|
229
|
+
__asm__ volatile( \
|
|
230
|
+
"int $0x80" \
|
|
231
|
+
: "=a" (eax) /* %eax */ \
|
|
232
|
+
: "a"(NUM), /* %eax */ \
|
|
233
|
+
"b"((ARG1)), /* %ebx */ \
|
|
234
|
+
"c"((ARG2)), /* %ecx */ \
|
|
235
|
+
"d"((ARG3)), /* %edx */ \
|
|
236
|
+
"S"((ARG4)), /* %esi */ \
|
|
237
|
+
"D"((ARG5)) /* %edi */ \
|
|
238
|
+
: "memory" \
|
|
239
|
+
); \
|
|
240
|
+
eax; \
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
/*
|
|
245
|
+
* On i386, the 6th argument of syscall goes in %ebp. However, both Clang
|
|
246
|
+
* and GCC cannot use %ebp in the clobber list and in the "r" constraint
|
|
247
|
+
* without using -fomit-frame-pointer. To make it always available for
|
|
248
|
+
* any kind of compilation, the below workaround is implemented:
|
|
249
|
+
*
|
|
250
|
+
* 1) Push the 6-th argument.
|
|
251
|
+
* 2) Push %ebp.
|
|
252
|
+
* 3) Load the 6-th argument from 4(%esp) to %ebp.
|
|
253
|
+
* 4) Do the syscall (int $0x80).
|
|
254
|
+
* 5) Pop %ebp (restore the old value of %ebp).
|
|
255
|
+
* 6) Add %esp by 4 (undo the stack pointer).
|
|
256
|
+
*
|
|
257
|
+
* WARNING:
|
|
258
|
+
* Don't use register variables for __do_syscall6(), there is a known
|
|
259
|
+
* GCC bug that results in an endless loop.
|
|
260
|
+
*
|
|
261
|
+
* BugLink: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105032
|
|
262
|
+
*
|
|
263
|
+
*/
|
|
264
|
+
#define __do_syscall6(NUM, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) ({ \
|
|
265
|
+
intptr_t eax = (intptr_t)(NUM); \
|
|
266
|
+
intptr_t arg6 = (intptr_t)(ARG6); /* Always in memory */ \
|
|
267
|
+
__asm__ volatile ( \
|
|
268
|
+
"pushl %[_arg6]\n\t" \
|
|
269
|
+
"pushl %%ebp\n\t" \
|
|
270
|
+
"movl 4(%%esp),%%ebp\n\t" \
|
|
271
|
+
"int $0x80\n\t" \
|
|
272
|
+
"popl %%ebp\n\t" \
|
|
273
|
+
"addl $4,%%esp" \
|
|
274
|
+
: "+a"(eax) /* %eax */ \
|
|
275
|
+
: "b"(ARG1), /* %ebx */ \
|
|
276
|
+
"c"(ARG2), /* %ecx */ \
|
|
277
|
+
"d"(ARG3), /* %edx */ \
|
|
278
|
+
"S"(ARG4), /* %esi */ \
|
|
279
|
+
"D"(ARG5), /* %edi */ \
|
|
280
|
+
[_arg6]"m"(arg6) /* memory */ \
|
|
281
|
+
: "memory", "cc" \
|
|
282
|
+
); \
|
|
283
|
+
eax; \
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
#include "../syscall-defs.h"
|
|
287
|
+
|
|
288
|
+
#else /* #ifdef CONFIG_NOLIBC */
|
|
289
|
+
|
|
290
|
+
#include "../generic/syscall.h"
|
|
291
|
+
|
|
292
|
+
#endif /* #ifdef CONFIG_NOLIBC */
|
|
293
|
+
|
|
294
|
+
#endif /* #if defined(__x86_64__) */
|
|
295
|
+
|
|
296
|
+
#endif /* #ifndef LIBURING_ARCH_X86_SYSCALL_H */
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
#define IOURINGINLINE
|
|
3
|
+
|
|
4
|
+
#ifdef __clang__
|
|
5
|
+
// clang doesn't seem to particularly like that we're including a header that
|
|
6
|
+
// deliberately contains function definitions so we explicitly silence it
|
|
7
|
+
#pragma clang diagnostic push
|
|
8
|
+
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
#include "liburing.h"
|
|
12
|
+
|
|
13
|
+
#ifdef __clang__
|
|
14
|
+
#pragma clang diagnostic pop
|
|
15
|
+
#endif
|