version 1.37, 2015/12/31 00:33:52 |
version 1.38, 2016/09/12 01:22:38 |
|
|
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
|
|
#include <sys/param.h> /* MIN */ |
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/tree.h> |
#include <sys/tree.h> |
#include <sys/queue.h> |
#include <sys/queue.h> |
|
|
int r; |
int r; |
|
|
if (a->len != b->len) { |
if (a->len != b->len) { |
if ((r = memcmp(a->blob, b->blob, MIN(a->len, b->len))) != 0) |
if ((r = memcmp(a->blob, b->blob, MINIMUM(a->len, b->len))) != 0) |
return r; |
return r; |
return a->len > b->len ? 1 : -1; |
return a->len > b->len ? 1 : -1; |
} else |
} else |
|
|
* Avoid unsigned overflows. |
* Avoid unsigned overflows. |
* The limits are high enough to avoid confusing the calculations. |
* The limits are high enough to avoid confusing the calculations. |
*/ |
*/ |
contig = MIN(contig, 1ULL<<31); |
contig = MINIMUM(contig, 1ULL<<31); |
last_gap = MIN(last_gap, 1ULL<<31); |
last_gap = MINIMUM(last_gap, 1ULL<<31); |
next_gap = MIN(next_gap, 1ULL<<31); |
next_gap = MINIMUM(next_gap, 1ULL<<31); |
|
|
/* |
/* |
* Calculate the cost to switch from the current state to candidates. |
* Calculate the cost to switch from the current state to candidates. |
|
|
/* Estimate base cost in bits of each section type */ |
/* Estimate base cost in bits of each section type */ |
cost_list += 64 * contig + (final ? 0 : 8+64); |
cost_list += 64 * contig + (final ? 0 : 8+64); |
cost_range += (2 * 64) + (final ? 0 : 8+64); |
cost_range += (2 * 64) + (final ? 0 : 8+64); |
cost_bitmap += last_gap + contig + (final ? 0 : MIN(next_gap, 8+64)); |
cost_bitmap += last_gap + contig + (final ? 0 : MINIMUM(next_gap, 8+64)); |
cost_bitmap_restart += contig + (final ? 0 : MIN(next_gap, 8+64)); |
cost_bitmap_restart += contig + (final ? 0 : MINIMUM(next_gap, 8+64)); |
|
|
/* Convert to byte costs for actual comparison */ |
/* Convert to byte costs for actual comparison */ |
cost_list = (cost_list + 7) / 8; |
cost_list = (cost_list + 7) / 8; |