summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure21
-rw-r--r--src/include/liburing.h16
-rw-r--r--src/queue.c5
-rw-r--r--test/timeout.c10
4 files changed, 41 insertions, 11 deletions
diff --git a/configure b/configure
index 0b185b8..81e4bcc 100755
--- a/configure
+++ b/configure
@@ -181,8 +181,29 @@ if compile_prog "" "" "__kernel_rwf_t"; then
fi
print_config "__kernel_rwf_t" "$__kernel_rwf_t"
+##########################################
+# check for __kernel_timespec
+__kernel_timespec="no"
+cat > $TMPC << EOF
+#include <linux/time.h>
+int main(int argc, char **argv)
+{
+ struct __kernel_timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1;
+ return 0;
+}
+EOF
+if compile_prog "" "" "__kernel_timespec"; then
+ __kernel_timespec="yes"
+fi
+print_config "__kernel_timespec" "$__kernel_timespec"
+
#############################################################################
if test "$__kernel_rwf_t" = "yes"; then
output_sym "CONFIG_HAVE_KERNEL_RWF_T"
fi
+if test "$__kernel_timespec" = "yes"; then
+ output_sym "CONFIG_HAVE_KERNEL_TIMESPEC"
+fi
diff --git a/src/include/liburing.h b/src/include/liburing.h
index a99a681..2fda45e 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -14,6 +14,13 @@ extern "C" {
#include "liburing/io_uring.h"
#include "liburing/barrier.h"
+#ifndef CONFIG_HAVE_KERNEL_TIMESPEC
+struct __kernel_timespec {
+ int64_t tv_sec;
+ long long tv_nsec;
+};
+#endif
+
/*
* Library interface to io_uring
*/
@@ -73,10 +80,10 @@ extern void io_uring_queue_exit(struct io_uring *ring);
unsigned io_uring_peek_batch_cqe(struct io_uring *ring,
struct io_uring_cqe **cqes, unsigned count);
extern int io_uring_wait_cqes(struct io_uring *ring,
- struct io_uring_cqe **cqe_ptr, unsigned wait_nr, struct timespec *ts,
- sigset_t *sigmask);
+ struct io_uring_cqe **cqe_ptr, unsigned wait_nr,
+ struct __kernel_timespec *ts, sigset_t *sigmask);
extern int io_uring_wait_cqe_timeout(struct io_uring *ring,
- struct io_uring_cqe **cqe_ptr, struct timespec *ts);
+ struct io_uring_cqe **cqe_ptr, struct __kernel_timespec *ts);
extern int io_uring_submit(struct io_uring *ring);
extern int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr);
extern struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring);
@@ -245,7 +252,8 @@ static inline void io_uring_prep_nop(struct io_uring_sqe *sqe)
}
static inline void io_uring_prep_timeout(struct io_uring_sqe *sqe,
- struct timespec *ts, unsigned count)
+ struct __kernel_timespec *ts,
+ unsigned count)
{
io_uring_prep_rw(IORING_OP_TIMEOUT, sqe, 0, ts, 1, count);
}
diff --git a/src/queue.c b/src/queue.c
index 2caea87..766aeac 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -105,7 +105,8 @@ static int __io_uring_flush_sq(struct io_uring *ring)
* this function, as we will do that on its behalf.
*/
int io_uring_wait_cqes(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
- unsigned wait_nr, struct timespec *ts, sigset_t *sigmask)
+ unsigned wait_nr, struct __kernel_timespec *ts,
+ sigset_t *sigmask)
{
int ret;
@@ -137,7 +138,7 @@ int io_uring_wait_cqes(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
*/
int io_uring_wait_cqe_timeout(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr,
- struct timespec *ts)
+ struct __kernel_timespec *ts)
{
return io_uring_wait_cqes(ring, cqe_ptr, 1, ts, NULL);
}
diff --git a/test/timeout.c b/test/timeout.c
index 4edc411..c759789 100644
--- a/test/timeout.c
+++ b/test/timeout.c
@@ -49,7 +49,7 @@ static int test_single_timeout_many(struct io_uring *ring)
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
unsigned long long exp;
- struct timespec ts;
+ struct __kernel_timespec ts;
struct timeval tv;
int ret;
@@ -106,7 +106,7 @@ static int test_single_timeout_nr(struct io_uring *ring)
{
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
- struct timespec ts;
+ struct __kernel_timespec ts;
int i, ret;
sqe = io_uring_get_sqe(ring);
@@ -181,7 +181,7 @@ static int test_single_timeout_wait(struct io_uring *ring)
{
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
- struct timespec ts;
+ struct __kernel_timespec ts;
int i, ret;
sqe = io_uring_get_sqe(ring);
@@ -230,7 +230,7 @@ static int test_single_timeout(struct io_uring *ring)
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
unsigned long long exp;
- struct timespec ts;
+ struct __kernel_timespec ts;
struct timeval tv;
int ret;
@@ -280,7 +280,7 @@ err:
static int test_single_timeout_exit(struct io_uring *ring)
{
struct io_uring_sqe *sqe;
- struct timespec ts;
+ struct __kernel_timespec ts;
int ret;
sqe = io_uring_get_sqe(ring);