From d285b548bfc64bc7ba4cd4f414479db06344efac Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 14 Nov 2020 19:50:00 -0800 Subject: [PATCH] util/endian: add package with const for whether platform is big endian (cherry picked from commit 000347d4cf9077b12c6e7e02461365f21fa633b0) --- util/endian/big.go | 10 ++++++++++ util/endian/endian.go | 6 ++++++ util/endian/little.go | 10 ++++++++++ 3 files changed, 26 insertions(+) create mode 100644 util/endian/big.go create mode 100644 util/endian/endian.go create mode 100644 util/endian/little.go diff --git a/util/endian/big.go b/util/endian/big.go new file mode 100644 index 000000000..0dcdbab1f --- /dev/null +++ b/util/endian/big.go @@ -0,0 +1,10 @@ +// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build mips mips64 ppc64 s390x + +package endian + +// Big is whether the current platform is big endian. +const Big = true diff --git a/util/endian/endian.go b/util/endian/endian.go new file mode 100644 index 000000000..863ab638e --- /dev/null +++ b/util/endian/endian.go @@ -0,0 +1,6 @@ +// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package endian exports a constant about whether the machine is big endian. +package endian diff --git a/util/endian/little.go b/util/endian/little.go new file mode 100644 index 000000000..dd8686356 --- /dev/null +++ b/util/endian/little.go @@ -0,0 +1,10 @@ +// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build 386 amd64 arm arm64 mips64le mipsle ppc64le riscv64 wasm + +package endian + +// Big is whether the current platform is big endian. +const Big = false