Deleted Added
full compact
104c104
< typedef signed long long tval_t;
---
> typedef int64_t tval_t;
106c106
< static inline tval_t GETMSECS(void);
---
> static inline tval_t GETUSECS(void);
109c109
< GETMSECS(void) {
---
> GETUSECS(void) {
113c113
< return (tval_t)tval.tv_sec*1000+tval.tv_usec/1000;
---
> return (tval_t)tval.tv_sec * 1000000 + tval.tv_usec;
173c173
< u_int msecs; /* millisecond value of the timer */
---
> uint64_t usecs; /* microsecond value of the timer */
177c177
< tval_t when; /* next time to trigger in msecs! */
---
> tval_t when; /* next time to trigger in usecs! */
299,300c299,300
< fprintf(stderr, "poll_register(%d, %#lx, %#lx, %#x)->%d",
< fd, (u_long)func, (u_long)arg, mask, p - regs);
---
> fprintf(stderr, "poll_register(%d, %p, %p, %#x)->%tu",
> fd, (void *)func, (void *)arg, mask, p - regs);
375a376,382
> return (poll_start_utimer((unsigned long long)msecs * 1000,
> repeat, func, arg));
> }
>
> int
> poll_start_utimer(unsigned long long usecs, int repeat, timer_f func, void *arg)
> {
395c402
< p->msecs = msecs;
---
> p->usecs = usecs;
399c406
< p->when = GETMSECS() + msecs;
---
> p->when = GETUSECS() + usecs;
406,407c413,414
< fprintf(stderr, "poll_start_timer(%u, %d, %#lx, %#lx)->%u",
< msecs, repeat, (u_long)func, (u_long)arg, p - tims);
---
> fprintf(stderr, "poll_start_utimer(%llu, %d, %p, %p)->%tu",
> usecs, repeat, (void *)func, (void *)arg, p - tims);
500c507
< int tout;
---
> tval_t tout;
522c529
< now = GETMSECS();
---
> now = GETUSECS();
525c532
< fprintf(stderr, "now=%"QUADFMT"u", now);
---
> fprintf(stderr, "now=%llu", now);
527c534,535
< fprintf(stderr, "timers[%2d] = %"QUADFMT"d", i, tfd[i]->when - now);
---
> fprintf(stderr, "timers[%2d] = %lld",
> i, tfd[i]->when - now);
542c550
< ret = poll(pfd, regs_used, tout);
---
> ret = poll(pfd, regs_used, tout == INFTIM ? INFTIM : (tout / 1000));
550,551c558,559
< tv.tv_sec = tout / 1000;
< tv.tv_usec = (tout % 1000) * 1000;
---
> tv.tv_sec = tout / 1000000;
> tv.tv_usec = tout % 1000000;
556c564
< SELECT_CAST(&nxset), (tout==INFTIM) ? 0 : &tv);
---
> SELECT_CAST(&nxset), (tout==INFTIM) ? NULL : &tv);
577c585,586
< if(regs[idx].pfd->revents & poll_in)
---
> if ((regs[idx].mask & POLL_IN) &&
> (regs[idx].pfd->revents & poll_in))
579c588,589
< if(regs[idx].pfd->revents & poll_out)
---
> if ((regs[idx].mask & POLL_OUT) &&
> (regs[idx].pfd->revents & poll_out))
581c591,592
< if(regs[idx].pfd->revents & poll_except)
---
> if((regs[idx].mask & POLL_EXCEPT) &&
> (regs[idx].pfd->revents & poll_except))
586c597,598
< if(FD_ISSET(regs[idx].fd, &nrset))
---
> if ((regs[idx].mask & POLL_IN) &&
> FD_ISSET(regs[idx].fd, &nrset))
588c600,601
< if(FD_ISSET(regs[idx].fd, &nwset))
---
> if ((regs[idx].mask & POLL_OUT) &&
> FD_ISSET(regs[idx].fd, &nwset))
590c603,604
< if(FD_ISSET(regs[idx].fd, &nxset))
---
> if ((regs[idx].mask & POLL_EXCEPT) &&
> FD_ISSET(regs[idx].fd, &nxset))
598,599c612,613
< "file %d/%d",
< regs[idx].fd, idx);
---
> "file %d/%d %x",
> regs[idx].fd, idx, mask);
610c624
< now = GETMSECS();
---
> now = GETUSECS();
622c636
< tims[tfd[i]].when = now + tims[tfd[i]].msecs;
---
> tims[tfd[i]].when = now + tims[tfd[i]].usecs;
647,648c661,662
< return (double)(10 * now.tv_sec + now.tv_usec / 100000 - 10 * start.tv_sec - start.tv_usec / 100000)
< / 10;
---
> return (double)(10 * now.tv_sec + now.tv_usec / 100000 -
> 10 * start.tv_sec - start.tv_usec / 100000) / 10;
677a692,695
> void
> tfunc2(int tid, void *arg)
> {
> static u_int count = 0;
678a697,700
> if (++count % 10000 == 0)
> printf("%4.1f -- %d\n", elaps(), tid);
> }
>
686c708
< poll_start_timer(5500, 0, first, "first");
---
> poll_start_utimer(5500000, 0, first, "first");
702d723
< argc = argc;
706,707d726
< t0 = poll_start_timer(1000, 1, tfunc0, "1 second");
< poll_start_timer(2500, 0, first, "first");
708a728,734
> if (argc < 2) {
> t0 = poll_start_timer(1000, 1, tfunc0, "1 second");
> poll_start_timer(2500, 0, first, "first");
> } else {
> t0 = poll_start_utimer(300, 1, tfunc2, NULL);
> }
>