You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ay...@apache.org on 2007/10/15 15:22:09 UTC
svn commit: r584782 -
/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/unix/EpollSelectorImpl.c
Author: ayza
Date: Mon Oct 15 06:22:08 2007
New Revision: 584782
URL: http://svn.apache.org/viewvc?rev=584782&view=rev
Log:
Additional fix for 2.4 kernels support. See HARMONY-4879 ([classlib][nio] epoll-based Selector).
Modified:
harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/unix/EpollSelectorImpl.c
Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/unix/EpollSelectorImpl.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/unix/EpollSelectorImpl.c?rev=584782&r1=584781&r2=584782&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/unix/EpollSelectorImpl.c (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/unix/EpollSelectorImpl.c Mon Oct 15 06:22:08 2007
@@ -16,10 +16,58 @@
*/
#include <jni.h>
-#include <sys/epoll.h>
+#include <linux/version.h>
#include "hysock.h"
#include "hyport.h"
#include "EpollSelectorImpl.h"
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
+
+// use kernel 2.6 epoll facility
+#include <sys/epoll.h>
+
+#else
+
+// make the stubs for epoll to fail gently
+
+#define EPOLLIN 0
+#define EPOLLOUT 0
+#define EPOLLPRI 0
+
+#define EPOLL_CTL_ADD 0
+#define EPOLL_CTL_DEL 0
+
+typedef union epoll_data {
+ int fd;
+} epoll_data_t;
+
+struct epoll_event {
+ __uint32_t events; /* Epoll events */
+ epoll_data_t data; /* User data variable */
+};
+
+
+void fail_msg() {
+ printf("No epoll facility support, please make sure you have build and run on 2.6.x kernel\n");
+ exit(0);
+}
+
+int epoll_create(int size) {
+ fail_msg();
+ return -1;
+}
+
+int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) {
+ fail_msg();
+ return -1;
+}
+
+int epoll_wait(int epfd, struct epoll_event * events, int maxevents, int timeout) {
+ fail_msg();
+ return -1;
+}
+
+#endif
/* Header for class org_apache_harmony_nio_internal_EPollSelectorImpl */
//#define EPOLL_DEBUG