Integer type name change.
[silc.git] / lib / silcutil / os2 / silcos2schedule.c
1 /*
2
3   silcos2schedule.c 
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2002 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19 /* $Id$ */
20
21 /* XXX TODO */
22
23 #include "silcincludes.h"
24 #include "silcschedule_i.h"
25
26 /* Calls normal select() system call. */
27
28 int silc_select(SilcScheduleFd fds, SilcUInt32 fds_count, struct timeval *timeout)
29 {
30   fd_set in, out;
31   int ret, i, max_fd = 0;
32
33   FD_ZERO(&in);
34   FD_ZERO(&out);
35
36   for (i = 0; i < fds_count; i++) {
37     if (!fds[i].events)
38       continue;
39
40     if (fds[i].fd > max_fd)
41       max_fd = fds[i].fd;
42
43     if (fds[i].events & SILC_TASK_READ)
44       FD_SET(fds[i].fd, &in);
45     if (fds[i].events & SILC_TASK_WRITE)
46       FD_SET(fds[i].fd, &out);
47
48     fds[i].revents = 0;
49   }
50
51   /*  ret = select(max_fd + 1, &in, &out, NULL, timeout); */
52   if (ret <= 0)
53     return ret;
54
55   for (i = 0; i < fds_count; i++) {
56     if (!fds[i].events)
57       continue;
58
59     if (FD_ISSET(fds[i].fd, &in))
60       fds[i].revents |= SILC_TASK_READ;
61     if (FD_ISSET(fds[i].fd, &out))
62       fds[i].revents |= SILC_TASK_WRITE;
63   }
64
65   return ret;
66 }
67
68 #ifdef SILC_THREADS
69
70 /* XXX Do this like it's done in win32/ */
71
72 /* Internal wakeup context. */
73 typedef struct {
74
75 } *SilcOs2Wakeup;
76
77 SILC_TASK_CALLBACK(silc_schedule_wakeup_cb)
78 {
79
80 }
81
82 #endif /* SILC_THREADS */
83
84 /* Initializes the wakeup of the scheduler. In multi-threaded environment
85    the scheduler needs to be wakenup when tasks are added or removed from
86    the task queues. This will initialize the wakeup for the scheduler.
87    Any tasks that needs to be registered must be registered to the `queue'.
88    It is quaranteed that the scheduler will automatically free any
89    registered tasks in this queue. This is system specific routine. */
90
91 void *silc_schedule_wakeup_init(SilcSchedule schedule)
92 {
93 #ifdef SILC_THREADS
94   return NULL;
95
96 #endif
97   return NULL;
98 }
99
100 /* Uninitializes the system specific wakeup. */
101
102 void silc_schedule_wakeup_uninit(void *context)
103 {
104 #ifdef SILC_THREADS
105
106 #endif
107 }
108
109 /* Wakes up the scheduler */
110
111 void silc_schedule_wakeup_internal(void *context)
112 {
113 #ifdef SILC_THREADS
114
115 #endif
116 }