-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/xcpu: Vendor golang.org/x/sys/cpu
Standard library does this too. Unfortunate wish they just exposed it in the standard library. Perhaps we can isolate the specific code we need later.
- Loading branch information
Showing
56 changed files
with
2,219 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
module nhooyr.io/websocket | ||
|
||
go 1.19 | ||
|
||
require golang.org/x/sys v0.17.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= | ||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Treat all files in this repo as binary, with no git magic updating | ||
# line endings. Windows users contributing to Go will need to use a | ||
# modern version of git and editors capable of LF line endings. | ||
# | ||
# We'll prevent accidental CRLF line endings from entering the repo | ||
# via the git-review gofmt checks. | ||
# | ||
# See golang.org/issue/9281 | ||
|
||
* -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Add no patterns to .gitignore except for files generated by the build. | ||
last-change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# cpu | ||
|
||
Vendored from https://github.com/golang/sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2018 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. | ||
|
||
//go:build gc | ||
|
||
#include "textflag.h" | ||
|
||
// | ||
// System calls for ppc64, AIX are implemented in runtime/syscall_aix.go | ||
// | ||
|
||
TEXT ·syscall6(SB),NOSPLIT,$0-88 | ||
JMP syscall·syscall6(SB) | ||
|
||
TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 | ||
JMP syscall·rawSyscall6(SB) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2019 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. | ||
|
||
package xcpu | ||
|
||
import ( | ||
"runtime" | ||
) | ||
|
||
// byteOrder is a subset of encoding/binary.ByteOrder. | ||
type byteOrder interface { | ||
Uint32([]byte) uint32 | ||
Uint64([]byte) uint64 | ||
} | ||
|
||
type littleEndian struct{} | ||
type bigEndian struct{} | ||
|
||
func (littleEndian) Uint32(b []byte) uint32 { | ||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 | ||
return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 | ||
} | ||
|
||
func (littleEndian) Uint64(b []byte) uint64 { | ||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 | ||
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | | ||
uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 | ||
} | ||
|
||
func (bigEndian) Uint32(b []byte) uint32 { | ||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 | ||
return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 | ||
} | ||
|
||
func (bigEndian) Uint64(b []byte) uint64 { | ||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 | ||
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | | ||
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 | ||
} | ||
|
||
// hostByteOrder returns littleEndian on little-endian machines and | ||
// bigEndian on big-endian machines. | ||
func hostByteOrder() byteOrder { | ||
switch runtime.GOARCH { | ||
case "386", "amd64", "amd64p32", | ||
"alpha", | ||
"arm", "arm64", | ||
"loong64", | ||
"mipsle", "mips64le", "mips64p32le", | ||
"nios2", | ||
"ppc64le", | ||
"riscv", "riscv64", | ||
"sh": | ||
return littleEndian{} | ||
case "armbe", "arm64be", | ||
"m68k", | ||
"mips", "mips64", "mips64p32", | ||
"ppc", "ppc64", | ||
"s390", "s390x", | ||
"shbe", | ||
"sparc", "sparc64": | ||
return bigEndian{} | ||
} | ||
panic("unknown architecture") | ||
} |
Oops, something went wrong.