-# $OpenBSD: Makefile,v 1.2 2021/11/21 06:21:01 visa Exp $
+# $OpenBSD: Makefile,v 1.3 2021/11/23 01:14:26 deraadt Exp $
-PROGS= poll_close pollnval
+PROGS= poll_close pollnval pollretval
LDADD= -lpthread
WARNINGS= yes
--- /dev/null
+#include <stdio.h>
+#include <poll.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <err.h>
+
+int
+main()
+{
+ struct pollfd pfd[100];
+ int i, r, r2 = 0;
+
+ for (i = 0; i < 100; i++) {
+ pfd[i].fd = 0;
+ pfd[i].events = arc4random() % 0x177;
+ }
+
+ r = poll(pfd, 100, INFTIM);
+
+ if (r == -1)
+ errx(1, "poll failed unexpectedly");
+
+ for (i = 0; i < 100; i++)
+ if (pfd[i].revents)
+ r2++;
+ if (r != r2)
+ errx(1, "poll return value %d miscounts .revents %d", r, r2);
+}