/trunk/uspace/lib/libc/include/time.h |
---|
File deleted |
/trunk/uspace/lib/libc/include/sys/time.h |
---|
52,7 → 52,11 |
int tz_dsttime; /* type of dst correction */ |
}; |
int gettimeofday(struct timeval *tv, struct timezone *tz); |
extern void tv_add(struct timeval *tv, suseconds_t usecs); |
extern suseconds_t tv_sub(struct timeval *tv1, struct timeval *tv2); |
extern int tv_gt(struct timeval *tv1, struct timeval *tv2); |
extern int tv_gteq(struct timeval *tv1, struct timeval *tv2); |
extern int gettimeofday(struct timeval *tv, struct timezone *tz); |
#endif |
/trunk/uspace/lib/libc/generic/time.c |
---|
54,7 → 54,74 |
volatile sysarg_t seconds2; |
} *ktime = NULL; |
/** Add microseconds to given timeval. |
* |
* @param tv Destination timeval. |
* @param usecs Number of microseconds to add. |
*/ |
void tv_add(struct timeval *tv, suseconds_t usecs) |
{ |
tv->tv_sec += usecs / 1000000; |
tv->tv_usec += usecs % 1000000; |
if (tv->tv_usec > 1000000) { |
tv->tv_sec++; |
tv->tv_usec -= 1000000; |
} |
} |
/** Subtract two timevals. |
* |
* @param tv1 First timeval. |
* @param tv2 Second timeval. |
* |
* @return Return difference between tv1 and tv2 (tv1 - tv2) in |
* microseconds. |
*/ |
suseconds_t tv_sub(struct timeval *tv1, struct timeval *tv2) |
{ |
suseconds_t result; |
result = tv1->tv_usec - tv2->tv_usec; |
result += (tv1->tv_sec - tv2->tv_sec) * 1000000; |
return result; |
} |
/** Decide if one timeval is greater than the other. |
* |
* @param t1 First timeval. |
* @param t2 Second timeval. |
* |
* @return Return true tv1 is greater than tv2. Otherwise return |
* false. |
*/ |
int tv_gt(struct timeval *tv1, struct timeval *tv2) |
{ |
if (tv1->tv_sec > tv2->tv_sec) |
return 1; |
if (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec > tv2->tv_usec) |
return 1; |
return 0; |
} |
/** Decide if one timeval is greater than or equal to the other. |
* |
* @param tv1 First timeval. |
* @param tv2 Second timeval. |
* |
* @return Return true if tv1 is greater than or equal to tv2. |
* Otherwise return false. |
*/ |
int tv_gteq(struct timeval *tv1, struct timeval *tv2) |
{ |
if (tv1->tv_sec > tv2->tv_sec) |
return 1; |
if (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec >= tv2->tv_usec) |
return 1; |
return 0; |
} |
/** POSIX gettimeofday |
* |
* The time variables are memory mapped(RO) from kernel, which updates |
/trunk/uspace/lib/libc/generic/async.c |
---|
99,7 → 99,7 |
#include <ipc/ipc.h> |
#include <assert.h> |
#include <errno.h> |
#include <time.h> |
#include <sys/time.h> |
#include <arch/barrier.h> |
atomic_t async_futex = FUTEX_INITIALIZER; |
161,49 → 161,6 |
static async_client_conn_t client_connection = default_client_connection; |
static async_client_conn_t interrupt_received = default_interrupt_received; |
/** Add microseconds to give timeval */ |
static void tv_add(struct timeval *tv, suseconds_t usecs) |
{ |
tv->tv_sec += usecs / 1000000; |
tv->tv_usec += usecs % 1000000; |
if (tv->tv_usec > 1000000) { |
tv->tv_sec++; |
tv->tv_usec -= 1000000; |
} |
} |
/** Subtract 2 timevals, return microseconds difference */ |
static suseconds_t tv_sub(struct timeval *tv1, struct timeval *tv2) |
{ |
suseconds_t result; |
result = tv1->tv_usec - tv2->tv_usec; |
result += (tv1->tv_sec - tv2->tv_sec) * 1000000; |
return result; |
} |
/** Compare timeval |
* |
* @return 1 if tv1 > tv2, otherwise 0 |
*/ |
static int tv_gt(struct timeval *tv1, struct timeval *tv2) |
{ |
if (tv1->tv_sec > tv2->tv_sec) |
return 1; |
if (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec > tv2->tv_usec) |
return 1; |
return 0; |
} |
static int tv_gteq(struct timeval *tv1, struct timeval *tv2) |
{ |
if (tv1->tv_sec > tv2->tv_sec) |
return 1; |
if (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec >= tv2->tv_usec) |
return 1; |
return 0; |
} |
/* Hash table functions */ |
#define CONN_HASH_TABLE_CHAINS 32 |