From: munkyu.im Date: Tue, 6 Aug 2013 09:52:24 +0000 (+0900) Subject: ecs: fix select() for macosx X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~841^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e56bb52879376a7c7d5bbb43bef22f36a5b4fcc0;p=sdk%2Femulator%2Fqemu.git ecs: fix select() for macosx fix compilation error Signed-off-by: munkyu.im --- diff --git a/tizen/src/ecs.c b/tizen/src/ecs.c index 609a96938b..62d4379fab 100644 --- a/tizen/src/ecs.c +++ b/tizen/src/ecs.c @@ -822,11 +822,11 @@ static bool device_command_proc(ECS_Client *clii, QObject *obj) { } else if (!strncmp(cmd, MSG_TYPE_NFC, 3)) { if (group == MSG_GROUP_STATUS) { - send_to_nfc(request_get, data, length); + send_to_nfc(request_nfc_get, data, length); } else { - send_to_nfc(request_set, data, length); + send_to_nfc(request_nfc_set, data, length); } } @@ -1081,7 +1081,7 @@ fail: ecs_client_close(cli); } -#ifndef _WIN32 +#ifdef CONFIG_LINUX static void epoll_cli_add(ECS_State *cs, int fd) { struct epoll_event events; @@ -1122,7 +1122,7 @@ static int ecs_add_client(ECS_State *cs, int fd) { clii->cs = cs; ecs_json_message_parser_init(&clii->parser, handle_ecs_command, clii); -#ifndef _WIN32 +#ifdef CONFIG_LINUX epoll_cli_add(cs, fd); #else FD_SET(fd, &cs->reads); @@ -1171,7 +1171,7 @@ static void ecs_accept(ECS_State *cs) { } } -#ifndef _WIN32 +#ifdef CONFIG_LINUX static void epoll_init(ECS_State *cs) { struct epoll_event events; @@ -1236,7 +1236,7 @@ static int socket_initialize(ECS_State *cs, QemuOpts *opts) { cs->listen_fd = fd; -#ifndef _WIN32 +#ifdef CONFIG_LINUX epoll_init(cs); #else FD_ZERO(&cs->reads); @@ -1251,7 +1251,7 @@ static int socket_initialize(ECS_State *cs, QemuOpts *opts) { return 0; } -#ifndef _WIN32 +#ifdef CONFIG_LINUX static int ecs_loop(ECS_State *cs) { int i, nfds; @@ -1275,7 +1275,7 @@ static int ecs_loop(ECS_State *cs) { return 0; } -#else +#elif defined(CONFIG_WIN32) static int ecs_loop(ECS_State *cs) { int index = 0; @@ -1285,7 +1285,7 @@ static int ecs_loop(ECS_State *cs) timeout.tv_sec = 5; timeout.tv_usec = 0; - if (select(0, &temps, 0, 0, &timeout) == SOCKET_ERROR) { + if (select(0, &temps, 0, 0, &timeout) < 0) { LOG("select error."); return -1; } @@ -1303,6 +1303,36 @@ static int ecs_loop(ECS_State *cs) return 0; } +#elif defined(CONFIG_DARWIN) +#define FD_MAX_SIZE 1024 +static int ecs_loop(ECS_State *cs) +{ + int index = 0; + struct timeval timeout; + fd_set temps = cs->reads; + + timeout.tv_sec = 5; + timeout.tv_usec = 0; + + if (select(0, &temps, 0, 0, &timeout) < 0) { + LOG("select error."); + return -1; + } + + for (index = 0; index < FD_MAX_SIZE; index++) { + if (FD_ISSET(cs->reads.fds_bits[index], &temps)) { + if (cs->reads.fds_bits[index] == cs->listen_fd) { + ecs_accept(cs); + continue; + } + + ecs_read(ecs_find_client(cs->reads.fds_bits[index])); + } + } + + return 0; +} + #endif static int check_port(int port) { diff --git a/tizen/src/ecs.h b/tizen/src/ecs.h index 2d426cadba..6ee9fefdca 100644 --- a/tizen/src/ecs.h +++ b/tizen/src/ecs.h @@ -1,7 +1,7 @@ #ifndef __ECS_H__ #define __ECS_H__ -#ifndef _WIN32 +#ifdef CONFIG_LINUX #include #endif @@ -101,7 +101,7 @@ struct Monitor { #define MAX_EVENTS 1000 typedef struct ECS_State { int listen_fd; -#ifndef _WIN32 +#ifdef CONFIG_LINUX int epoll_fd; struct epoll_event events[MAX_EVENTS]; #else diff --git a/tizen/src/ecs_msg.c b/tizen/src/ecs_msg.c index cd3391606a..d9b1c713b6 100644 --- a/tizen/src/ecs_msg.c +++ b/tizen/src/ecs_msg.c @@ -15,7 +15,7 @@ #include "sysemu/char.h" #include "qemu/main-loop.h" -#ifndef _WIN32 +#ifdef CONFIG_LINUX #include #endif diff --git a/tizen/src/hw/maru_virtio_nfc.h b/tizen/src/hw/maru_virtio_nfc.h index 69eb2f8093..ae6f16ee02 100755 --- a/tizen/src/hw/maru_virtio_nfc.h +++ b/tizen/src/hw/maru_virtio_nfc.h @@ -62,7 +62,7 @@ typedef struct VirtIONFC{ OBJECT_CHECK(VirtIONFC, (obj), TYPE_VIRTIO_NFC) -bool send_to_nfc(enum request_cmd_nfc req, char* data, const uint32_t len); +bool send_to_nfc(enum request_cmd_nfc req, const char* data, const uint32_t len); #ifdef __cplusplus