diff options
| author | 2003-09-23 16:51:11 +0000 | |
|---|---|---|
| committer | 2003-09-23 16:51:11 +0000 | |
| commit | 154dfaaa7e8e47825c6990a73b3eba25e82ebbb9 (patch) | |
| tree | bae4f380ce55fc233a68444dffc895a9dabf0b91 /sys/dev/rnd.c | |
| parent | regen (Prepare for conversion of select backend -> poll) (diff) | |
| download | wireguard-openbsd-154dfaaa7e8e47825c6990a73b3eba25e82ebbb9.tar.xz wireguard-openbsd-154dfaaa7e8e47825c6990a73b3eba25e82ebbb9.zip | |
Replace select backends with poll backends. selscan() and pollscan()
now call the poll backend. With this change we implement greater
poll(2) functionality instead of emulating it via the select backend.
Adapted from NetBSD and including some changes from FreeBSD.
Tested by many, deraadt@ OK
Diffstat (limited to 'sys/dev/rnd.c')
| -rw-r--r-- | sys/dev/rnd.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index a90b8ebfde3..54b692e47a8 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.63 2003/08/15 20:32:16 tedu Exp $ */ +/* $OpenBSD: rnd.c,v 1.64 2003/09/23 16:51:12 millert Exp $ */ /* * rnd.c -- A strong random number generator @@ -246,6 +246,7 @@ #include <sys/md5k.h> #include <sys/sysctl.h> #include <sys/timeout.h> +#include <sys/poll.h> #include <dev/rndvar.h> #include <dev/rndioctl.h> @@ -1021,22 +1022,23 @@ randomread(dev, uio, ioflag) } int -randomselect(dev, rw, p) +randompoll(dev, events, p) dev_t dev; - int rw; + int events; struct proc *p; { - switch (rw) { - case FREAD: + int revents = 0; + + if (events & (POLLIN | POLLRDNORM)) { if (random_state.entropy_count > 0) - return (1); + revents |= events & (POLLIN | POLLRDNORM); else selrecord(p, &rnd_rsel); - break; - case FWRITE: - return 1; } - return 0; + if (events & (POLLOUT | POLLWRNORM)) + revents = events & (POLLOUT | POLLWRNORM); /* always writable */ + + return (revents); } int |
