merge of bill's code plus lint (plus, of course, cleanup of bill's bugs)
[unix-history] / usr / src / sys / ufs / ffs / ffs_tables.c
CommitLineData
88a7a62a 1/* ffs_tables.c 2.4 83/05/27 */
5576d804
KM
2
3#include "../h/param.h"
4
5576d804 5/*
88a7a62a 6 * Bit patterns for identifying fragments in the block map
5576d804
KM
7 * used as ((map & around) == inside)
8 */
9int around[9] = {
10 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff
11};
12int inside[9] = {
13 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
14};
15
16/*
88a7a62a 17 * Given a block map bit pattern, the frag tables tell whether a
5576d804 18 * particular size fragment is available.
b6407c9d 19 *
5576d804 20 * used as:
b6407c9d 21 * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] {
5576d804
KM
22 * at least one fragment of the indicated size is available
23 * }
b6407c9d
KM
24 *
25 * These tables are used by the scanc instruction on the VAX to
5576d804
KM
26 * quickly find an appropriate fragment.
27 */
88a7a62a 28u_char fragtbl124[256] = {
156b8f82
KM
29 0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e,
30 0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a,
31 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
32 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
33 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
34 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
35 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
36 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa,
37 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
38 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0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 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a,
5576d804 61};
5576d804 62
88a7a62a 63u_char fragtbl8[256] = {
5576d804
KM
64 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04,
65 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08,
66 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
67 0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10,
68 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
69 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
70 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
71 0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20,
72 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
73 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
74 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
75 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
76 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
77 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
78 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
79 0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40,
80 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
81 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
82 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
83 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
84 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
85 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
86 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
87 0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21,
88 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
89 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
90 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
91 0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12,
92 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
93 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c,
94 0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c,
95 0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80,
96};
b6407c9d
KM
97
98/*
88a7a62a 99 * The actual fragtbl array.
b6407c9d 100 */
88a7a62a 101u_char *fragtbl[MAXFRAG + 1] = {
156b8f82 102 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
b6407c9d 103};