Module Name:    src
Committed By:   pooka
Date:           Sun Sep  6 20:02:49 UTC 2009

Modified Files:
        src/sys/rump/librump/rumpnet: Makefile.rumpnet
Added Files:
        src/sys/rump/librump/rumpnet: net_emul.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/rump/librump/rumpnet/Makefile.rumpnet
cvs rdiff -u -r0 -r1.1 src/sys/rump/librump/rumpnet/net_emul.c

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

Modified files:

Index: src/sys/rump/librump/rumpnet/Makefile.rumpnet
diff -u src/sys/rump/librump/rumpnet/Makefile.rumpnet:1.6 src/sys/rump/librump/rumpnet/Makefile.rumpnet:1.7
--- src/sys/rump/librump/rumpnet/Makefile.rumpnet:1.6	Wed Jun 10 20:54:55 2009
+++ src/sys/rump/librump/rumpnet/Makefile.rumpnet	Sun Sep  6 20:02:49 2009
@@ -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	\

Added files:

Index: src/sys/rump/librump/rumpnet/net_emul.c
diff -u /dev/null src/sys/rump/librump/rumpnet/net_emul.c:1.1
--- /dev/null	Sun Sep  6 20:02:50 2009
+++ src/sys/rump/librump/rumpnet/net_emul.c	Sun Sep  6 20:02:49 2009
@@ -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;
+}

Reply via email to