7 #include "../common/plat.h"
10 int plat_is_dir(const char *path)
13 if ((dir = opendir(path))) {
21 /* Wiz has a borked gettimeofday().. */
22 #define plat_get_ticks_ms plat_get_ticks_ms_gtod
23 #define plat_get_ticks_us plat_get_ticks_us_gtod
26 unsigned int plat_get_ticks_ms(void)
31 gettimeofday(&tv, NULL);
33 ret = (unsigned)tv.tv_sec * 1000;
34 /* approximate /= 1000 */
35 ret += ((unsigned)tv.tv_usec * 4195) >> 22;
40 unsigned int plat_get_ticks_us(void)
45 gettimeofday(&tv, NULL);
47 ret = (unsigned)tv.tv_sec * 1000000;
48 ret += (unsigned)tv.tv_usec;
53 void plat_sleep_ms(int ms)
58 int plat_wait_event(int *fds_hnds, int count, int timeout_ms)
60 struct timeval tv, *timeout = NULL;
61 int i, ret, fdmax = -1;
64 if (timeout_ms >= 0) {
65 tv.tv_sec = timeout_ms / 1000;
66 tv.tv_usec = (timeout_ms % 1000) * 1000;
71 for (i = 0; i < count; i++) {
72 if (fds_hnds[i] > fdmax) fdmax = fds_hnds[i];
73 FD_SET(fds_hnds[i], &fdset);
76 ret = select(fdmax + 1, &fdset, NULL, NULL, timeout);
79 perror("plat_wait_event: select failed");
85 return -1; /* timeout */
88 for (i = 0; i < count; i++)
89 if (FD_ISSET(fds_hnds[i], &fdset))