1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
pkg std =
generic getle64 : (buf : byte[:] -> @a::(numeric,integral))
generic getbe64 : (buf : byte[:] -> @a::(numeric,integral))
generic getle32 : (buf : byte[:] -> @a::(numeric,integral))
generic getbe32 : (buf : byte[:] -> @a::(numeric,integral))
generic getle16 : (buf : byte[:] -> @a::(numeric,integral))
generic getbe16 : (buf : byte[:] -> @a::(numeric,integral))
generic getle8 : (buf : byte[:] -> @a::(numeric,integral))
generic getbe8 : (buf : byte[:] -> @a::(numeric,integral))
;;
generic getbe64 = {buf -> @a::(numeric,integral)
-> ((buf[0] castto(@a::(numeric,integral))) << 56) | \
((buf[1] castto(@a::(numeric,integral))) << 48) | \
((buf[2] castto(@a::(numeric,integral))) << 40) | \
((buf[3] castto(@a::(numeric,integral))) << 32) | \
((buf[4] castto(@a::(numeric,integral))) << 24) | \
((buf[5] castto(@a::(numeric,integral))) << 16) | \
((buf[6] castto(@a::(numeric,integral))) << 8) | \
((buf[7] castto(@a::(numeric,integral))) << 0)
}
generic getle64 = {buf
-> ((buf[0] castto(@a::(numeric,integral))) << 0) | \
((buf[1] castto(@a::(numeric,integral))) << 8) | \
((buf[2] castto(@a::(numeric,integral))) << 16) | \
((buf[3] castto(@a::(numeric,integral))) << 24) | \
((buf[4] castto(@a::(numeric,integral))) << 32) | \
((buf[5] castto(@a::(numeric,integral))) << 40) | \
((buf[6] castto(@a::(numeric,integral))) << 48) | \
((buf[7] castto(@a::(numeric,integral))) << 56)
}
generic getbe32 = {buf
-> ((buf[0] castto(@a::(numeric,integral))) << 24) | \
((buf[1] castto(@a::(numeric,integral))) << 16) | \
((buf[2] castto(@a::(numeric,integral))) << 8) | \
((buf[3] castto(@a::(numeric,integral))) << 0)
}
generic getle32 = {buf
-> ((buf[0] castto(@a::(numeric,integral))) << 0) | \
((buf[1] castto(@a::(numeric,integral))) << 8) | \
((buf[2] castto(@a::(numeric,integral))) << 16) | \
((buf[3] castto(@a::(numeric,integral))) << 24)
}
generic getbe16 = {buf
-> ((buf[0] castto(@a::(numeric,integral))) << 8) | \
((buf[1] castto(@a::(numeric,integral))) << 0)
}
generic getle16 = {buf
-> ((buf[0] castto(@a::(numeric,integral))) << 0) | \
((buf[1] castto(@a::(numeric,integral))) << 8)
}
generic getbe8 = {buf
-> (buf[0] castto(@a::(numeric,integral))) << 0
}
generic getle8 = {buf
-> (buf[0] castto(@a::(numeric,integral))) << 0
}
|