Root/
1 | /* |
2 | * Today's hack: quantum tunneling in structs |
3 | * |
4 | * 'entries' and 'term' are never anywhere referenced by word in code. In fact, |
5 | * they serve as the hanging-off data accessed through repl.data[]. |
6 | */ |
7 | |
8 | #define xt_alloc_initial_table(type, typ2) ({ \ |
9 | unsigned int hook_mask = info->valid_hooks; \ |
10 | unsigned int nhooks = hweight32(hook_mask); \ |
11 | unsigned int bytes = 0, hooknum = 0, i = 0; \ |
12 | struct { \ |
13 | struct type##_replace repl; \ |
14 | struct type##_standard entries[nhooks]; \ |
15 | struct type##_error term; \ |
16 | } *tbl = kzalloc(sizeof(*tbl), GFP_KERNEL); \ |
17 | if (tbl == NULL) \ |
18 | return NULL; \ |
19 | strncpy(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \ |
20 | tbl->term = (struct type##_error)typ2##_ERROR_INIT; \ |
21 | tbl->repl.valid_hooks = hook_mask; \ |
22 | tbl->repl.num_entries = nhooks + 1; \ |
23 | tbl->repl.size = nhooks * sizeof(struct type##_standard) + \ |
24 | sizeof(struct type##_error); \ |
25 | for (; hook_mask != 0; hook_mask >>= 1, ++hooknum) { \ |
26 | if (!(hook_mask & 1)) \ |
27 | continue; \ |
28 | tbl->repl.hook_entry[hooknum] = bytes; \ |
29 | tbl->repl.underflow[hooknum] = bytes; \ |
30 | tbl->entries[i++] = (struct type##_standard) \ |
31 | typ2##_STANDARD_INIT(NF_ACCEPT); \ |
32 | bytes += sizeof(struct type##_standard); \ |
33 | } \ |
34 | tbl; \ |
35 | }) |
36 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9