Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Implement BPF_MOD.
details: https://anonhg.NetBSD.org/src/rev/aa5215b14a0a
branches: trunk
changeset: 333885:aa5215b14a0a
user: alnsn <alnsn%NetBSD.org@localhost>
date: Thu Nov 20 20:31:22 2014 +0000
description:
Implement BPF_MOD.
diffstat:
sys/net/bpfjit.c | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 deletions(-)
diffs (64 lines):
diff -r 8fcbf88cd63a -r aa5215b14a0a sys/net/bpfjit.c
--- a/sys/net/bpfjit.c Thu Nov 20 19:18:52 2014 +0000
+++ b/sys/net/bpfjit.c Thu Nov 20 20:31:22 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bpfjit.c,v 1.35 2014/11/20 19:18:52 alnsn Exp $ */
+/* $NetBSD: bpfjit.c,v 1.36 2014/11/20 20:31:22 alnsn Exp $ */
/*-
* Copyright (c) 2011-2014 Alexander Nasonov.
@@ -31,9 +31,9 @@
#include <sys/cdefs.h>
#ifdef _KERNEL
-__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.35 2014/11/20 19:18:52 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.36 2014/11/20 20:31:22 alnsn Exp $");
#else
-__RCSID("$NetBSD: bpfjit.c,v 1.35 2014/11/20 19:18:52 alnsn Exp $");
+__RCSID("$NetBSD: bpfjit.c,v 1.36 2014/11/20 20:31:22 alnsn Exp $");
#endif
#include <sys/types.h>
@@ -76,11 +76,6 @@
#endif
/*
- * XXX: Until we support SLJIT_UMOD properly
- */
-#undef BPFJIT_USE_UDIV
-
-/*
* Arguments of generated bpfjit_func_t.
* The first argument is reassigned upon entry
* to a more frequently used buf argument.
@@ -1183,14 +1178,25 @@
#if defined(BPFJIT_USE_UDIV)
status = sljit_emit_op0(compiler, SLJIT_UDIV|SLJIT_INT_OP);
+ if (BPF_OP(pc->code) == BPF_DIV) {
#if BJ_AREG != SLJIT_SCRATCH_REG1
- status = sljit_emit_op1(compiler,
- SLJIT_MOV,
- BJ_AREG, 0,
- SLJIT_SCRATCH_REG1, 0);
+ status = sljit_emit_op1(compiler,
+ SLJIT_MOV,
+ BJ_AREG, 0,
+ SLJIT_SCRATCH_REG1, 0);
+#endif
+ } else {
+#if BJ_AREG != SLJIT_SCRATCH_REG2
+ /* Remainder is in SLJIT_SCRATCH_REG2. */
+ status = sljit_emit_op1(compiler,
+ SLJIT_MOV,
+ BJ_AREG, 0,
+ SLJIT_SCRATCH_REG2, 0);
+#endif
+ }
+
if (status != SLJIT_SUCCESS)
return status;
-#endif
#else
status = sljit_emit_ijump(compiler,
SLJIT_CALL2,
Home |
Main Index |
Thread Index |
Old Index