Squashed 'third_party/rawrtc/re/' content from commit f3163ce8b

Change-Id: I6a235e6ac0f03269d951026f9d195da05c40fdab
git-subtree-dir: third_party/rawrtc/re
git-subtree-split: f3163ce8b526a13b35ef71ce4dd6f43585064d8a
diff --git a/src/main/epoll.c b/src/main/epoll.c
new file mode 100644
index 0000000..dfe91fe
--- /dev/null
+++ b/src/main/epoll.c
@@ -0,0 +1,55 @@
+/**
+ * @file epoll.c  epoll specific routines
+ *
+ * Copyright (C) 2010 Creytiv.com
+ */
+#include <unistd.h>
+#include <sys/epoll.h>
+#include <re_types.h>
+#include <re_mbuf.h>
+#include <re_sys.h>
+#include "main.h"
+
+
+#define DEBUG_MODULE "epoll"
+#define DEBUG_LEVEL 5
+#include <re_dbg.h>
+
+
+/**
+ * Check for working epoll() kernel support
+ *
+ * @return true if support, false if not
+ */
+bool epoll_check(void)
+{
+	uint32_t osrel;
+	int err, epfd;
+
+	err = sys_rel_get(&osrel, NULL, NULL, NULL);
+	if (err)
+		return false;
+
+	if (osrel < 0x020542) {
+		DEBUG_INFO("epoll not supported in osrel=0x%08x\n", osrel);
+		return false;
+	}
+
+#ifdef OPENWRT
+	/* epoll is working again with 2.6.25.7 */
+	if (osrel < 0x020619) {
+		DEBUG_NOTICE("epoll is broken in osrel=0x%08x\n", osrel);
+		return false;
+	}
+#endif
+
+	epfd = epoll_create(64);
+	if (-1 == epfd) {
+		DEBUG_NOTICE("epoll_create: %m\n", errno);
+		return false;
+	}
+
+	(void)close(epfd);
+
+	return true;
+}