aboutsummaryrefslogtreecommitdiffstats
path: root/leaf_alts.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-11-03 16:23:07 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-11-11 14:53:30 +0100
commita4a02eeacf9d49566df85e8cff878e5527e51779 (patch)
tree4a56fa945d9a98e188c548bcb13d28345210bd37 /leaf_alts.go
parentImport from a59e332 (diff)
downloadgo118-netip-master.tar.xz
go118-netip-master.zip
Import from e83a204HEADmaster
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'leaf_alts.go')
-rw-r--r--leaf_alts.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/leaf_alts.go b/leaf_alts.go
index c51f7df..70513ab 100644
--- a/leaf_alts.go
+++ b/leaf_alts.go
@@ -41,3 +41,14 @@ func bePutUint32(b []byte, v uint32) {
b[2] = byte(v >> 8)
b[3] = byte(v)
}
+
+func leUint16(b []byte) uint16 {
+ _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
+ return uint16(b[0]) | uint16(b[1])<<8
+}
+
+func lePutUint16(b []byte, v uint16) {
+ _ = b[1] // early bounds check to guarantee safety of writes below
+ b[0] = byte(v)
+ b[1] = byte(v >> 8)
+}