Subversion Repositories HelenOS

Rev

Rev 2485 | Rev 2488 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2485 Rev 2486
Line 97... Line 97...
97
#include <libadt/hash_table.h>
97
#include <libadt/hash_table.h>
98
#include <libadt/list.h>
98
#include <libadt/list.h>
99
#include <ipc/ipc.h>
99
#include <ipc/ipc.h>
100
#include <assert.h>
100
#include <assert.h>
101
#include <errno.h>
101
#include <errno.h>
102
#include <time.h>
102
#include <sys/time.h>
103
#include <arch/barrier.h>
103
#include <arch/barrier.h>
104
 
104
 
105
atomic_t async_futex = FUTEX_INITIALIZER;
105
atomic_t async_futex = FUTEX_INITIALIZER;
106
static hash_table_t conn_hash_table;
106
static hash_table_t conn_hash_table;
107
static LIST_INITIALIZE(timeout_list);
107
static LIST_INITIALIZE(timeout_list);
Line 159... Line 159...
159
static void default_client_connection(ipc_callid_t callid, ipc_call_t *call);
159
static void default_client_connection(ipc_callid_t callid, ipc_call_t *call);
160
static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call);
160
static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call);
161
static async_client_conn_t client_connection = default_client_connection;
161
static async_client_conn_t client_connection = default_client_connection;
162
static async_client_conn_t interrupt_received = default_interrupt_received;
162
static async_client_conn_t interrupt_received = default_interrupt_received;
163
 
163
 
164
/** Add microseconds to give timeval */
-
 
165
static void tv_add(struct timeval *tv, suseconds_t usecs)
-
 
166
{
-
 
167
    tv->tv_sec += usecs / 1000000;
-
 
168
    tv->tv_usec += usecs % 1000000;
-
 
169
    if (tv->tv_usec > 1000000) {
-
 
170
        tv->tv_sec++;
-
 
171
        tv->tv_usec -= 1000000;
-
 
172
    }
-
 
173
}
-
 
174
 
-
 
175
/** Subtract 2 timevals, return microseconds difference */
-
 
176
static suseconds_t tv_sub(struct timeval *tv1, struct timeval *tv2)
-
 
177
{
-
 
178
    suseconds_t result;
-
 
179
 
-
 
180
    result = tv1->tv_usec - tv2->tv_usec;
-
 
181
    result += (tv1->tv_sec - tv2->tv_sec) * 1000000;
-
 
182
 
-
 
183
    return result;
-
 
184
}
-
 
185
 
-
 
186
/** Compare timeval
-
 
187
 *
-
 
188
 * @return 1 if tv1 > tv2, otherwise 0
-
 
189
 */
-
 
190
static int tv_gt(struct timeval *tv1, struct timeval *tv2)
-
 
191
{
-
 
192
    if (tv1->tv_sec > tv2->tv_sec)
-
 
193
        return 1;
-
 
194
    if (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec > tv2->tv_usec)
-
 
195
        return 1;
-
 
196
    return 0;
-
 
197
}
-
 
198
static int tv_gteq(struct timeval *tv1, struct timeval *tv2)
-
 
199
{
-
 
200
    if (tv1->tv_sec > tv2->tv_sec)
-
 
201
        return 1;
-
 
202
    if (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec >= tv2->tv_usec)
-
 
203
        return 1;
-
 
204
    return 0;
-
 
205
}
-
 
206
 
-
 
207
/* Hash table functions */
164
/* Hash table functions */
208
#define CONN_HASH_TABLE_CHAINS  32
165
#define CONN_HASH_TABLE_CHAINS  32
209
 
166
 
210
static hash_index_t conn_hash(unsigned long *key)
167
static hash_index_t conn_hash(unsigned long *key)
211
{
168
{