mirror of
https://git.mediani.de/mirrors_public/oddlama_nixos-extra-modules.git
synced 2025-10-11 06:10:39 +02:00
fix: libnet usage
fix: use list for lookuptable for speeeeeeeeeeeeeeeeeeeeeed
This commit is contained in:
parent
32f790ae7f
commit
0875c4f06e
2 changed files with 87 additions and 87 deletions
140
lib/netu.nix
140
lib/netu.nix
|
@ -460,71 +460,71 @@ let
|
|||
|
||||
bit =
|
||||
let
|
||||
lut = {
|
||||
"0" = 1;
|
||||
"1" = 2;
|
||||
"2" = 4;
|
||||
"3" = 8;
|
||||
"4" = 16;
|
||||
"5" = 32;
|
||||
"6" = 64;
|
||||
"7" = 128;
|
||||
"8" = 256;
|
||||
"9" = 512;
|
||||
"10" = 1024;
|
||||
"11" = 2048;
|
||||
"12" = 4096;
|
||||
"13" = 8192;
|
||||
"14" = 16384;
|
||||
"15" = 32768;
|
||||
"16" = 65536;
|
||||
"17" = 131072;
|
||||
"18" = 262144;
|
||||
"19" = 524288;
|
||||
"20" = 1048576;
|
||||
"21" = 2097152;
|
||||
"22" = 4194304;
|
||||
"23" = 8388608;
|
||||
"24" = 16777216;
|
||||
"25" = 33554432;
|
||||
"26" = 67108864;
|
||||
"27" = 134217728;
|
||||
"28" = 268435456;
|
||||
"29" = 536870912;
|
||||
"30" = 1073741824;
|
||||
"31" = 2147483648;
|
||||
"32" = 4294967296;
|
||||
"33" = 8589934592;
|
||||
"34" = 17179869184;
|
||||
"35" = 34359738368;
|
||||
"36" = 68719476736;
|
||||
"37" = 137438953472;
|
||||
"38" = 274877906944;
|
||||
"39" = 549755813888;
|
||||
"40" = 1099511627776;
|
||||
"41" = 2199023255552;
|
||||
"42" = 4398046511104;
|
||||
"43" = 8796093022208;
|
||||
"44" = 17592186044416;
|
||||
"45" = 35184372088832;
|
||||
"46" = 70368744177664;
|
||||
"47" = 140737488355328;
|
||||
"48" = 281474976710656;
|
||||
"49" = 562949953421312;
|
||||
"50" = 1125899906842624;
|
||||
"51" = 2251799813685248;
|
||||
"52" = 4503599627370496;
|
||||
"53" = 9007199254740992;
|
||||
"54" = 18014398509481984;
|
||||
"55" = 36028797018963968;
|
||||
"56" = 72057594037927936;
|
||||
"57" = 144115188075855872;
|
||||
"58" = 288230376151711744;
|
||||
"59" = 576460752303423488;
|
||||
"60" = 1152921504606846976;
|
||||
"61" = 2305843009213693952;
|
||||
"62" = 4611686018427387904;
|
||||
};
|
||||
lut = [
|
||||
1 # 0
|
||||
2 # 1
|
||||
4 # 2
|
||||
8 # 3
|
||||
16 # 4
|
||||
32 # 5
|
||||
64 # 6
|
||||
128 # 7
|
||||
256 # 8
|
||||
512 # 9
|
||||
1024 # 10
|
||||
2048 # 11
|
||||
4096 # 12
|
||||
8192 # 13
|
||||
16384 # 14
|
||||
32768 # 15
|
||||
65536 # 16
|
||||
131072 # 17
|
||||
262144 # 18
|
||||
524288 # 19
|
||||
1048576 # 20
|
||||
2097152 # 21
|
||||
4194304 # 22
|
||||
8388608 # 23
|
||||
16777216 # 24
|
||||
33554432 # 25
|
||||
67108864 # 26
|
||||
134217728 # 27
|
||||
268435456 # 28
|
||||
536870912 # 29
|
||||
1073741824 # 30
|
||||
2147483648 # 31
|
||||
4294967296 # 32
|
||||
8589934592 # 33
|
||||
17179869184 # 34
|
||||
34359738368 # 35
|
||||
68719476736 # 36
|
||||
137438953472 # 37
|
||||
274877906944 # 38
|
||||
549755813888 # 39
|
||||
1099511627776 # 40
|
||||
2199023255552 # 41
|
||||
4398046511104 # 42
|
||||
8796093022208 # 43
|
||||
17592186044416 # 44
|
||||
35184372088832 # 45
|
||||
70368744177664 # 46
|
||||
140737488355328 # 47
|
||||
281474976710656 # 48
|
||||
562949953421312 # 49
|
||||
1125899906842624 # 50
|
||||
2251799813685248 # 51
|
||||
4503599627370496 # 52
|
||||
9007199254740992 # 53
|
||||
18014398509481984 # 54
|
||||
36028797018963968 # 55
|
||||
72057594037927936 # 56
|
||||
144115188075855872 # 57
|
||||
288230376151711744 # 58
|
||||
576460752303423488 # 59
|
||||
1152921504606846976 # 60
|
||||
2305843009213693952 # 61
|
||||
4611686018427387904 # 62
|
||||
];
|
||||
intmin = (-9223372036854775807) - 1;
|
||||
intmax = 9223372036854775807;
|
||||
left =
|
||||
|
@ -539,11 +539,11 @@ let
|
|||
else
|
||||
let
|
||||
inv = 63 - a;
|
||||
mask = if inv == 63 then intmax else lut.${toString inv} - 1;
|
||||
mask = if inv == 63 then intmax else (builtins.elemAt lut inv) - 1;
|
||||
masked = and b mask;
|
||||
checker = if inv == 63 then intmin else lut.${toString inv};
|
||||
checker = if inv == 63 then intmin else builtins.elemAt lut inv;
|
||||
negate = (and b checker) != 0;
|
||||
mult = if a == 63 then intmin else lut.${toString a};
|
||||
mult = if a == 63 then intmin else builtins.elemAt lut a;
|
||||
result = masked * mult;
|
||||
in
|
||||
if !negate then result else intmin + result;
|
||||
|
@ -560,9 +560,9 @@ let
|
|||
let
|
||||
masked = and b intmax;
|
||||
negate = b < 0;
|
||||
result = masked / lut.${toString a};
|
||||
result = masked / 2 / (builtins.elemAt lut (a - 1));
|
||||
inv = 63 - a;
|
||||
highest_bit = lut.${toString inv};
|
||||
highest_bit = builtins.elemAt lut inv;
|
||||
in
|
||||
if !negate then result else result + highest_bit;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue