Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump/rumpnet add a very simple version of pollso...



details:   https://anonhg.NetBSD.org/src/rev/0067234d273a
branches:  trunk
changeset: 747232:0067234d273a
user:      pooka <pooka%NetBSD.org@localhost>
date:      Sun Sep 06 20:02:49 2009 +0000

description:
add a very simple version of pollsock()
XXX: it seems to exist purely for the pleasure of netsmb??

diffstat:

 sys/rump/librump/rumpnet/Makefile.rumpnet |   4 +-
 sys/rump/librump/rumpnet/net_emul.c       |  66 +++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 2 deletions(-)

diffs (88 lines):

diff -r ceec0c0d09c3 -r 0067234d273a sys/rump/librump/rumpnet/Makefile.rumpnet
--- a/sys/rump/librump/rumpnet/Makefile.rumpnet Sun Sep 06 19:46:24 2009 +0000
+++ b/sys/rump/librump/rumpnet/Makefile.rumpnet Sun Sep 06 20:02:49 2009 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.rumpnet,v 1.6 2009/06/10 20:54:55 pooka Exp $
+#      $NetBSD: Makefile.rumpnet,v 1.7 2009/09/06 20:02:49 pooka Exp $
 #
 
 .include "${RUMPTOP}/Makefile.rump"
@@ -10,7 +10,7 @@
        ${RUMPTOP}/../net                                       \
        ${RUMPTOP}/../compat/common
 
-SRCS=  net_stub.c netisr.c rump_net.c
+SRCS=  net_stub.c netisr.c rump_net.c net_emul.c
 
 # sys/kern networking (sockets, mbufs, etc.)
 SRCS+= sys_socket.c uipc_accf.c uipc_domain.c uipc_mbuf.c uipc_mbuf2.c \
diff -r ceec0c0d09c3 -r 0067234d273a sys/rump/librump/rumpnet/net_emul.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/librump/rumpnet/net_emul.c       Sun Sep 06 20:02:49 2009 +0000
@@ -0,0 +1,66 @@
+/*     $NetBSD: net_emul.c,v 1.1 2009/09/06 20:02:49 pooka Exp $       */
+
+/*
+ * Copyright (c) 2009 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/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: net_emul.c,v 1.1 2009/09/06 20:02:49 pooka Exp $");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/time.h>
+
+/*
+ * A very simplistic (and polling ;) implementation of pollsock().
+ * Hopefully I'll soon be able to run sys_select.c
+ */
+
+int
+pollsock(struct socket *so, const struct timespec *tsp, int events)
+{
+       struct timespec ts, sts;
+
+       if (tsp) {
+               ts = *tsp;
+               if (inittimeleft(&ts, &sts) == -1)
+                       return EINVAL;
+       }
+
+       for (;;) {
+               if (tsp) {
+                       if (gettimeleft(&ts, &sts) < 0) {
+                               break;
+                       }
+               }
+               if (sopoll(so, events) != 0)
+                       break;
+               kpause("lol", false, hz/10, 0);
+       }
+
+       return 0;
+}



Home | Main Index | Thread Index | Old Index