summaryrefslogtreecommitdiff
path: root/doc/api/libstd/misc.txt
blob: 13ab4782179e7a10c2e328983c15b3afa741e064 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{
        title:  Misc
        description:  libstd: Misc
}

Misc
-----

The mongrels and mutts of libstd.

    pkg std =
            generic KiB	: @a::(integral,numeric)	
            generic MiB	: @a::(integral,numeric)	
            generic GiB	: @a::(integral,numeric)	
            generic TiB	: @a::(integral,numeric)	
            generic PiB	: @a::(integral,numeric)	
            generic EiB	: @a::(integral,numeric)	
            generic ZiB	: @a::(integral,numeric)	
            generic YiB	: @a::(integral,numeric)	

            /* time */
            const now	: (-> time)

            /* packing integers */
            generic putle64	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
            generic putbe64	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
            generic putle32	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
            generic putbe32	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
            generic putle16	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
            generic putbe16	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
            generic putle8	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
            generic putbe8	: (buf : byte[:], v :  @a::(numeric,integral) -> size)

            /* unpacking integers */
            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))

            /* exploding and stitching floats */
            const flt64bits	: (flt : flt64 -> int64)
            const flt32bits	: (flt : flt32 -> int32)
            const flt64frombits	: (bits : uint64 -> flt64)
            const flt32frombits	: (bits : uint32 -> flt32)
            const flt64explode	: (flt : flt64 -> (bool, int64, int64))
            const flt32explode	: (flt : flt32 -> (bool, int32, int32))
            const flt64stitch	: (flt : flt64 -> (bool, int64, int64))
            const flt32stitch	: (flt : flt32 -> (bool, int32, int32))

    ;;

Constants
----------

    generic KiB	: @a::(integral,numeric)	
    generic MiB	: @a::(integral,numeric)	
    generic GiB	: @a::(integral,numeric)	
    generic TiB	: @a::(integral,numeric)	
    generic PiB	: @a::(integral,numeric)	
    generic EiB	: @a::(integral,numeric)	
    generic ZiB	: @a::(integral,numeric)	
    generic YiB	: @a::(integral,numeric)	

    generic Sec	: time
    generic Msec : time
    generic Usec : time

These are just constants that you can multiply things by in order to scale
units. If you want to get a 

    const now	: (-> time)

Returns the current time in signed microseconds since the Unix epoch. Can
represent dates approximatelyl 70,000 years in either direction from the
present.

    generic putle64	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
    generic putbe64	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
    generic putle32	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
    generic putbe32	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
    generic putle16	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
    generic putbe16	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
    generic putle8	: (buf : byte[:], v :  @a::(numeric,integral) -> size)
    generic putbe8	: (buf : byte[:], v :  @a::(numeric,integral) -> size)

These functions pack integers into buffers. The suffix describes the number of
bits that will be packed -- the values will be implicitly converted to an
integer that is `nbits` long before packing into the buffer. Signed integers
will be sign extended, and unsigned ones will be zero extended.

    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))

These functions unpack integers from buffers. The numeric suffix describes how
many bits will be extracted from the buffer. The value will implicitly be
truncated or widened to the result returned by the specialization of this
function.