-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
94 additions
and
28 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
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,20 @@ | ||
//go:build armbe || arm64be || mips || mips64 || mips64p32 || ppc || ppc64 || sparc || sparc64 || s390 || s390x | ||
// +build armbe arm64be mips mips64 mips64p32 ppc ppc64 sparc sparc64 s390 s390x | ||
|
||
package base64 | ||
|
||
import "unsafe" | ||
|
||
func putTail(ptr uintptr, tail *[4]byte, n int) { | ||
switch n { | ||
case 3: | ||
*(*byte)(unsafe.Pointer(ptr)) = tail[3] | ||
*(*byte)(unsafe.Pointer(ptr + 1)) = tail[2] | ||
*(*byte)(unsafe.Pointer(ptr + 2)) = tail[1] | ||
case 2: | ||
*(*byte)(unsafe.Pointer(ptr)) = tail[3] | ||
*(*byte)(unsafe.Pointer(ptr + 1)) = tail[2] | ||
case 1: | ||
*(*byte)(unsafe.Pointer(ptr)) = tail[3] | ||
} | ||
} |
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,20 @@ | ||
//go:build 386 || amd64 || amd64p32 || arm || arm64 || mipsle || mis64le || mips64p32le || ppc64le || riscv || riscv64 || wasm | ||
// +build 386 amd64 amd64p32 arm arm64 mipsle mis64le mips64p32le ppc64le riscv riscv64 wasm | ||
|
||
package base64 | ||
|
||
import "unsafe" | ||
|
||
func putTail(ptr uintptr, tail *[4]byte, n int) { | ||
switch n { | ||
case 3: | ||
*(*byte)(unsafe.Pointer(ptr)) = tail[0] | ||
*(*byte)(unsafe.Pointer(ptr + 1)) = tail[1] | ||
*(*byte)(unsafe.Pointer(ptr + 2)) = tail[2] | ||
case 2: | ||
*(*byte)(unsafe.Pointer(ptr)) = tail[0] | ||
*(*byte)(unsafe.Pointer(ptr + 1)) = tail[1] | ||
case 1: | ||
*(*byte)(unsafe.Pointer(ptr)) = tail[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
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,24 @@ | ||
//go:build armbe || arm64be || mips || mips64 || mips64p32 || ppc || ppc64 || sparc || sparc64 || s390 || s390x | ||
// +build armbe arm64be mips mips64 mips64p32 ppc ppc64 sparc sparc64 s390 s390x | ||
|
||
package base64 | ||
|
||
import ( | ||
"math/bits" | ||
"unsafe" | ||
) | ||
|
||
//go:nosplit | ||
func bswap32(ptr uintptr) uint32 { | ||
return *(*uint32)(unsafe.Pointer(ptr)) | ||
} | ||
|
||
//go:nosplit | ||
func stou32(cp uintptr, x uint32) { | ||
*(*uint32)(unsafe.Pointer(cp)) = bits.ReverseBytes32(x) | ||
} | ||
|
||
//go:nosplit | ||
func ctou32(cp uintptr) uint32 { | ||
return bits.ReverseBytes32(*(*uint32)(unsafe.Pointer(cp))) | ||
} |
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,24 @@ | ||
//go:build 386 || amd64 || amd64p32 || arm || arm64 || mipsle || mis64le || mips64p32le || ppc64le || riscv || riscv64 || wasm | ||
// +build 386 amd64 amd64p32 arm arm64 mipsle mis64le mips64p32le ppc64le riscv riscv64 wasm | ||
|
||
package base64 | ||
|
||
import ( | ||
"math/bits" | ||
"unsafe" | ||
) | ||
|
||
//go:nosplit | ||
func bswap32(ptr uintptr) uint32 { | ||
return bits.ReverseBytes32(*(*uint32)(unsafe.Pointer(ptr))) | ||
} | ||
|
||
//go:nosplit | ||
func stou32(cp uintptr, x uint32) { | ||
*(*uint32)(unsafe.Pointer(cp)) = x | ||
} | ||
|
||
//go:nosplit | ||
func ctou32(cp uintptr) uint32 { | ||
return *(*uint32)(unsafe.Pointer(cp)) | ||
} |