add epoll functions to libport
Mike McCormack
mike at codeweavers.com
Fri Sep 24 04:33:12 CDT 2004
This patch allows systems that don't have a newer glibc with the epoll
functions, but have the 2.6 kernel to use epoll.
Mike
ChangeLog:
* add epoll functions to libport
-------------- next part --------------
Index: server/fd.c
===================================================================
RCS file: /home/wine/wine/server/fd.c,v
retrieving revision 1.27
diff -u -r1.27 fd.c
--- server/fd.c 23 Sep 2004 04:48:24 -0000 1.27
+++ server/fd.c 24 Sep 2004 07:42:02 -0000
@@ -54,7 +54,7 @@
#include "winreg.h"
#include "winternl.h"
-#if defined(HAVE_SYS_EPOLL_H) && defined(HAVE_EPOLL_CREATE)
+#if defined(HAVE_SYS_EPOLL_H)
# define USE_EPOLL
#endif
Index: libs/port/Makefile.in
===================================================================
RCS file: /home/wine/wine/libs/port/Makefile.in,v
retrieving revision 1.11
diff -u -r1.11 Makefile.in
--- libs/port/Makefile.in 6 Apr 2004 03:33:25 -0000 1.11
+++ libs/port/Makefile.in 24 Sep 2004 07:42:02 -0000
@@ -7,6 +7,7 @@
MODULE = libwine_port.a
C_SRCS = \
+ epoll.c \
fstatvfs.c \
getopt.c \
getopt1.c \
Index: include/wine/port.h
===================================================================
RCS file: /home/wine/wine/include/wine/port.h,v
retrieving revision 1.59
diff -u -r1.59 port.h
--- include/wine/port.h 16 Sep 2004 20:34:27 -0000 1.59
+++ include/wine/port.h 24 Sep 2004 07:42:02 -0000
@@ -43,6 +43,9 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
/****************************************************************
@@ -252,6 +255,31 @@
*/
#ifndef NO_LIBWINE_PORT
+
+#ifndef HAVE_EPOLL_H
+
+enum EPOLL_EVENTS
+{
+ EPOLLIN = 0x001,
+ EPOLLPRI = 0x002,
+ EPOLLOUT = 0x004,
+ EPOLLERR = 0x008,
+ EPOLLHUP = 0x010
+};
+
+typedef union epoll_data {
+ void *ptr;
+ int fd;
+ __uint32_t u32;
+ __uint64_t u64;
+} epoll_data_t;
+
+struct epoll_event {
+ __uint32_t events;
+ epoll_data_t data;
+};
+
+#endif
#ifndef HAVE_FSTATVFS
int fstatvfs( int fd, struct statvfs *buf );
--- /dev/null 1994-07-18 08:46:18.000000000 +0900
+++ libs/port/epoll.c 2004-09-24 18:01:07.000000000 +0900
@@ -0,0 +1,79 @@
+/*
+ * epoll syscall implementation
+ *
+ * Copyright (C) 2004 The Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "config.h"
+
+#ifdef HAVE_SYS_EPOLL_H
+#include <sys/epoll.h>
+#endif
+
+#include "wine/port.h"
+
+#ifndef HAVE_EPOLL_CREATE
+
+#ifdef linux
+
+#ifndef __NR_epoll_create
+#define __NR_epoll_create 254
+#endif
+
+#ifndef __NR_epoll_ctl
+#define __NR_epoll_ctl 255
+#endif
+
+#ifndef __NR_epoll_wait
+#define __NR_epoll_wait 256
+#endif
+
+int epoll_create( int size )
+{
+ return syscall(__NR_epoll_create, size);
+}
+
+int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
+{
+ return syscall(__NR_epoll_ctl, epfd, op, fd, event);
+}
+
+int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
+{
+ return syscall(__NR_epoll_wait, epfd, events, maxevents, timeout);
+}
+
+#else
+
+int epoll_create( int size )
+{
+ return -ENOSYS;
+}
+
+int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
+{
+ return -ENOSYS;
+}
+
+int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
+{
+ return -ENOSYS;
+}
+
+#endif
+
+#endif
More information about the wine-patches
mailing list