summaryrefslogtreecommitdiff
path: root/rrdformat/rrdbinary/types.go
blob: a036d5d32ce469151bf0917aade6620a5f6aad73 (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
package rrdbinary

import (
	"encoding/binary"
	"math"
)

type Architecture struct {
	ByteOrder binary.ByteOrder
	// C `double`
	FloatWidth int // always 8 -- we assume IEEE 754 doubles
	FloatAlign int
	// C `long` or `unsigned long`
	IntWidth int
	IntAlign int
	// C `union { unsigned long; double; }`
	UnivalWidth int // max(FloatWidth, IntWidth)
	UnivalAlign int // max(FloatAlign, IntAlign)
	// C `time_t`
	TimeWidth int
	TimeAlign int
}

type String string // \0-terminated
type Float float64 // 8 bytes
type Uint uint64   // 4 or 8 bytes
type Int int64     // 4 or 8 bytes
type Unival uint64 // 8 bytes
type Time int64    // 4 or 8 bytes, only has second-precision

func (u Unival) AsUint64() uint64   { return uint64(u) }
func (u Unival) AsFloat64() float64 { return math.Float64frombits(uint64(u)) }