eventfd2: fix flags decoding

* configure.ac (AC_CHECK_HEADERS): Add sys/eventfd.h.
* eventfd.c: Include <fcntl.h>.
[HAVE_SYS_EVENTFD_H] Include <sys/eventfd.h>.
Include "xlat/efd_flags.h".
(do_eventfd): Use efd_flags for flags decoding.
* xlat/efd_flags.in: New file.
* tests/eventfd.c: New file.
* tests/eventfd.expected: Likewise.
* tests/eventfd.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add eventfd.
(TESTS): Add eventfd.test.
(EXTRA_DIST): Add eventfd.expected.
* tests/.gitignore: Add eventfd.
diff --git a/tests/eventfd.c b/tests/eventfd.c
new file mode 100644
index 0000000..07a0b10
--- /dev/null
+++ b/tests/eventfd.c
@@ -0,0 +1,19 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+int
+main(void)
+{
+#ifdef __NR_eventfd2
+	(void) close(0);
+	return syscall(__NR_eventfd2, -1L, 1 | O_CLOEXEC | O_NONBLOCK) == 0 ?
+		0 : 77;
+#else
+        return 77;
+#endif
+}