ecs: fix select() for macosx
authormunkyu.im <munkyu.im@samsung.com>
Tue, 6 Aug 2013 09:52:24 +0000 (18:52 +0900)
committermunkyu.im <munkyu.im@samsung.com>
Tue, 6 Aug 2013 10:01:41 +0000 (19:01 +0900)
fix compilation error

Signed-off-by: munkyu.im <munkyu.im@samsung.com>
tizen/src/ecs.c
tizen/src/ecs.h
tizen/src/ecs_msg.c
tizen/src/hw/maru_virtio_nfc.h

index 609a969..62d4379 100644 (file)
@@ -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) {
index 2d426ca..6ee9fef 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __ECS_H__
 #define __ECS_H__
 
-#ifndef _WIN32
+#ifdef CONFIG_LINUX
 #include <sys/epoll.h>
 #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
index cd33916..d9b1c71 100644 (file)
@@ -15,7 +15,7 @@
 #include "sysemu/char.h"
 #include "qemu/main-loop.h"
 
-#ifndef _WIN32
+#ifdef CONFIG_LINUX
 #include <sys/epoll.h>
 #endif
 
index 69eb2f8..ae6f16e 100755 (executable)
@@ -62,7 +62,7 @@ typedef struct VirtIONFC{
         OBJECT_CHECK(VirtIONFC, (obj), TYPE_VIRTIO_NFC)\r
 \r
 \r
-bool send_to_nfc(enum request_cmd_nfc req, char* data, const uint32_t len);\r
+bool send_to_nfc(enum request_cmd_nfc req, const char* data, const uint32_t len);\r
 \r
 \r
 #ifdef __cplusplus\r