implement POSIX asynchronous io
[musl] / src / aio / aio_cancel.c
diff --git a/src/aio/aio_cancel.c b/src/aio/aio_cancel.c
new file mode 100644 (file)
index 0000000..5a753b1
--- /dev/null
@@ -0,0 +1,16 @@
+#include <aio.h>
+#include <pthread.h>
+#include <errno.h>
+
+int aio_cancel(int fd, struct aiocb *cb)
+{
+       if (!cb) {
+               /* FIXME: for correctness, we should return AIO_ALLDONE
+                * if there are no outstanding aio operations on this
+                * file descriptor, but that would require making aio
+                * much slower, and seems to have little advantage since
+                * we don't support cancellation anyway. */
+               return AIO_NOTCANCELED;
+       }
+       return cb->__err==EINPROGRESS ? AIO_NOTCANCELED : AIO_ALLDONE;
+}