to_eof = cmp64(rule->start, rule->end) >= 0;
if (cmp64(pos, rule->start) > 0) {
- if (skip != NULL) *skip = pos - rule->start;
+ if (skip != NULL) *skip = sub64(pos, rule->start);
off = 0;
}
else {
if (skip != NULL) *skip = ((u64_t)(0));
- delta = rule->start - pos;
+ delta = sub64(rule->start, pos);
assert(ex64hi(delta) == 0);
if (!to_eof) {
assert(cmp64(pos, rule->end) < 0);
- delta = rule->end - pos;
+ delta = sub64(rule->end, pos);
if (cmp64u(delta, *size) < 0)
*size = ex64lo(delta);
* here, because we have no idea about the actual disk size, and the
* resulting address must of course be valid..
*/
- range = ((rule->params.misdir.end - rule->params.misdir.start) + 1)
- / rule->params.misdir.align;
-
+ range = div64u(add64u(sub64(rule->params.misdir.end,
+ rule->params.misdir.start), 1), rule->params.misdir.align);
+
if (range > 0)
choice = get_rand(range - 1);
else
choice = 0;
- *pos = rule->params.misdir.start +
- (u64_t)(choice * rule->params.misdir.align);
+ *pos = add64(rule->params.misdir.start,
+ mul64u(choice, rule->params.misdir.align));
}
/*===========================================================================*