diff options
-rw-r--r-- | adb/Android.mk | 3 | ||||
-rw-r--r-- | adb/transport_local.cpp | 2 | ||||
-rw-r--r-- | include/system/qemu_pipe.h (renamed from qemu_pipe/qemu_pipe.cpp) | 16 | ||||
-rw-r--r-- | qemu_pipe/Android.mk | 19 | ||||
-rw-r--r-- | qemu_pipe/include/qemu_pipe.h | 62 |
5 files changed, 11 insertions, 91 deletions
diff --git a/adb/Android.mk b/adb/Android.mk index a05bb551e..e84120542 100644 --- a/adb/Android.mk +++ b/adb/Android.mk | |||
@@ -128,7 +128,7 @@ LOCAL_SANITIZE := $(adb_target_sanitize) | |||
128 | 128 | ||
129 | # Even though we're building a static library (and thus there's no link step for | 129 | # Even though we're building a static library (and thus there's no link step for |
130 | # this to take effect), this adds the includes to our path. | 130 | # this to take effect), this adds the includes to our path. |
131 | LOCAL_STATIC_LIBRARIES := libcrypto_utils libcrypto libqemu_pipe libbase | 131 | LOCAL_STATIC_LIBRARIES := libcrypto_utils libcrypto libbase |
132 | 132 | ||
133 | LOCAL_WHOLE_STATIC_LIBRARIES := libadbd_usb | 133 | LOCAL_WHOLE_STATIC_LIBRARIES := libadbd_usb |
134 | 134 | ||
@@ -361,7 +361,6 @@ LOCAL_STRIP_MODULE := keep_symbols | |||
361 | LOCAL_STATIC_LIBRARIES := \ | 361 | LOCAL_STATIC_LIBRARIES := \ |
362 | libadbd \ | 362 | libadbd \ |
363 | libbase \ | 363 | libbase \ |
364 | libqemu_pipe \ | ||
365 | libbootloader_message \ | 364 | libbootloader_message \ |
366 | libfs_mgr \ | 365 | libfs_mgr \ |
367 | libfec \ | 366 | libfec \ |
diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp index 12b98ba3b..4198a5247 100644 --- a/adb/transport_local.cpp +++ b/adb/transport_local.cpp | |||
@@ -289,7 +289,7 @@ static void server_socket_thread(void* arg) { | |||
289 | #define open adb_open | 289 | #define open adb_open |
290 | #define read adb_read | 290 | #define read adb_read |
291 | #define write adb_write | 291 | #define write adb_write |
292 | #include <qemu_pipe.h> | 292 | #include <system/qemu_pipe.h> |
293 | #undef open | 293 | #undef open |
294 | #undef read | 294 | #undef read |
295 | #undef write | 295 | #undef write |
diff --git a/qemu_pipe/qemu_pipe.cpp b/include/system/qemu_pipe.h index a4529deb8..af2507997 100644 --- a/qemu_pipe/qemu_pipe.cpp +++ b/include/system/qemu_pipe.h | |||
@@ -13,15 +13,13 @@ | |||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | #ifndef ANDROID_INCLUDE_SYSTEM_QEMU_PIPE_H | |
17 | #include "qemu_pipe.h" | 17 | #define ANDROID_INCLUDE_SYSTEM_QEMU_PIPE_H |
18 | 18 | ||
19 | #include <unistd.h> | 19 | #include <unistd.h> |
20 | #include <fcntl.h> | 20 | #include <fcntl.h> |
21 | #include <string.h> | 21 | #include <string.h> |
22 | #include <errno.h> | 22 | #include <errno.h> |
23 | #include <stdio.h> | ||
24 | |||
25 | 23 | ||
26 | // Define QEMU_PIPE_DEBUG if you want to print error messages when an error | 24 | // Define QEMU_PIPE_DEBUG if you want to print error messages when an error |
27 | // occurs during pipe operations. The macro should simply take a printf-style | 25 | // occurs during pipe operations. The macro should simply take a printf-style |
@@ -50,7 +48,7 @@ | |||
50 | // You should be able to open several pipes to the same pipe service, | 48 | // You should be able to open several pipes to the same pipe service, |
51 | // except for a few special cases (e.g. GSM modem), where EBUSY will be | 49 | // except for a few special cases (e.g. GSM modem), where EBUSY will be |
52 | // returned if more than one client tries to connect to it. | 50 | // returned if more than one client tries to connect to it. |
53 | int qemu_pipe_open(const char* pipeName) { | 51 | static __inline__ int qemu_pipe_open(const char* pipeName) { |
54 | // Sanity check. | 52 | // Sanity check. |
55 | if (!pipeName || memcmp(pipeName, "pipe:", 5) != 0) { | 53 | if (!pipeName || memcmp(pipeName, "pipe:", 5) != 0) { |
56 | errno = EINVAL; | 54 | errno = EINVAL; |
@@ -83,7 +81,9 @@ int qemu_pipe_open(const char* pipeName) { | |||
83 | // Send a framed message |buff| of |len| bytes through the |fd| descriptor. | 81 | // Send a framed message |buff| of |len| bytes through the |fd| descriptor. |
84 | // This really adds a 4-hexchar prefix describing the payload size. | 82 | // This really adds a 4-hexchar prefix describing the payload size. |
85 | // Returns 0 on success, and -1 on error. | 83 | // Returns 0 on success, and -1 on error. |
86 | int qemu_pipe_frame_send(int fd, const void* buff, size_t len) { | 84 | static int __inline__ qemu_pipe_frame_send(int fd, |
85 | const void* buff, | ||
86 | size_t len) { | ||
87 | char header[5]; | 87 | char header[5]; |
88 | snprintf(header, sizeof(header), "%04zx", len); | 88 | snprintf(header, sizeof(header), "%04zx", len); |
89 | ssize_t ret = TEMP_FAILURE_RETRY(write(fd, header, 4)); | 89 | ssize_t ret = TEMP_FAILURE_RETRY(write(fd, header, 4)); |
@@ -104,7 +104,7 @@ int qemu_pipe_frame_send(int fd, const void* buff, size_t len) { | |||
104 | // content is lost. Otherwise, this returns the size of the message. NOTE: | 104 | // content is lost. Otherwise, this returns the size of the message. NOTE: |
105 | // empty messages are possible in a framed wire protocol and do not mean | 105 | // empty messages are possible in a framed wire protocol and do not mean |
106 | // end-of-stream. | 106 | // end-of-stream. |
107 | int qemu_pipe_frame_recv(int fd, void* buff, size_t len) { | 107 | static int __inline__ qemu_pipe_frame_recv(int fd, void* buff, size_t len) { |
108 | char header[5]; | 108 | char header[5]; |
109 | ssize_t ret = TEMP_FAILURE_RETRY(read(fd, header, 4)); | 109 | ssize_t ret = TEMP_FAILURE_RETRY(read(fd, header, 4)); |
110 | if (ret != 4) { | 110 | if (ret != 4) { |
@@ -130,3 +130,5 @@ int qemu_pipe_frame_recv(int fd, void* buff, size_t len) { | |||
130 | } | 130 | } |
131 | return size; | 131 | return size; |
132 | } | 132 | } |
133 | |||
134 | #endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_PIPE_H */ | ||
diff --git a/qemu_pipe/Android.mk b/qemu_pipe/Android.mk deleted file mode 100644 index 6e0144ce1..000000000 --- a/qemu_pipe/Android.mk +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | # Copyright 2011 The Android Open Source Project | ||
2 | |||
3 | LOCAL_PATH:= $(call my-dir) | ||
4 | |||
5 | common_static_libraries := \ | ||
6 | libbase | ||
7 | include $(CLEAR_VARS) | ||
8 | LOCAL_CLANG := true | ||
9 | LOCAL_SANITIZE := integer | ||
10 | LOCAL_SRC_FILES:= \ | ||
11 | qemu_pipe.cpp | ||
12 | LOCAL_C_INCLUDES := \ | ||
13 | $(LOCAL_PATH)/include \ | ||
14 | system/base/include | ||
15 | LOCAL_MODULE:= libqemu_pipe | ||
16 | LOCAL_STATIC_LIBRARIES := $(common_static_libraries) | ||
17 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include | ||
18 | LOCAL_CFLAGS := -Werror | ||
19 | include $(BUILD_STATIC_LIBRARY) | ||
diff --git a/qemu_pipe/include/qemu_pipe.h b/qemu_pipe/include/qemu_pipe.h deleted file mode 100644 index 16486c087..000000000 --- a/qemu_pipe/include/qemu_pipe.h +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | #ifndef ANDROID_CORE_INCLUDE_QEMU_PIPE_H | ||
17 | #define ANDROID_CORE_INCLUDE_QEMU_PIPE_H | ||
18 | |||
19 | #include <stddef.h> | ||
20 | |||
21 | #ifdef __cplusplus | ||
22 | extern "C" { | ||
23 | #endif | ||
24 | // Try to open a new Qemu fast-pipe. This function returns a file descriptor | ||
25 | // that can be used to communicate with a named service managed by the | ||
26 | // emulator. | ||
27 | // | ||
28 | // This file descriptor can be used as a standard pipe/socket descriptor. | ||
29 | // | ||
30 | // 'pipeName' is the name of the emulator service you want to connect to, | ||
31 | // and must begin with 'pipe:' (e.g. 'pipe:camera' or 'pipe:opengles'). | ||
32 | // | ||
33 | // On success, return a valid file descriptor, or -1/errno on failure. E.g.: | ||
34 | // | ||
35 | // EINVAL -> unknown/unsupported pipeName | ||
36 | // ENOSYS -> fast pipes not available in this system. | ||
37 | // | ||
38 | // ENOSYS should never happen, except if you're trying to run within a | ||
39 | // misconfigured emulator. | ||
40 | // | ||
41 | // You should be able to open several pipes to the same pipe service, | ||
42 | // except for a few special cases (e.g. GSM modem), where EBUSY will be | ||
43 | // returned if more than one client tries to connect to it. | ||
44 | int qemu_pipe_open(const char* pipeName); | ||
45 | |||
46 | // Send a framed message |buff| of |len| bytes through the |fd| descriptor. | ||
47 | // This really adds a 4-hexchar prefix describing the payload size. | ||
48 | // Returns 0 on success, and -1 on error. | ||
49 | int qemu_pipe_frame_send(int fd, const void* buff, size_t len); | ||
50 | |||
51 | // Read a frame message from |fd|, and store it into |buff| of |len| bytes. | ||
52 | // If the framed message is larger than |len|, then this returns -1 and the | ||
53 | // content is lost. Otherwise, this returns the size of the message. NOTE: | ||
54 | // empty messages are possible in a framed wire protocol and do not mean | ||
55 | // end-of-stream. | ||
56 | int qemu_pipe_frame_recv(int fd, void* buff, size_t len); | ||
57 | |||
58 | #ifdef __cplusplus | ||
59 | } | ||
60 | #endif | ||
61 | |||
62 | #endif /* ANDROID_CORE_INCLUDE_QEMU_PIPE_H */ | ||