diff options
author | Josh Gao | 2018-05-25 00:59:58 -0500 |
---|---|---|
committer | Gerrit Code Review | 2018-05-25 00:59:58 -0500 |
commit | e82401e592c6c45eca854525c91530ef8422db40 (patch) | |
tree | d48a98b4e800a88a3da46e45a31ca6dbca0a8b66 /adb/adb_unique_fd.h | |
parent | 6c9bb058c5801bd2fd52ceabd0aecd96776f0e71 (diff) | |
parent | 6e1246c234bdfc41ff80b6d23599c56284d297ad (diff) | |
download | platform-system-core-e82401e592c6c45eca854525c91530ef8422db40.tar.gz platform-system-core-e82401e592c6c45eca854525c91530ef8422db40.tar.xz platform-system-core-e82401e592c6c45eca854525c91530ef8422db40.zip |
Merge "adb: really fix the mac build."
Diffstat (limited to 'adb/adb_unique_fd.h')
-rw-r--r-- | adb/adb_unique_fd.h | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/adb/adb_unique_fd.h b/adb/adb_unique_fd.h index d1dc9d10e..be6326255 100644 --- a/adb/adb_unique_fd.h +++ b/adb/adb_unique_fd.h | |||
@@ -29,44 +29,5 @@ struct AdbCloser { | |||
29 | using unique_fd = android::base::unique_fd_impl<AdbCloser>; | 29 | using unique_fd = android::base::unique_fd_impl<AdbCloser>; |
30 | 30 | ||
31 | #if !defined(_WIN32) | 31 | #if !defined(_WIN32) |
32 | inline bool Pipe(unique_fd* read, unique_fd* write, int flags = 0) { | 32 | bool Pipe(unique_fd* read, unique_fd* write, int flags = 0); |
33 | int pipefd[2]; | ||
34 | #if !defined(__APPLE__) | ||
35 | if (pipe2(pipefd, flags) != 0) { | ||
36 | return false; | ||
37 | } | ||
38 | #else | ||
39 | // Darwin doesn't have pipe2. Implement it ourselves. | ||
40 | if (flags != 0 && (flags & ~(O_CLOEXEC | O_NONBLOCK)) != 0) { | ||
41 | errno = EINVAL; | ||
42 | return false; | ||
43 | } | ||
44 | |||
45 | if (pipe(pipefd) != 0) { | ||
46 | return false; | ||
47 | } | ||
48 | |||
49 | if (flags & O_CLOEXEC) { | ||
50 | if (fcntl(pipefd[0], F_SETFD, FD_CLOEXEC) != 0 || | ||
51 | fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) != 0) { | ||
52 | close(pipefd[0]); | ||
53 | close(pipefd[1]); | ||
54 | return false; | ||
55 | } | ||
56 | } | ||
57 | |||
58 | if (flags & O_NONBLOCK) { | ||
59 | if (fcntl(pipefd[0], F_SETFL, O_NONBLOCK) != 0 || | ||
60 | fcntl(pipefd[1], F_SETFL, O_NONBLOCK) != 0) { | ||
61 | close(pipefd[0]); | ||
62 | close(pipefd[1]); | ||
63 | return false; | ||
64 | } | ||
65 | } | ||
66 | #endif | ||
67 | |||
68 | read->reset(pipefd[0]); | ||
69 | write->reset(pipefd[1]); | ||
70 | return true; | ||
71 | } | ||
72 | #endif | 33 | #endif |