summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/sys')
-rw-r--r--usr/src/uts/common/sys/Makefile3
-rw-r--r--usr/src/uts/common/sys/devpoll.h18
-rw-r--r--usr/src/uts/common/sys/epoll.h89
-rw-r--r--usr/src/uts/common/sys/file.h5
-rw-r--r--usr/src/uts/common/sys/poll.h13
-rw-r--r--usr/src/uts/common/sys/poll_impl.h10
6 files changed, 130 insertions, 8 deletions
diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile
index ee396632ad..c2bf2f0483 100644
--- a/usr/src/uts/common/sys/Makefile
+++ b/usr/src/uts/common/sys/Makefile
@@ -20,7 +20,7 @@
#
#
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2013, Joyent, Inc. All rights reserved.
+# Copyright 2014, Joyent, Inc. All rights reserved.
# Copyright 2013 Garrett D'Amore <garrett@damore.org>
# Copyright 2013 Saso Kiselkov. All rights reserved.
# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
@@ -215,6 +215,7 @@ CHKHDRS= \
emul64cmd.h \
emul64var.h \
epm.h \
+ epoll.h \
errno.h \
errorq.h \
errorq_impl.h \
diff --git a/usr/src/uts/common/sys/devpoll.h b/usr/src/uts/common/sys/devpoll.h
index 36c815c69f..4e4c76d9b0 100644
--- a/usr/src/uts/common/sys/devpoll.h
+++ b/usr/src/uts/common/sys/devpoll.h
@@ -24,11 +24,13 @@
* All rights reserved.
*/
+/*
+ * Copyright (c) 2014, Joyent, Inc. All rights reserved.
+ */
+
#ifndef _SYS_DEVPOLL_H
#define _SYS_DEVPOLL_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/poll_impl.h>
#include <sys/types32.h>
@@ -39,8 +41,10 @@ extern "C" {
/* /dev/poll ioctl */
#define DPIOC (0xD0 << 8)
-#define DP_POLL (DPIOC | 1) /* poll on fds in cached in /dev/poll */
+#define DP_POLL (DPIOC | 1) /* poll on fds cached via /dev/poll */
#define DP_ISPOLLED (DPIOC | 2) /* is this fd cached in /dev/poll */
+#define DP_PPOLL (DPIOC | 3) /* ppoll on fds cached via /dev/poll */
+#define DP_EPOLLCOMPAT (DPIOC | 4) /* turn on epoll compatibility */
#define DEVPOLLSIZE 1000 /* /dev/poll table size increment */
@@ -51,14 +55,21 @@ typedef struct dvpoll {
pollfd_t *dp_fds; /* pollfd array */
nfds_t dp_nfds; /* num of pollfd's in dp_fds[] */
int dp_timeout; /* time out in milisec */
+ sigset_t *dp_setp; /* sigset, if any */
} dvpoll_t;
typedef struct dvpoll32 {
caddr32_t dp_fds; /* pollfd array */
uint32_t dp_nfds; /* num of pollfd's in dp_fds[] */
int32_t dp_timeout; /* time out in milisec */
+ caddr32_t dp_setp; /* sigset, if any */
} dvpoll32_t;
+typedef struct dvpoll_epollfd {
+ pollfd_t dpep_pollfd; /* must be first member */
+ uint64_t dpep_data; /* data payload */
+} dvpoll_epollfd_t;
+
#ifdef _KERNEL
typedef struct dp_entry {
@@ -71,6 +82,7 @@ typedef struct dp_entry {
} dp_entry_t;
#define DP_WRITER_PRESENT 0x1 /* a write is in progress */
+#define DP_ISEPOLLCOMPAT 0x2 /* epoll compatibility mode */
#define DP_REFRELE(dpep) { \
mutex_enter(&(dpep)->dpe_lock); \
diff --git a/usr/src/uts/common/sys/epoll.h b/usr/src/uts/common/sys/epoll.h
new file mode 100644
index 0000000000..f2e4b90ab7
--- /dev/null
+++ b/usr/src/uts/common/sys/epoll.h
@@ -0,0 +1,89 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright (c) 2014, Joyent, Inc. All rights reserved.
+ */
+
+#ifndef _SYS_EPOLL_H
+#define _SYS_EPOLL_H
+
+#include <sys/types.h>
+#include <sys/poll.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef union epoll_data {
+ void *ptr;
+ int fd;
+ uint32_t u32;
+ uint64_t u64;
+} epoll_data_t;
+
+#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
+#pragma pack(4)
+#endif
+
+typedef struct epoll_event {
+ uint32_t events; /* events */
+ epoll_data_t data; /* user-specified data */
+} epoll_event_t;
+
+#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
+#pragma pack()
+#endif
+
+/*
+ * Define the EPOLL* constants in terms of their poll(2)/poll(7) equivalents.
+ * Note that the values match the equivalents in Linux to allow for any binary
+ * compatibility layers to not need to translate them.
+ */
+#define EPOLLIN 0x0001
+#define EPOLLPRI 0x0002
+#define EPOLLOUT 0x0004
+#define EPOLLRDNORM 0x0040
+#define EPOLLRDBAND 0x0080
+#define EPOLLWRNORM 0x0100
+#define EPOLLWRBAND 0x0200
+#define EPOLLMSG 0x0400 /* not used */
+#define EPOLLERR 0x0008
+#define EPOLLHUP 0x0010
+#define EPOLLRDHUP 0x2000
+
+#define EPOLLWAKEUP (1UL << 29) /* no meaning; silently ignored */
+#define EPOLLONESHOT (1UL << 30) /* translated to POLLONESHOT */
+#define EPOLLET (1UL << 31) /* translated to POLLET */
+
+#define EPOLL_CTL_ADD 1
+#define EPOLL_CTL_DEL 2
+#define EPOLL_CTL_MOD 3
+
+#define EPOLL_CLOEXEC 02000000
+
+#if !defined(_KERNEL)
+
+extern int epoll_create(int size);
+extern int epoll_create1(int flags);
+extern int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
+extern int epoll_wait(int epfd, struct epoll_event *events,
+ int maxevents, int timeout);
+extern int epoll_pwait(int epfd, struct epoll_event *events,
+ int maxevents, int timeout, const sigset_t *sigmask);
+
+#endif /* !_KERNEL */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_EPOLL_H */
diff --git a/usr/src/uts/common/sys/file.h b/usr/src/uts/common/sys/file.h
index 03acc088c2..1f736d3d01 100644
--- a/usr/src/uts/common/sys/file.h
+++ b/usr/src/uts/common/sys/file.h
@@ -120,6 +120,11 @@ typedef struct fpollinfo {
#ifdef _KERNEL
/*
+ * This is a flag that is set on f_flag2, but is never user-visible
+ */
+#define FEPOLLED 0x8000
+
+/*
* Fake flags for driver ioctl calls to inform them of the originating
* process' model. See <sys/model.h>
*
diff --git a/usr/src/uts/common/sys/poll.h b/usr/src/uts/common/sys/poll.h
index 9fff78a966..efc8457a6a 100644
--- a/usr/src/uts/common/sys/poll.h
+++ b/usr/src/uts/common/sys/poll.h
@@ -30,6 +30,10 @@
* All rights reserved.
*/
+/*
+ * Copyright (c) 2014, Joyent, Inc. All rights reserved.
+ */
+
#ifndef _SYS_POLL_H
#define _SYS_POLL_H
@@ -59,6 +63,7 @@ typedef unsigned long nfds_t;
#define POLLWRNORM POLLOUT
#define POLLRDBAND 0x0080 /* out-of-band data is readable */
#define POLLWRBAND 0x0100 /* out-of-band data is writeable */
+#define POLLRDHUP 0x4000 /* read-side hangup */
#define POLLNORM POLLRDNORM
@@ -70,7 +75,13 @@ typedef unsigned long nfds_t;
#define POLLHUP 0x0010 /* fd has been hung up on */
#define POLLNVAL 0x0020 /* invalid pollfd entry */
-#define POLLREMOVE 0x0800 /* remove a cached poll fd from /dev/poll */
+/*
+ * These events will never be specified in revents, but may be specified in
+ * events to control /dev/poll behavior.
+ */
+#define POLLREMOVE 0x0800 /* remove cached /dev/poll fd */
+#define POLLONESHOT 0x1000 /* /dev/poll should one-shot this fd */
+#define POLLET 0x2000 /* edge-triggered /dev/poll fd */
#ifdef _KERNEL
diff --git a/usr/src/uts/common/sys/poll_impl.h b/usr/src/uts/common/sys/poll_impl.h
index ede99d0df2..2e866ec4d4 100644
--- a/usr/src/uts/common/sys/poll_impl.h
+++ b/usr/src/uts/common/sys/poll_impl.h
@@ -24,11 +24,13 @@
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2014, Joyent, Inc. All rights reserved.
+ */
+
#ifndef _SYS_POLL_IMPL_H
#define _SYS_POLL_IMPL_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Caching Poll Subsystem:
*
@@ -160,6 +162,7 @@ typedef struct polldat {
int pd_nsets; /* num of xref sets, used by poll(2) */
xref_t *pd_ref; /* ptr to xref info, 1 for each set */
struct port_kevent *pd_portev; /* associated port event struct */
+ uint64_t pd_epolldata; /* epoll data, if any */
} polldat_t;
/*
@@ -187,7 +190,8 @@ typedef struct pollcache {
} pollcache_t;
/* pc_flag */
-#define T_POLLWAKE 0x02 /* pollwakeup() occurred */
+#define PC_POLLWAKE 0x02 /* pollwakeup() occurred */
+#define PC_WRITEWANTED 0x04 /* writer wishes to modify the pollcache_t */
#if defined(_KERNEL)
/*