The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | |
| 17 | /* this file contains system-dependent definitions used by ADB |
| 18 | * they're related to threads, sockets and file descriptors |
| 19 | */ |
| 20 | #ifndef _ADB_SYSDEPS_H |
| 21 | #define _ADB_SYSDEPS_H |
| 22 | |
| 23 | #ifdef __CYGWIN__ |
| 24 | # undef _WIN32 |
| 25 | #endif |
| 26 | |
Elliott Hughes | 43df109 | 2015-07-23 17:12:58 -0700 | [diff] [blame] | 27 | #include <errno.h> |
| 28 | |
Spencer Low | 753d485 | 2015-07-30 23:07:55 -0700 | [diff] [blame] | 29 | #include <string> |
| 30 | |
Dan Albert | 66a91b0 | 2015-02-24 21:26:58 -0800 | [diff] [blame] | 31 | /* |
| 32 | * TEMP_FAILURE_RETRY is defined by some, but not all, versions of |
| 33 | * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's |
| 34 | * not already defined, then define it here. |
| 35 | */ |
| 36 | #ifndef TEMP_FAILURE_RETRY |
| 37 | /* Used to retry syscalls that can return EINTR. */ |
| 38 | #define TEMP_FAILURE_RETRY(exp) ({ \ |
| 39 | typeof (exp) _rc; \ |
| 40 | do { \ |
| 41 | _rc = (exp); \ |
| 42 | } while (_rc == -1 && errno == EINTR); \ |
| 43 | _rc; }) |
| 44 | #endif |
| 45 | |
Spencer Low | 6815c07 | 2015-05-11 01:08:48 -0700 | [diff] [blame] | 46 | // Some printf-like functions are implemented in terms of |
| 47 | // android::base::StringAppendV, so they should use the same attribute for |
| 48 | // compile-time format string checking. On Windows, if the mingw version of |
| 49 | // vsnprintf is used in StringAppendV, use `gnu_printf' which allows z in %zd |
| 50 | // and PRIu64 (and related) to be recognized by the compile-time checking. |
| 51 | #define ADB_FORMAT_ARCHETYPE __printf__ |
| 52 | #ifdef __USE_MINGW_ANSI_STDIO |
| 53 | #if __USE_MINGW_ANSI_STDIO |
| 54 | #undef ADB_FORMAT_ARCHETYPE |
| 55 | #define ADB_FORMAT_ARCHETYPE gnu_printf |
| 56 | #endif |
| 57 | #endif |
| 58 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 59 | #ifdef _WIN32 |
| 60 | |
Dan Albert | bbbbea6 | 2014-11-24 23:34:35 -0800 | [diff] [blame] | 61 | #include <ctype.h> |
| 62 | #include <direct.h> |
Spencer Low | 6815c07 | 2015-05-11 01:08:48 -0700 | [diff] [blame] | 63 | #include <dirent.h> |
Dan Albert | bbbbea6 | 2014-11-24 23:34:35 -0800 | [diff] [blame] | 64 | #include <errno.h> |
| 65 | #include <fcntl.h> |
| 66 | #include <io.h> |
| 67 | #include <process.h> |
| 68 | #include <sys/stat.h> |
Spencer Low | 6815c07 | 2015-05-11 01:08:48 -0700 | [diff] [blame] | 69 | #include <utime.h> |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 70 | #include <winsock2.h> |
Stephen Hines | b117085 | 2014-10-01 17:37:06 -0700 | [diff] [blame] | 71 | #include <windows.h> |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 72 | #include <ws2tcpip.h> |
Dan Albert | bbbbea6 | 2014-11-24 23:34:35 -0800 | [diff] [blame] | 73 | |
Spencer Low | 2bbb3a9 | 2015-08-26 18:46:09 -0700 | [diff] [blame] | 74 | #include <memory> // unique_ptr |
Spencer Low | 6815c07 | 2015-05-11 01:08:48 -0700 | [diff] [blame] | 75 | #include <string> // Prototypes for narrow() and widen() use std::(w)string. |
Alex Vallée | 28d1f8d | 2015-05-06 16:26:00 -0400 | [diff] [blame] | 76 | |
Dan Albert | bbbbea6 | 2014-11-24 23:34:35 -0800 | [diff] [blame] | 77 | #include "fdevent.h" |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 78 | |
Elliott Hughes | d189cfb | 2015-07-30 17:42:01 -0700 | [diff] [blame] | 79 | #define OS_PATH_SEPARATORS "\\/" |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 80 | #define OS_PATH_SEPARATOR '\\' |
| 81 | #define OS_PATH_SEPARATOR_STR "\\" |
Benoit Goby | 2cc19e4 | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 82 | #define ENV_PATH_SEPARATOR_STR ";" |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 83 | |
| 84 | typedef CRITICAL_SECTION adb_mutex_t; |
| 85 | |
| 86 | #define ADB_MUTEX_DEFINE(x) adb_mutex_t x |
| 87 | |
| 88 | /* declare all mutexes */ |
JP Abgrall | 2e5dd6e | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 89 | /* For win32, adb_sysdeps_init() will do the mutex runtime initialization. */ |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 90 | #define ADB_MUTEX(x) extern adb_mutex_t x; |
| 91 | #include "mutex_list.h" |
| 92 | |
| 93 | extern void adb_sysdeps_init(void); |
| 94 | |
| 95 | static __inline__ void adb_mutex_lock( adb_mutex_t* lock ) |
| 96 | { |
| 97 | EnterCriticalSection( lock ); |
| 98 | } |
| 99 | |
| 100 | static __inline__ void adb_mutex_unlock( adb_mutex_t* lock ) |
| 101 | { |
| 102 | LeaveCriticalSection( lock ); |
| 103 | } |
| 104 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 105 | typedef void* (*adb_thread_func_t)(void* arg); |
| 106 | |
| 107 | typedef void (*win_thread_func_t)(void* arg); |
| 108 | |
Elliott Hughes | f251714 | 2015-05-05 13:41:21 -0700 | [diff] [blame] | 109 | static __inline__ bool adb_thread_create(adb_thread_func_t func, void* arg) { |
Elliott Hughes | 30f2e2b | 2015-05-05 14:34:41 -0700 | [diff] [blame] | 110 | uintptr_t tid = _beginthread((win_thread_func_t)func, 0, arg); |
| 111 | return (tid != static_cast<uintptr_t>(-1L)); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 112 | } |
| 113 | |
Siva Velusamy | 2669cf9 | 2015-08-28 16:37:29 -0700 | [diff] [blame] | 114 | static __inline__ int adb_thread_setname(const std::string& name) { |
| 115 | // TODO: See https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx for how to set |
| 116 | // the thread name in Windows. Unfortunately, it only works during debugging, but |
| 117 | // our build process doesn't generate PDB files needed for debugging. |
| 118 | return 0; |
| 119 | } |
| 120 | |
leozwang | 1be5462 | 2014-08-15 09:51:27 -0700 | [diff] [blame] | 121 | static __inline__ unsigned long adb_thread_id() |
| 122 | { |
| 123 | return GetCurrentThreadId(); |
| 124 | } |
| 125 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 126 | static __inline__ void close_on_exec(int fd) |
| 127 | { |
David 'Digit' Turner | 1f1efb5 | 2009-05-18 17:36:28 +0200 | [diff] [blame] | 128 | /* nothing really */ |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 129 | } |
| 130 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 131 | #define lstat stat /* no symlinks on Win32 */ |
| 132 | |
| 133 | #define S_ISLNK(m) 0 /* no symlinks on Win32 */ |
| 134 | |
Spencer Low | 6815c07 | 2015-05-11 01:08:48 -0700 | [diff] [blame] | 135 | extern int adb_unlink(const char* path); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 136 | #undef unlink |
| 137 | #define unlink ___xxx_unlink |
| 138 | |
Spencer Low | 6815c07 | 2015-05-11 01:08:48 -0700 | [diff] [blame] | 139 | extern int adb_mkdir(const std::string& path, int mode); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 140 | #undef mkdir |
| 141 | #define mkdir ___xxx_mkdir |
| 142 | |
Spencer Low | 3a2421b | 2015-05-22 20:09:06 -0700 | [diff] [blame] | 143 | // See the comments for the !defined(_WIN32) versions of adb_*(). |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 144 | extern int adb_open(const char* path, int options); |
| 145 | extern int adb_creat(const char* path, int mode); |
| 146 | extern int adb_read(int fd, void* buf, int len); |
| 147 | extern int adb_write(int fd, const void* buf, int len); |
| 148 | extern int adb_lseek(int fd, int pos, int where); |
Mike Lockwood | 81ffe17 | 2009-10-11 23:04:18 -0400 | [diff] [blame] | 149 | extern int adb_shutdown(int fd); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 150 | extern int adb_close(int fd); |
| 151 | |
Spencer Low | 3a2421b | 2015-05-22 20:09:06 -0700 | [diff] [blame] | 152 | // See the comments for the !defined(_WIN32) version of unix_close(). |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 153 | static __inline__ int unix_close(int fd) |
| 154 | { |
| 155 | return close(fd); |
| 156 | } |
| 157 | #undef close |
| 158 | #define close ____xxx_close |
| 159 | |
Spencer Low | 3a2421b | 2015-05-22 20:09:06 -0700 | [diff] [blame] | 160 | // See the comments for the !defined(_WIN32) version of unix_read(). |
Spencer Low | beb6198 | 2015-03-01 15:06:21 -0800 | [diff] [blame] | 161 | extern int unix_read(int fd, void* buf, size_t len); |
| 162 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 163 | #undef read |
| 164 | #define read ___xxx_read |
| 165 | |
Spencer Low | 3a2421b | 2015-05-22 20:09:06 -0700 | [diff] [blame] | 166 | // See the comments for the !defined(_WIN32) version of unix_write(). |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 167 | static __inline__ int unix_write(int fd, const void* buf, size_t len) |
| 168 | { |
| 169 | return write(fd, buf, len); |
| 170 | } |
| 171 | #undef write |
| 172 | #define write ___xxx_write |
| 173 | |
Spencer Low | 3a2421b | 2015-05-22 20:09:06 -0700 | [diff] [blame] | 174 | // See the comments for the !defined(_WIN32) version of adb_open_mode(). |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 175 | static __inline__ int adb_open_mode(const char* path, int options, int mode) |
| 176 | { |
David 'Digit' Turner | 1f1efb5 | 2009-05-18 17:36:28 +0200 | [diff] [blame] | 177 | return adb_open(path, options); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 178 | } |
| 179 | |
Spencer Low | 3a2421b | 2015-05-22 20:09:06 -0700 | [diff] [blame] | 180 | // See the comments for the !defined(_WIN32) version of unix_open(). |
Spencer Low | 6815c07 | 2015-05-11 01:08:48 -0700 | [diff] [blame] | 181 | extern int unix_open(const char* path, int options, ...); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 182 | #define open ___xxx_unix_open |
| 183 | |
| 184 | |
| 185 | /* normally provided by <cutils/misc.h> */ |
| 186 | extern void* load_file(const char* pathname, unsigned* psize); |
| 187 | |
David 'Digit' Turner | b1c2c95 | 2009-05-18 17:07:46 +0200 | [diff] [blame] | 188 | /* normally provided by "fdevent.h" */ |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 189 | |
| 190 | #define FDE_READ 0x0001 |
| 191 | #define FDE_WRITE 0x0002 |
| 192 | #define FDE_ERROR 0x0004 |
| 193 | #define FDE_DONT_CLOSE 0x0080 |
| 194 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 195 | typedef void (*fd_func)(int fd, unsigned events, void *userdata); |
| 196 | |
| 197 | fdevent *fdevent_create(int fd, fd_func func, void *arg); |
| 198 | void fdevent_destroy(fdevent *fde); |
| 199 | void fdevent_install(fdevent *fde, int fd, fd_func func, void *arg); |
| 200 | void fdevent_remove(fdevent *item); |
| 201 | void fdevent_set(fdevent *fde, unsigned events); |
| 202 | void fdevent_add(fdevent *fde, unsigned events); |
| 203 | void fdevent_del(fdevent *fde, unsigned events); |
| 204 | void fdevent_loop(); |
| 205 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 206 | static __inline__ void adb_sleep_ms( int mseconds ) |
| 207 | { |
David 'Digit' Turner | 1f1efb5 | 2009-05-18 17:36:28 +0200 | [diff] [blame] | 208 | Sleep( mseconds ); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 209 | } |
| 210 | |
Spencer Low | 753d485 | 2015-07-30 23:07:55 -0700 | [diff] [blame] | 211 | int network_loopback_client(int port, int type, std::string* error); |
| 212 | int network_loopback_server(int port, int type, std::string* error); |
| 213 | int network_inaddr_any_server(int port, int type, std::string* error); |
| 214 | int network_connect(const std::string& host, int port, int type, int timeout, |
| 215 | std::string* error); |
| 216 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 217 | extern int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrlen); |
| 218 | |
| 219 | #undef accept |
| 220 | #define accept ___xxx_accept |
| 221 | |
Spencer Low | 31aafa6 | 2015-01-25 14:40:16 -0800 | [diff] [blame] | 222 | extern int adb_setsockopt(int fd, int level, int optname, const void* optval, socklen_t optlen); |
| 223 | |
| 224 | #undef setsockopt |
| 225 | #define setsockopt ___xxx_setsockopt |
| 226 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 227 | static __inline__ int adb_socket_setbufsize( int fd, int bufsize ) |
| 228 | { |
| 229 | int opt = bufsize; |
Spencer Low | 31aafa6 | 2015-01-25 14:40:16 -0800 | [diff] [blame] | 230 | return adb_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const void*)&opt, sizeof(opt)); |
| 231 | } |
| 232 | |
| 233 | static __inline__ void disable_tcp_nagle( int fd ) |
| 234 | { |
| 235 | int on = 1; |
| 236 | adb_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void*)&on, sizeof(on)); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | extern int adb_socketpair( int sv[2] ); |
| 240 | |
Elliott Hughes | d189cfb | 2015-07-30 17:42:01 -0700 | [diff] [blame] | 241 | static __inline__ int adb_is_absolute_host_path(const char* path) { |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 242 | return isalpha(path[0]) && path[1] == ':' && path[2] == '\\'; |
| 243 | } |
| 244 | |
Spencer Low | 753d485 | 2015-07-30 23:07:55 -0700 | [diff] [blame] | 245 | // Like strerror(), but for Win32 error codes. |
| 246 | std::string SystemErrorCodeToString(DWORD error_code); |
| 247 | |
Spencer Low | 6815c07 | 2015-05-11 01:08:48 -0700 | [diff] [blame] | 248 | // We later define a macro mapping 'stat' to 'adb_stat'. This causes: |
| 249 | // struct stat s; |
| 250 | // stat(filename, &s); |
| 251 | // To turn into the following: |
| 252 | // struct adb_stat s; |
| 253 | // adb_stat(filename, &s); |
| 254 | // To get this to work, we need to make 'struct adb_stat' the same as |
| 255 | // 'struct stat'. Note that this definition of 'struct adb_stat' uses the |
| 256 | // *current* macro definition of stat, so it may actually be inheriting from |
| 257 | // struct _stat32i64 (or some other remapping). |
| 258 | struct adb_stat : public stat {}; |
| 259 | |
| 260 | static_assert(sizeof(struct adb_stat) == sizeof(struct stat), |
| 261 | "structures should be the same"); |
| 262 | |
| 263 | extern int adb_stat(const char* f, struct adb_stat* s); |
| 264 | |
| 265 | // stat is already a macro, undefine it so we can redefine it. |
| 266 | #undef stat |
| 267 | #define stat adb_stat |
| 268 | |
| 269 | // UTF-8 versions of POSIX APIs. |
| 270 | extern DIR* adb_opendir(const char* dirname); |
| 271 | extern struct dirent* adb_readdir(DIR* dir); |
| 272 | extern int adb_closedir(DIR* dir); |
| 273 | |
| 274 | extern int adb_utime(const char *, struct utimbuf *); |
| 275 | extern int adb_chmod(const char *, int); |
| 276 | |
| 277 | extern int adb_vfprintf(FILE *stream, const char *format, va_list ap) |
| 278 | __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 2, 0))); |
| 279 | extern int adb_fprintf(FILE *stream, const char *format, ...) |
| 280 | __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 2, 3))); |
| 281 | extern int adb_printf(const char *format, ...) |
| 282 | __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 1, 2))); |
| 283 | |
| 284 | extern int adb_fputs(const char* buf, FILE* stream); |
| 285 | extern int adb_fputc(int ch, FILE* stream); |
| 286 | extern size_t adb_fwrite(const void* ptr, size_t size, size_t nmemb, |
| 287 | FILE* stream); |
| 288 | |
| 289 | extern FILE* adb_fopen(const char* f, const char* m); |
| 290 | |
| 291 | extern char* adb_getenv(const char* name); |
| 292 | |
| 293 | extern char* adb_getcwd(char* buf, int size); |
| 294 | |
| 295 | // Remap calls to POSIX APIs to our UTF-8 versions. |
| 296 | #define opendir adb_opendir |
| 297 | #define readdir adb_readdir |
| 298 | #define closedir adb_closedir |
| 299 | #define rewinddir rewinddir_utf8_not_yet_implemented |
| 300 | #define telldir telldir_utf8_not_yet_implemented |
| 301 | #define seekdir seekdir_utf8_not_yet_implemented |
| 302 | |
| 303 | #define utime adb_utime |
| 304 | #define chmod adb_chmod |
| 305 | |
| 306 | #define vfprintf adb_vfprintf |
| 307 | #define fprintf adb_fprintf |
| 308 | #define printf adb_printf |
| 309 | #define fputs adb_fputs |
| 310 | #define fputc adb_fputc |
| 311 | #define fwrite adb_fwrite |
| 312 | |
| 313 | #define fopen adb_fopen |
| 314 | |
| 315 | #define getenv adb_getenv |
| 316 | #define putenv putenv_utf8_not_yet_implemented |
| 317 | #define setenv setenv_utf8_not_yet_implemented |
| 318 | #define unsetenv unsetenv_utf8_not_yet_implemented |
| 319 | |
| 320 | #define getcwd adb_getcwd |
| 321 | |
| 322 | // Convert from UTF-8 to UTF-16, typically used to convert char strings into |
| 323 | // wchar_t strings that can be passed to wchar_t-based OS and C Runtime APIs |
| 324 | // on Windows. |
| 325 | extern std::wstring widen(const std::string& utf8); |
| 326 | extern std::wstring widen(const char* utf8); |
| 327 | |
| 328 | // Convert from UTF-16 to UTF-8, typically used to convert strings from OS and |
| 329 | // C Runtime APIs that return wchar_t, to a format for our char-based data |
| 330 | // structures. |
| 331 | extern std::string narrow(const std::wstring& utf16); |
| 332 | extern std::string narrow(const wchar_t* utf16); |
| 333 | |
| 334 | // Helper class to convert UTF-16 argv from wmain() to UTF-8 args that can be |
| 335 | // passed to main(). |
| 336 | class NarrowArgs { |
| 337 | public: |
| 338 | NarrowArgs(int argc, wchar_t** argv); |
| 339 | ~NarrowArgs(); |
| 340 | |
| 341 | inline char** data() { |
| 342 | return narrow_args; |
| 343 | } |
| 344 | |
| 345 | private: |
| 346 | char** narrow_args; |
| 347 | }; |
| 348 | |
Spencer Low | b28812f | 2015-08-08 15:07:07 -0700 | [diff] [blame] | 349 | // Windows HANDLE values only use 32-bits of the type, even on 64-bit machines, |
| 350 | // so they can fit in an int. To convert back, we just need to sign-extend. |
| 351 | // https://msdn.microsoft.com/en-us/library/windows/desktop/aa384203%28v=vs.85%29.aspx |
| 352 | // Note that this does not make a HANDLE value work with APIs like open(), nor |
| 353 | // does this make a value from open() passable to APIs taking a HANDLE. This |
| 354 | // just lets you take a HANDLE, pass it around as an int, and then use it again |
| 355 | // as a HANDLE. |
| 356 | inline int cast_handle_to_int(const HANDLE h) { |
| 357 | // truncate |
| 358 | return static_cast<int>(reinterpret_cast<INT_PTR>(h)); |
| 359 | } |
| 360 | |
| 361 | inline HANDLE cast_int_to_handle(const int fd) { |
| 362 | // sign-extend |
| 363 | return reinterpret_cast<HANDLE>(static_cast<INT_PTR>(fd)); |
| 364 | } |
| 365 | |
Spencer Low | 2bbb3a9 | 2015-08-26 18:46:09 -0700 | [diff] [blame] | 366 | // Deleter for unique_handle. Adapted from many sources, including: |
| 367 | // http://stackoverflow.com/questions/14841396/stdunique-ptr-deleters-and-the-win32-api |
| 368 | // https://visualstudiomagazine.com/articles/2013/09/01/get-a-handle-on-the-windows-api.aspx |
| 369 | class handle_deleter { |
| 370 | public: |
| 371 | typedef HANDLE pointer; |
| 372 | |
| 373 | void operator()(HANDLE h); |
| 374 | }; |
| 375 | |
| 376 | // Like std::unique_ptr, but for Windows HANDLE objects that should be |
| 377 | // CloseHandle()'d. Operator bool() only checks if the handle != nullptr, |
| 378 | // but does not check if the handle != INVALID_HANDLE_VALUE. |
| 379 | typedef std::unique_ptr<HANDLE, handle_deleter> unique_handle; |
| 380 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 381 | #else /* !_WIN32 a.k.a. Unix */ |
| 382 | |
David 'Digit' Turner | b1c2c95 | 2009-05-18 17:07:46 +0200 | [diff] [blame] | 383 | #include "fdevent.h" |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 384 | #include <cutils/misc.h> |
Spencer Low | 753d485 | 2015-07-30 23:07:55 -0700 | [diff] [blame] | 385 | #include <cutils/sockets.h> |
Spencer Low | 5c761bd | 2015-07-21 02:06:26 -0700 | [diff] [blame] | 386 | #include <cutils/threads.h> |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 387 | #include <signal.h> |
| 388 | #include <sys/wait.h> |
| 389 | #include <sys/stat.h> |
| 390 | #include <fcntl.h> |
| 391 | |
| 392 | #include <pthread.h> |
| 393 | #include <unistd.h> |
| 394 | #include <fcntl.h> |
| 395 | #include <stdarg.h> |
Spencer Low | 753d485 | 2015-07-30 23:07:55 -0700 | [diff] [blame] | 396 | #include <netdb.h> |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 397 | #include <netinet/in.h> |
| 398 | #include <netinet/tcp.h> |
| 399 | #include <string.h> |
Kenny Root | eac025c | 2012-10-12 15:26:45 -0700 | [diff] [blame] | 400 | #include <unistd.h> |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 401 | |
Alex Vallée | 28d1f8d | 2015-05-06 16:26:00 -0400 | [diff] [blame] | 402 | #include <string> |
| 403 | |
Elliott Hughes | d189cfb | 2015-07-30 17:42:01 -0700 | [diff] [blame] | 404 | #define OS_PATH_SEPARATORS "/" |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 405 | #define OS_PATH_SEPARATOR '/' |
| 406 | #define OS_PATH_SEPARATOR_STR "/" |
Benoit Goby | 2cc19e4 | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 407 | #define ENV_PATH_SEPARATOR_STR ":" |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 408 | |
| 409 | typedef pthread_mutex_t adb_mutex_t; |
JP Abgrall | 2e5dd6e | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 410 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 411 | #define ADB_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER |
| 412 | #define adb_mutex_init pthread_mutex_init |
| 413 | #define adb_mutex_lock pthread_mutex_lock |
| 414 | #define adb_mutex_unlock pthread_mutex_unlock |
| 415 | #define adb_mutex_destroy pthread_mutex_destroy |
| 416 | |
JP Abgrall | 2e5dd6e | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 417 | #define ADB_MUTEX_DEFINE(m) adb_mutex_t m = PTHREAD_MUTEX_INITIALIZER |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 418 | |
| 419 | #define adb_cond_t pthread_cond_t |
| 420 | #define adb_cond_init pthread_cond_init |
| 421 | #define adb_cond_wait pthread_cond_wait |
| 422 | #define adb_cond_broadcast pthread_cond_broadcast |
| 423 | #define adb_cond_signal pthread_cond_signal |
| 424 | #define adb_cond_destroy pthread_cond_destroy |
| 425 | |
JP Abgrall | 2e5dd6e | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 426 | /* declare all mutexes */ |
| 427 | #define ADB_MUTEX(x) extern adb_mutex_t x; |
| 428 | #include "mutex_list.h" |
| 429 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 430 | static __inline__ void close_on_exec(int fd) |
| 431 | { |
David 'Digit' Turner | 1f1efb5 | 2009-05-18 17:36:28 +0200 | [diff] [blame] | 432 | fcntl( fd, F_SETFD, FD_CLOEXEC ); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 433 | } |
| 434 | |
Spencer Low | 3a2421b | 2015-05-22 20:09:06 -0700 | [diff] [blame] | 435 | // Open a file and return a file descriptor that may be used with unix_read(), |
| 436 | // unix_write(), unix_close(), but not adb_read(), adb_write(), adb_close(). |
| 437 | // |
| 438 | // On Unix, this is based on open(), so the file descriptor is a real OS file |
| 439 | // descriptor, but the Windows implementation (in sysdeps_win32.cpp) returns a |
| 440 | // file descriptor that can only be used with C Runtime APIs (which are wrapped |
| 441 | // by unix_read(), unix_write(), unix_close()). Also, the C Runtime has |
| 442 | // configurable CR/LF translation which defaults to text mode, but is settable |
| 443 | // with _setmode(). |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 444 | static __inline__ int unix_open(const char* path, int options,...) |
| 445 | { |
| 446 | if ((options & O_CREAT) == 0) |
| 447 | { |
Kenny Root | eac025c | 2012-10-12 15:26:45 -0700 | [diff] [blame] | 448 | return TEMP_FAILURE_RETRY( open(path, options) ); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 449 | } |
| 450 | else |
| 451 | { |
| 452 | int mode; |
| 453 | va_list args; |
| 454 | va_start( args, options ); |
| 455 | mode = va_arg( args, int ); |
| 456 | va_end( args ); |
Kenny Root | eac025c | 2012-10-12 15:26:45 -0700 | [diff] [blame] | 457 | return TEMP_FAILURE_RETRY( open( path, options, mode ) ); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 458 | } |
| 459 | } |
| 460 | |
Spencer Low | 3a2421b | 2015-05-22 20:09:06 -0700 | [diff] [blame] | 461 | // Similar to the two-argument adb_open(), but takes a mode parameter for file |
| 462 | // creation. See adb_open() for more info. |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 463 | static __inline__ int adb_open_mode( const char* pathname, int options, int mode ) |
| 464 | { |
Kenny Root | eac025c | 2012-10-12 15:26:45 -0700 | [diff] [blame] | 465 | return TEMP_FAILURE_RETRY( open( pathname, options, mode ) ); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | |
Spencer Low | 3a2421b | 2015-05-22 20:09:06 -0700 | [diff] [blame] | 469 | // Open a file and return a file descriptor that may be used with adb_read(), |
| 470 | // adb_write(), adb_close(), but not unix_read(), unix_write(), unix_close(). |
| 471 | // |
| 472 | // On Unix, this is based on open(), but the Windows implementation (in |
| 473 | // sysdeps_win32.cpp) uses Windows native file I/O and bypasses the C Runtime |
| 474 | // and its CR/LF translation. The returned file descriptor should be used with |
| 475 | // adb_read(), adb_write(), adb_close(), etc. |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 476 | static __inline__ int adb_open( const char* pathname, int options ) |
| 477 | { |
Kenny Root | eac025c | 2012-10-12 15:26:45 -0700 | [diff] [blame] | 478 | int fd = TEMP_FAILURE_RETRY( open( pathname, options ) ); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 479 | if (fd < 0) |
| 480 | return -1; |
| 481 | close_on_exec( fd ); |
| 482 | return fd; |
| 483 | } |
| 484 | #undef open |
| 485 | #define open ___xxx_open |
| 486 | |
Mike Lockwood | 81ffe17 | 2009-10-11 23:04:18 -0400 | [diff] [blame] | 487 | static __inline__ int adb_shutdown(int fd) |
| 488 | { |
| 489 | return shutdown(fd, SHUT_RDWR); |
| 490 | } |
David Pursell | 3fe11f6 | 2015-10-06 15:30:03 -0700 | [diff] [blame^] | 491 | static __inline__ int adb_shutdown(int fd, int direction) |
| 492 | { |
| 493 | return shutdown(fd, direction); |
| 494 | } |
Mike Lockwood | 81ffe17 | 2009-10-11 23:04:18 -0400 | [diff] [blame] | 495 | #undef shutdown |
| 496 | #define shutdown ____xxx_shutdown |
| 497 | |
Spencer Low | 3a2421b | 2015-05-22 20:09:06 -0700 | [diff] [blame] | 498 | // Closes a file descriptor that came from adb_open() or adb_open_mode(), but |
| 499 | // not designed to take a file descriptor from unix_open(). See the comments |
| 500 | // for adb_open() for more info. |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 501 | static __inline__ int adb_close(int fd) |
| 502 | { |
| 503 | return close(fd); |
| 504 | } |
| 505 | #undef close |
| 506 | #define close ____xxx_close |
| 507 | |
| 508 | |
| 509 | static __inline__ int adb_read(int fd, void* buf, size_t len) |
| 510 | { |
Kenny Root | eac025c | 2012-10-12 15:26:45 -0700 | [diff] [blame] | 511 | return TEMP_FAILURE_RETRY( read( fd, buf, len ) ); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | #undef read |
| 515 | #define read ___xxx_read |
| 516 | |
| 517 | static __inline__ int adb_write(int fd, const void* buf, size_t len) |
| 518 | { |
Kenny Root | eac025c | 2012-10-12 15:26:45 -0700 | [diff] [blame] | 519 | return TEMP_FAILURE_RETRY( write( fd, buf, len ) ); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 520 | } |
| 521 | #undef write |
| 522 | #define write ___xxx_write |
| 523 | |
| 524 | static __inline__ int adb_lseek(int fd, int pos, int where) |
| 525 | { |
| 526 | return lseek(fd, pos, where); |
| 527 | } |
| 528 | #undef lseek |
| 529 | #define lseek ___xxx_lseek |
| 530 | |
| 531 | static __inline__ int adb_unlink(const char* path) |
| 532 | { |
| 533 | return unlink(path); |
| 534 | } |
| 535 | #undef unlink |
| 536 | #define unlink ___xxx_unlink |
| 537 | |
| 538 | static __inline__ int adb_creat(const char* path, int mode) |
| 539 | { |
Kenny Root | eac025c | 2012-10-12 15:26:45 -0700 | [diff] [blame] | 540 | int fd = TEMP_FAILURE_RETRY( creat( path, mode ) ); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 541 | |
David 'Digit' Turner | 1f1efb5 | 2009-05-18 17:36:28 +0200 | [diff] [blame] | 542 | if ( fd < 0 ) |
| 543 | return -1; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 544 | |
| 545 | close_on_exec(fd); |
David 'Digit' Turner | 1f1efb5 | 2009-05-18 17:36:28 +0200 | [diff] [blame] | 546 | return fd; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 547 | } |
| 548 | #undef creat |
| 549 | #define creat ___xxx_creat |
| 550 | |
Spencer Low | 753d485 | 2015-07-30 23:07:55 -0700 | [diff] [blame] | 551 | // Helper for network_* functions. |
| 552 | inline int _fd_set_error_str(int fd, std::string* error) { |
| 553 | if (fd == -1) { |
| 554 | *error = strerror(errno); |
| 555 | } |
| 556 | return fd; |
| 557 | } |
| 558 | |
| 559 | inline int network_loopback_client(int port, int type, std::string* error) { |
| 560 | return _fd_set_error_str(socket_loopback_client(port, type), error); |
| 561 | } |
| 562 | |
| 563 | inline int network_loopback_server(int port, int type, std::string* error) { |
| 564 | return _fd_set_error_str(socket_loopback_server(port, type), error); |
| 565 | } |
| 566 | |
| 567 | inline int network_inaddr_any_server(int port, int type, std::string* error) { |
| 568 | return _fd_set_error_str(socket_inaddr_any_server(port, type), error); |
| 569 | } |
| 570 | |
| 571 | inline int network_local_server(const char *name, int namespace_id, int type, |
| 572 | std::string* error) { |
| 573 | return _fd_set_error_str(socket_local_server(name, namespace_id, type), |
| 574 | error); |
| 575 | } |
| 576 | |
| 577 | inline int network_connect(const std::string& host, int port, int type, |
| 578 | int timeout, std::string* error) { |
| 579 | int getaddrinfo_error = 0; |
| 580 | int fd = socket_network_client_timeout(host.c_str(), port, type, timeout, |
| 581 | &getaddrinfo_error); |
| 582 | if (fd != -1) { |
| 583 | return fd; |
| 584 | } |
| 585 | if (getaddrinfo_error != 0) { |
| 586 | *error = gai_strerror(getaddrinfo_error); |
| 587 | } else { |
| 588 | *error = strerror(errno); |
| 589 | } |
| 590 | return -1; |
| 591 | } |
| 592 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 593 | static __inline__ int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrlen) |
| 594 | { |
Benoit Goby | f4ded74 | 2011-02-01 18:57:41 -0800 | [diff] [blame] | 595 | int fd; |
| 596 | |
Kenny Root | eac025c | 2012-10-12 15:26:45 -0700 | [diff] [blame] | 597 | fd = TEMP_FAILURE_RETRY( accept( serverfd, addr, addrlen ) ); |
Benoit Goby | f4ded74 | 2011-02-01 18:57:41 -0800 | [diff] [blame] | 598 | if (fd >= 0) |
| 599 | close_on_exec(fd); |
| 600 | |
| 601 | return fd; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | #undef accept |
| 605 | #define accept ___xxx_accept |
| 606 | |
Spencer Low | 3a2421b | 2015-05-22 20:09:06 -0700 | [diff] [blame] | 607 | // Operate on a file descriptor returned from unix_open() or a well-known file |
| 608 | // descriptor such as STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO. |
| 609 | // |
| 610 | // On Unix, unix_read(), unix_write(), unix_close() map to adb_read(), |
| 611 | // adb_write(), adb_close() (which all map to Unix system calls), but the |
| 612 | // Windows implementations (in the ifdef above and in sysdeps_win32.cpp) call |
| 613 | // into the C Runtime and its configurable CR/LF translation (which is settable |
| 614 | // via _setmode()). |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 615 | #define unix_read adb_read |
| 616 | #define unix_write adb_write |
| 617 | #define unix_close adb_close |
| 618 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 619 | typedef void* (*adb_thread_func_t)( void* arg ); |
| 620 | |
Elliott Hughes | f251714 | 2015-05-05 13:41:21 -0700 | [diff] [blame] | 621 | static __inline__ bool adb_thread_create(adb_thread_func_t start, void* arg) { |
| 622 | pthread_attr_t attr; |
| 623 | pthread_attr_init(&attr); |
| 624 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 625 | |
Elliott Hughes | f251714 | 2015-05-05 13:41:21 -0700 | [diff] [blame] | 626 | pthread_t thread; |
| 627 | errno = pthread_create(&thread, &attr, start, arg); |
| 628 | return (errno == 0); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 629 | } |
| 630 | |
Siva Velusamy | 2669cf9 | 2015-08-28 16:37:29 -0700 | [diff] [blame] | 631 | static __inline__ int adb_thread_setname(const std::string& name) { |
| 632 | #ifdef __APPLE__ |
| 633 | return pthread_setname_np(name.c_str()); |
| 634 | #else |
| 635 | const char *s = name.c_str(); |
| 636 | |
| 637 | // pthread_setname_np fails rather than truncating long strings. |
| 638 | const int max_task_comm_len = 16; // including the null terminator |
| 639 | if (name.length() > (max_task_comm_len - 1)) { |
| 640 | char buf[max_task_comm_len]; |
| 641 | strncpy(buf, name.c_str(), sizeof(buf) - 1); |
| 642 | buf[sizeof(buf) - 1] = '\0'; |
| 643 | s = buf; |
| 644 | } |
| 645 | |
| 646 | return pthread_setname_np(pthread_self(), s) ; |
| 647 | #endif |
| 648 | } |
| 649 | |
| 650 | static __inline__ int adb_socket_setbufsize(int fd, int bufsize ) |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 651 | { |
| 652 | int opt = bufsize; |
| 653 | return setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(opt)); |
| 654 | } |
| 655 | |
| 656 | static __inline__ void disable_tcp_nagle(int fd) |
| 657 | { |
| 658 | int on = 1; |
| 659 | setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on) ); |
| 660 | } |
| 661 | |
Spencer Low | 31aafa6 | 2015-01-25 14:40:16 -0800 | [diff] [blame] | 662 | static __inline__ int adb_setsockopt( int fd, int level, int optname, const void* optval, socklen_t optlen ) |
| 663 | { |
| 664 | return setsockopt( fd, level, optname, optval, optlen ); |
| 665 | } |
| 666 | |
| 667 | #undef setsockopt |
| 668 | #define setsockopt ___xxx_setsockopt |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 669 | |
| 670 | static __inline__ int unix_socketpair( int d, int type, int protocol, int sv[2] ) |
| 671 | { |
| 672 | return socketpair( d, type, protocol, sv ); |
| 673 | } |
| 674 | |
| 675 | static __inline__ int adb_socketpair( int sv[2] ) |
| 676 | { |
| 677 | int rc; |
| 678 | |
| 679 | rc = unix_socketpair( AF_UNIX, SOCK_STREAM, 0, sv ); |
| 680 | if (rc < 0) |
| 681 | return -1; |
| 682 | |
| 683 | close_on_exec( sv[0] ); |
| 684 | close_on_exec( sv[1] ); |
| 685 | return 0; |
| 686 | } |
| 687 | |
| 688 | #undef socketpair |
| 689 | #define socketpair ___xxx_socketpair |
| 690 | |
| 691 | static __inline__ void adb_sleep_ms( int mseconds ) |
| 692 | { |
David 'Digit' Turner | 1f1efb5 | 2009-05-18 17:36:28 +0200 | [diff] [blame] | 693 | usleep( mseconds*1000 ); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 694 | } |
| 695 | |
Alex Vallée | 28d1f8d | 2015-05-06 16:26:00 -0400 | [diff] [blame] | 696 | static __inline__ int adb_mkdir(const std::string& path, int mode) |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 697 | { |
Alex Vallée | 28d1f8d | 2015-05-06 16:26:00 -0400 | [diff] [blame] | 698 | return mkdir(path.c_str(), mode); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 699 | } |
Alex Vallée | 28d1f8d | 2015-05-06 16:26:00 -0400 | [diff] [blame] | 700 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 701 | #undef mkdir |
| 702 | #define mkdir ___xxx_mkdir |
| 703 | |
| 704 | static __inline__ void adb_sysdeps_init(void) |
| 705 | { |
| 706 | } |
| 707 | |
Alex Vallée | 28d1f8d | 2015-05-06 16:26:00 -0400 | [diff] [blame] | 708 | static __inline__ int adb_is_absolute_host_path(const char* path) { |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 709 | return path[0] == '/'; |
| 710 | } |
| 711 | |
leozwang | 1be5462 | 2014-08-15 09:51:27 -0700 | [diff] [blame] | 712 | static __inline__ unsigned long adb_thread_id() |
| 713 | { |
Spencer Low | 5c761bd | 2015-07-21 02:06:26 -0700 | [diff] [blame] | 714 | return (unsigned long)gettid(); |
leozwang | 1be5462 | 2014-08-15 09:51:27 -0700 | [diff] [blame] | 715 | } |
| 716 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 717 | #endif /* !_WIN32 */ |
| 718 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 719 | #endif /* _ADB_SYSDEPS_H */ |