8 #include "../common/plat.h"
11 int plat_is_dir(const char *path)
14 if ((dir = opendir(path))) {
21 int plat_get_root_dir(char *dst, int len)
26 strncpy(dst, g_argv[0], len);
30 for (j = strlen(dst); j > 0; j--)
31 if (dst[j] == '/') { dst[j+1] = 0; break; }
37 /* Wiz has a borked gettimeofday().. */
38 #define plat_get_ticks_ms plat_get_ticks_ms_good
39 #define plat_get_ticks_us plat_get_ticks_us_good
42 unsigned int plat_get_ticks_ms(void)
47 gettimeofday(&tv, NULL);
49 ret = (unsigned)tv.tv_sec * 1000;
50 /* approximate /= 1000 */
51 ret += ((unsigned)tv.tv_usec * 4195) >> 22;
56 unsigned int plat_get_ticks_us(void)
61 gettimeofday(&tv, NULL);
63 ret = (unsigned)tv.tv_sec * 1000000;
64 ret += (unsigned)tv.tv_usec;
69 void plat_sleep_ms(int ms)
74 int plat_wait_event(int *fds_hnds, int count, int timeout_ms)
76 struct timeval tv, *timeout = NULL;
77 int i, ret, fdmax = -1;
80 if (timeout_ms >= 0) {
81 tv.tv_sec = timeout_ms / 1000;
82 tv.tv_usec = (timeout_ms % 1000) * 1000;
87 for (i = 0; i < count; i++) {
88 if (fds_hnds[i] > fdmax) fdmax = fds_hnds[i];
89 FD_SET(fds_hnds[i], &fdset);
92 ret = select(fdmax + 1, &fdset, NULL, NULL, timeout);
95 perror("plat_wait_event: select failed");
101 return -1; /* timeout */
104 for (i = 0; i < count; i++)
105 if (FD_ISSET(fds_hnds[i], &fdset))