diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/lib/libc/port/mapfile-vers | 10 | ||||
-rw-r--r-- | usr/src/lib/libc/sparcv9/Makefile.com | 1 | ||||
-rw-r--r-- | usr/src/man/man3c/eventfd.3c | 323 | ||||
-rw-r--r-- | usr/src/man/man5/eventfd.5 | 60 | ||||
-rw-r--r-- | usr/src/man/man9e/chpoll.9e | 5 | ||||
-rw-r--r-- | usr/src/pkg/manifests/SUNWcs.mf | 3 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-header.mf | 1 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-library.man3c.inc | 1 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-library.man5.inc | 1 | ||||
-rw-r--r-- | usr/src/uts/common/io/eventfd.c | 12 |
10 files changed, 227 insertions, 190 deletions
diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers index 6d2a77e1df..904cd18ca5 100644 --- a/usr/src/lib/libc/port/mapfile-vers +++ b/usr/src/lib/libc/port/mapfile-vers @@ -93,6 +93,13 @@ $if _x86 && _ELF64 $add amd64 $endif +SYMBOL_VERSION ILLUMOS_0.13 { # eventfd + protected: + eventfd; + eventfd_read; + eventfd_write; +} ILLUMOS_0.12; + SYMBOL_VERSION ILLUMOS_0.12 { # arc4random and friends protected: arc4random; @@ -2841,9 +2848,6 @@ $endif epoll_pwait; _errfp; _errxfp; - eventfd; - eventfd_read; - eventfd_write; exportfs; _F_cplx_div; _F_cplx_div_ix; diff --git a/usr/src/lib/libc/sparcv9/Makefile.com b/usr/src/lib/libc/sparcv9/Makefile.com index 7ebd92289e..5a9d35132a 100644 --- a/usr/src/lib/libc/sparcv9/Makefile.com +++ b/usr/src/lib/libc/sparcv9/Makefile.com @@ -883,6 +883,7 @@ PORTSYS= \ chown.o \ corectl.o \ epoll.o \ + eventfd.o \ exacctsys.o \ execl.o \ execle.o \ diff --git a/usr/src/man/man3c/eventfd.3c b/usr/src/man/man3c/eventfd.3c index 6e7d1c6a5b..3a9f8be284 100644 --- a/usr/src/man/man3c/eventfd.3c +++ b/usr/src/man/man3c/eventfd.3c @@ -1,161 +1,184 @@ -'\" te -.\" Copyright (c) 2014, Joyent, Inc. All Rights Reserved. -.\" 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. -.TH EVENTFD 3C "Dec 3, 2014" -.SH NAME -eventfd \- create a file descriptor for event notification -.SH SYNOPSIS - -.LP -.nf -#include <sys/eventfd.h> - -\fBint\fR \fBeventfd\fR(\fBunsigned int\fR \fIinitval\fR, \fBint\fR \fIflags\fR); -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBeventfd()\fR function creates an \fBeventfd\fR(5) instance that -has an associated 64-bit unsigned counter. It returns a file descriptor -that can be operated upon via \fBread\fR(2), \fBwrite\fR(2) and the facilities -that notify of file descriptor activity (e.g., \fBpoll\fR(2), -\fBport_get\fR(3C), \fBepoll_wait\fR(3C)). To dispose of the instance, -\fBclose\fR(2) should be called on the file descriptor. - -The \fIinitval\fR argument specifies the -initial value of the 64-bit counter associated with the instance. (Note -that this limits the initial value to be a 32-bit quantity despite the -fact that the underlying counter is 64-bit.) - +.\" +.\" 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. +.\" +.Dd Dec 3, 2014 +.Dt EVENTFD 3C +.Os +.Sh NAME +.Nm eventfd +.Nd create a file descriptor for event notification +.Sh SYNOPSIS +.In sys/eventfd.h +.Ft int +.Fo eventfd +.Fa "unsigned int initval" +.Fa "int flags" +.Fc +.Sh DESCRIPTION +The +.Fn eventfd +function creates an +.Xr eventfd 5 +instance that has an associated 64-bit unsigned counter. It returns a file +descriptor that can be operated upon via +.Xr read 2 , +.Xr write 2 +and the facilities that notify of file descriptor activity (e.g., +.Xr poll 2 , +.Xr port_get 3C , +.Xr epoll_wait 3C Ns ). +To dispose of the instance, +.Xr close 2 +should be called on the file descriptor. +.Pp +The +.Fa initval +argument specifies the initial value of the 64-bit counter associated with the +instance. (Note that this limits the initial value to be a 32-bit quantity +despite the fact that the underlying counter is 64-bit.) +.Pp The \fIflags\fR argument specifies additional parameters for the instance, and can have any of the following values: - -.sp -.ne 2 -.na -\fBEFD_CLOEXEC\fR -.ad -.RS 12n +.Bl -hang -width Ds +.It Sy EFD_CLOEXEC +.Bd -filled -compact Instance will be closed upon an -\fBexec\fR(2); see \fBopen\fR(2)'s description of \fBO_CLOEXEC\fR. -.RE - -.sp -.ne 2 -.na -\fBEFD_NONBLOCK\fR -.ad -.RS 12n -Instance will be set to be non-blocking. A \fBread\fR(2) on an -\fBeventfd\fR instance that has been initialized with -\fBEFD_NONBLOCK\fR will return \fBEAGAIN\fR in lieu of blocking if the -count associated with the instance is zero. -.RE - -.sp -.ne 2 -.na -\fBEFD_SEMAPHORE\fR -.ad -.RS 12n -Provide counting semaphore semantics whereby a \fBread\fR(2) will -atomically decrement rather than atomically clear the count when it -becomes non-zero. See below for details on \fBread\fR(2) semantics. -.RE - -.sp -The following operations can be performed upon an \fBeventfd\fR instance: - -.sp -.ne 2 -.na -\fBread\fR(2) -.ad -.RS 12n +.Xr exec 2 ; +see +.Xr open 2 Ns 's +description of +.Sy O_CLOEXEC . +.Ed +.It Sy EFD_NONBLOCK +.Bd -filled -compact +Instance will be set to be non-blocking. A +.Xr read 2 +on an +.Sy eventfd +instance that has been initialized with +.Sy EFD_NONBLOCK +will return +.Sy EAGAIN +in lieu of blocking if the count associated with the instance is zero. +.Ed +.It EFD_SEMAPHORE +.Bd -filled -compact +Provide counting semaphore semantics whereby a +.Xr read 2 +will atomically decrement rather than atomically clear the count when it +becomes non-zero. See below for details on +.Xr read 2 +semantics. +.Ed +.El +.Pp +The following operations can be performed upon an +.Sy eventfd +instance: +.Bl -hang -width Ds +.It Sy read(2) +.Bd -filled -compact Atomically reads and modifies the value of the 64-bit counter associated with the instance. The precise semantics -of \fBread\fR(2) depend on the disposition of \fBEFD_SEMAPHORE\fR with -respect to the instance: if \fBEFD_SEMAPHORE\fR was set when the instance -was created, \fBread\fR(2) will \fIatomically decrement\fR the counter if -(and when) -it is non-zero, copying the value 1 to the eight byte buffer passed to -the system call; if \fBEFD_SEMAPHORE\fR was not set, \fBread\fR(2) will -\fIatomically clear\fR the counter if (and when) it is non-zero, copying -the former value of the counter to the eight byte buffer passed to the -system call. In either case, \fBread\fR(2) will block if the counter is -zero (or return \fBEAGAIN\fR if the instance was created with -\fBEFD_NONBLOCK\fR). If the buffer specified to \fBread\fR(2) is less than -eight bytes in length, \fBEINVAL\fR will be returned. - -.RE - -.sp -.ne 2 -.na -\fBwrite\fR(2) -.ad -.RS 12n +of +.Xr read 2 +depend on the disposition of +.Sy EFD_SEMAPHORE +with +respect to the instance: if +.Sy EFD_SEMAPTHORE +was set when the instance was created, +.Xr read 2 +will +.Em atomically decrement +the counter if (and when) it is non-zero, copying the value 1 to the eight +byte buffer passed to the system call; if +.Sy EFD_SEMAPHORE +was not set, +.Xr read 2 +will +.Em atomically clear +the counter if (and when) it is non-zero, copying the former value of the +counter to the eight byte buffer passed to the +system call. In either case, +.Xr read 2 +will block if the counter is +zero (or return +.Sy EAGAIN +if the instance was created with +.Sy EFD_NONBLOCK Ns ). +If the buffer specified to +.Xr read 2 +is less than +eight bytes in length, +.Sy EINVAL +will be returned. +.Ed +.It Sy write(2) +.Bd -filled -compact Atomically adds the 64-bit value pointed to by the buffer to the 64-bit counter associated with the instance. If the resulting value would overflow, -the \fBwrite\fR(2) will block until the value would not overflow -(or return \fBEAGAIN\fR if the instance was created with -\fBEFD_NONBLOCK\fR). If the buffer specified to \fBwrite\fR(2) is less than -eight bytes in length, \fBEINVAL\fR will be returned. - -.RE - -.sp -.ne 2 -.na -\fBpoll\fR(2), \fBport_get\fR(3C), \fBepoll_wait\fR(3C) -.ad -.RS 12n +the +.Xr write 2 +will block until the value would not overflow +(or return +.Sy EAGAIN +EAGAIN if the instance was created with +.Sy EFD_NONBLOCK Ns ). +If the buffer specified to +.Xr write 2 +is less than eight bytes in length, +.Sy EINVAL +will be returned. +.Ed +.It Sy poll(2), port_get(3C), epoll_wait(3C) +.Bd -filled -compact Provide notification when the 64-bit counter associated with the instance is ready for reading or writing, as specified. -If the 64-bit value associated with the instance is non-zero, \fBPOLLIN\fR -and \fBPOLLRDNORM\fR will be set; if the value 1 can be added the value -without blocking, \fBPOLLOUT\fR and \fBPOLLWRNORM\fR will be set. -.RE - -.SH RETURN VALUES -.sp -.LP +If the 64-bit value associated with the instance is non-zero, +.Sy POLLIN +and +.Sy POLLRDNORM +will be set; if the value 1 can be added the value +without blocking, +.Sy POLLOUT +and +.Sy POLLWRNORM +will be set. +.Ed +.El +.Sh RETURN VALUES Upon succesful completion, a file descriptor associated with the instance -is returned. Otherwise, -1 is returned and errno +is returned. Otherwise, +.Sy -1 is returned and +.Sy errno is set to indicate the error. -.SH ERRORS -.sp -.LP -The \fBeventfd()\fR function will fail if: -.sp -.ne 2 -.na -\fB\fBEINVAL\fR\fR -.ad -.RS 10n -The \fIflags\fR are invalid. -.RE - -.sp -.ne 2 -.na -\fB\fBEMFILE\fR\fR -.ad -.RS 10n -There are currently {\fBOPEN_MAX\fR} file descriptors open in the calling -process. -.RE - -.SH SEE ALSO -.sp -.LP -\fBpoll\fR(2), \fBport_get\fR(3C), \fBepoll_wait\fR(3C), \fBeventfd\fR(5) - +.Sh ERRORS +The +.Fn eventfd +function will fail if: +.Bl -tag -width Er +.It Er EINVAL +The +.Fa flags +are invalid. +.It Er EMFILE +There are currently +.Pf { Sy OPEN_MAX Ns } +file descriptors open in the calling process. +.El +.Sh SEE ALSO +.Xr poll 2 , +.Xr port_get 3C , +.Xr epoll_wait 3C , +.Xr eventfd 5 diff --git a/usr/src/man/man5/eventfd.5 b/usr/src/man/man5/eventfd.5 index fc30495070..bcf9f58347 100644 --- a/usr/src/man/man5/eventfd.5 +++ b/usr/src/man/man5/eventfd.5 @@ -1,34 +1,32 @@ -'\" te -.\" Copyright (c) 2014, Joyent, Inc. All Rights Reserved. -.\" 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. -.TH EVENTFD 5 "Dec 3, 2014" -.SH NAME -eventfd \- Linux-compatible user event notification facility -.SH SYNOPSIS - -.LP -.nf -#include <sys/eventfd.h> -.fi - -.SH DESCRIPTION -.sp -.LP - -\fBeventfd\fR is a Linux-borne facility for sending and receiving user +.\" +.\" 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. +.\" +.Dd Dec 3, 2014 +.Dt EVENTFD 5 +.Os +.Sh NAME +.Nm eventfd +.Nd Linux-compatible user event notification facility +.Sh SYNOPSIS +.In sys/eventfd.h +.Sh DESCRIPTION +.Nm +is a Linux-borne facility for sending and receiving user events via a file descriptor. While the facility itself is somewhat dubious (it can be mimicked in an entirely portable way with a pipe), it is small and straightforward and this implementation is entirely compatible -with its Linux antecedent; see \fBeventfd\fR(3C) for details. - -.SH SEE ALSO -.sp -.LP -\fBeventfd\fR(3C) +with its Linux antecedent; see +.Xr eventfd 3C +for details. +.Sh SEE ALSO +.Xr eventfd 3C diff --git a/usr/src/man/man9e/chpoll.9e b/usr/src/man/man9e/chpoll.9e index b63f75e4e8..7b4b3edf0b 100644 --- a/usr/src/man/man9e/chpoll.9e +++ b/usr/src/man/man9e/chpoll.9e @@ -22,11 +22,9 @@ chpoll \- poll entry point for a non-STREAMS character driver .fi .SH INTERFACE LEVEL -.sp .LP This entry point is optional. Architecture independent level 1 (DDI/DKI). .SH PARAMETERS -.sp .ne 2 .na \fB\fIdev\fR\fR @@ -167,7 +165,6 @@ A pointer to a pointer to a \fBpollhead\fR structure. .RE .SH DESCRIPTION -.sp .LP The \fBchpoll()\fR entry point routine is used by non-STREAMS character device drivers that wish to support polling. The driver must implement the polling @@ -250,12 +247,10 @@ associated with the \fBpollhead\fR is about to be deallocated by the .RE .SH RETURN VALUES -.sp .LP \fBchpoll()\fR should return \fB0\fR for success, or the appropriate error number. .SH SEE ALSO -.sp .LP \fBpoll\fR(2), \fBnochpoll\fR(9F), \fBpollwakeup\fR(9F) .sp diff --git a/usr/src/pkg/manifests/SUNWcs.mf b/usr/src/pkg/manifests/SUNWcs.mf index 70a2ebf2b0..7e5f61a969 100644 --- a/usr/src/pkg/manifests/SUNWcs.mf +++ b/usr/src/pkg/manifests/SUNWcs.mf @@ -858,6 +858,7 @@ file path=usr/has/man/man1has/ex.1has file path=usr/has/man/man1has/sh.1has file path=usr/has/man/man1has/vi.1has file path=usr/kernel/drv/$(ARCH64)/dump group=sys +file path=usr/kernel/drv/$(ARCH64)/eventfd group=sys file path=usr/kernel/drv/$(ARCH64)/fssnap group=sys file path=usr/kernel/drv/$(ARCH64)/kstat group=sys file path=usr/kernel/drv/$(ARCH64)/ksyms group=sys @@ -866,6 +867,8 @@ file path=usr/kernel/drv/$(ARCH64)/ptm group=sys file path=usr/kernel/drv/$(ARCH64)/pts group=sys $(i386_ONLY)file path=usr/kernel/drv/dump group=sys file path=usr/kernel/drv/dump.conf group=sys +$(i386_ONLY)file path=usr/kernel/drv/eventfd group=sys +file path=usr/kernel/drv/eventfd.conf group=sys $(i386_ONLY)file path=usr/kernel/drv/fssnap group=sys file path=usr/kernel/drv/fssnap.conf group=sys $(i386_ONLY)file path=usr/kernel/drv/kstat group=sys diff --git a/usr/src/pkg/manifests/system-header.mf b/usr/src/pkg/manifests/system-header.mf index eba786e9d0..18d7611554 100644 --- a/usr/src/pkg/manifests/system-header.mf +++ b/usr/src/pkg/manifests/system-header.mf @@ -958,6 +958,7 @@ file path=usr/include/sys/esunddi.h file path=usr/include/sys/ethernet.h file path=usr/include/sys/euc.h file path=usr/include/sys/eucioctl.h +file path=usr/include/sys/eventfd.h file path=usr/include/sys/exacct.h file path=usr/include/sys/exacct_catalog.h file path=usr/include/sys/exacct_impl.h diff --git a/usr/src/pkg/manifests/system-library.man3c.inc b/usr/src/pkg/manifests/system-library.man3c.inc index ee9934f801..85b54e1430 100644 --- a/usr/src/pkg/manifests/system-library.man3c.inc +++ b/usr/src/pkg/manifests/system-library.man3c.inc @@ -107,6 +107,7 @@ file path=usr/share/man/man3c/encrypt.3c file path=usr/share/man/man3c/end.3c file path=usr/share/man/man3c/err.3c file path=usr/share/man/man3c/euclen.3c +file path=usr/share/man/man3c/eventfd.3c file path=usr/share/man/man3c/exit.3c file path=usr/share/man/man3c/fattach.3c file path=usr/share/man/man3c/fclose.3c diff --git a/usr/src/pkg/manifests/system-library.man5.inc b/usr/src/pkg/manifests/system-library.man5.inc index 1344b918e2..fd222bcec4 100644 --- a/usr/src/pkg/manifests/system-library.man5.inc +++ b/usr/src/pkg/manifests/system-library.man5.inc @@ -27,6 +27,7 @@ file path=usr/share/man/man5/crypt_sha512.5 file path=usr/share/man/man5/crypt_sunmd5.5 file path=usr/share/man/man5/crypt_unix.5 file path=usr/share/man/man5/environ.5 +file path=usr/share/man/man5/eventfd.5 file path=usr/share/man/man5/extendedFILE.5 file path=usr/share/man/man5/fnmatch.5 file path=usr/share/man/man5/isalist.5 diff --git a/usr/src/uts/common/io/eventfd.c b/usr/src/uts/common/io/eventfd.c index 6683a9ca8e..e5082b49b6 100644 --- a/usr/src/uts/common/io/eventfd.c +++ b/usr/src/uts/common/io/eventfd.c @@ -269,10 +269,20 @@ eventfd_close(dev_t dev, int flag, int otyp, cred_t *cred_p) return (0); } -/*ARGSUSED*/ static int eventfd_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) { + switch (cmd) { + case DDI_ATTACH: + break; + + case DDI_RESUME: + return (DDI_SUCCESS); + + default: + return (DDI_FAILURE); + } + mutex_enter(&eventfd_lock); if (ddi_soft_state_init(&eventfd_softstate, |