summaryrefslogtreecommitdiff
path: root/src/io_pgetevents.c
diff options
context:
space:
mode:
authorJeff Moyer <jmoyer@redhat.com>2018-10-22 12:34:58 -0400
committerJeff Moyer <jmoyer@redhat.com>2018-10-22 12:34:58 -0400
commitcaed0bc756738ce7ae03118466b950a5af4ff510 (patch)
tree2d855ebaa5feb3fe874d9a852d1446f0c094c33f /src/io_pgetevents.c
parentf66be22ab0a59a39858900ab72a8c6a6e8b0b7ec (diff)
parent9c6935e81854d1585bbfa48c35b185849d746864 (diff)
downloadlibaio-caed0bc756738ce7ae03118466b950a5af4ff510.tar.gz
Merge branch 'aio-poll'
Diffstat (limited to 'src/io_pgetevents.c')
-rw-r--r--src/io_pgetevents.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/io_pgetevents.c b/src/io_pgetevents.c
new file mode 100644
index 0000000..e6b0614
--- /dev/null
+++ b/src/io_pgetevents.c
@@ -0,0 +1,56 @@
+/*
+ libaio Linux async I/O interface
+ Copyright 2018 Christoph Hellwig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <libaio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include <signal.h>
+#include "syscall.h"
+#include "aio_ring.h"
+
+#ifdef __NR_io_pgetevents
+io_syscall6(int, __io_pgetevents, io_pgetevents, io_context_t, ctx, long,
+ min_nr, long, nr, struct io_event *, events,
+ struct timespec *, timeout, void *, sigmask);
+
+int io_pgetevents(io_context_t ctx, long min_nr, long nr,
+ struct io_event *events, struct timespec *timeout,
+ sigset_t *sigmask)
+{
+ struct {
+ unsigned long ss;
+ unsigned long ss_len;
+ } data;
+
+ if (aio_ring_is_empty(ctx, timeout))
+ return 0;
+
+ data.ss = (unsigned long)sigmask;
+ data.ss_len = _NSIG / 8;
+ return __io_pgetevents(ctx, min_nr, nr, events, timeout, &data);
+}
+#else
+int io_pgetevents(io_context_t ctx, long min_nr, long nr,
+ struct io_event *events, struct timespec *timeout,
+ sigset_t *sigmask)
+
+{
+ return -ENOSYS;
+}
+#endif /* __NR_io_pgetevents */