summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2022-02-11 15:06:25 -0700
committerJens Axboe <axboe@kernel.dk>2022-02-11 15:06:25 -0700
commitea1e6f8c4e9180bde1844bd56a072bd4c1afae3e (patch)
tree22cdd173821670f700bb9b70d24aa9962178ef90
parent333561791386112e4801b61be15feaf4044c02c6 (diff)
parente18f1ce24bf1800721dec9070cda6f172dcea25c (diff)
downloadliburing-ea1e6f8c4e9180bde1844bd56a072bd4c1afae3e.tar.gz
liburing-ea1e6f8c4e9180bde1844bd56a072bd4c1afae3e.tar.bz2
Merge branch 'master' of ssh://git.kernel.dk/data/git/liburing
* 'master' of ssh://git.kernel.dk/data/git/liburing: test/pollfree: ignore run if argument is given Change all syscall function name prefix to __sys lib.h: Split off lib header for arch specific and generic arch/x86, syscall: Refactor arch specific and generic syscall wrappers arch/generic: Create arch generic syscall wrappers
-rw-r--r--src/arch/generic/lib.h21
-rw-r--r--src/arch/generic/syscall.h87
-rw-r--r--src/arch/x86/lib.h20
-rw-r--r--src/arch/x86/syscall.h57
-rw-r--r--src/lib.h45
-rw-r--r--src/nolibc.c4
-rw-r--r--src/register.c4
-rw-r--r--src/setup.c22
-rw-r--r--src/syscall.h155
-rw-r--r--test/pollfree.c6
10 files changed, 219 insertions, 202 deletions
diff --git a/src/arch/generic/lib.h b/src/arch/generic/lib.h
new file mode 100644
index 0000000..737e795
--- /dev/null
+++ b/src/arch/generic/lib.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef __INTERNAL__LIBURING_LIB_H
+ #error "This file should be included from src/lib.h (liburing)"
+#endif
+
+#ifndef LIBURING_ARCH_GENERIC_LIB_H
+#define LIBURING_ARCH_GENERIC_LIB_H
+
+static inline long get_page_size(void)
+{
+ long page_size;
+
+ page_size = sysconf(_SC_PAGESIZE);
+ if (page_size < 0)
+ page_size = 4096;
+
+ return page_size;
+}
+
+#endif /* #ifndef LIBURING_ARCH_GENERIC_LIB_H */
diff --git a/src/arch/generic/syscall.h b/src/arch/generic/syscall.h
new file mode 100644
index 0000000..fa93064
--- /dev/null
+++ b/src/arch/generic/syscall.h
@@ -0,0 +1,87 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef __INTERNAL__LIBURING_SYSCALL_H
+ #error "This file should be included from src/syscall.h (liburing)"
+#endif
+
+#ifndef LIBURING_ARCH_GENERIC_SYSCALL_H
+#define LIBURING_ARCH_GENERIC_SYSCALL_H
+
+static inline int ____sys_io_uring_register(int fd, unsigned opcode,
+ const void *arg, unsigned nr_args)
+{
+ int ret;
+ ret = syscall(__NR_io_uring_register, fd, opcode, arg, nr_args);
+ return (ret < 0) ? -errno : ret;
+}
+
+static inline int ____sys_io_uring_setup(unsigned entries,
+ struct io_uring_params *p)
+{
+ int ret;
+ ret = syscall(__NR_io_uring_setup, entries, p);
+ return (ret < 0) ? -errno : ret;
+}
+
+static inline int ____sys_io_uring_enter2(int fd, unsigned to_submit,
+ unsigned min_complete, unsigned flags,
+ sigset_t *sig, int sz)
+{
+ int ret;
+ ret = syscall(__NR_io_uring_enter, fd, to_submit, min_complete, flags,
+ sig, sz);
+ return (ret < 0) ? -errno : ret;
+}
+
+static inline int ____sys_io_uring_enter(int fd, unsigned to_submit,
+ unsigned min_complete, unsigned flags,
+ sigset_t *sig)
+{
+ return ____sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
+ _NSIG / 8);
+}
+
+static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
+ int fd, off_t offset)
+{
+ void *ret;
+ ret = mmap(addr, length, prot, flags, fd, offset);
+ return (ret == MAP_FAILED) ? ERR_PTR(-errno) : ret;
+}
+
+static inline int __sys_munmap(void *addr, size_t length)
+{
+ int ret;
+ ret = munmap(addr, length);
+ return (ret < 0) ? -errno : ret;
+}
+
+static inline int __sys_madvise(void *addr, size_t length, int advice)
+{
+ int ret;
+ ret = madvise(addr, length, advice);
+ return (ret < 0) ? -errno : ret;
+}
+
+static inline int __sys_getrlimit(int resource, struct rlimit *rlim)
+{
+ int ret;
+ ret = getrlimit(resource, rlim);
+ return (ret < 0) ? -errno : ret;
+}
+
+static inline int __sys_setrlimit(int resource, const struct rlimit *rlim)
+{
+ int ret;
+ ret = setrlimit(resource, rlim);
+ return (ret < 0) ? -errno : ret;
+}
+
+static inline int __sys_close(int fd)
+{
+ int ret;
+ ret = close(fd);
+ return (ret < 0) ? -errno : ret;
+}
+
+#endif /* #ifndef LIBURING_ARCH_GENERIC_SYSCALL_H */
diff --git a/src/arch/x86/lib.h b/src/arch/x86/lib.h
index 65ad396..bacf74e 100644
--- a/src/arch/x86/lib.h
+++ b/src/arch/x86/lib.h
@@ -1,15 +1,15 @@
/* SPDX-License-Identifier: MIT */
+#ifndef __INTERNAL__LIBURING_LIB_H
+ #error "This file should be included from src/lib.h (liburing)"
+#endif
+
#ifndef LIBURING_ARCH_X86_LIB_H
#define LIBURING_ARCH_X86_LIB_H
-#ifndef LIBURING_LIB_H
-# error "This file should be included from src/lib.h (liburing)"
-#endif
-
#if defined(__x86_64__)
-static inline long __arch_impl_get_page_size(void)
+static inline long get_page_size(void)
{
return 4096;
}
@@ -17,9 +17,15 @@ static inline long __arch_impl_get_page_size(void)
#else /* #if defined(__x86_64__) */
/*
- * TODO: Add x86 (32-bit) support here.
+ * For x86 (32-bit), fallback to libc wrapper.
+ * We can't use CONFIG_NOLIBC for x86 (32-bit) at the moment.
+ *
+ * TODO: Add x86 (32-bit) nolibc support.
*/
-#error "x86 (32-bit) is currently not supported for nolibc builds"
+#ifdef CONFIG_NOLIBC
+ #error "x86 (32-bit) is currently not supported for nolibc builds"
+#endif
+#include "../generic/lib.h"
#endif /* #if defined(__x86_64__) */
diff --git a/src/arch/x86/syscall.h b/src/arch/x86/syscall.h
index 2fb3552..02677f2 100644
--- a/src/arch/x86/syscall.h
+++ b/src/arch/x86/syscall.h
@@ -1,12 +1,12 @@
/* SPDX-License-Identifier: MIT */
+#ifndef __INTERNAL__LIBURING_SYSCALL_H
+ #error "This file should be included from src/syscall.h (liburing)"
+#endif
+
#ifndef LIBURING_ARCH_X86_SYSCALL_H
#define LIBURING_ARCH_X86_SYSCALL_H
-#ifndef LIBURING_SYSCALL_H
-# error "This file should be included from src/syscall.h (liburing)"
-#endif
-
#if defined(__x86_64__)
/**
* Note for syscall registers usage (x86-64):
@@ -29,8 +29,8 @@
* %r11 == %rflags and %rcx == %rip.
*/
-static inline void *__arch_impl_mmap(void *addr, size_t length, int prot,
- int flags, int fd, off_t offset)
+static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
+ int fd, off_t offset)
{
void *rax;
register int r10 __asm__("r10") = flags;
@@ -52,7 +52,7 @@ static inline void *__arch_impl_mmap(void *addr, size_t length, int prot,
return rax;
}
-static inline int __arch_impl_munmap(void *addr, size_t length)
+static inline int __sys_munmap(void *addr, size_t length)
{
long rax;
@@ -67,7 +67,7 @@ static inline int __arch_impl_munmap(void *addr, size_t length)
return (int) rax;
}
-static inline int __arch_impl_madvise(void *addr, size_t length, int advice)
+static inline int __sys_madvise(void *addr, size_t length, int advice)
{
long rax;
@@ -83,7 +83,7 @@ static inline int __arch_impl_madvise(void *addr, size_t length, int advice)
return (int) rax;
}
-static inline int __arch_impl_getrlimit(int resource, struct rlimit *rlim)
+static inline int __sys_getrlimit(int resource, struct rlimit *rlim)
{
long rax;
@@ -98,7 +98,7 @@ static inline int __arch_impl_getrlimit(int resource, struct rlimit *rlim)
return (int) rax;
}
-static inline int __arch_impl_setrlimit(int resource, const struct rlimit *rlim)
+static inline int __sys_setrlimit(int resource, const struct rlimit *rlim)
{
long rax;
@@ -113,7 +113,7 @@ static inline int __arch_impl_setrlimit(int resource, const struct rlimit *rlim)
return (int) rax;
}
-static inline int __arch_impl_close(int fd)
+static inline int __sys_close(int fd)
{
long rax;
@@ -127,9 +127,9 @@ static inline int __arch_impl_close(int fd)
return (int) rax;
}
-static inline int __arch_impl_io_uring_register(int fd, unsigned opcode,
- const void *arg,
- unsigned nr_args)
+static inline int ____sys_io_uring_register(int fd, unsigned opcode,
+ const void *arg,
+ unsigned nr_args)
{
long rax;
register unsigned r10 __asm__("r10") = nr_args;
@@ -147,8 +147,8 @@ static inline int __arch_impl_io_uring_register(int fd, unsigned opcode,
return (int) rax;
}
-static inline int __arch_impl_io_uring_setup(unsigned entries,
- struct io_uring_params *p)
+static inline int ____sys_io_uring_setup(unsigned entries,
+ struct io_uring_params *p)
{
long rax;
@@ -163,10 +163,9 @@ static inline int __arch_impl_io_uring_setup(unsigned entries,
return (int) rax;
}
-static inline int __arch_impl_io_uring_enter(int fd, unsigned to_submit,
- unsigned min_complete,
- unsigned flags, sigset_t *sig,
- int sz)
+static inline int ____sys_io_uring_enter2(int fd, unsigned to_submit,
+ unsigned min_complete, unsigned flags,
+ sigset_t *sig, int sz)
{
long rax;
register unsigned r10 __asm__("r10") = flags;
@@ -188,12 +187,26 @@ static inline int __arch_impl_io_uring_enter(int fd, unsigned to_submit,
return (int) rax;
}
+static inline int ____sys_io_uring_enter(int fd, unsigned to_submit,
+ unsigned min_complete, unsigned flags,
+ sigset_t *sig)
+{
+ return ____sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
+ _NSIG / 8);
+}
+
#else /* #if defined(__x86_64__) */
/*
- * TODO: Add x86 (32-bit) support here.
+ * For x86 (32-bit), fallback to libc wrapper.
+ * We can't use CONFIG_NOLIBC for x86 (32-bit) at the moment.
+ *
+ * TODO: Add x86 (32-bit) nolibc support.
*/
-#error "x86 (32-bit) is currently not supported for nolibc builds"
+#ifdef CONFIG_NOLIBC
+ #error "x86 (32-bit) is currently not supported for nolibc builds"
+#endif
+#include "../generic/syscall.h"
#endif /* #if defined(__x86_64__) */
diff --git a/src/lib.h b/src/lib.h
index bd02805..6672cc5 100644
--- a/src/lib.h
+++ b/src/lib.h
@@ -6,23 +6,31 @@
#include <string.h>
#include <unistd.h>
-#ifdef CONFIG_NOLIBC
-# if defined(__x86_64__) || defined(__i386__)
-# include "arch/x86/lib.h"
-# else
-# error "This arch doesn't support building liburing without libc"
-# endif
+#define __INTERNAL__LIBURING_LIB_H
+#if defined(__x86_64__) || defined(__i386__)
+ #include "arch/x86/lib.h"
+#else
+ /*
+ * We don't have nolibc support for this arch. Must use libc!
+ */
+ #ifdef CONFIG_NOLIBC
+ #error "This arch doesn't support building liburing without libc"
+ #endif
+ /* libc wrappers. */
+ #include "arch/generic/lib.h"
#endif
+#undef __INTERNAL__LIBURING_LIB_H
+
#ifndef offsetof
-# define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD)
+ #define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD)
#endif
#ifndef container_of
-# define container_of(PTR, TYPE, FIELD) ({ \
- __typeof__(((TYPE *)0)->FIELD) *__FIELD_PTR = (PTR); \
- (TYPE *)((char *) __FIELD_PTR - offsetof(TYPE, FIELD)); \
-})
+ #define container_of(PTR, TYPE, FIELD) ({ \
+ __typeof__(((TYPE *)0)->FIELD) *__FIELD_PTR = (PTR); \
+ (TYPE *)((char *) __FIELD_PTR - offsetof(TYPE, FIELD)); \
+ })
#endif
void *__uring_malloc(size_t len);
@@ -46,19 +54,4 @@ static inline void uring_free(void *ptr)
#endif
}
-static inline long get_page_size(void)
-{
-#ifdef CONFIG_NOLIBC
- return __arch_impl_get_page_size();
-#else
- long page_size;
-
- page_size = sysconf(_SC_PAGESIZE);
- if (page_size < 0)
- page_size = 4096;
-
- return page_size;
-#endif
-}
-
#endif /* #ifndef LIBURING_LIB_H */
diff --git a/src/nolibc.c b/src/nolibc.c
index f7848d3..1e17d22 100644
--- a/src/nolibc.c
+++ b/src/nolibc.c
@@ -27,7 +27,7 @@ void *__uring_malloc(size_t len)
{
struct uring_heap *heap;
- heap = uring_mmap(NULL, sizeof(*heap) + len, PROT_READ | PROT_WRITE,
+ heap = __sys_mmap(NULL, sizeof(*heap) + len, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (IS_ERR(heap))
return NULL;
@@ -44,5 +44,5 @@ void __uring_free(void *p)
return;
heap = container_of(p, struct uring_heap, user_p);
- uring_munmap(heap, heap->len);
+ __sys_munmap(heap, heap->len);
}
diff --git a/src/register.c b/src/register.c
index a1b1a22..cd73fce 100644
--- a/src/register.c
+++ b/src/register.c
@@ -100,13 +100,13 @@ static int increase_rlimit_nofile(unsigned nr)
int ret;
struct rlimit rlim;
- ret = uring_getrlimit(RLIMIT_NOFILE, &rlim);
+ ret = __sys_getrlimit(RLIMIT_NOFILE, &rlim);
if (ret < 0)
return ret;
if (rlim.rlim_cur < nr) {
rlim.rlim_cur += nr;
- uring_setrlimit(RLIMIT_NOFILE, &rlim);
+ __sys_setrlimit(RLIMIT_NOFILE, &rlim);
}
return 0;
diff --git a/src/setup.c b/src/setup.c
index 1e4dbf4..544adaf 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -10,9 +10,9 @@
static void io_uring_unmap_rings(struct io_uring_sq *sq, struct io_uring_cq *cq)
{
- uring_munmap(sq->ring_ptr, sq->ring_sz);
+ __sys_munmap(sq->ring_ptr, sq->ring_sz);
if (cq->ring_ptr && cq->ring_ptr != sq->ring_ptr)
- uring_munmap(cq->ring_ptr, cq->ring_sz);
+ __sys_munmap(cq->ring_ptr, cq->ring_sz);
}
static int io_uring_mmap(int fd, struct io_uring_params *p,
@@ -29,7 +29,7 @@ static int io_uring_mmap(int fd, struct io_uring_params *p,
sq->ring_sz = cq->ring_sz;
cq->ring_sz = sq->ring_sz;
}
- sq->ring_ptr = uring_mmap(0, sq->ring_sz, PROT_READ | PROT_WRITE,
+ sq->ring_ptr = __sys_mmap(0, sq->ring_sz, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE, fd,
IORING_OFF_SQ_RING);
if (IS_ERR(sq->ring_ptr))
@@ -38,7 +38,7 @@ static int io_uring_mmap(int fd, struct io_uring_params *p,
if (p->features & IORING_FEAT_SINGLE_MMAP) {
cq->ring_ptr = sq->ring_ptr;
} else {
- cq->ring_ptr = uring_mmap(0, cq->ring_sz, PROT_READ | PROT_WRITE,
+ cq->ring_ptr = __sys_mmap(0, cq->ring_sz, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE, fd,
IORING_OFF_CQ_RING);
if (IS_ERR(cq->ring_ptr)) {
@@ -57,7 +57,7 @@ static int io_uring_mmap(int fd, struct io_uring_params *p,
sq->array = sq->ring_ptr + p->sq_off.array;
size = p->sq_entries * sizeof(struct io_uring_sqe);
- sq->sqes = uring_mmap(0, size, PROT_READ | PROT_WRITE,
+ sq->sqes = __sys_mmap(0, size, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE, fd, IORING_OFF_SQES);
if (IS_ERR(sq->sqes)) {
ret = PTR_ERR(sq->sqes);
@@ -109,18 +109,18 @@ int io_uring_ring_dontfork(struct io_uring *ring)
return -EINVAL;
len = *ring->sq.kring_entries * sizeof(struct io_uring_sqe);
- ret = uring_madvise(ring->sq.sqes, len, MADV_DONTFORK);
+ ret = __sys_madvise(ring->sq.sqes, len, MADV_DONTFORK);
if (ret < 0)
return ret;
len = ring->sq.ring_sz;
- ret = uring_madvise(ring->sq.ring_ptr, len, MADV_DONTFORK);
+ ret = __sys_madvise(ring->sq.ring_ptr, len, MADV_DONTFORK);
if (ret < 0)
return ret;
if (ring->cq.ring_ptr != ring->sq.ring_ptr) {
len = ring->cq.ring_sz;
- ret = uring_madvise(ring->cq.ring_ptr, len, MADV_DONTFORK);
+ ret = __sys_madvise(ring->cq.ring_ptr, len, MADV_DONTFORK);
if (ret < 0)
return ret;
}
@@ -139,7 +139,7 @@ int io_uring_queue_init_params(unsigned entries, struct io_uring *ring,
ret = io_uring_queue_mmap(fd, p, ring);
if (ret) {
- uring_close(fd);
+ __sys_close(fd);
return ret;
}
@@ -166,9 +166,9 @@ void io_uring_queue_exit(struct io_uring *ring)
struct io_uring_sq *sq = &ring->sq;
struct io_uring_cq *cq = &ring->cq;
- uring_munmap(sq->sqes, *sq->kring_entries * sizeof(struct io_uring_sqe));
+ __sys_munmap(sq->sqes, *sq->kring_entries * sizeof(struct io_uring_sqe));
io_uring_unmap_rings(sq, cq);
- uring_close(ring->ring_fd);
+ __sys_close(ring->ring_fd);
}
struct io_uring_probe *io_uring_get_probe_ring(struct io_uring *ring)
diff --git a/src/syscall.h b/src/syscall.h
index 4b336f1..beb357e 100644
--- a/src/syscall.h
+++ b/src/syscall.h
@@ -55,27 +55,6 @@
*/
struct io_uring_params;
-
-#ifdef CONFIG_NOLIBC
-# if defined(__x86_64__) || defined(__i386__)
-# include "arch/x86/syscall.h"
-# else
-# error "This arch doesn't support building liburing without libc"
-# endif
-#endif
-
-
-/*
- * System calls
- */
-int __sys_io_uring_setup(unsigned entries, struct io_uring_params *p);
-int __sys_io_uring_enter(int fd, unsigned to_submit, unsigned min_complete,
- unsigned flags, sigset_t *sig);
-int __sys_io_uring_enter2(int fd, unsigned to_submit, unsigned min_complete,
- unsigned flags, sigset_t *sig, int sz);
-int __sys_io_uring_register(int fd, unsigned int opcode, const void *arg,
- unsigned int nr_args);
-
static inline void *ERR_PTR(intptr_t n)
{
return (void *) n;
@@ -91,118 +70,32 @@ static inline bool IS_ERR(const void *ptr)
return uring_unlikely((uintptr_t) ptr >= (uintptr_t) -4095UL);
}
-static inline int ____sys_io_uring_register(int fd, unsigned opcode,
- const void *arg, unsigned nr_args)
-{
-#ifdef CONFIG_NOLIBC
- return __arch_impl_io_uring_register(fd, opcode, arg, nr_args);
-#else
- int ret;
- ret = syscall(__NR_io_uring_register, fd, opcode, arg, nr_args);
- return (ret < 0) ? -errno : ret;
-#endif
-}
-
-static inline int ____sys_io_uring_setup(unsigned entries,
- struct io_uring_params *p)
-{
-#ifdef CONFIG_NOLIBC
- return __arch_impl_io_uring_setup(entries, p);
+#define __INTERNAL__LIBURING_SYSCALL_H
+#if defined(__x86_64__) || defined(__i386__)
+ #include "arch/x86/syscall.h"
#else
- int ret;
- ret = syscall(__NR_io_uring_setup, entries, p);
- return (ret < 0) ? -errno : ret;
+ /*
+ * We don't have native syscall wrappers
+ * for this arch. Must use libc!
+ */
+ #ifdef CONFIG_NOLIBC
+ #error "This arch doesn't support building liburing without libc"
+ #endif
+ /* libc syscall wrappers. */
+ #include "arch/generic/syscall.h"
#endif
-}
-
-static inline int ____sys_io_uring_enter2(int fd, unsigned to_submit,
- unsigned min_complete, unsigned flags,
- sigset_t *sig, int sz)
-{
-#ifdef CONFIG_NOLIBC
- return __arch_impl_io_uring_enter(fd, to_submit, min_complete, flags,
- sig, sz);
-#else
- int ret;
- ret = syscall(__NR_io_uring_enter, fd, to_submit, min_complete, flags,
- sig, sz);
- return (ret < 0) ? -errno : ret;
-#endif
-}
-
-static inline int ____sys_io_uring_enter(int fd, unsigned to_submit,
- unsigned min_complete, unsigned flags,
- sigset_t *sig)
-{
- return ____sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
- _NSIG / 8);
-}
-
-static inline void *uring_mmap(void *addr, size_t length, int prot, int flags,
- int fd, off_t offset)
-{
-#ifdef CONFIG_NOLIBC
- return __arch_impl_mmap(addr, length, prot, flags, fd, offset);
-#else
- void *ret;
- ret = mmap(addr, length, prot, flags, fd, offset);
- return (ret == MAP_FAILED) ? ERR_PTR(-errno) : ret;
-#endif
-}
+#undef __INTERNAL__LIBURING_SYSCALL_H
-static inline int uring_munmap(void *addr, size_t length)
-{
-#ifdef CONFIG_NOLIBC
- return __arch_impl_munmap(addr, length);
-#else
- int ret;
- ret = munmap(addr, length);
- return (ret < 0) ? -errno : ret;
-#endif
-}
-
-static inline int uring_madvise(void *addr, size_t length, int advice)
-{
-#ifdef CONFIG_NOLIBC
- return __arch_impl_madvise(addr, length, advice);
-#else
- int ret;
- ret = madvise(addr, length, advice);
- return (ret < 0) ? -errno : ret;
-#endif
-}
-
-static inline int uring_getrlimit(int resource, struct rlimit *rlim)
-{
-#ifdef CONFIG_NOLIBC
- return __arch_impl_getrlimit(resource, rlim);
-#else
- int ret;
- ret = getrlimit(resource, rlim);
- return (ret < 0) ? -errno : ret;
-#endif
-}
-
-static inline int uring_setrlimit(int resource, const struct rlimit *rlim)
-{
-#ifdef CONFIG_NOLIBC
- return __arch_impl_setrlimit(resource, rlim);
-#else
- int ret;
- ret = setrlimit(resource, rlim);
- return (ret < 0) ? -errno : ret;
-#endif
-}
-
-static inline int uring_close(int fd)
-{
-#ifdef CONFIG_NOLIBC
- return __arch_impl_close(fd);
-#else
- int ret;
- ret = close(fd);
- return (ret < 0) ? -errno : ret;
-#endif
-}
+/*
+ * For backward compatibility.
+ * (these __sys* functions always use libc, see syscall.c)
+ */
+int __sys_io_uring_setup(unsigned entries, struct io_uring_params *p);
+int __sys_io_uring_enter(int fd, unsigned to_submit, unsigned min_complete,
+ unsigned flags, sigset_t *sig);
+int __sys_io_uring_enter2(int fd, unsigned to_submit, unsigned min_complete,
+ unsigned flags, sigset_t *sig, int sz);
+int __sys_io_uring_register(int fd, unsigned int opcode, const void *arg,
+ unsigned int nr_args);
#endif
diff --git a/test/pollfree.c b/test/pollfree.c
index f73b6ad..cdc7af0 100644
--- a/test/pollfree.c
+++ b/test/pollfree.c
@@ -388,8 +388,12 @@ void execute_call(int call)
break;
}
}
-int main(void)
+
+int main(int argc, char *argv[])
{
+ if (argc > 1)
+ return 0;
+
syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);