am 1b154930
: Merge change 1867 into donut
Merge commit '1b154930b2c2634dce9c04d5d5cec7acb229ccb0' * commit '1b154930b2c2634dce9c04d5d5cec7acb229ccb0': Cleaning up whitespace in adb sources. Nothing more, nothing less.
This commit is contained in:
commit
342520f2ed
7 changed files with 54 additions and 47 deletions
|
@ -87,7 +87,7 @@ static void fdevent_init()
|
|||
{
|
||||
/* XXX: what's a good size for the passed in hint? */
|
||||
epoll_fd = epoll_create(256);
|
||||
|
||||
|
||||
if(epoll_fd < 0) {
|
||||
perror("epoll_create() failed");
|
||||
exit(1);
|
||||
|
@ -105,7 +105,7 @@ static void fdevent_connect(fdevent *fde)
|
|||
ev.events = 0;
|
||||
ev.data.ptr = fde;
|
||||
|
||||
#if 0
|
||||
#if 0
|
||||
if(epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fde->fd, &ev)) {
|
||||
perror("epoll_ctl() failed\n");
|
||||
exit(1);
|
||||
|
@ -116,7 +116,7 @@ static void fdevent_connect(fdevent *fde)
|
|||
static void fdevent_disconnect(fdevent *fde)
|
||||
{
|
||||
struct epoll_event ev;
|
||||
|
||||
|
||||
memset(&ev, 0, sizeof(ev));
|
||||
ev.events = 0;
|
||||
ev.data.ptr = fde;
|
||||
|
@ -133,9 +133,9 @@ static void fdevent_update(fdevent *fde, unsigned events)
|
|||
{
|
||||
struct epoll_event ev;
|
||||
int active;
|
||||
|
||||
|
||||
active = (fde->state & FDE_EVENTMASK) != 0;
|
||||
|
||||
|
||||
memset(&ev, 0, sizeof(ev));
|
||||
ev.events = 0;
|
||||
ev.data.ptr = fde;
|
||||
|
@ -241,7 +241,7 @@ static void fdevent_connect(fdevent *fde)
|
|||
static void fdevent_disconnect(fdevent *fde)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
|
||||
FD_CLR(fde->fd, &read_fds);
|
||||
FD_CLR(fde->fd, &write_fds);
|
||||
FD_CLR(fde->fd, &error_fds);
|
||||
|
@ -283,9 +283,9 @@ static void fdevent_process()
|
|||
memcpy(&rfd, &read_fds, sizeof(fd_set));
|
||||
memcpy(&wfd, &write_fds, sizeof(fd_set));
|
||||
memcpy(&efd, &error_fds, sizeof(fd_set));
|
||||
|
||||
|
||||
n = select(select_n, &rfd, &wfd, &efd, 0);
|
||||
|
||||
|
||||
if(n < 0) {
|
||||
if(errno == EINTR) return;
|
||||
perror("select");
|
||||
|
@ -300,12 +300,12 @@ static void fdevent_process()
|
|||
|
||||
if(events) {
|
||||
n--;
|
||||
|
||||
|
||||
fde = fd_table[i];
|
||||
if(fde == 0) FATAL("missing fde for fd %d\n", i);
|
||||
|
||||
fde->events |= events;
|
||||
|
||||
|
||||
if(fde->state & FDE_PENDING) continue;
|
||||
fde->state |= FDE_PENDING;
|
||||
fdevent_plist_enqueue(fde);
|
||||
|
@ -320,7 +320,7 @@ static void fdevent_register(fdevent *fde)
|
|||
if(fde->fd < 0) {
|
||||
FATAL("bogus negative fd (%d)\n", fde->fd);
|
||||
}
|
||||
|
||||
|
||||
if(fde->fd >= fd_table_max) {
|
||||
int oldmax = fd_table_max;
|
||||
if(fde->fd > 32000) {
|
||||
|
@ -383,9 +383,9 @@ static fdevent *fdevent_plist_dequeue(void)
|
|||
{
|
||||
fdevent *list = &list_pending;
|
||||
fdevent *node = list->next;
|
||||
|
||||
|
||||
if(node == list) return 0;
|
||||
|
||||
|
||||
list->next = node->next;
|
||||
list->next->prev = list;
|
||||
node->next = 0;
|
||||
|
@ -449,9 +449,9 @@ void fdevent_remove(fdevent *fde)
|
|||
void fdevent_set(fdevent *fde, unsigned events)
|
||||
{
|
||||
events &= FDE_EVENTMASK;
|
||||
|
||||
|
||||
if((fde->state & FDE_EVENTMASK) == events) return;
|
||||
|
||||
|
||||
if(fde->state & FDE_ACTIVE) {
|
||||
fdevent_update(fde, events);
|
||||
dump_fde(fde, "update");
|
||||
|
@ -487,13 +487,13 @@ void fdevent_del(fdevent *fde, unsigned events)
|
|||
void fdevent_loop()
|
||||
{
|
||||
fdevent *fde;
|
||||
|
||||
|
||||
for(;;) {
|
||||
#if DEBUG
|
||||
fprintf(stderr,"--- ---- waiting for events\n");
|
||||
#endif
|
||||
fdevent_process();
|
||||
|
||||
|
||||
while((fde = fdevent_plist_dequeue())) {
|
||||
unsigned events = fde->events;
|
||||
fde->events = 0;
|
||||
|
|
|
@ -17,10 +17,13 @@
|
|||
#ifndef __FDEVENT_H
|
||||
#define __FDEVENT_H
|
||||
|
||||
#include <stdint.h> /* for int64_t */
|
||||
|
||||
/* events that may be observed */
|
||||
#define FDE_READ 0x0001
|
||||
#define FDE_WRITE 0x0002
|
||||
#define FDE_ERROR 0x0004
|
||||
#define FDE_TIMEOUT 0x0008
|
||||
|
||||
/* features that may be set (via the events set/add/del interface) */
|
||||
#define FDE_DONT_CLOSE 0x0080
|
||||
|
@ -30,6 +33,8 @@ typedef struct fdevent fdevent;
|
|||
typedef void (*fd_func)(int fd, unsigned events, void *userdata);
|
||||
|
||||
/* Allocate and initialize a new fdevent object
|
||||
* Note: use FD_TIMER as 'fd' to create a fd-less object
|
||||
* (used to implement timers).
|
||||
*/
|
||||
fdevent *fdevent_create(int fd, fd_func func, void *arg);
|
||||
|
||||
|
@ -53,6 +58,8 @@ void fdevent_set(fdevent *fde, unsigned events);
|
|||
void fdevent_add(fdevent *fde, unsigned events);
|
||||
void fdevent_del(fdevent *fde, unsigned events);
|
||||
|
||||
void fdevent_set_timeout(fdevent *fde, int64_t timeout_ms);
|
||||
|
||||
/* loop forever, handling events.
|
||||
*/
|
||||
void fdevent_loop();
|
||||
|
@ -65,7 +72,7 @@ struct fdevent
|
|||
int fd;
|
||||
unsigned short state;
|
||||
unsigned short events;
|
||||
|
||||
|
||||
fd_func func;
|
||||
void *arg;
|
||||
};
|
||||
|
|
|
@ -165,7 +165,7 @@ static int sync_start_readtime(int fd, const char *path)
|
|||
}
|
||||
|
||||
static int sync_finish_readtime(int fd, unsigned int *timestamp,
|
||||
unsigned int *mode, unsigned int *size)
|
||||
unsigned int *mode, unsigned int *size)
|
||||
{
|
||||
syncmsg msg;
|
||||
|
||||
|
@ -908,12 +908,12 @@ static int copy_remote_dir_local(int fd, const char *rpath, const char *lpath,
|
|||
unsigned int timestamp, mode, size;
|
||||
if (sync_finish_readtime(fd, ×tamp, &mode, &size))
|
||||
return 1;
|
||||
if (size == ci->size) {
|
||||
if (size == ci->size) {
|
||||
/* for links, we cannot update the atime/mtime */
|
||||
if ((S_ISREG(ci->mode & mode) && timestamp == ci->time) ||
|
||||
(S_ISLNK(ci->mode & mode) && timestamp >= ci->time))
|
||||
(S_ISLNK(ci->mode & mode) && timestamp >= ci->time))
|
||||
ci->flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@ implementation to be much more robust.
|
|||
|
||||
|
||||
--- protocol overview and basics ---------------------------------------
|
||||
|
||||
|
||||
The transport layer deals in "messages", which consist of a 24 byte
|
||||
header followed (optionally) by a payload. The header consists of 6
|
||||
32 bit words which are sent across the wire in little endian format.
|
||||
|
@ -52,7 +52,7 @@ The identifiers "local-id" and "remote-id" are always relative to the
|
|||
reversed.
|
||||
|
||||
|
||||
|
||||
|
||||
--- CONNECT(version, maxdata, "system-identity-string") ----------------
|
||||
|
||||
The CONNECT message establishes the presence of a remote system.
|
||||
|
@ -114,7 +114,7 @@ is used to establish the connection). Nonetheless, the local-id MUST
|
|||
not change on later READY messages sent to the same stream.
|
||||
|
||||
|
||||
|
||||
|
||||
--- WRITE(0, remote-id, "data") ----------------------------------------
|
||||
|
||||
The WRITE message sends data to the recipient's stream identified by
|
||||
|
@ -172,7 +172,7 @@ to send across the wire.
|
|||
#define A_WRTE 0x45545257
|
||||
|
||||
|
||||
|
||||
|
||||
--- implementation details ---------------------------------------------
|
||||
|
||||
The core of the bridge program will use three threads. One thread
|
||||
|
|
|
@ -67,16 +67,16 @@ typedef void (*win_thread_func_t)(void* arg);
|
|||
|
||||
static __inline__ int adb_thread_create( adb_thread_t *thread, adb_thread_func_t func, void* arg)
|
||||
{
|
||||
thread->tid = _beginthread( (win_thread_func_t)func, 0, arg );
|
||||
if (thread->tid == (unsigned)-1L) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
thread->tid = _beginthread( (win_thread_func_t)func, 0, arg );
|
||||
if (thread->tid == (unsigned)-1L) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __inline__ void close_on_exec(int fd)
|
||||
{
|
||||
/* nothing really */
|
||||
/* nothing really */
|
||||
}
|
||||
|
||||
extern void disable_tcp_nagle(int fd);
|
||||
|
@ -138,7 +138,7 @@ static __inline__ int unix_write(int fd, const void* buf, size_t len)
|
|||
|
||||
static __inline__ int adb_open_mode(const char* path, int options, int mode)
|
||||
{
|
||||
return adb_open(path, options);
|
||||
return adb_open(path, options);
|
||||
}
|
||||
|
||||
static __inline__ int unix_open(const char* path, int options,...)
|
||||
|
@ -203,7 +203,7 @@ struct fdevent {
|
|||
|
||||
static __inline__ void adb_sleep_ms( int mseconds )
|
||||
{
|
||||
Sleep( mseconds );
|
||||
Sleep( mseconds );
|
||||
}
|
||||
|
||||
extern int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrlen);
|
||||
|
@ -290,7 +290,7 @@ typedef pthread_mutex_t adb_mutex_t;
|
|||
|
||||
static __inline__ void close_on_exec(int fd)
|
||||
{
|
||||
fcntl( fd, F_SETFD, FD_CLOEXEC );
|
||||
fcntl( fd, F_SETFD, FD_CLOEXEC );
|
||||
}
|
||||
|
||||
static __inline__ int unix_open(const char* path, int options,...)
|
||||
|
@ -312,7 +312,7 @@ static __inline__ int unix_open(const char* path, int options,...)
|
|||
|
||||
static __inline__ int adb_open_mode( const char* pathname, int options, int mode )
|
||||
{
|
||||
return open( pathname, options, mode );
|
||||
return open( pathname, options, mode );
|
||||
}
|
||||
|
||||
|
||||
|
@ -368,11 +368,11 @@ static __inline__ int adb_creat(const char* path, int mode)
|
|||
{
|
||||
int fd = creat(path, mode);
|
||||
|
||||
if ( fd < 0 )
|
||||
return -1;
|
||||
if ( fd < 0 )
|
||||
return -1;
|
||||
|
||||
close_on_exec(fd);
|
||||
return fd;
|
||||
return fd;
|
||||
}
|
||||
#undef creat
|
||||
#define creat ___xxx_creat
|
||||
|
@ -439,12 +439,12 @@ static __inline__ int adb_socketpair( int sv[2] )
|
|||
|
||||
static __inline__ void adb_sleep_ms( int mseconds )
|
||||
{
|
||||
usleep( mseconds*1000 );
|
||||
usleep( mseconds*1000 );
|
||||
}
|
||||
|
||||
static __inline__ int adb_mkdir(const char* path, int mode)
|
||||
{
|
||||
return mkdir(path, mode);
|
||||
return mkdir(path, mode);
|
||||
}
|
||||
#undef mkdir
|
||||
#define mkdir ___xxx_mkdir
|
||||
|
|
|
@ -739,12 +739,12 @@ int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrle
|
|||
{
|
||||
FH serverfh = _fh_from_int(serverfd);
|
||||
FH fh;
|
||||
|
||||
|
||||
if ( !serverfh || serverfh->clazz != &_fh_socket_class ) {
|
||||
D( "adb_socket_accept: invalid fd %d\n", serverfd );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
fh = _fh_alloc( &_fh_socket_class );
|
||||
if (!fh) {
|
||||
D( "adb_socket_accept: not enough memory to allocate accepted socket descriptor\n" );
|
||||
|
@ -757,7 +757,7 @@ int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrle
|
|||
D( "adb_socket_accept: accept on fd %d return error %ld\n", serverfd, GetLastError() );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
snprintf( fh->name, sizeof(fh->name), "%d(accept:%s)", _fh_to_int(fh), serverfh->name );
|
||||
D( "adb_socket_accept on fd %d returns fd %d\n", serverfd, _fh_to_int(fh) );
|
||||
return _fh_to_int(fh);
|
||||
|
@ -768,7 +768,7 @@ void disable_tcp_nagle(int fd)
|
|||
{
|
||||
FH fh = _fh_from_int(fd);
|
||||
int on;
|
||||
|
||||
|
||||
if ( !fh || fh->clazz != &_fh_socket_class )
|
||||
return;
|
||||
|
||||
|
@ -1746,7 +1746,7 @@ void fdevent_loop()
|
|||
|
||||
/** FILE EVENT HOOKS
|
||||
**/
|
||||
|
||||
|
||||
static void _event_file_prepare( EventHook hook )
|
||||
{
|
||||
if (hook->wanted & (FDE_READ|FDE_WRITE)) {
|
||||
|
|
|
@ -446,7 +446,7 @@ int recognized_device(usb_handle* handle) {
|
|||
}
|
||||
|
||||
void find_devices() {
|
||||
usb_handle* handle = NULL;
|
||||
usb_handle* handle = NULL;
|
||||
char entry_buffer[2048];
|
||||
char interf_name[2048];
|
||||
AdbInterfaceInfo* next_interface = (AdbInterfaceInfo*)(&entry_buffer[0]);
|
||||
|
|
Loading…
Reference in a new issue