Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Move the rumpuser_net set of hypercalls to be a private to t...



details:   https://anonhg.NetBSD.org/src/rev/86352640a0cf
branches:  trunk
changeset: 785533:86352640a0cf
user:      pooka <pooka%NetBSD.org@localhost>
date:      Mon Mar 18 13:14:10 2013 +0000

description:
Move the rumpuser_net set of hypercalls to be a private to the sockin
component.  This cleans up the generic hypercall interfaces from ones
specific to only one component.  They should always have been private,
but the infrastructure to "make it so" didn't exist earlier.

no functional change

diffstat:

 lib/librumpuser/Makefile                   |    4 +-
 lib/librumpuser/rumpuser_net.c             |  130 ----------------------
 sys/rump/net/lib/libsockin/Makefile        |    4 +-
 sys/rump/net/lib/libsockin/rumpcomp_user.c |  166 +++++++++++++++++++++++++++++
 sys/rump/net/lib/libsockin/rumpcomp_user.h |   42 +++++++
 sys/rump/net/lib/libsockin/sockin.c        |   36 +++--
 6 files changed, 233 insertions(+), 149 deletions(-)

diffs (truncated from 514 to 300 lines):

diff -r f096bd8f2f54 -r 86352640a0cf lib/librumpuser/Makefile
--- a/lib/librumpuser/Makefile  Mon Mar 18 11:40:39 2013 +0000
+++ b/lib/librumpuser/Makefile  Mon Mar 18 13:14:10 2013 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.8 2013/03/01 18:15:36 pooka Exp $
+#      $NetBSD: Makefile,v 1.9 2013/03/18 13:14:10 pooka Exp $
 #
 
 WARNS?=                5
@@ -11,7 +11,7 @@
 CPPFLAGS+=     -DLIBRUMPUSER
 #CPPFLAGS+=    -D_DIAGNOSTIC
 
-SRCS=          rumpuser.c rumpuser_net.c
+SRCS=          rumpuser.c
 SRCS+=         rumpuser_pth.c
 SRCS+=         rumpuser_dl.c rumpuser_sp.c rumpuser_daemonize.c
 SRCS+=         rumpuser_component.c
diff -r f096bd8f2f54 -r 86352640a0cf lib/librumpuser/rumpuser_net.c
--- a/lib/librumpuser/rumpuser_net.c    Mon Mar 18 11:40:39 2013 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*     $NetBSD: rumpuser_net.c,v 1.3 2012/07/27 09:09:05 pooka Exp $   */
-
-/*
- * Copyright (c) 2008 Antti Kantee.  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 AUTHOR ``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 AUTHOR 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.
- */
-
-/*
- * Purely to satisfy compilation.  This module is not expected to work on
- * non-NetBSD due to type conflicts.
- */
-#include "rumpuser_port.h"
-
-#if !defined(lint)
-__RCSID("$NetBSD: rumpuser_net.c,v 1.3 2012/07/27 09:09:05 pooka Exp $");
-#endif /* !lint */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <errno.h>
-
-#include <rump/rumpuser.h>
-
-#include "rumpuser_int.h"
-
-int
-rumpuser_net_socket(int domain, int type, int proto, int *error)
-{
-
-       DOCALL_KLOCK(int, (socket(domain, type, proto)));
-}
-
-int
-rumpuser_net_sendmsg(int s, const struct msghdr *msg, int flags, int *error)
-{
-
-       DOCALL_KLOCK(ssize_t, (sendmsg(s, msg, flags)));
-}
-
-int
-rumpuser_net_recvmsg(int s, struct msghdr *msg, int flags, int *error)
-{
-
-       DOCALL_KLOCK(ssize_t, (recvmsg(s, msg, flags)));
-}
-
-int
-rumpuser_net_connect(int s, const struct sockaddr *name, int len, int *error)
-{
-
-       DOCALL_KLOCK(int, (connect(s, name, (socklen_t)len)));
-}
-
-int
-rumpuser_net_bind(int s, const struct sockaddr *name, int len, int *error)
-{
-
-       DOCALL_KLOCK(int, (bind(s, name, (socklen_t)len)));
-}
-
-int
-rumpuser_net_accept(int s, struct sockaddr *name, int *lenp, int *error)
-{
-
-       DOCALL_KLOCK(int, (accept(s, name, (socklen_t *)lenp)));
-}
-
-int
-rumpuser_net_listen(int s, int backlog, int *error)
-{
-
-       DOCALL_KLOCK(int, (listen(s, backlog)));
-}
-
-int
-rumpuser_net_getname(int s, struct sockaddr *so, int *lenp,
-       enum rumpuser_getnametype which, int *error)
-{
-       socklen_t slen = *lenp;
-       int rv;
-
-       if (which == RUMPUSER_SOCKNAME)
-               rv = getsockname(s, so, &slen);
-       else
-               rv = getpeername(s, so, &slen);
-
-       *lenp = slen;
-       if (rv == -1)
-               seterror(errno);
-       else
-               seterror(0);
-
-       return rv;
-}
-
-int
-rumpuser_net_setsockopt(int s, int level, int name,
-       const void *data, int dlen, int *error)
-{
-       socklen_t slen = dlen;
-       int rv;
-
-       rv = setsockopt(s, level, name, data, slen);
-       if (rv == -1)
-               seterror(errno);
-       else
-               seterror(0);
-       return rv;
-}
diff -r f096bd8f2f54 -r 86352640a0cf sys/rump/net/lib/libsockin/Makefile
--- a/sys/rump/net/lib/libsockin/Makefile       Mon Mar 18 11:40:39 2013 +0000
+++ b/sys/rump/net/lib/libsockin/Makefile       Mon Mar 18 13:14:10 2013 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.5 2009/12/12 17:10:20 pooka Exp $
+#      $NetBSD: Makefile,v 1.6 2013/03/18 13:14:11 pooka Exp $
 #
 
 LIB=   rumpnet_sockin
@@ -8,5 +8,7 @@
 
 CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern
 
+RUMPCOMP_USER= #defined
+
 .include <bsd.lib.mk>
 .include <bsd.klinks.mk>
diff -r f096bd8f2f54 -r 86352640a0cf sys/rump/net/lib/libsockin/rumpcomp_user.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/net/lib/libsockin/rumpcomp_user.c        Mon Mar 18 13:14:10 2013 +0000
@@ -0,0 +1,166 @@
+/*     $NetBSD: rumpcomp_user.c,v 1.1 2013/03/18 13:14:11 pooka Exp $  */
+
+/*
+ * Copyright (c) 2008 Antti Kantee.  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 AUTHOR ``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 AUTHOR 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/types.h>
+#include <sys/socket.h>
+
+#include <errno.h>
+
+#include <rump/rumpuser_component.h>
+
+#include "rumpcomp_user.h"
+
+#define seterror() if (rv == -1) *error = errno; else *error = 0;
+
+int
+rumpcomp_sockin_socket(int domain, int type, int proto, int *error)
+{
+       void *cookie;
+       int rv;
+
+       cookie = rumpuser_component_unschedule();
+       rv = socket(domain, type, proto);
+       rumpuser_component_schedule(cookie);
+
+       seterror();
+       return rv;
+}
+
+int
+rumpcomp_sockin_sendmsg(int s, const struct msghdr *msg, int flags, int *error)
+{
+       void *cookie;
+       ssize_t rv;
+
+       cookie = rumpuser_component_unschedule();
+       rv = sendmsg(s, msg, flags);
+       rumpuser_component_schedule(cookie);
+
+       seterror();
+       return rv;
+}
+
+int
+rumpcomp_sockin_recvmsg(int s, struct msghdr *msg, int flags, int *error)
+{
+       void *cookie;
+       ssize_t rv;
+
+       cookie = rumpuser_component_unschedule();
+       rv = recvmsg(s, msg, flags);
+       rumpuser_component_schedule(cookie);
+
+       seterror();
+       return rv;
+}
+
+int
+rumpcomp_sockin_connect(int s, const struct sockaddr *name, int len, int *error)
+{
+       void *cookie;
+       int rv;
+
+       cookie = rumpuser_component_unschedule();
+       rv = connect(s, name, (socklen_t)len);
+       rumpuser_component_schedule(cookie);
+
+       seterror();
+       return rv;
+}
+
+int
+rumpcomp_sockin_bind(int s, const struct sockaddr *name, int len, int *error)
+{
+       void *cookie;
+       int rv;
+
+       cookie = rumpuser_component_unschedule();
+       rv = bind(s, name, (socklen_t)len);
+       rumpuser_component_schedule(cookie);
+
+       seterror();
+       return rv;
+}
+
+int
+rumpcomp_sockin_accept(int s, struct sockaddr *name, int *lenp, int *error)
+{
+       void *cookie;
+       int rv;
+
+       cookie = rumpuser_component_unschedule();
+       rv = accept(s, name, (socklen_t *)lenp);
+       rumpuser_component_schedule(cookie);
+
+       seterror();
+       return rv;
+}
+
+int
+rumpcomp_sockin_listen(int s, int backlog, int *error)
+{
+       void *cookie;
+       int rv;



Home | Main Index | Thread Index | Old Index