OSDN Git Service

Implement epoll_create1 and epoll_pwait system calls.
authorThierry Reding <thierry.reding@avionic-design.de>
Wed, 11 May 2011 07:28:13 +0000 (09:28 +0200)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 11 May 2011 19:57:20 +0000 (21:57 +0200)
Note: TODO: This lacks cancellation support.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
libc/sysdeps/linux/common/epoll.c
libc/sysdeps/linux/common/sys/epoll.h
libc/sysdeps/linux/x86_64/sys/epoll.h

index dda9228..41c4eac 100644 (file)
@@ -18,6 +18,13 @@ _syscall1(int, epoll_create, int, size)
 #endif
 
 /*
+ * epoll_create1()
+ */
+#ifdef __NR_epoll_create1
+_syscall1(int, epoll_create1, int, flags)
+#endif
+
+/*
  * epoll_ctl()
  */
 #ifdef __NR_epoll_ctl
@@ -29,4 +36,13 @@ _syscall4(int,epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, even
  */
 #ifdef __NR_epoll_wait
 _syscall4(int, epoll_wait, int, epfd, struct epoll_event *, events, int, maxevents, int, timeout)
+/* TODO: add cancellation for epoll_wait */
+#endif
+
+/*
+ * epoll_pwait()
+ */
+#ifdef __NR_epoll_pwait
+_syscall5(int, epoll_pwait, int, epfd, struct epoll_event *, events, int, maxevents, int, timeout, __const sigset_t *, ss)
+/* TODO: add cancellation for epoll_pwait */
 #endif
index 44e814b..f6a6488 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
 #include <stdint.h>
 #include <sys/types.h>
 
+/* Get __sigset_t.  */
+#include <bits/sigset.h>
+
+#ifndef __sigset_t_defined
+# define __sigset_t_defined
+typedef __sigset_t sigset_t;
+#endif
+
+
+/* Flags to be passed to epoll_create1.  */
+enum
+  {
+    EPOLL_CLOEXEC = 02000000,
+#define EPOLL_CLOEXEC EPOLL_CLOEXEC
+    EPOLL_NONBLOCK = 04000
+#define EPOLL_NONBLOCK EPOLL_NONBLOCK
+  };
+
 
 enum EPOLL_EVENTS
   {
@@ -55,9 +73,9 @@ enum EPOLL_EVENTS
 
 
 /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl().  */
-#define EPOLL_CTL_ADD 1        /* Add a file decriptor to the interface.  */
-#define EPOLL_CTL_DEL 2        /* Remove a file decriptor from the interface.  */
-#define EPOLL_CTL_MOD 3        /* Change file decriptor epoll_event structure.  */
+#define EPOLL_CTL_ADD 1        /* Add a file descriptor to the interface.  */
+#define EPOLL_CTL_DEL 2        /* Remove a file descriptor from the interface.  */
+#define EPOLL_CTL_MOD 3        /* Change file descriptor epoll_event structure.  */
 
 
 typedef union epoll_data
@@ -83,6 +101,10 @@ __BEGIN_DECLS
    returned by epoll_create() should be closed with close().  */
 extern int epoll_create (int __size) __THROW;
 
+/* Same as epoll_create but with a FLAGS parameter.  The unused SIZE
+   parameter has been dropped.  */
+extern int epoll_create1 (int __flags) __THROW;
+
 
 /* Manipulate an epoll instance "epfd". Returns 0 in case of success,
    -1 in case of error ( the "errno" variable will contain the
@@ -107,6 +129,16 @@ extern int epoll_ctl (int __epfd, int __op, int __fd,
 extern int epoll_wait (int __epfd, struct epoll_event *__events,
                       int __maxevents, int __timeout);
 
+
+/* Same as epoll_wait, but the thread's signal mask is temporarily
+   and atomically replaced with the one provided as parameter.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int epoll_pwait (int __epfd, struct epoll_event *__events,
+                       int __maxevents, int __timeout,
+                       __const __sigset_t *__ss);
+
 __END_DECLS
 
 #endif /* sys/epoll.h */
index 02672d3..a8171cc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002,2003,2004,2005,2006 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2008, 2010 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
 #include <stdint.h>
 #include <sys/types.h>
 
+/* Get __sigset_t.  */
+#include <bits/sigset.h>
+
+#ifndef __sigset_t_defined
+# define __sigset_t_defined
+typedef __sigset_t sigset_t;
+#endif
+
+
+/* Flags to be passed to epoll_create1.  */
+enum
+  {
+    EPOLL_CLOEXEC = 02000000,
+#define EPOLL_CLOEXEC EPOLL_CLOEXEC
+    EPOLL_NONBLOCK = 04000
+#define EPOLL_NONBLOCK EPOLL_NONBLOCK
+  };
+
 
 enum EPOLL_EVENTS
   {
@@ -45,6 +63,8 @@ enum EPOLL_EVENTS
 #define EPOLLERR EPOLLERR
     EPOLLHUP = 0x010,
 #define EPOLLHUP EPOLLHUP
+    EPOLLRDHUP = 0x2000,
+#define EPOLLRDHUP EPOLLRDHUP
     EPOLLONESHOT = (1 << 30),
 #define EPOLLONESHOT EPOLLONESHOT
     EPOLLET = (1 << 31)
@@ -81,6 +101,10 @@ __BEGIN_DECLS
    returned by epoll_create() should be closed with close().  */
 extern int epoll_create (int __size) __THROW;
 
+/* Same as epoll_create but with a FLAGS parameter.  The unused SIZE
+   parameter has been dropped.  */
+extern int epoll_create1 (int __flags) __THROW;
+
 
 /* Manipulate an epoll instance "epfd". Returns 0 in case of success,
    -1 in case of error ( the "errno" variable will contain the
@@ -105,6 +129,16 @@ extern int epoll_ctl (int __epfd, int __op, int __fd,
 extern int epoll_wait (int __epfd, struct epoll_event *__events,
                       int __maxevents, int __timeout);
 
+
+/* Same as epoll_wait, but the thread's signal mask is temporarily
+   and atomically replaced with the one provided as parameter.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int epoll_pwait (int __epfd, struct epoll_event *__events,
+                       int __maxevents, int __timeout,
+                       __const __sigset_t *__ss);
+
 __END_DECLS
 
 #endif /* sys/epoll.h */