diff options
-rw-r--r-- | adb/daemon/usb.cpp | 2 | ||||
-rw-r--r-- | libasyncio/AsyncIO.cpp | 11 | ||||
-rw-r--r-- | libasyncio/include/asyncio/AsyncIO.h | 16 |
3 files changed, 22 insertions, 7 deletions
diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp index 87ed3db67..20fb6a3d1 100644 --- a/adb/daemon/usb.cpp +++ b/adb/daemon/usb.cpp | |||
@@ -317,6 +317,8 @@ bool init_functionfs(struct usb_handle* h) { | |||
317 | goto err; | 317 | goto err; |
318 | } | 318 | } |
319 | 319 | ||
320 | memset(&h->read_aiob.ctx, 0, sizeof(h->read_aiob.ctx)); | ||
321 | memset(&h->write_aiob.ctx, 0, sizeof(h->write_aiob.ctx)); | ||
320 | if (io_setup(USB_FFS_NUM_BUFS, &h->read_aiob.ctx) || | 322 | if (io_setup(USB_FFS_NUM_BUFS, &h->read_aiob.ctx) || |
321 | io_setup(USB_FFS_NUM_BUFS, &h->write_aiob.ctx)) { | 323 | io_setup(USB_FFS_NUM_BUFS, &h->write_aiob.ctx)) { |
322 | D("[ aio: got error on io_setup (%d) ]", errno); | 324 | D("[ aio: got error on io_setup (%d) ]", errno); |
diff --git a/libasyncio/AsyncIO.cpp b/libasyncio/AsyncIO.cpp index 7430bc81e..6149f09d1 100644 --- a/libasyncio/AsyncIO.cpp +++ b/libasyncio/AsyncIO.cpp | |||
@@ -17,9 +17,10 @@ | |||
17 | #include <asyncio/AsyncIO.h> | 17 | #include <asyncio/AsyncIO.h> |
18 | #include <sys/syscall.h> | 18 | #include <sys/syscall.h> |
19 | #include <unistd.h> | 19 | #include <unistd.h> |
20 | #include <cstdint> | ||
21 | #include <cstring> | ||
20 | 22 | ||
21 | int io_setup(unsigned nr, aio_context_t* ctxp) { | 23 | int io_setup(unsigned nr, aio_context_t* ctxp) { |
22 | memset(ctxp, 0, sizeof(*ctxp)); | ||
23 | return syscall(__NR_io_setup, nr, ctxp); | 24 | return syscall(__NR_io_setup, nr, ctxp); |
24 | } | 25 | } |
25 | 26 | ||
@@ -48,3 +49,11 @@ void io_prep(iocb* iocb, int fd, const void* buf, uint64_t count, int64_t offset | |||
48 | iocb->aio_nbytes = count; | 49 | iocb->aio_nbytes = count; |
49 | iocb->aio_offset = offset; | 50 | iocb->aio_offset = offset; |
50 | } | 51 | } |
52 | |||
53 | void io_prep_pread(struct iocb* iocb, int fd, void* buf, size_t count, long long offset) { | ||
54 | io_prep(iocb, fd, buf, count, offset, true); | ||
55 | } | ||
56 | |||
57 | void io_prep_pwrite(struct iocb* iocb, int fd, void* buf, size_t count, long long offset) { | ||
58 | io_prep(iocb, fd, buf, count, offset, false); | ||
59 | } | ||
diff --git a/libasyncio/include/asyncio/AsyncIO.h b/libasyncio/include/asyncio/AsyncIO.h index e3fb93a4d..9620d2a84 100644 --- a/libasyncio/include/asyncio/AsyncIO.h +++ b/libasyncio/include/asyncio/AsyncIO.h | |||
@@ -17,9 +17,9 @@ | |||
17 | #ifndef _ASYNCIO_H | 17 | #ifndef _ASYNCIO_H |
18 | #define _ASYNCIO_H | 18 | #define _ASYNCIO_H |
19 | 19 | ||
20 | #include <cstring> | ||
21 | #include <cstdint> | ||
22 | #include <linux/aio_abi.h> | 20 | #include <linux/aio_abi.h> |
21 | #include <stdbool.h> | ||
22 | #include <stdint.h> | ||
23 | #include <sys/cdefs.h> | 23 | #include <sys/cdefs.h> |
24 | #include <sys/types.h> | 24 | #include <sys/types.h> |
25 | #include <time.h> | 25 | #include <time.h> |
@@ -35,10 +35,14 @@ extern "C" { | |||
35 | 35 | ||
36 | int io_setup(unsigned nr, aio_context_t* ctxp); | 36 | int io_setup(unsigned nr, aio_context_t* ctxp); |
37 | int io_destroy(aio_context_t ctx); | 37 | int io_destroy(aio_context_t ctx); |
38 | int io_submit(aio_context_t ctx, long nr, iocb** iocbpp); | 38 | int io_submit(aio_context_t ctx, long nr, struct iocb** iocbpp); |
39 | int io_getevents(aio_context_t ctx, long min_nr, long max_nr, io_event* events, timespec* timeout); | 39 | int io_getevents(aio_context_t ctx, long min_nr, long max_nr, struct io_event* events, |
40 | int io_cancel(aio_context_t ctx, iocb*, io_event* result); | 40 | struct timespec* timeout); |
41 | void io_prep(iocb* iocb, int fd, const void* buf, uint64_t count, int64_t offset, bool read); | 41 | int io_cancel(aio_context_t ctx, struct iocb*, struct io_event* result); |
42 | |||
43 | void io_prep_pread(struct iocb* iocb, int fd, void* buf, size_t count, long long offset); | ||
44 | void io_prep_pwrite(struct iocb* iocb, int fd, void* buf, size_t count, long long offset); | ||
45 | void io_prep(struct iocb* iocb, int fd, const void* buf, uint64_t count, int64_t offset, bool read); | ||
42 | 46 | ||
43 | #ifdef __cplusplus | 47 | #ifdef __cplusplus |
44 | }; | 48 | }; |