Module Name: src Committed By: alnsn Date: Thu Nov 20 20:31:22 UTC 2014
Modified Files: src/sys/net: bpfjit.c Log Message: Implement BPF_MOD. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/net/bpfjit.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/net/bpfjit.c diff -u src/sys/net/bpfjit.c:1.35 src/sys/net/bpfjit.c:1.36 --- src/sys/net/bpfjit.c:1.35 Thu Nov 20 19:18:52 2014 +++ src/sys/net/bpfjit.c Thu Nov 20 20:31:22 2014 @@ -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 @@ __RCSID("$NetBSD: bpfjit.c,v 1.35 2014/1 #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 @@ emit_moddiv(struct sljit_compiler *compi #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,