staticinlinebool test_div64_verify(u64 quotient, u32 remainder, int i, int j)
{ return (quotient == test_div64_results[i][j].quotient &&
remainder == test_div64_results[i][j].remainder);
}
/* * This needs to be a macro, because we don't want to rely on the compiler * to do constant propagation, and `do_div' may take a different path for * constants, so we do want to verify that as well.
*/ #define test_div64_one(dividend, divisor, i, j) ({ \ bool result = true; \
u64 quotient; \
u32 remainder; \
\
quotient = dividend; \
remainder = do_div(quotient, divisor); \ if (!test_div64_verify(quotient, remainder, i, j)) { \
pr_err("ERROR: %016llx / %08x => %016llx,%08x\n", \
dividend, divisor, quotient, remainder); \
pr_err("ERROR: expected value => %016llx,%08x\n",\
test_div64_results[i][j].quotient, \
test_div64_results[i][j].remainder); \
result = false; \
} \
result; \
})
/* * Run calculation for the same divisor value expressed as a constant * and as a variable, so as to verify the implementation for both cases * should they be handled by different code execution paths.
*/ staticbool __init test_div64(void)
{
u64 dividend; int i, j;
for (i = 0; i < SIZE_DIV64_DIVIDENDS; i++) {
dividend = test_div64_dividends[i]; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_0, i, 0)) returnfalse; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_1, i, 1)) returnfalse; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_2, i, 2)) returnfalse; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_3, i, 3)) returnfalse; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_4, i, 4)) returnfalse; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_5, i, 5)) returnfalse; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_6, i, 6)) returnfalse; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_7, i, 7)) returnfalse; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_8, i, 8)) returnfalse; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_9, i, 9)) returnfalse; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_A, i, 10)) returnfalse; if (!test_div64_one(dividend, TEST_DIV64_DIVISOR_B, i, 11)) returnfalse; for (j = 0; j < SIZE_DIV64_DIVISORS; j++) { if (!test_div64_one(dividend, test_div64_divisors[j],
i, j)) returnfalse;
}
} returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.