// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Stuff that exists in std, but we can't use due to being a dependency
// of net, for go/build deps_test policy reasons.

package netip

func beUint64( []byte) uint64 {
	_ = [7] // bounds check hint to compiler; see golang.org/issue/14808
	return uint64([7]) | uint64([6])<<8 | uint64([5])<<16 | uint64([4])<<24 |
		uint64([3])<<32 | uint64([2])<<40 | uint64([1])<<48 | uint64([0])<<56
}

func bePutUint64( []byte,  uint64) {
	_ = [7] // early bounds check to guarantee safety of writes below
	[0] = byte( >> 56)
	[1] = byte( >> 48)
	[2] = byte( >> 40)
	[3] = byte( >> 32)
	[4] = byte( >> 24)
	[5] = byte( >> 16)
	[6] = byte( >> 8)
	[7] = byte()
}

func bePutUint32( []byte,  uint32) {
	_ = [3] // early bounds check to guarantee safety of writes below
	[0] = byte( >> 24)
	[1] = byte( >> 16)
	[2] = byte( >> 8)
	[3] = byte()
}

func leUint16( []byte) uint16 {
	_ = [1] // bounds check hint to compiler; see golang.org/issue/14808
	return uint16([0]) | uint16([1])<<8
}

func lePutUint16( []byte,  uint16) {
	_ = [1] // early bounds check to guarantee safety of writes below
	[0] = byte()
	[1] = byte( >> 8)
}