Re: kqueue for usb_dev

看板FB_current作者時間12年前 (2014/02/27 15:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串6/14 (看更多)
----Next_Part(Thu_Feb_27_16_03_54_2014_940)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi John-Mark, I tested the attached sample source with USB mouse. Thanks, Kohji Okuno From: John-Mark Gurney <jmg@funkthat.com> > Kohji Okuno wrote this message on Thu, Feb 27, 2014 at 14:26 +0900: >> I tried add kqueue I/F to usb_dev.c. I attached my patch. >> What do you think about my patch? > > Do you have test cases for these patches? > > -- > John-Mark Gurney Voice: +1 415 225 5579 > > "All that I will do, has been done, All that I have, has not." ----Next_Part(Thu_Feb_27_16_03_54_2014_940)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ums.c" #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <sys/types.h> #include <sys/event.h> #include <sys/select.h> #include <sys/time.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #define DEV "/dev/ums0" #if 0 int main() { int i; ssize_t ret; uint8_t buf[128]; int fd = open(DEV, O_RDONLY); fd_set readfds; for (i = 0; i < 10; i++) { FD_ZERO(&readfds); FD_SET(fd, &readfds); ret = select(fd+1, &readfds, NULL, NULL, NULL); printf("select=%d\n", ret); ret = read(fd, buf, sizeof(buf)); printf("%d:%02x %02x %02x\n", ret, buf[0], buf[1], buf[2]); } close(fd); exit(0); } #else int main() { int i; int err; ssize_t ret; uint8_t buf[128]; int fd = open(DEV, O_RDONLY); int kqfd = kqueue(); struct kevent evlist[1]; EV_SET(&evlist[0], fd, EVFILT_READ, EV_ADD, 0, 0, 0); err = kevent(kqfd, evlist, 1, 0, 0, 0); if (err) { perror("kevent"); close(fd); close(kqfd); exit(1); } for (i = 0; i < 10; i++) { ret = kevent(kqfd, 0, 0, evlist, 1, 0); printf("kev=%d\n", ret); ret = read(fd, buf, sizeof(buf)); printf("%d:%02x %02x %02x\n", ret, buf[0], buf[1], buf[2]); } close(fd); exit(0); } #endif ----Next_Part(Thu_Feb_27_16_03_54_2014_940)-- Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" ----Next_Part(Thu_Feb_27_16_03_54_2014_940)----
文章代碼(AID): #1J3kdoNg (FB_current)
討論串 (同標題文章)
文章代碼(AID): #1J3kdoNg (FB_current)