Module Name:    src
Committed By:   maya
Date:           Wed Feb  8 17:58:41 UTC 2017

Modified Files:
        src/lib/libc/sys: Makefile.inc
        src/sys/sys: socket.h
Added Files:
        src/lib/libc/sys: accept4.c

Log Message:
Add accept4, a tiny wrapper around paccept.

accept4 is a syscall in Linux, FreeBSD and OpenBSD. It is used in
LLVM, zeromq, and probably others. paccept is a superset of it.

adding it to libc ensures it is used by programs and prevents the
need to define the same wrapper in every program.


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/lib/libc/sys/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/sys/accept4.c
cvs rdiff -u -r1.120 -r1.121 src/sys/sys/socket.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/sys/Makefile.inc
diff -u src/lib/libc/sys/Makefile.inc:1.233 src/lib/libc/sys/Makefile.inc:1.234
--- src/lib/libc/sys/Makefile.inc:1.233	Wed Feb  8 17:30:27 2017
+++ src/lib/libc/sys/Makefile.inc	Wed Feb  8 17:58:41 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.233 2017/02/08 17:30:27 maya Exp $
+#	$NetBSD: Makefile.inc,v 1.234 2017/02/08 17:58:41 maya Exp $
 #	@(#)Makefile.inc	8.3 (Berkeley) 10/24/94
 
 # sys sources
@@ -9,7 +9,7 @@ SRCS+=	cpuset.c
 # glue to offer userland wrappers for some syscalls
 SRCS+=	posix_fadvise.c posix_madvise.c sched.c sigqueue.c sigtimedwait.c \
 	sigwait.c sigwaitinfo.c statvfs.c swapon.c semctl.c \
-	clock_getcpuclockid.c
+	clock_getcpuclockid.c accept4.c
 
 .if ${RUMPRUN} != "yes"
 # modules with non-default implementations on at least one architecture:

Index: src/sys/sys/socket.h
diff -u src/sys/sys/socket.h:1.120 src/sys/sys/socket.h:1.121
--- src/sys/sys/socket.h:1.120	Wed Sep 21 10:50:23 2016
+++ src/sys/sys/socket.h	Wed Feb  8 17:58:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: socket.h,v 1.120 2016/09/21 10:50:23 roy Exp $	*/
+/*	$NetBSD: socket.h,v 1.121 2017/02/08 17:58:41 maya Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -644,6 +644,7 @@ __END_DECLS
 
 __BEGIN_DECLS
 int	accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
+int	accept4(int, struct sockaddr * __restrict, socklen_t * __restrict, int);
 int	bind(int, const struct sockaddr *, socklen_t);
 int	connect(int, const struct sockaddr *, socklen_t);
 int	getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);

Added files:

Index: src/lib/libc/sys/accept4.c
diff -u /dev/null src/lib/libc/sys/accept4.c:1.1
--- /dev/null	Wed Feb  8 17:58:41 2017
+++ src/lib/libc/sys/accept4.c	Wed Feb  8 17:58:41 2017
@@ -0,0 +1,84 @@
+/*	$NetBSD: accept4.c,v 1.1 2017/02/08 17:58:41 maya Exp $	*/
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: accept4.c,v 1.1 2017/02/08 17:58:41 maya Exp $");
+
+#include "namespace.h"
+#include <sys/socket.h>
+
+#include <stddef.h>
+
+int
+accept4(int s, struct sockaddr * restrict addr, socklen_t * restrict addrlen,
+    int flags)
+{
+	return paccept(s, addr, addrlen, NULL, flags);
+}
+/*	$NetBSD: accept4.c,v 1.1 2017/02/08 17:58:41 maya Exp $	*/
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: accept4.c,v 1.1 2017/02/08 17:58:41 maya Exp $");
+
+#include "namespace.h"
+#include <sys/socket.h>
+
+#include <stddef.h>
+
+int
+accept4(int s, struct sockaddr * restrict addr, socklen_t * restrict addrlen,
+    int flags)
+{
+	return paccept(s, addr, addrlen, NULL, flags);
+}

Reply via email to