summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerry Zhang2018-03-06 13:35:21 -0600
committerGerrit Code Review2018-03-06 13:35:21 -0600
commit5180d5b4dc77eac334632902dae9bc6794ca3299 (patch)
tree8e89055c214b3322c88132771fda205b583fb3b8
parentd555e08224d2a08f4f12c16ae4109b63b9f7def9 (diff)
parentc3d4e7226a74c3c4092480606ef07e0d30a2d42d (diff)
downloadplatform-system-core-5180d5b4dc77eac334632902dae9bc6794ca3299.tar.gz
platform-system-core-5180d5b4dc77eac334632902dae9bc6794ca3299.tar.xz
platform-system-core-5180d5b4dc77eac334632902dae9bc6794ca3299.zip
Merge "Make libasyncio headers usable from C"android-p-preview-1
-rw-r--r--adb/daemon/usb.cpp2
-rw-r--r--libasyncio/AsyncIO.cpp11
-rw-r--r--libasyncio/include/asyncio/AsyncIO.h16
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
21int io_setup(unsigned nr, aio_context_t* ctxp) { 23int 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
53void 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
57void 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
36int io_setup(unsigned nr, aio_context_t* ctxp); 36int io_setup(unsigned nr, aio_context_t* ctxp);
37int io_destroy(aio_context_t ctx); 37int io_destroy(aio_context_t ctx);
38int io_submit(aio_context_t ctx, long nr, iocb** iocbpp); 38int io_submit(aio_context_t ctx, long nr, struct iocb** iocbpp);
39int io_getevents(aio_context_t ctx, long min_nr, long max_nr, io_event* events, timespec* timeout); 39int io_getevents(aio_context_t ctx, long min_nr, long max_nr, struct io_event* events,
40int io_cancel(aio_context_t ctx, iocb*, io_event* result); 40 struct timespec* timeout);
41void io_prep(iocb* iocb, int fd, const void* buf, uint64_t count, int64_t offset, bool read); 41int io_cancel(aio_context_t ctx, struct iocb*, struct io_event* result);
42
43void io_prep_pread(struct iocb* iocb, int fd, void* buf, size_t count, long long offset);
44void io_prep_pwrite(struct iocb* iocb, int fd, void* buf, size_t count, long long offset);
45void 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};