├── .github └── workflows │ └── go.yml ├── .gitignore ├── LICENSE ├── README.md ├── git-setup ├── pre-commit └── setup-hooks.sh ├── go.mod ├── go.sum ├── offheap ├── docs.go ├── fuzz_test.go ├── internal │ └── pointerstore │ │ ├── allocation_config.go │ │ ├── free_list.go │ │ ├── free_list_test.go │ │ ├── metadata.go │ │ ├── mmap.go │ │ ├── pointer_reference.go │ │ ├── pointer_reference_test.go │ │ ├── pointer_store.go │ │ ├── pointer_store_test.go │ │ ├── tagged_address.go │ │ └── tagged_address_test.go ├── object_bench_test.go ├── object_examples_test.go ├── object_reference.go ├── object_reference_multitype_test.go ├── object_reference_race_test.go ├── object_reference_test.go ├── object_store.go ├── reference.go ├── reference_examples_test.go ├── slice_examples_test.go ├── slice_reference.go ├── slice_reference_test.go ├── string_examples_test.go ├── string_reference.go ├── string_reference_test.go ├── testdata │ └── fuzz │ │ └── FuzzObjectStore │ │ └── 98e78b0c025d9788 ├── type_checker.go ├── type_checker_test.go ├── type_size_utils.go └── type_size_utils_test.go ├── pkg ├── intern │ ├── bytes_interner.go │ ├── bytes_interner_bench_test.go │ ├── bytes_interner_test.go │ ├── docs.go │ ├── float64_interner.go │ ├── float64_interner_bench_test.go │ ├── float64_interner_test.go │ ├── int64_interner.go │ ├── int64_interner_bench_test.go │ ├── int64_interner_test.go │ ├── intern_race_test.go │ ├── internbase │ │ ├── config.go │ │ ├── intern_controller.go │ │ ├── interner_with_bytes_id.go │ │ ├── interner_with_int64_id.go │ │ └── stats.go │ ├── interner.go │ ├── interner_suite_test.go │ ├── string_interner.go │ ├── string_interner_bench_test.go │ ├── string_interner_test.go │ ├── time_interner.go │ ├── time_interner_bench_test.go │ └── time_interner_test.go ├── linkedlist │ ├── linked_list.go │ ├── linked_list_complex_test.go │ └── linked_list_test.go └── quadtree │ ├── .gitignore │ ├── README │ ├── internal_node.go │ ├── node_store.go │ ├── quadtree.go │ ├── tquadtree_test.go │ ├── tview_test.go │ ├── util.go │ └── view.go ├── scripts └── copyright_header.sh ├── testpkg ├── fuzzutil │ ├── byte_consumer.go │ ├── byte_consumer_test.go │ ├── randombytes.go │ └── test_run.go └── testutil │ ├── random_strings.go │ └── random_strings_test.go └── vendor ├── github.com ├── cespare │ └── xxhash │ │ └── v2 │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── testall.sh │ │ ├── xxhash.go │ │ ├── xxhash_amd64.s │ │ ├── xxhash_arm64.s │ │ ├── xxhash_asm.go │ │ ├── xxhash_other.go │ │ ├── xxhash_safe.go │ │ └── xxhash_unsafe.go ├── davecgh │ └── go-spew │ │ ├── LICENSE │ │ └── spew │ │ ├── bypass.go │ │ ├── bypasssafe.go │ │ ├── common.go │ │ ├── config.go │ │ ├── doc.go │ │ ├── dump.go │ │ ├── format.go │ │ └── spew.go ├── fmstephe │ └── flib │ │ ├── LICENSE.txt │ │ ├── fmath │ │ ├── icompare.go │ │ └── integer.go │ │ └── funsafe │ │ ├── README.md │ │ └── convert.go ├── pmezard │ └── go-difflib │ │ ├── LICENSE │ │ └── difflib │ │ └── difflib.go └── stretchr │ └── testify │ ├── LICENSE │ ├── assert │ ├── assertion_compare.go │ ├── assertion_compare_can_convert.go │ ├── assertion_compare_legacy.go │ ├── assertion_format.go │ ├── assertion_format.go.tmpl │ ├── assertion_forward.go │ ├── assertion_forward.go.tmpl │ ├── assertion_order.go │ ├── assertions.go │ ├── doc.go │ ├── errors.go │ ├── forward_assertions.go │ └── http_assertions.go │ └── require │ ├── doc.go │ ├── forward_requirements.go │ ├── require.go │ ├── require.go.tmpl │ ├── require_forward.go │ ├── require_forward.go.tmpl │ └── requirements.go ├── golang.org └── x │ └── sys │ ├── LICENSE │ ├── PATENTS │ └── unix │ ├── .gitignore │ ├── README.md │ ├── affinity_linux.go │ ├── aliases.go │ ├── asm_aix_ppc64.s │ ├── asm_bsd_386.s │ ├── asm_bsd_amd64.s │ ├── asm_bsd_arm.s │ ├── asm_bsd_arm64.s │ ├── asm_bsd_ppc64.s │ ├── asm_bsd_riscv64.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_loong64.s │ ├── asm_linux_mips64x.s │ ├── asm_linux_mipsx.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_riscv64.s │ ├── asm_linux_s390x.s │ ├── asm_openbsd_mips64.s │ ├── asm_solaris_amd64.s │ ├── asm_zos_s390x.s │ ├── bluetooth_linux.go │ ├── cap_freebsd.go │ ├── constants.go │ ├── dev_aix_ppc.go │ ├── dev_aix_ppc64.go │ ├── dev_darwin.go │ ├── dev_dragonfly.go │ ├── dev_freebsd.go │ ├── dev_linux.go │ ├── dev_netbsd.go │ ├── dev_openbsd.go │ ├── dev_zos.go │ ├── dirent.go │ ├── endian_big.go │ ├── endian_little.go │ ├── env_unix.go │ ├── epoll_zos.go │ ├── fcntl.go │ ├── fcntl_darwin.go │ ├── fcntl_linux_32bit.go │ ├── fdset.go │ ├── fstatfs_zos.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── ifreq_linux.go │ ├── ioctl_linux.go │ ├── ioctl_signed.go │ ├── ioctl_unsigned.go │ ├── ioctl_zos.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── mmap_nomremap.go │ ├── mremap.go │ ├── pagesize_unix.go │ ├── pledge_openbsd.go │ ├── ptrace_darwin.go │ ├── ptrace_ios.go │ ├── race.go │ ├── race0.go │ ├── readdirent_getdents.go │ ├── readdirent_getdirentries.go │ ├── sockcmsg_dragonfly.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── sockcmsg_unix_other.go │ ├── syscall.go │ ├── syscall_aix.go │ ├── syscall_aix_ppc.go │ ├── syscall_aix_ppc64.go │ ├── syscall_bsd.go │ ├── syscall_darwin.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm64.go │ ├── syscall_darwin_libSystem.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_freebsd_arm64.go │ ├── syscall_freebsd_riscv64.go │ ├── syscall_hurd.go │ ├── syscall_hurd_386.go │ ├── syscall_illumos.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_alarm.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_amd64_gc.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_gc.go │ ├── syscall_linux_gc_386.go │ ├── syscall_linux_gc_arm.go │ ├── syscall_linux_gccgo_386.go │ ├── syscall_linux_gccgo_arm.go │ ├── syscall_linux_loong64.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_mipsx.go │ ├── syscall_linux_ppc.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_riscv64.go │ ├── syscall_linux_s390x.go │ ├── syscall_linux_sparc64.go │ ├── syscall_netbsd.go │ ├── syscall_netbsd_386.go │ ├── syscall_netbsd_amd64.go │ ├── syscall_netbsd_arm.go │ ├── syscall_netbsd_arm64.go │ ├── syscall_openbsd.go │ ├── syscall_openbsd_386.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_openbsd_arm.go │ ├── syscall_openbsd_arm64.go │ ├── syscall_openbsd_libc.go │ ├── syscall_openbsd_mips64.go │ ├── syscall_openbsd_ppc64.go │ ├── syscall_openbsd_riscv64.go │ ├── syscall_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_unix.go │ ├── syscall_unix_gc.go │ ├── syscall_unix_gc_ppc64x.go │ ├── syscall_zos_s390x.go │ ├── sysvshm_linux.go │ ├── sysvshm_unix.go │ ├── sysvshm_unix_other.go │ ├── timestruct.go │ ├── unveil_openbsd.go │ ├── xattr_bsd.go │ ├── zerrors_aix_ppc.go │ ├── zerrors_aix_ppc64.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_freebsd_arm64.go │ ├── zerrors_freebsd_riscv64.go │ ├── zerrors_linux.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_loong64.go │ ├── zerrors_linux_mips.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_mipsle.go │ ├── zerrors_linux_ppc.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_riscv64.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_linux_sparc64.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_netbsd_arm64.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_openbsd_arm.go │ ├── zerrors_openbsd_arm64.go │ ├── zerrors_openbsd_mips64.go │ ├── zerrors_openbsd_ppc64.go │ ├── zerrors_openbsd_riscv64.go │ ├── zerrors_solaris_amd64.go │ ├── zerrors_zos_s390x.go │ ├── zptrace_armnn_linux.go │ ├── zptrace_linux_arm64.go │ ├── zptrace_mipsnn_linux.go │ ├── zptrace_mipsnnle_linux.go │ ├── zptrace_x86_linux.go │ ├── zsyscall_aix_ppc.go │ ├── zsyscall_aix_ppc64.go │ ├── zsyscall_aix_ppc64_gc.go │ ├── zsyscall_aix_ppc64_gccgo.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_amd64.s │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_darwin_arm64.s │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_freebsd_arm64.go │ ├── zsyscall_freebsd_riscv64.go │ ├── zsyscall_illumos_amd64.go │ ├── zsyscall_linux.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_loong64.go │ ├── zsyscall_linux_mips.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_mipsle.go │ ├── zsyscall_linux_ppc.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_linux_riscv64.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_linux_sparc64.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_netbsd_arm64.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_386.s │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_openbsd_amd64.s │ ├── zsyscall_openbsd_arm.go │ ├── zsyscall_openbsd_arm.s │ ├── zsyscall_openbsd_arm64.go │ ├── zsyscall_openbsd_arm64.s │ ├── zsyscall_openbsd_mips64.go │ ├── zsyscall_openbsd_mips64.s │ ├── zsyscall_openbsd_ppc64.go │ ├── zsyscall_openbsd_ppc64.s │ ├── zsyscall_openbsd_riscv64.go │ ├── zsyscall_openbsd_riscv64.s │ ├── zsyscall_solaris_amd64.go │ ├── zsyscall_zos_s390x.go │ ├── zsysctl_openbsd_386.go │ ├── zsysctl_openbsd_amd64.go │ ├── zsysctl_openbsd_arm.go │ ├── zsysctl_openbsd_arm64.go │ ├── zsysctl_openbsd_mips64.go │ ├── zsysctl_openbsd_ppc64.go │ ├── zsysctl_openbsd_riscv64.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_freebsd_arm64.go │ ├── zsysnum_freebsd_riscv64.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_loong64.go │ ├── zsysnum_linux_mips.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_mipsle.go │ ├── zsysnum_linux_ppc.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_linux_riscv64.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_linux_sparc64.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_netbsd_arm64.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_openbsd_arm.go │ ├── zsysnum_openbsd_arm64.go │ ├── zsysnum_openbsd_mips64.go │ ├── zsysnum_openbsd_ppc64.go │ ├── zsysnum_openbsd_riscv64.go │ ├── zsysnum_zos_s390x.go │ ├── ztypes_aix_ppc.go │ ├── ztypes_aix_ppc64.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_freebsd_arm64.go │ ├── ztypes_freebsd_riscv64.go │ ├── ztypes_linux.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_loong64.go │ ├── ztypes_linux_mips.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_mipsle.go │ ├── ztypes_linux_ppc.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_linux_riscv64.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_linux_sparc64.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_netbsd_arm64.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ ├── ztypes_openbsd_arm.go │ ├── ztypes_openbsd_arm64.go │ ├── ztypes_openbsd_mips64.go │ ├── ztypes_openbsd_ppc64.go │ ├── ztypes_openbsd_riscv64.go │ ├── ztypes_solaris_amd64.go │ └── ztypes_zos_s390x.go ├── gopkg.in └── yaml.v3 │ ├── LICENSE │ ├── NOTICE │ ├── README.md │ ├── apic.go │ ├── decode.go │ ├── emitterc.go │ ├── encode.go │ ├── parserc.go │ ├── readerc.go │ ├── resolve.go │ ├── scannerc.go │ ├── sorter.go │ ├── writerc.go │ ├── yaml.go │ ├── yamlh.go │ └── yamlprivateh.go └── modules.txt /.github/workflows/go.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a golang project 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go 3 | 4 | name: Go 5 | 6 | on: 7 | push: 8 | branches: [ "master" ] 9 | pull_request: 10 | branches: [ "master" ] 11 | 12 | jobs: 13 | 14 | build: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v3 18 | 19 | - name: Set up Go 20 | uses: actions/setup-go@v4 21 | with: 22 | go-version: '1.22' 23 | 24 | - name: Build 25 | run: go build -v ./... 26 | 27 | - name: Test 28 | run: go test -v -short ./... 29 | 30 | - name: Run gcassert 31 | run: | 32 | go install github.com/fmstephe/gcassert/cmd/gcassert@v0.0.3 33 | $(go env GOPATH)/bin/gcassert ./... 34 | 35 | - name: Check code quality 36 | uses: dominikh/staticcheck-action@v1 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | *.test 4 | .vscode 5 | temp 6 | memprofile 7 | cpuprofile 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Francis Michael Stephens 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Memory Manager 2 | 3 | This project contains a number of packages built to allow for manual memory management in Go. 4 | 5 | This project was motivated by my experiences of the very high garbage collection costs associated with building in memory caches in Go. These pools of relatively long lived memory allocations can often cause very long garbage collection runs with associated high CPU usage. I envision that the offheap package can be used to build large long lived, and relatively stable, datastructures such as in-memory caches. It's definitely not expected to replace or even reach parity with conventionally managed Go allocations, but to be applied in specialised situations or in specialised services. 6 | 7 | The primary package is the [offheap](offheap/docs.go) ([docs](https://pkg.go.dev/github.com/fmstephe/memorymanager/offheap)) package sitting at the root of the project. This project allows us to allocate and free _reasonably_ normal Go data types. Convention Go pointers cannot be stored in these offheap allocations, but a number of pointer-like Reference types can be used for this purpose and clearly identify memory which must be managed manually. 8 | 9 | The pkg/ directory contains utilities packages built using the offheap package. Most interestingly (to me) is the [intern](pkg/intern/docs.go) ([docs](https://pkg.go.dev/github.com/fmstephe/memorymanager/pkg/intern)) package which allows for the interning of very large numbers of strings with near zero garbage collection impact. 10 | 11 | (Also, unrelated to such serious minded things as garbage collection or CPU usage, this project has been so much fun) 12 | -------------------------------------------------------------------------------- /git-setup/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | STAGED_GO_FILES=$(git diff --cached --name-only | grep ".go$" | grep -v "vendor") 4 | 5 | if [[ "$STAGED_GO_FILES" = "" ]]; then 6 | exit 0 7 | fi 8 | 9 | STATUS=0 10 | 11 | for FILE in $STAGED_GO_FILES 12 | do 13 | DIFF=$(goimports -d -w $FILE) 14 | if [[ -n "$DIFF" ]]; then 15 | echo "Badly formatted go source:" $FILE 16 | STATUS=1 17 | fi 18 | done 19 | 20 | exit $STATUS 21 | -------------------------------------------------------------------------------- /git-setup/setup-hooks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cp pre-commit ../.git/hooks 4 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/fmstephe/memorymanager 2 | 3 | go 1.22 4 | 5 | require ( 6 | github.com/cespare/xxhash/v2 v2.3.0 7 | github.com/fmstephe/flib v0.0.1 8 | github.com/stretchr/testify v1.8.0 9 | golang.org/x/sys v0.18.0 10 | ) 11 | 12 | require ( 13 | github.com/davecgh/go-spew v1.1.1 // indirect 14 | github.com/pmezard/go-difflib v1.0.0 // indirect 15 | gopkg.in/yaml.v3 v3.0.1 // indirect 16 | ) 17 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= 2 | github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 3 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 5 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 6 | github.com/fmstephe/flib v0.0.1 h1:9HRDRg69x/Fnd+w/j/lvhd2/xYDyKs1MFizoi/8O2Ns= 7 | github.com/fmstephe/flib v0.0.1/go.mod h1:0sqY88QLMOPpjONud935JDF3QJ/qhdMGBG2wJOMSUmU= 8 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 9 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 10 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 11 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 12 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 13 | github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= 14 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 15 | golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= 16 | golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 17 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 18 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 19 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 20 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 21 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 22 | -------------------------------------------------------------------------------- /offheap/internal/pointerstore/allocation_config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package pointerstore 6 | 7 | import ( 8 | "unsafe" 9 | 10 | "github.com/fmstephe/flib/fmath" 11 | ) 12 | 13 | type AllocConfig struct { 14 | RequestedObjectSize uint64 15 | RequestedSlabSize uint64 16 | // 17 | ObjectsPerSlab uint64 18 | ObjectSize uint64 19 | TotalObjectSize uint64 20 | MetadataSize uint64 21 | TotalMetadataSize uint64 22 | TotalSlabSize uint64 23 | } 24 | 25 | func NewAllocConfigBySize(requestedObjectSize uint64, requestedSlabSize uint64) AllocConfig { 26 | objectSize := uint64(fmath.NxtPowerOfTwo(int64(requestedObjectSize))) 27 | 28 | totalObjectSize := uint64(fmath.NxtPowerOfTwo(int64(requestedSlabSize))) 29 | 30 | if totalObjectSize < objectSize { 31 | // If the slab is too small - we match the object size for one 32 | // allocation per slab 33 | totalObjectSize = objectSize 34 | } 35 | 36 | objectsPerSlab := totalObjectSize / objectSize 37 | 38 | // TODO have a think about this - we don't strictly _need_ the metadata 39 | // to be aligned by a power of 2 (do we?) 40 | metadataSize := uint64(fmath.NxtPowerOfTwo(int64(unsafe.Sizeof(metadata{})))) 41 | 42 | totalMetadataSize := metadataSize * objectsPerSlab 43 | 44 | totalSlabSize := totalObjectSize + totalMetadataSize 45 | 46 | return AllocConfig{ 47 | RequestedObjectSize: requestedObjectSize, 48 | RequestedSlabSize: requestedSlabSize, 49 | 50 | ObjectsPerSlab: objectsPerSlab, 51 | ObjectSize: objectSize, 52 | TotalObjectSize: totalObjectSize, 53 | MetadataSize: metadataSize, 54 | TotalMetadataSize: totalMetadataSize, 55 | TotalSlabSize: totalSlabSize, 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /offheap/internal/pointerstore/free_list.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package pointerstore 6 | 7 | type freeStack struct { 8 | free []RefPointer 9 | } 10 | 11 | func (s *freeStack) push(r RefPointer) { 12 | s.free = append(s.free, r) 13 | } 14 | 15 | func (s *freeStack) pop() (r RefPointer, ok bool) { 16 | l := len(s.free) 17 | if l == 0 { 18 | return RefPointer{}, false 19 | } 20 | 21 | r = s.free[l-1] 22 | s.free = s.free[:l-1] 23 | return r, true 24 | } 25 | -------------------------------------------------------------------------------- /offheap/internal/pointerstore/free_list_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package pointerstore 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | ) 12 | 13 | func TestFreeStack_Empty(t *testing.T) { 14 | s := freeStack{} 15 | r, ok := s.pop() 16 | assert.True(t, r.IsNil()) 17 | assert.False(t, ok) 18 | } 19 | 20 | // Push 3 references onto the stack. Pop them off in reverse order 21 | func TestFreeStack_PushPop(t *testing.T) { 22 | allocConfig := NewAllocConfigBySize(8, 32*8) 23 | objects, metadatas := MmapSlab(allocConfig) 24 | 25 | s := freeStack{} 26 | 27 | r1Push := NewReference(objects[0], metadatas[0]) 28 | r2Push := NewReference(objects[1], metadatas[1]) 29 | r3Push := NewReference(objects[2], metadatas[2]) 30 | 31 | s.push(r1Push) 32 | s.push(r2Push) 33 | s.push(r3Push) 34 | 35 | r3Pop, ok3 := s.pop() 36 | assert.Equal(t, r3Push, r3Pop) 37 | assert.True(t, ok3) 38 | 39 | r2Pop, ok2 := s.pop() 40 | assert.Equal(t, r2Push, r2Pop) 41 | assert.True(t, ok2) 42 | 43 | r1Pop, ok1 := s.pop() 44 | assert.Equal(t, r1Push, r1Pop) 45 | assert.True(t, ok1) 46 | 47 | r0Pop, ok0 := s.pop() 48 | assert.True(t, r0Pop.IsNil()) 49 | assert.False(t, ok0) 50 | } 51 | 52 | // Push three references off, pop two, push two more. Pop remaining references. 53 | func TestFreeStack_PushPopComplex(t *testing.T) { 54 | allocConfig := NewAllocConfigBySize(8, 32*8) 55 | objects, metadatas := MmapSlab(allocConfig) 56 | 57 | s := freeStack{} 58 | 59 | r1Push := NewReference(objects[0], metadatas[0]) 60 | r2Push := NewReference(objects[1], metadatas[1]) 61 | r3Push := NewReference(objects[2], metadatas[2]) 62 | r4Push := NewReference(objects[3], metadatas[3]) 63 | r5Push := NewReference(objects[4], metadatas[4]) 64 | 65 | s.push(r1Push) 66 | s.push(r2Push) 67 | s.push(r3Push) 68 | 69 | r3Pop, ok3 := s.pop() 70 | assert.Equal(t, r3Push, r3Pop) 71 | assert.True(t, ok3) 72 | 73 | r2Pop, ok2 := s.pop() 74 | assert.Equal(t, r2Push, r2Pop) 75 | assert.True(t, ok2) 76 | 77 | s.push(r4Push) 78 | s.push(r5Push) 79 | 80 | r5Pop, ok5 := s.pop() 81 | assert.Equal(t, r5Push, r5Pop) 82 | assert.True(t, ok5) 83 | 84 | r4Pop, ok4 := s.pop() 85 | assert.Equal(t, r4Push, r4Pop) 86 | assert.True(t, ok4) 87 | 88 | r1Pop, ok1 := s.pop() 89 | assert.Equal(t, r1Push, r1Pop) 90 | assert.True(t, ok1) 91 | 92 | r0Pop, ok0 := s.pop() 93 | assert.True(t, r0Pop.IsNil()) 94 | assert.False(t, ok0) 95 | } 96 | -------------------------------------------------------------------------------- /offheap/internal/pointerstore/metadata.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package pointerstore 6 | 7 | // A RefPointer smuggles a generation tag. Only references with the same gen 8 | // value can access/free objects they point to. This is a best-effort safety 9 | // check to try to catch use-after-free type errors. 10 | // 11 | // Metadata smuggles a generation tag and an is-free tag into its 12 | // taggedAddress. When accessing the data from a RefPointer we check that the 13 | // metadata indicates the object is not free and that the RefPointer's 14 | // generation matches that of the metadat. 15 | type metadata struct { 16 | dataAddressAndGen taggedAddress 17 | } 18 | 19 | //gcassert:noescape 20 | func (m *metadata) gen() uint8 { 21 | return m.dataAddressAndGen.gen() 22 | } 23 | 24 | //gcassert:noescape 25 | func (m *metadata) incGen() uint8 { 26 | m.dataAddressAndGen = m.dataAddressAndGen.withIncGen() 27 | return m.dataAddressAndGen.gen() 28 | } 29 | 30 | //gcassert:noescape 31 | func (m *metadata) isFree() bool { 32 | return m.dataAddressAndGen.isFree() 33 | } 34 | 35 | //gcassert:noescape 36 | func (m *metadata) setFree() { 37 | m.dataAddressAndGen = m.dataAddressAndGen.withFree() 38 | } 39 | 40 | //gcassert:noescape 41 | func (m *metadata) setNotFree() { 42 | m.dataAddressAndGen = m.dataAddressAndGen.withNotFree() 43 | } 44 | -------------------------------------------------------------------------------- /offheap/internal/pointerstore/mmap.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package pointerstore 6 | 7 | import ( 8 | "fmt" 9 | "unsafe" 10 | 11 | "golang.org/x/sys/unix" 12 | ) 13 | 14 | func MmapSlab(conf AllocConfig) (objects, metadata []uintptr) { 15 | data, err := unix.Mmap(-1, 0, int(conf.TotalSlabSize), unix.PROT_READ|unix.PROT_WRITE, unix.MAP_ANON|unix.MAP_PRIVATE) 16 | if err != nil { 17 | panic(fmt.Errorf("cannot allocate %#v via mmap because %s", conf, err)) 18 | } 19 | 20 | // Collect pointers to each object allocation slot 21 | objects = make([]uintptr, conf.ObjectsPerSlab) 22 | for i := range objects { 23 | idx := uint64(i) * conf.ObjectSize 24 | objects[i] = (uintptr)((unsafe.Pointer)(&data[idx])) 25 | } 26 | 27 | // Collect pointers to each metadata slot 28 | metadata = make([]uintptr, conf.ObjectsPerSlab) 29 | for i := range metadata { 30 | idx := conf.TotalObjectSize + (uint64(i) * conf.MetadataSize) 31 | metadata[i] = (uintptr)((unsafe.Pointer)(&data[idx])) 32 | } 33 | 34 | return objects, metadata 35 | } 36 | 37 | func MunmapSlab(ptr uintptr, allocConf AllocConfig) error { 38 | b := pointerToBytes(ptr, int(allocConf.TotalSlabSize)) 39 | return unix.Munmap(b) 40 | } 41 | 42 | func pointerToBytes(ptr uintptr, size int) []byte { 43 | return ([]byte)(unsafe.Slice((*byte)((unsafe.Pointer)(ptr)), size)) 44 | } 45 | -------------------------------------------------------------------------------- /offheap/internal/pointerstore/pointer_store_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package pointerstore 6 | 7 | import ( 8 | "fmt" 9 | "testing" 10 | "unsafe" 11 | 12 | "github.com/stretchr/testify/assert" 13 | ) 14 | 15 | func TestSlabIntegrity(t *testing.T) { 16 | for _, objectSize := range []uint64{ 17 | 0, 18 | 1, 19 | 2, 20 | 3, 21 | (1 << 3) - 1, 22 | 1 << 3, 23 | (1 << 3) + 1, 24 | (1 << 4) - 1, 25 | 1 << 4, 26 | (1 << 4) + 1, 27 | (1 << 5) - 1, 28 | 1 << 5, 29 | (1 << 5) + 1, 30 | (1 << 6) - 1, 31 | 1 << 6, 32 | (1 << 6) + 1, 33 | (1 << 7) - 1, 34 | 1 << 7, 35 | (1 << 7) + 1, 36 | (1 << 8) - 1, 37 | 1 << 8, 38 | (1 << 8) + 1, 39 | (1 << 9) - 1, 40 | 1 << 9, 41 | (1 << 9) + 1, 42 | (1 << 10) - 1, 43 | 1 << 10, 44 | (1 << 10) + 1, 45 | (1 << 11) - 1, 46 | 1 << 11, 47 | (1 << 11) + 1, 48 | (1 << 12) - 1, 49 | 1 << 12, 50 | (1 << 12) + 1, 51 | (1 << 13) - 1, 52 | 1 << 13, 53 | (1 << 13) + 1, 54 | (1 << 14) - 1, 55 | 1 << 14, 56 | (1 << 14) + 1, 57 | (1 << 15) - 1, 58 | 1 << 15, 59 | (1 << 15) + 1, 60 | } { 61 | t.Run(fmt.Sprintf("Test allocation integrity for %d", objectSize), func(t *testing.T) { 62 | conf := NewAllocConfigBySize(objectSize, 1<<16) 63 | store := New(conf) 64 | defer func() { 65 | assert.NoError(t, store.Destroy()) 66 | }() 67 | 68 | // Force 3 slabs to be created for this object size 69 | // Test that the allocations for each slab are correct 70 | for range 3 { 71 | refs := []RefPointer{} 72 | for range conf.ObjectsPerSlab { 73 | refs = append(refs, store.Alloc()) 74 | } 75 | 76 | baseSlabData := refs[0].DataPtr() 77 | baseSlabMetadata := uintptr(unsafe.Pointer(refs[0].metadata())) 78 | 79 | // Check that the metadata is allocated immediately _after_ the data 80 | assert.Equal(t, baseSlabMetadata, baseSlabData+uintptr(conf.TotalObjectSize)) 81 | 82 | // Check all the allocations for their integrity 83 | for i, ref := range refs { 84 | // Check that the data allocations are spaced out appropriately 85 | dataPtr := ref.DataPtr() 86 | expectedDataOffset := uintptr(conf.ObjectSize) * uintptr(i) 87 | assert.Equal(t, baseSlabData+expectedDataOffset, dataPtr) 88 | 89 | // Check that the metadata allocations are spaced out appropriately 90 | metaPtr := uintptr(unsafe.Pointer(ref.metadata())) 91 | expectedMetaOffset := uintptr(conf.MetadataSize) * uintptr(i) 92 | assert.Equal(t, baseSlabMetadata+expectedMetaOffset, metaPtr) 93 | } 94 | } 95 | }) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /offheap/object_bench_test.go: -------------------------------------------------------------------------------- 1 | package offheap 2 | 3 | import "testing" 4 | 5 | type benchStruct struct { 6 | field int 7 | } 8 | 9 | func BenchmarkAllocWriteRead(b *testing.B) { 10 | os := New() 11 | 12 | refs := make([]RefObject[benchStruct], 0, b.N) 13 | 14 | for range b.N { 15 | ref := AllocObject[benchStruct](os) 16 | refs = append(refs, ref) 17 | } 18 | 19 | b.ResetTimer() 20 | b.ReportAllocs() 21 | 22 | for i := range b.N { 23 | refs[i].Value().field = i 24 | } 25 | 26 | sum := 0 27 | 28 | for i := range b.N { 29 | sum += refs[i].Value().field 30 | } 31 | 32 | println(sum) 33 | } 34 | -------------------------------------------------------------------------------- /offheap/reference.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package offheap 6 | 7 | // This type constraint allows us to build generic types which accept any 8 | // Reference type. There is an awkward problem if your type is RefString, 9 | // because you are forced to include an _unused_ parameterised type. We may 10 | // learn to live with this peacefully in time. 11 | type Reference[T any] interface { 12 | RefString | RefSlice[T] | RefObject[T] 13 | } 14 | -------------------------------------------------------------------------------- /offheap/testdata/fuzz/FuzzObjectStore/98e78b0c025d9788: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("1000010000100000000000000000000010000100000000000000000000000") 3 | -------------------------------------------------------------------------------- /pkg/intern/bytes_interner.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | import ( 8 | "github.com/fmstephe/memorymanager/pkg/intern/internbase" 9 | ) 10 | 11 | type bytesInterner struct { 12 | interner internbase.InternerWithBytesId[bytesConverter] 13 | } 14 | 15 | func NewBytesInterner(config internbase.Config) Interner[[]byte] { 16 | return &bytesInterner{ 17 | interner: internbase.NewInternerWithBytesId[bytesConverter](config), 18 | } 19 | } 20 | 21 | func (i *bytesInterner) Get(bytes []byte) string { 22 | return i.interner.Get(newBytesConverter(bytes)) 23 | } 24 | 25 | func (i *bytesInterner) GetStats() internbase.StatsSummary { 26 | return i.interner.GetStats() 27 | } 28 | 29 | var _ internbase.ConverterWithBytesId = bytesConverter{} 30 | 31 | type bytesConverter struct { 32 | bytes []byte 33 | } 34 | 35 | func newBytesConverter(bytes []byte) bytesConverter { 36 | return bytesConverter{ 37 | bytes: bytes, 38 | } 39 | } 40 | 41 | func (c bytesConverter) Identity() []byte { 42 | return c.bytes 43 | } 44 | -------------------------------------------------------------------------------- /pkg/intern/bytes_interner_bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | import ( 8 | "strconv" 9 | "testing" 10 | 11 | "github.com/fmstephe/memorymanager/pkg/intern/internbase" 12 | ) 13 | 14 | func BenchmarkBytesInterner_NoneInterned(b *testing.B) { 15 | interner := NewBytesInterner(internbase.Config{MaxLen: 0, MaxBytes: 0}) 16 | 17 | bytes := make([][]byte, b.N) 18 | for i := range bytes { 19 | bytes[i] = []byte(strconv.Itoa(i)) 20 | } 21 | 22 | b.ReportAllocs() 23 | b.ResetTimer() 24 | for _, bytesVal := range bytes { 25 | interner.Get(bytesVal) 26 | } 27 | } 28 | 29 | func BenchmarkBytesInterner_AllInterned(b *testing.B) { 30 | interner := NewBytesInterner(internbase.Config{MaxLen: 0, MaxBytes: 0}) 31 | 32 | bytes := make([][]byte, b.N) 33 | for i := range bytes { 34 | bytes[i] = []byte(strconv.Itoa(i)) 35 | } 36 | 37 | for _, bytesVal := range bytes { 38 | interner.Get(bytesVal) 39 | } 40 | 41 | b.ReportAllocs() 42 | b.ResetTimer() 43 | 44 | for _, bytesVal := range bytes { 45 | interner.Get(bytesVal) 46 | } 47 | } 48 | 49 | // Benchmark getting already interned values, but limit the size of the set of interned values. 50 | // 51 | // This simulates the behaviour when the interner is used on a smallish fixed set of common values. 52 | func BenchmarkBytesInterner_AllInterned10K(b *testing.B) { 53 | interner := NewBytesInterner(internbase.Config{MaxLen: 0, MaxBytes: 0}) 54 | 55 | bytes := make([][]byte, 10_000) 56 | for i := range bytes { 57 | bytes[i] = []byte(strconv.Itoa(i)) 58 | } 59 | 60 | for _, bytesVal := range bytes { 61 | interner.Get(bytesVal) 62 | } 63 | 64 | b.ReportAllocs() 65 | b.ResetTimer() 66 | 67 | count := 0 68 | for { 69 | for _, bytesVal := range bytes { 70 | interner.Get(bytesVal) 71 | count++ 72 | if count >= b.N { 73 | return 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /pkg/intern/float64_interner.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | import ( 8 | "math" 9 | "strconv" 10 | 11 | "github.com/fmstephe/memorymanager/pkg/intern/internbase" 12 | ) 13 | 14 | type float64Interner struct { 15 | interner internbase.InternerWithUint64Id[float64Converter] 16 | fmt byte 17 | prec int 18 | bitSize int 19 | } 20 | 21 | func NewFloat64Interner(config internbase.Config, fmt byte, prec, bitSize int) Interner[float64] { 22 | return &float64Interner{ 23 | interner: internbase.NewInternerWithUint64Id[float64Converter](config), 24 | fmt: fmt, 25 | prec: prec, 26 | bitSize: bitSize, 27 | } 28 | } 29 | 30 | func (i *float64Interner) Get(value float64) string { 31 | return i.interner.Get(newFloat64Converter(value, i.fmt, i.prec, i.bitSize)) 32 | } 33 | 34 | func (i *float64Interner) GetStats() internbase.StatsSummary { 35 | return i.interner.GetStats() 36 | } 37 | 38 | var _ internbase.ConverterWithUint64Id = float64Converter{} 39 | 40 | // A flexible converter for float64 values. Here the identity is generated by a 41 | // call to math.Float64bits(...) and we convert the value into a string using 42 | // strconv.FormatFloat(...) 43 | type float64Converter struct { 44 | value float64 45 | fmt byte 46 | prec int 47 | bitSize int 48 | } 49 | 50 | func newFloat64Converter(value float64, fmt byte, prec, bitSize int) float64Converter { 51 | return float64Converter{ 52 | value: value, 53 | fmt: fmt, 54 | prec: prec, 55 | bitSize: bitSize, 56 | } 57 | } 58 | 59 | func (c float64Converter) Identity() uint64 { 60 | return math.Float64bits(c.value) 61 | } 62 | 63 | func (c float64Converter) String() string { 64 | return strconv.FormatFloat(c.value, c.fmt, c.prec, c.bitSize) 65 | } 66 | -------------------------------------------------------------------------------- /pkg/intern/float64_interner_bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/fmstephe/memorymanager/pkg/intern/internbase" 11 | ) 12 | 13 | func BenchmarkFloat64Interner_NoneInterned(b *testing.B) { 14 | interner := NewFloat64Interner(internbase.Config{MaxLen: 0, MaxBytes: 0}, 'f', -1, 64) 15 | 16 | floats := make([]float64, b.N) 17 | for i := range floats { 18 | floats[i] = float64(i) + 0.123 19 | } 20 | 21 | b.ReportAllocs() 22 | b.ResetTimer() 23 | for _, floatVal := range floats { 24 | interner.Get(floatVal) 25 | } 26 | } 27 | 28 | func BenchmarkFloat64Interner_AllInterned(b *testing.B) { 29 | interner := NewFloat64Interner(internbase.Config{MaxLen: 0, MaxBytes: 0}, 'f', -1, 64) 30 | 31 | floats := make([]float64, b.N) 32 | for i := range floats { 33 | floats[i] = float64(i) + 0.123 34 | } 35 | 36 | for _, floatVal := range floats { 37 | interner.Get(floatVal) 38 | } 39 | 40 | b.ReportAllocs() 41 | b.ResetTimer() 42 | 43 | for _, floatVal := range floats { 44 | interner.Get(floatVal) 45 | } 46 | } 47 | 48 | // Benchmark getting already interned values, but limit the size of the set of interned values. 49 | // 50 | // This simulates the behaviour when the interner is used on a smallish fixed set of common values. 51 | func BenchmarkFloat64Interner_AllInterned10K(b *testing.B) { 52 | interner := NewFloat64Interner(internbase.Config{MaxLen: 0, MaxBytes: 0}, 'f', -1, 64) 53 | 54 | floats := make([]float64, 10_000) 55 | for i := range floats { 56 | floats[i] = float64(i) + 0.123 57 | } 58 | 59 | for _, floatVal := range floats { 60 | interner.Get(floatVal) 61 | } 62 | 63 | b.ReportAllocs() 64 | b.ResetTimer() 65 | 66 | count := 0 67 | for { 68 | for _, floatVal := range floats { 69 | interner.Get(floatVal) 70 | count++ 71 | if count >= b.N { 72 | return 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /pkg/intern/int64_interner.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | import ( 8 | "strconv" 9 | 10 | "github.com/fmstephe/memorymanager/pkg/intern/internbase" 11 | ) 12 | 13 | type int64Interner struct { 14 | interner internbase.InternerWithUint64Id[int64Converter] 15 | base int 16 | } 17 | 18 | func NewInt64Interner(config internbase.Config, base int) Interner[int64] { 19 | return &int64Interner{ 20 | interner: internbase.NewInternerWithUint64Id[int64Converter](config), 21 | base: base, 22 | } 23 | } 24 | 25 | func (i *int64Interner) Get(value int64) string { 26 | return i.interner.Get(newInt64Converter(value, i.base)) 27 | } 28 | 29 | func (i *int64Interner) GetStats() internbase.StatsSummary { 30 | return i.interner.GetStats() 31 | } 32 | 33 | var _ internbase.ConverterWithUint64Id = int64Converter{} 34 | 35 | // A converter for int64 values. Here the identity is just the value itself. 36 | type int64Converter struct { 37 | value int64 38 | base int 39 | } 40 | 41 | func newInt64Converter(value int64, base int) int64Converter { 42 | return int64Converter{ 43 | value: value, 44 | base: base, 45 | } 46 | } 47 | 48 | func (c int64Converter) Identity() uint64 { 49 | return uint64(c.value) 50 | } 51 | 52 | func (c int64Converter) String() string { 53 | return strconv.FormatInt(c.value, c.base) 54 | } 55 | -------------------------------------------------------------------------------- /pkg/intern/int64_interner_bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/fmstephe/memorymanager/pkg/intern/internbase" 11 | ) 12 | 13 | func BenchmarkInt64Interner_NoneInterned(b *testing.B) { 14 | interner := NewInt64Interner(internbase.Config{MaxLen: 0, MaxBytes: 0}, 10) 15 | 16 | ints := make([]int64, b.N) 17 | for i := range ints { 18 | ints[i] = int64(i) 19 | } 20 | 21 | b.ReportAllocs() 22 | b.ResetTimer() 23 | for _, intVal := range ints { 24 | interner.Get(intVal) 25 | } 26 | } 27 | 28 | func BenchmarkInt64Interner_AllInterned(b *testing.B) { 29 | interner := NewInt64Interner(internbase.Config{MaxLen: 0, MaxBytes: 0}, 10) 30 | 31 | ints := make([]int64, b.N) 32 | for i := range ints { 33 | ints[i] = int64(i) 34 | } 35 | 36 | for _, intVal := range ints { 37 | interner.Get(intVal) 38 | } 39 | 40 | b.ReportAllocs() 41 | b.ResetTimer() 42 | 43 | for _, intVal := range ints { 44 | interner.Get(intVal) 45 | } 46 | } 47 | 48 | // Benchmark getting already interned values, but limit the size of the set of interned values. 49 | // 50 | // This simulates the behaviour when the interner is used on a smallish fixed set of common values. 51 | func BenchmarkInt64Interner_AllInterned10K(b *testing.B) { 52 | interner := NewInt64Interner(internbase.Config{MaxLen: 0, MaxBytes: 0}, 10) 53 | 54 | ints := make([]int64, 10_000) 55 | for i := range ints { 56 | ints[i] = int64(i) 57 | } 58 | 59 | for _, intVal := range ints { 60 | interner.Get(intVal) 61 | } 62 | 63 | b.ReportAllocs() 64 | b.ResetTimer() 65 | 66 | count := 0 67 | for { 68 | for _, intVal := range ints { 69 | interner.Get(intVal) 70 | count++ 71 | if count >= b.N { 72 | return 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /pkg/intern/intern_race_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | /* 8 | import ( 9 | "math/rand" 10 | "testing" 11 | "time" 12 | 13 | "github.com/fmstephe/memorymanager/testpkg/testutil" 14 | ) 15 | 16 | func TestInterner_Race(t *testing.T) { 17 | interner := New(-1, -1) 18 | 19 | bytes, ints, floats := buildTestData(100_000, 1000) 20 | const goroutines = 100 21 | const iterations = 100_000_000 22 | 23 | for range goroutines { 24 | go internStrings(interner, bytes, iterations) 25 | go internInts(interner, ints, iterations) 26 | go internFloats(interner, floats, iterations) 27 | } 28 | } 29 | 30 | func internStrings(interner *StringInterner, bytes [][]byte, iterations int) { 31 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 32 | 33 | for i := 0; i < iterations; i++ { 34 | interner.GetFromBytes(bytes[r.Intn(len(bytes))]) 35 | } 36 | } 37 | 38 | func internInts(interner *StringInterner, ints []int64, iterations int) { 39 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 40 | 41 | for i := 0; i < iterations; i++ { 42 | interner.GetFromInt64(ints[r.Intn(len(ints))]) 43 | } 44 | } 45 | 46 | func internFloats(interner *StringInterner, ints []float64, iterations int) { 47 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 48 | 49 | for i := 0; i < iterations; i++ { 50 | interner.GetFromFloat64(ints[r.Intn(len(ints))]) 51 | } 52 | } 53 | 54 | func buildTestData(size, bytesLimit int) ([][]byte, []int64, []float64) { 55 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 56 | 57 | bytes := make([][]byte, 0, size) 58 | rsm := testutil.NewRandomStringMaker() 59 | for range size { 60 | bytes = append(bytes, rsm.MakeSizedBytes(r.Intn(bytesLimit))) 61 | } 62 | 63 | ints := make([]int64, 0, size) 64 | for range size { 65 | ints = append(ints, int64(r.Uint64())) 66 | } 67 | 68 | floats := make([]float64, 0, size) 69 | for range size { 70 | floats = append(floats, r.NormFloat64()) 71 | } 72 | 73 | return bytes, ints, floats 74 | } 75 | */ 76 | -------------------------------------------------------------------------------- /pkg/intern/internbase/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package internbase 6 | 7 | import ( 8 | "math/bits" 9 | "runtime" 10 | 11 | "github.com/fmstephe/memorymanager/offheap" 12 | ) 13 | 14 | type Config struct { 15 | // Defines the maximum length of a string which can be interned. 16 | // Strings longer than this will be generated but not interned. 17 | // 18 | // <= 0 indicates no limit on string length. 19 | MaxLen int 20 | 21 | // Defines the maximum total number of bytes which can be interned. 22 | // Once this limit is reached no new strings will be interned. 23 | // 24 | // <= 0 indicates no limit on total bytes, this may risk memory 25 | // exhaustion. 26 | MaxBytes int 27 | 28 | // Defines the number shards used internally to determine the level of 29 | // available concurrency for the interner. 30 | // 31 | // Important to note that this is not an exactly configurable 32 | // parameter. The number of shards must always be a power of two, and 33 | // the value provided here may be rounded up if necessary. 34 | // 35 | // <= 0 indicates that the interner should determine the number of 36 | // shards automatically. 37 | Shards int 38 | 39 | // Defines the offheap store to use for allocating interned strings. 40 | // 41 | // If nil then a new store will be created internally. Only needed if 42 | // you want to share a single offheap store across multiple interners. 43 | Store *offheap.Store 44 | } 45 | 46 | func (c *Config) getMaxLen() int { 47 | return c.MaxLen 48 | } 49 | 50 | func (c *Config) getMaxBytes() int { 51 | return c.MaxBytes 52 | } 53 | 54 | func (c *Config) getShards() int { 55 | if c.Shards <= 0 { 56 | c.Shards = runtime.NumCPU() 57 | } 58 | 59 | return nextPowerOfTwo(c.Shards) 60 | } 61 | 62 | func (c *Config) getStore() *offheap.Store { 63 | if c.Store == nil { 64 | c.Store = offheap.New() 65 | } 66 | return c.Store 67 | } 68 | 69 | // Returns the smallest power of two >= val 70 | func nextPowerOfTwo(val int) int { 71 | if val <= 1 { 72 | return 1 73 | } 74 | // Test if val is a power of two 75 | if val > 0 && val&(val-1) == 0 { 76 | return val 77 | } 78 | return 1 << bits.Len64(uint64(val)) 79 | } 80 | -------------------------------------------------------------------------------- /pkg/intern/internbase/intern_controller.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package internbase 6 | 7 | import "sync/atomic" 8 | 9 | type internController struct { 10 | // Immutable fields 11 | maxLen int // set to <= 0 for unlimited string length 12 | maxBytes int64 // set to <= 0 for unlimited bytes 13 | // Mutable fields 14 | usedBytes atomic.Int64 15 | } 16 | 17 | func newController(maxLen, maxBytes int) *internController { 18 | return &internController{ 19 | maxLen: maxLen, 20 | maxBytes: int64(maxBytes), 21 | usedBytes: atomic.Int64{}, 22 | } 23 | } 24 | 25 | func (c *internController) getUsedBytes() int { 26 | return int(c.usedBytes.Load()) 27 | } 28 | 29 | func (c *internController) canInternMaxLen(str string) bool { 30 | if c.maxLen <= 0 { 31 | // No length limit 32 | return true 33 | } 34 | 35 | // There is a limit to how long an interned string can be 36 | return len(str) <= c.maxLen 37 | } 38 | 39 | func (c *internController) canInternUsedBytes(str string) bool { 40 | for { 41 | usedBytes := c.usedBytes.Load() 42 | nextUsedBytes := usedBytes + int64(len(str)) 43 | 44 | if (c.maxBytes > 0) && (nextUsedBytes > c.maxBytes) { 45 | // There is a limit to the total number of bytes that 46 | // can be interned and interning str would cause us to 47 | // exceed that limit 48 | return false 49 | } 50 | 51 | // Cas the new value into usedBytes 52 | // 53 | // if this fails then someone else has probably 54 | // interned a string - check usedBytes again 55 | if c.usedBytes.CompareAndSwap(usedBytes, nextUsedBytes) { 56 | break 57 | } 58 | } 59 | 60 | // str can be interned, and the additional bytes have been accounted for 61 | return true 62 | } 63 | -------------------------------------------------------------------------------- /pkg/intern/internbase/stats.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package internbase 6 | 7 | // A summary of the stats for a specific type of interned converter. 8 | // 9 | // UsedBytes stat is global across all converters. 10 | // 11 | // Total is sum across all shards of the fields in Stats. 12 | // 13 | // Shards holds the individual shard Stats. 14 | type StatsSummary struct { 15 | UsedBytes int 16 | Total Stats 17 | Shards []Stats 18 | } 19 | 20 | // The statistics capturing the runtime behaviour of the interner. 21 | // 22 | // Returned indicates the number of previously interned strings that have 23 | // been returned. 24 | // 25 | // Interned indicates the number of strings which have been interned. 26 | // 27 | // MaxLenExceeded indicates the number of strings not interned because they 28 | // were too long. 29 | // 30 | // UsedBytesExceeded indicates the number of strings not interned because the 31 | // global usedBytes limit was exceeded. 32 | // 33 | // HashCollision indicates the number of strings not interned because of a hash 34 | // collision. 35 | type Stats struct { 36 | Returned int 37 | Interned int 38 | MaxLenExceeded int 39 | UsedBytesExceeded int 40 | HashCollision int 41 | } 42 | 43 | func MakeSummary(shards []Stats, usedBytes int) StatsSummary { 44 | total := Stats{} 45 | 46 | for i := range shards { 47 | total.Returned += shards[i].Returned 48 | total.Interned += shards[i].Interned 49 | total.MaxLenExceeded += shards[i].MaxLenExceeded 50 | total.UsedBytesExceeded += shards[i].UsedBytesExceeded 51 | total.HashCollision += shards[i].HashCollision 52 | } 53 | 54 | return StatsSummary{ 55 | UsedBytes: usedBytes, 56 | Total: total, 57 | Shards: shards, 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /pkg/intern/interner.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | import "github.com/fmstephe/memorymanager/pkg/intern/internbase" 8 | 9 | type Interner[T any] interface { 10 | Get(t T) string 11 | GetStats() internbase.StatsSummary 12 | } 13 | -------------------------------------------------------------------------------- /pkg/intern/string_interner.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | import ( 8 | "unsafe" 9 | 10 | "github.com/fmstephe/memorymanager/pkg/intern/internbase" 11 | ) 12 | 13 | type stringInterner struct { 14 | interner internbase.InternerWithBytesId[stringConverter] 15 | } 16 | 17 | func NewStringInterner(config internbase.Config) Interner[string] { 18 | return &stringInterner{ 19 | interner: internbase.NewInternerWithBytesId[stringConverter](config), 20 | } 21 | } 22 | 23 | func (i *stringInterner) Get(str string) string { 24 | return i.interner.Get(newStringConverter(str)) 25 | } 26 | 27 | func (i *stringInterner) GetStats() internbase.StatsSummary { 28 | return i.interner.GetStats() 29 | } 30 | 31 | var _ internbase.ConverterWithBytesId = stringConverter{} 32 | 33 | type stringConverter struct { 34 | str string 35 | } 36 | 37 | func newStringConverter(str string) stringConverter { 38 | return stringConverter{ 39 | str: str, 40 | } 41 | } 42 | 43 | func (c stringConverter) Identity() []byte { 44 | return unsafe.Slice(unsafe.StringData(c.str), len(c.str)) 45 | } 46 | -------------------------------------------------------------------------------- /pkg/intern/string_interner_bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | import ( 8 | "strconv" 9 | "testing" 10 | 11 | "github.com/fmstephe/memorymanager/pkg/intern/internbase" 12 | ) 13 | 14 | func BenchmarkStringInterner_NoneInterned(b *testing.B) { 15 | interner := NewStringInterner(internbase.Config{MaxLen: 0, MaxBytes: 0}) 16 | 17 | strings := make([]string, b.N) 18 | for i := range strings { 19 | strings[i] = strconv.Itoa(i) 20 | } 21 | 22 | b.ReportAllocs() 23 | b.ResetTimer() 24 | for _, stringVal := range strings { 25 | interner.Get(stringVal) 26 | } 27 | } 28 | 29 | func BenchmarkStringInterner_AllInterned(b *testing.B) { 30 | interner := NewStringInterner(internbase.Config{MaxLen: 0, MaxBytes: 0}) 31 | 32 | strings := make([]string, b.N) 33 | for i := range strings { 34 | strings[i] = strconv.Itoa(i) 35 | } 36 | 37 | for _, stringVal := range strings { 38 | interner.Get(stringVal) 39 | } 40 | 41 | b.ReportAllocs() 42 | b.ResetTimer() 43 | 44 | for _, stringVal := range strings { 45 | interner.Get(stringVal) 46 | } 47 | } 48 | 49 | // Benchmark getting already interned values, but limit the size of the set of interned values. 50 | // 51 | // This simulates the behaviour when the interner is used on a smallish fixed set of common values. 52 | func BenchmarkStringInterner_AllInterned10K(b *testing.B) { 53 | interner := NewStringInterner(internbase.Config{MaxLen: 0, MaxBytes: 0}) 54 | 55 | strings := make([]string, 10_000) 56 | for i := range strings { 57 | strings[i] = strconv.Itoa(i) 58 | } 59 | 60 | for _, stringVal := range strings { 61 | interner.Get(stringVal) 62 | } 63 | 64 | b.ReportAllocs() 65 | b.ResetTimer() 66 | 67 | count := 0 68 | for { 69 | for _, stringVal := range strings { 70 | interner.Get(stringVal) 71 | count++ 72 | if count >= b.N { 73 | return 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /pkg/intern/time_interner.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | import ( 8 | "time" 9 | 10 | "github.com/fmstephe/memorymanager/pkg/intern/internbase" 11 | ) 12 | 13 | type timeInterner struct { 14 | interner internbase.InternerWithUint64Id[timeConverter] 15 | format string 16 | } 17 | 18 | func NewTimeInterner(config internbase.Config, format string) Interner[time.Time] { 19 | return &timeInterner{ 20 | interner: internbase.NewInternerWithUint64Id[timeConverter](config), 21 | format: format, 22 | } 23 | } 24 | 25 | func (i *timeInterner) Get(value time.Time) string { 26 | return i.interner.Get(newTimeConverter(value, i.format)) 27 | } 28 | 29 | func (i *timeInterner) GetStats() internbase.StatsSummary { 30 | return i.interner.GetStats() 31 | } 32 | 33 | var _ internbase.ConverterWithUint64Id = timeConverter{} 34 | 35 | // Converter for time.Time. The int64 UnixNano() value is used to uniquely 36 | // identify each time.Time. If time.Time values are used with different time 37 | // zones but which have the same nanosecond values, this converter will 38 | // consider them to be the same and may produce unexpected output. 39 | // 40 | // Having a converter/interner per timezone is currently the best way to handle 41 | // this. 42 | type timeConverter struct { 43 | value time.Time 44 | format string 45 | } 46 | 47 | func newTimeConverter(value time.Time, format string) timeConverter { 48 | return timeConverter{ 49 | value: value, 50 | format: format, 51 | } 52 | } 53 | 54 | func (c timeConverter) Identity() uint64 { 55 | return uint64(c.value.UnixNano()) 56 | } 57 | 58 | func (c timeConverter) String() string { 59 | return c.value.Format(c.format) 60 | } 61 | -------------------------------------------------------------------------------- /pkg/intern/time_interner_bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package intern 6 | 7 | import ( 8 | "testing" 9 | "time" 10 | 11 | "github.com/fmstephe/memorymanager/pkg/intern/internbase" 12 | ) 13 | 14 | func BenchmarkTimeInterner_NoneInterned(b *testing.B) { 15 | interner := NewTimeInterner(internbase.Config{MaxLen: 0, MaxBytes: 0}, time.RFC1123) 16 | 17 | timestamps := make([]time.Time, b.N) 18 | now := time.Now() 19 | for i := range timestamps { 20 | timestamps[i] = now.Add(time.Nanosecond) 21 | } 22 | 23 | b.ReportAllocs() 24 | b.ResetTimer() 25 | for _, timestamp := range timestamps { 26 | interner.Get(timestamp) 27 | } 28 | } 29 | 30 | func BenchmarkTimeInterner_AllInterned(b *testing.B) { 31 | interner := NewTimeInterner(internbase.Config{MaxLen: 0, MaxBytes: 0}, time.RFC1123) 32 | 33 | timestamps := make([]time.Time, b.N) 34 | now := time.Now() 35 | for i := range timestamps { 36 | timestamps[i] = now.Add(time.Nanosecond) 37 | } 38 | 39 | for _, timestamp := range timestamps { 40 | interner.Get(timestamp) 41 | } 42 | 43 | b.ReportAllocs() 44 | b.ResetTimer() 45 | 46 | for _, timestamp := range timestamps { 47 | interner.Get(timestamp) 48 | } 49 | } 50 | 51 | // Benchmark getting already interned values, but limit the size of the set of interned values. 52 | // 53 | // This simulates the behaviour when the interner is used on a smallish fixed set of common values. 54 | func BenchmarkTimeInterner_AllInterned10K(b *testing.B) { 55 | interner := NewTimeInterner(internbase.Config{MaxLen: 0, MaxBytes: 0}, time.RFC1123) 56 | 57 | timestamps := make([]time.Time, 10_000) 58 | now := time.Now() 59 | for i := range timestamps { 60 | timestamps[i] = now.Add(time.Nanosecond) 61 | } 62 | 63 | for _, timestamp := range timestamps { 64 | interner.Get(timestamp) 65 | } 66 | 67 | b.ReportAllocs() 68 | b.ResetTimer() 69 | 70 | count := 0 71 | for { 72 | for _, timestamp := range timestamps { 73 | interner.Get(timestamp) 74 | count++ 75 | if count >= b.N { 76 | return 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /pkg/quadtree/.gitignore: -------------------------------------------------------------------------------- 1 | *.6 2 | /_obj 3 | *.swp 4 | _* 5 | *.out 6 | -------------------------------------------------------------------------------- /pkg/quadtree/README: -------------------------------------------------------------------------------- 1 | This is a simple quad tree implementation written in Go. It does not support concurrent access, but may do in the future. It allows for the (2D) location based storage of arbitrary Go types, interface{}. 2 | -------------------------------------------------------------------------------- /pkg/quadtree/node_store.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package quadtree 6 | 7 | import ( 8 | "github.com/fmstephe/memorymanager/offheap" 9 | ) 10 | 11 | type nodeStore[T any] struct { 12 | nodes *offheap.Store 13 | } 14 | 15 | func newTreeStore[T any]() *nodeStore[T] { 16 | return &nodeStore[T]{ 17 | nodes: offheap.New(), 18 | } 19 | } 20 | 21 | func (s *nodeStore[T]) allocNode(view View) (offheap.RefObject[node[T]], *node[T]) { 22 | r := offheap.AllocObject[node[T]](s.nodes) 23 | newNode := r.Value() 24 | newNode.view = view 25 | newNode.isLeaf = false 26 | return r, newNode 27 | } 28 | 29 | func (s *nodeStore[T]) allocLeaf(view View) offheap.RefObject[node[T]] { 30 | r := offheap.AllocObject[node[T]](s.nodes) 31 | newLeaf := r.Value() 32 | newLeaf.view = view 33 | newLeaf.isLeaf = true 34 | return r 35 | } 36 | 37 | func (s *nodeStore[T]) newSlice(data T) offheap.RefSlice[T] { 38 | slc := offheap.AllocSlice[T](s.nodes, 1, 1) 39 | slc.Value()[0] = data 40 | return slc 41 | } 42 | -------------------------------------------------------------------------------- /pkg/quadtree/quadtree.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package quadtree 6 | 7 | import ( 8 | "fmt" 9 | 10 | "github.com/fmstephe/memorymanager/offheap" 11 | ) 12 | 13 | // This struct is the exported root of a quad tree 14 | type Tree[T any] struct { 15 | store *nodeStore[T] 16 | treeReference offheap.RefObject[node[T]] 17 | view View 18 | } 19 | 20 | // Returns a new Tree ready for use as an empty quadtree 21 | // 22 | // A Tree node is initialised and the tree is ready for service. 23 | func NewTree[T any](view View) *Tree[T] { 24 | store := newTreeStore[T]() 25 | st := makeNode[T](view, store) 26 | return &Tree[T]{ 27 | store: store, 28 | treeReference: st, 29 | view: view, 30 | } 31 | } 32 | 33 | // Inserts data into this tree 34 | func (r *Tree[T]) Insert(x, y float64, data T) error { 35 | if !r.view.containsPoint(x, y) { 36 | return fmt.Errorf("cannot insert x(%f) y(%f) into view %s", x, y, r.view) 37 | } 38 | list := r.store.newSlice(data) 39 | st := r.treeReference.Value() 40 | st.insert(x, y, list, r.store) 41 | return nil 42 | } 43 | 44 | // Applies fun to every element occurring within view in this tree 45 | func (r *Tree[T]) Survey(view View, fun func(x, y float64, data *T) bool) { 46 | st := r.treeReference.Value() 47 | st.survey(view, fun, r.store) 48 | } 49 | 50 | // Applies fun to every element occurring within view in this tree 51 | func (r *Tree[T]) Count(view View) int64 { 52 | st := r.treeReference.Value() 53 | return st.count(view, r.store) 54 | } 55 | 56 | // Returns the View for this tree 57 | func (r *Tree[T]) View() View { 58 | return r.view 59 | } 60 | 61 | func (r *Tree[T]) String() string { 62 | st := r.treeReference.Value() 63 | return st.String() 64 | } 65 | -------------------------------------------------------------------------------- /pkg/quadtree/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package quadtree 6 | 7 | // A Simple quadtree collector which will push every element into col 8 | func LimitSurvey[K any](limit int) (fun func(x, y float64, e *K) bool, colP *[]K) { 9 | count := 0 10 | col := []K{} 11 | colP = &col 12 | 13 | fun = func(x, y float64, e *K) bool { 14 | if count >= limit { 15 | return false 16 | } 17 | 18 | col = *colP 19 | col = append(col, *e) 20 | colP = &col 21 | count++ 22 | return true 23 | } 24 | return fun, colP 25 | } 26 | 27 | // A Simple quadtree collector which will push every element into col 28 | func SliceSurvey[K any]() (fun func(x, y float64, e *K) bool, colP *[]K) { 29 | col := []K{} 30 | colP = &col 31 | fun = func(x, y float64, e *K) bool { 32 | col = *colP 33 | col = append(col, *e) 34 | colP = &col 35 | return true 36 | } 37 | return fun, colP 38 | } 39 | -------------------------------------------------------------------------------- /scripts/copyright_header.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | 3 | HEADER="// Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 4 | // source code is governed by an MIT license that can be found in the LICENSE 5 | // file. 6 | " 7 | 8 | echo "$HEADER" > copyright-file 9 | 10 | for file in $(find . -type f -name \*.go -not -path "./vendor/*"); do 11 | echo $file 12 | line=$(head -n 1 $file) 13 | if [[ $line != "// Copyright"* ]]; then 14 | echo "$HEADER" > copyright-file 15 | cat $file >> copyright-file 16 | mv copyright-file $file 17 | fi 18 | done 19 | 20 | rm copyright-file 21 | -------------------------------------------------------------------------------- /testpkg/fuzzutil/byte_consumer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package fuzzutil 6 | 7 | import ( 8 | "encoding/binary" 9 | ) 10 | 11 | type ByteConsumer struct { 12 | bytes []byte 13 | } 14 | 15 | func NewByteConsumer(bytes []byte) *ByteConsumer { 16 | return &ByteConsumer{ 17 | bytes: bytes, 18 | } 19 | } 20 | 21 | func (c *ByteConsumer) Len() int { 22 | return len(c.bytes) 23 | } 24 | 25 | func (c *ByteConsumer) Bytes(size int) []byte { 26 | consumed := make([]byte, size) 27 | copy(consumed, c.bytes) 28 | 29 | if len(c.bytes) <= size { 30 | c.bytes = c.bytes[:0] 31 | } else { 32 | c.bytes = c.bytes[size:] 33 | } 34 | return consumed 35 | } 36 | 37 | // Test only 38 | func (c *ByteConsumer) pushBytes(bytes []byte) { 39 | c.bytes = append(c.bytes, bytes...) 40 | } 41 | 42 | func (c *ByteConsumer) Byte() byte { 43 | dest := c.Bytes(1) 44 | return dest[0] 45 | } 46 | 47 | // Test only 48 | func (c *ByteConsumer) pushByte(b byte) { 49 | c.pushBytes([]byte{b}) 50 | } 51 | 52 | func (c *ByteConsumer) Uint16() uint16 { 53 | dest := c.Bytes(2) 54 | return binary.LittleEndian.Uint16(dest) 55 | } 56 | 57 | // Test only 58 | func (c *ByteConsumer) pushUint16(value uint16) { 59 | bytes := make([]byte, 2) 60 | binary.LittleEndian.PutUint16(bytes, value) 61 | c.pushBytes(bytes) 62 | } 63 | 64 | func (c *ByteConsumer) Uint32() uint32 { 65 | dest := c.Bytes(4) 66 | return binary.LittleEndian.Uint32(dest) 67 | } 68 | 69 | // Test only 70 | func (c *ByteConsumer) pushUint32(value uint32) { 71 | bytes := make([]byte, 4) 72 | binary.LittleEndian.PutUint32(bytes, value) 73 | c.pushBytes(bytes) 74 | } 75 | -------------------------------------------------------------------------------- /testpkg/fuzzutil/randombytes.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package fuzzutil 6 | 7 | import "math/rand" 8 | 9 | func MakeRandomTestCases() [][]byte { 10 | r := rand.New(rand.NewSource(1)) 11 | return [][]byte{ 12 | []byte{}, 13 | randomBytes(r, 1), 14 | randomBytes(r, 10), 15 | randomBytes(r, 50), 16 | randomBytes(r, 100), 17 | randomBytes(r, 500), 18 | randomBytes(r, 1000), 19 | randomBytes(r, 5000), 20 | randomBytes(r, 10000), 21 | randomBytes(r, 50000), 22 | } 23 | } 24 | 25 | func randomBytes(r *rand.Rand, size int) []byte { 26 | bytes := make([]byte, size) 27 | r.Read(bytes) 28 | return bytes 29 | } 30 | -------------------------------------------------------------------------------- /testpkg/fuzzutil/test_run.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package fuzzutil 6 | 7 | type TestRun struct { 8 | steps []Step 9 | cleanup func() 10 | } 11 | 12 | func NewTestRun(bytes []byte, stepMaker func(*ByteConsumer) Step, cleanup func()) *TestRun { 13 | tr := &TestRun{ 14 | steps: make([]Step, 0), 15 | cleanup: cleanup, 16 | } 17 | byteConsumer := NewByteConsumer(bytes) 18 | 19 | for byteConsumer.Len() > 0 { 20 | step := stepMaker(byteConsumer) 21 | tr.steps = append(tr.steps, step) 22 | } 23 | return tr 24 | } 25 | 26 | func (t *TestRun) Run() { 27 | //fmt.Printf("\nTesting Run with %d steps\n", len(t.steps)) 28 | defer t.cleanup() 29 | for _, step := range t.steps { 30 | step.DoStep() 31 | } 32 | } 33 | 34 | type Step interface { 35 | DoStep() 36 | } 37 | -------------------------------------------------------------------------------- /testpkg/testutil/random_strings.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package testutil 6 | 7 | import ( 8 | "math/rand" 9 | "strings" 10 | ) 11 | 12 | const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 13 | 14 | type RandomStringMaker struct { 15 | r *rand.Rand 16 | } 17 | 18 | func NewRandomStringMaker() *RandomStringMaker { 19 | return &RandomStringMaker{ 20 | r: rand.New(rand.NewSource(1)), 21 | } 22 | } 23 | 24 | func (rsm *RandomStringMaker) MakeSizedBytes(length int) []byte { 25 | bytes := make([]byte, 0, length) 26 | for range length { 27 | bytes = append(bytes, letters[rsm.r.Intn(len(letters))]) 28 | } 29 | return bytes 30 | } 31 | 32 | func (rsm *RandomStringMaker) MakeSizedString(length int) string { 33 | builder := strings.Builder{} 34 | builder.Grow(length) 35 | for range length { 36 | builder.WriteByte(letters[rsm.r.Intn(len(letters))]) 37 | } 38 | return builder.String() 39 | } 40 | -------------------------------------------------------------------------------- /testpkg/testutil/random_strings_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Francis Michael Stephens. All rights reserved. Use of this 2 | // source code is governed by an MIT license that can be found in the LICENSE 3 | // file. 4 | 5 | package testutil 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | ) 12 | 13 | func TestRandomStringMaker_MakeSizedString(t *testing.T) { 14 | rsm := NewRandomStringMaker() 15 | 16 | for i := 0; i < 1000; i++ { 17 | str := rsm.MakeSizedString(i) 18 | assert.Equal(t, i, len(str)) 19 | } 20 | } 21 | 22 | func TestRandomStringMaker_MakeSizedBytes(t *testing.T) { 23 | rsm := NewRandomStringMaker() 24 | 25 | for i := 0; i < 1000; i++ { 26 | bytes := rsm.MakeSizedBytes(i) 27 | assert.Equal(t, i, len(bytes)) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Caleb Spare 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/testall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu -o pipefail 3 | 4 | # Small convenience script for running the tests with various combinations of 5 | # arch/tags. This assumes we're running on amd64 and have qemu available. 6 | 7 | go test ./... 8 | go test -tags purego ./... 9 | GOARCH=arm64 go test 10 | GOARCH=arm64 go test -tags purego 11 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/xxhash_asm.go: -------------------------------------------------------------------------------- 1 | //go:build (amd64 || arm64) && !appengine && gc && !purego 2 | // +build amd64 arm64 3 | // +build !appengine 4 | // +build gc 5 | // +build !purego 6 | 7 | package xxhash 8 | 9 | // Sum64 computes the 64-bit xxHash digest of b with a zero seed. 10 | // 11 | //go:noescape 12 | func Sum64(b []byte) uint64 13 | 14 | //go:noescape 15 | func writeBlocks(d *Digest, b []byte) int 16 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/xxhash_other.go: -------------------------------------------------------------------------------- 1 | //go:build (!amd64 && !arm64) || appengine || !gc || purego 2 | // +build !amd64,!arm64 appengine !gc purego 3 | 4 | package xxhash 5 | 6 | // Sum64 computes the 64-bit xxHash digest of b with a zero seed. 7 | func Sum64(b []byte) uint64 { 8 | // A simpler version would be 9 | // d := New() 10 | // d.Write(b) 11 | // return d.Sum64() 12 | // but this is faster, particularly for small inputs. 13 | 14 | n := len(b) 15 | var h uint64 16 | 17 | if n >= 32 { 18 | v1 := primes[0] + prime2 19 | v2 := prime2 20 | v3 := uint64(0) 21 | v4 := -primes[0] 22 | for len(b) >= 32 { 23 | v1 = round(v1, u64(b[0:8:len(b)])) 24 | v2 = round(v2, u64(b[8:16:len(b)])) 25 | v3 = round(v3, u64(b[16:24:len(b)])) 26 | v4 = round(v4, u64(b[24:32:len(b)])) 27 | b = b[32:len(b):len(b)] 28 | } 29 | h = rol1(v1) + rol7(v2) + rol12(v3) + rol18(v4) 30 | h = mergeRound(h, v1) 31 | h = mergeRound(h, v2) 32 | h = mergeRound(h, v3) 33 | h = mergeRound(h, v4) 34 | } else { 35 | h = prime5 36 | } 37 | 38 | h += uint64(n) 39 | 40 | for ; len(b) >= 8; b = b[8:] { 41 | k1 := round(0, u64(b[:8])) 42 | h ^= k1 43 | h = rol27(h)*prime1 + prime4 44 | } 45 | if len(b) >= 4 { 46 | h ^= uint64(u32(b[:4])) * prime1 47 | h = rol23(h)*prime2 + prime3 48 | b = b[4:] 49 | } 50 | for ; len(b) > 0; b = b[1:] { 51 | h ^= uint64(b[0]) * prime5 52 | h = rol11(h) * prime1 53 | } 54 | 55 | h ^= h >> 33 56 | h *= prime2 57 | h ^= h >> 29 58 | h *= prime3 59 | h ^= h >> 32 60 | 61 | return h 62 | } 63 | 64 | func writeBlocks(d *Digest, b []byte) int { 65 | v1, v2, v3, v4 := d.v1, d.v2, d.v3, d.v4 66 | n := len(b) 67 | for len(b) >= 32 { 68 | v1 = round(v1, u64(b[0:8:len(b)])) 69 | v2 = round(v2, u64(b[8:16:len(b)])) 70 | v3 = round(v3, u64(b[16:24:len(b)])) 71 | v4 = round(v4, u64(b[24:32:len(b)])) 72 | b = b[32:len(b):len(b)] 73 | } 74 | d.v1, d.v2, d.v3, d.v4 = v1, v2, v3, v4 75 | return n - len(b) 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/xxhash_safe.go: -------------------------------------------------------------------------------- 1 | //go:build appengine 2 | // +build appengine 3 | 4 | // This file contains the safe implementations of otherwise unsafe-using code. 5 | 6 | package xxhash 7 | 8 | // Sum64String computes the 64-bit xxHash digest of s with a zero seed. 9 | func Sum64String(s string) uint64 { 10 | return Sum64([]byte(s)) 11 | } 12 | 13 | // WriteString adds more data to d. It always returns len(s), nil. 14 | func (d *Digest) WriteString(s string) (n int, err error) { 15 | return d.Write([]byte(s)) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go: -------------------------------------------------------------------------------- 1 | //go:build !appengine 2 | // +build !appengine 3 | 4 | // This file encapsulates usage of unsafe. 5 | // xxhash_safe.go contains the safe implementations. 6 | 7 | package xxhash 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | // In the future it's possible that compiler optimizations will make these 14 | // XxxString functions unnecessary by realizing that calls such as 15 | // Sum64([]byte(s)) don't need to copy s. See https://go.dev/issue/2205. 16 | // If that happens, even if we keep these functions they can be replaced with 17 | // the trivial safe code. 18 | 19 | // NOTE: The usual way of doing an unsafe string-to-[]byte conversion is: 20 | // 21 | // var b []byte 22 | // bh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) 23 | // bh.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data 24 | // bh.Len = len(s) 25 | // bh.Cap = len(s) 26 | // 27 | // Unfortunately, as of Go 1.15.3 the inliner's cost model assigns a high enough 28 | // weight to this sequence of expressions that any function that uses it will 29 | // not be inlined. Instead, the functions below use a different unsafe 30 | // conversion designed to minimize the inliner weight and allow both to be 31 | // inlined. There is also a test (TestInlining) which verifies that these are 32 | // inlined. 33 | // 34 | // See https://github.com/golang/go/issues/42739 for discussion. 35 | 36 | // Sum64String computes the 64-bit xxHash digest of s with a zero seed. 37 | // It may be faster than Sum64([]byte(s)) by avoiding a copy. 38 | func Sum64String(s string) uint64 { 39 | b := *(*[]byte)(unsafe.Pointer(&sliceHeader{s, len(s)})) 40 | return Sum64(b) 41 | } 42 | 43 | // WriteString adds more data to d. It always returns len(s), nil. 44 | // It may be faster than Write([]byte(s)) by avoiding a copy. 45 | func (d *Digest) WriteString(s string) (n int, err error) { 46 | d.Write(*(*[]byte)(unsafe.Pointer(&sliceHeader{s, len(s)}))) 47 | // d.Write always returns len(s), nil. 48 | // Ignoring the return output and returning these fixed values buys a 49 | // savings of 6 in the inliner's cost model. 50 | return len(s), nil 51 | } 52 | 53 | // sliceHeader is similar to reflect.SliceHeader, but it assumes that the layout 54 | // of the first two words is the same as the layout of a string. 55 | type sliceHeader struct { 56 | s string 57 | cap int 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012-2016 Dave Collins 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2016 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is running on Google App Engine, compiled by GopherJS, or 17 | // "-tags safe" is added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // +build js appengine safe disableunsafe !go1.4 20 | 21 | package spew 22 | 23 | import "reflect" 24 | 25 | const ( 26 | // UnsafeDisabled is a build-time constant which specifies whether or 27 | // not access to the unsafe package is available. 28 | UnsafeDisabled = true 29 | ) 30 | 31 | // unsafeReflectValue typically converts the passed reflect.Value into a one 32 | // that bypasses the typical safety restrictions preventing access to 33 | // unaddressable and unexported data. However, doing this relies on access to 34 | // the unsafe package. This is a stub version which simply returns the passed 35 | // reflect.Value when the unsafe package is not available. 36 | func unsafeReflectValue(v reflect.Value) reflect.Value { 37 | return v 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/fmstephe/flib/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright © 2016 Francis Stephens All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, 4 | are permitted provided that the following conditions are met: 5 | * Redistributions of source code must retain the above copyright notice, this 6 | list of conditions and the following disclaimer. 7 | * Redistributions in binary form must reproduce the above copyright notice, this 8 | list of conditions and the following disclaimer in the documentation and/or 9 | other materials provided with the distribution. 10 | * Neither the name of Francis Stephens nor the names of its contributors may be used to 11 | endorse or promote products derived from this software without specific prior 12 | written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/fmstephe/flib/fmath/icompare.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Francis Stephens. All rights reserved. 2 | // Use of this source code is governed by a BSD 3 | // license which can be found in LICENSE.txt 4 | 5 | package fmath 6 | 7 | // uint64 comparisons 8 | 9 | // Returns 1 if x > y, 0 otherwise 10 | func UIGT(x, y uint64) uint8 { 11 | return uint8((y - x) >> 63) 12 | } 13 | 14 | // Returns 1 if x >= y, 0 otherwise 15 | func UIGTE(x, y uint64) uint8 { 16 | return uint8(((x - y) >> 63) ^ 1) 17 | } 18 | 19 | // Returns 1 if x < y, 0 otherwise 20 | func UILT(x, y uint64) uint8 { 21 | return uint8(((x - y) >> 63)) 22 | } 23 | 24 | // Returns 1 if x <= y, 0 otherwise 25 | func UILTE(x, y uint64) uint8 { 26 | return uint8(((y - x) >> 63) ^ 1) 27 | } 28 | 29 | // Returns 1 if x == 0 30 | // Returns 0 if x == 1 31 | // Undfined for all other inputs 32 | func UINot(x uint64) uint8 { 33 | return uint8(x ^ 1) 34 | } 35 | 36 | // uint8 comparisons 37 | 38 | // Returns 1 if x > y, 0 otherwise 39 | func UI8GT(x, y uint8) uint8 { 40 | return (y - x) >> 7 41 | } 42 | 43 | // Returns 1 if x >= y, 0 otherwise 44 | func UI8GTE(x, y uint8) uint8 { 45 | return ((x - y) >> 7) ^ 1 46 | } 47 | 48 | // Returns 1 if x < y, 0 otherwise 49 | func UI8LT(x, y uint8) uint8 { 50 | return ((x - y) >> 7) 51 | } 52 | 53 | // Returns 1 if x <= y, 0 otherwise 54 | func UI8LTE(x, y uint8) uint8 { 55 | return ((y - x) >> 7) ^ 1 56 | } 57 | 58 | // Returns 1 if x == 0 59 | // Returns 0 if x == 1 60 | // Undfined for all other inputs 61 | func UI8Not(x uint8) uint8 { 62 | return x ^ 1 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/fmstephe/flib/fmath/integer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Francis Stephens. All rights reserved. 2 | // Use of this source code is governed by a BSD 3 | // license which can be found in LICENSE.txt 4 | 5 | package fmath 6 | 7 | import "math/bits" 8 | 9 | // Returns true if val is a power of two, otherwise returns false 10 | func PowerOfTwo(val int64) bool { 11 | return val > 0 && val&(val-1) == 0 12 | } 13 | 14 | // Returns the smallest power of two >= val 15 | func NxtPowerOfTwo(val int64) int64 { 16 | if val <= 1 { 17 | return 1 18 | } 19 | if PowerOfTwo(val) { 20 | return val 21 | } 22 | return 1 << bits.Len64(uint64(val)) 23 | } 24 | 25 | // Returns x if x < y, otherwise returns y 26 | // 27 | // NB: Only valid if math.MinInt64 <= x-y <= math.MaxInt64 28 | // In particular, always valid if both arguments are positive 29 | func Min(x, y int64) int64 { 30 | return y + ((x - y) & ((x - y) >> 63)) 31 | } 32 | 33 | // Returns x if x > y, otherwise returns y 34 | // 35 | // NB: Only valid if math.MinInt64 <= x-y <= math.MaxInt64 36 | // In particular, always valid if both arguments are positive 37 | func Max(x, y int64) int64 { 38 | return x ^ ((x ^ y) & ((x - y) >> 63)) 39 | } 40 | 41 | // Combines two int32 values into a single int64 42 | // high occupies bits 32-63 43 | // low occupies bits 0-31 44 | func CombineInt32(high, low int32) int64 { 45 | high64 := int64(uint32(high)) << 32 46 | low64 := int64(uint32(low)) 47 | return high64 | low64 48 | } 49 | 50 | // Returns the highest 32 bits of an int64 51 | func HighInt32(whole int64) int32 { 52 | return int32(whole >> 32) 53 | } 54 | 55 | // Returns the lowest 32 bits of an int64 56 | func LowInt32(whole int64) int32 { 57 | return int32(whole) 58 | } 59 | 60 | func Abs(val int64) int64 { 61 | if val >= 0 { 62 | return val 63 | } 64 | return -val 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/fmstephe/flib/funsafe/README.md: -------------------------------------------------------------------------------- 1 | # Unsafe Conversions Between String <-> []byte 2 | 3 | This package is intended to be a clear implementation of the solution suggested by Keith Randal here 4 | 5 | https://groups.google.com/d/msg/golang-nuts/Zsfk-VMd_fU/WXPjfZwPBAAJ 6 | 7 | This avoids the problems associated with using a `uintptr` as well as failing tests if the runtime representation of string or []byte changes. 8 | -------------------------------------------------------------------------------- /vendor/github.com/fmstephe/flib/funsafe/convert.go: -------------------------------------------------------------------------------- 1 | package funsafe 2 | 3 | import ( 4 | "unsafe" 5 | ) 6 | 7 | // stringHeader is the runtime representation of a string. 8 | // It should be identical to reflect.StringHeader 9 | type stringHeader struct { 10 | data unsafe.Pointer 11 | stringLen int 12 | } 13 | 14 | // sliceHeader is the runtime representation of a slice. 15 | // It should be identical to reflect.sliceHeader 16 | type sliceHeader struct { 17 | data unsafe.Pointer 18 | sliceLen int 19 | sliceCap int 20 | } 21 | 22 | // Unsafely converts s into a byte slice. 23 | // If you modify b, then s will also be modified. This violates the 24 | // property that strings are immutable. 25 | func StringToBytes(s string) (b []byte) { 26 | stringHeader := (*stringHeader)(unsafe.Pointer(&s)) 27 | sliceHeader := (*sliceHeader)(unsafe.Pointer(&b)) 28 | sliceHeader.data = stringHeader.data 29 | sliceHeader.sliceLen = len(s) 30 | sliceHeader.sliceCap = len(s) 31 | return b 32 | } 33 | 34 | // Unsafely converts b into a string. 35 | // If you modify b, then s will also be modified. This violates the 36 | // property that strings are immutable. 37 | func BytesToString(b []byte) (s string) { 38 | sliceHeader := (*sliceHeader)(unsafe.Pointer(&b)) 39 | stringHeader := (*stringHeader)(unsafe.Pointer(&s)) 40 | stringHeader.data = sliceHeader.data 41 | stringHeader.stringLen = len(b) 42 | return s 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2012-2020 Mat Ryer, Tyler Bunnell and contributors. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go: -------------------------------------------------------------------------------- 1 | //go:build go1.17 2 | // +build go1.17 3 | 4 | // TODO: once support for Go 1.16 is dropped, this file can be 5 | // merged/removed with assertion_compare_go1.17_test.go and 6 | // assertion_compare_legacy.go 7 | 8 | package assert 9 | 10 | import "reflect" 11 | 12 | // Wrapper around reflect.Value.CanConvert, for compatibility 13 | // reasons. 14 | func canConvert(value reflect.Value, to reflect.Type) bool { 15 | return value.CanConvert(to) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go: -------------------------------------------------------------------------------- 1 | //go:build !go1.17 2 | // +build !go1.17 3 | 4 | // TODO: once support for Go 1.16 is dropped, this file can be 5 | // merged/removed with assertion_compare_go1.17_test.go and 6 | // assertion_compare_can_convert.go 7 | 8 | package assert 9 | 10 | import "reflect" 11 | 12 | // Older versions of Go does not have the reflect.Value.CanConvert 13 | // method. 14 | func canConvert(value reflect.Value, to reflect.Type) bool { 15 | return false 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentFormat}} 2 | func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool { 3 | if h, ok := t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | if h, ok := a.t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs" 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/doc.go: -------------------------------------------------------------------------------- 1 | // Package require implements the same assertions as the `assert` package but 2 | // stops test execution when a test fails. 3 | // 4 | // Example Usage 5 | // 6 | // The following is a complete example using require in a standard test function: 7 | // import ( 8 | // "testing" 9 | // "github.com/stretchr/testify/require" 10 | // ) 11 | // 12 | // func TestSomething(t *testing.T) { 13 | // 14 | // var a string = "Hello" 15 | // var b string = "Hello" 16 | // 17 | // require.Equal(t, a, b, "The two words should be the same.") 18 | // 19 | // } 20 | // 21 | // Assertions 22 | // 23 | // The `require` package have same global functions as in the `assert` package, 24 | // but instead of returning a boolean result they call `t.FailNow()`. 25 | // 26 | // Every assertion function also takes an optional string message as the final argument, 27 | // allowing custom error messages to be appended to the message the assertion method outputs. 28 | package require 29 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/forward_requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require_forward.go.tmpl -include-format-funcs" 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.Comment}} 2 | func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { 3 | if h, ok := t.(tHelper); ok { h.Helper() } 4 | if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return } 5 | t.FailNow() 6 | } 7 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { 3 | if h, ok := a.t.(tHelper); ok { h.Helper() } 4 | {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // TestingT is an interface wrapper around *testing.T 4 | type TestingT interface { 5 | Errorf(format string, args ...interface{}) 6 | FailNow() 7 | } 8 | 9 | type tHelper interface { 10 | Helper() 11 | } 12 | 13 | // ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful 14 | // for table driven tests. 15 | type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) 16 | 17 | // ValueAssertionFunc is a common function prototype when validating a single value. Can be useful 18 | // for table driven tests. 19 | type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) 20 | 21 | // BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful 22 | // for table driven tests. 23 | type BoolAssertionFunc func(TestingT, bool, ...interface{}) 24 | 25 | // ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful 26 | // for table driven tests. 27 | type ErrorAssertionFunc func(TestingT, error, ...interface{}) 28 | 29 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require.go.tmpl -include-format-funcs" 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/affinity_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // CPU affinity functions 6 | 7 | package unix 8 | 9 | import ( 10 | "math/bits" 11 | "unsafe" 12 | ) 13 | 14 | const cpuSetSize = _CPU_SETSIZE / _NCPUBITS 15 | 16 | // CPUSet represents a CPU affinity mask. 17 | type CPUSet [cpuSetSize]cpuMask 18 | 19 | func schedAffinity(trap uintptr, pid int, set *CPUSet) error { 20 | _, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set))) 21 | if e != 0 { 22 | return errnoErr(e) 23 | } 24 | return nil 25 | } 26 | 27 | // SchedGetaffinity gets the CPU affinity mask of the thread specified by pid. 28 | // If pid is 0 the calling thread is used. 29 | func SchedGetaffinity(pid int, set *CPUSet) error { 30 | return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set) 31 | } 32 | 33 | // SchedSetaffinity sets the CPU affinity mask of the thread specified by pid. 34 | // If pid is 0 the calling thread is used. 35 | func SchedSetaffinity(pid int, set *CPUSet) error { 36 | return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set) 37 | } 38 | 39 | // Zero clears the set s, so that it contains no CPUs. 40 | func (s *CPUSet) Zero() { 41 | for i := range s { 42 | s[i] = 0 43 | } 44 | } 45 | 46 | func cpuBitsIndex(cpu int) int { 47 | return cpu / _NCPUBITS 48 | } 49 | 50 | func cpuBitsMask(cpu int) cpuMask { 51 | return cpuMask(1 << (uint(cpu) % _NCPUBITS)) 52 | } 53 | 54 | // Set adds cpu to the set s. 55 | func (s *CPUSet) Set(cpu int) { 56 | i := cpuBitsIndex(cpu) 57 | if i < len(s) { 58 | s[i] |= cpuBitsMask(cpu) 59 | } 60 | } 61 | 62 | // Clear removes cpu from the set s. 63 | func (s *CPUSet) Clear(cpu int) { 64 | i := cpuBitsIndex(cpu) 65 | if i < len(s) { 66 | s[i] &^= cpuBitsMask(cpu) 67 | } 68 | } 69 | 70 | // IsSet reports whether cpu is in the set s. 71 | func (s *CPUSet) IsSet(cpu int) bool { 72 | i := cpuBitsIndex(cpu) 73 | if i < len(s) { 74 | return s[i]&cpuBitsMask(cpu) != 0 75 | } 76 | return false 77 | } 78 | 79 | // Count returns the number of CPUs in the set s. 80 | func (s *CPUSet) Count() int { 81 | c := 0 82 | for _, b := range s { 83 | c += bits.OnesCount64(uint64(b)) 84 | } 85 | return c 86 | } 87 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | type Signal = syscall.Signal 12 | type Errno = syscall.Errno 13 | type SysProcAttr = syscall.SysProcAttr 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_aix_ppc64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 11 | // 12 | 13 | TEXT ·syscall6(SB),NOSPLIT,$0-88 14 | JMP syscall·syscall6(SB) 15 | 16 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSyscall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (freebsd || netbsd || openbsd) && gc 6 | 7 | #include "textflag.h" 8 | 9 | // System call support for 386 BSD 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-28 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 21 | JMP syscall·Syscall9(SB) 22 | 23 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 24 | JMP syscall·RawSyscall(SB) 25 | 26 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 27 | JMP syscall·RawSyscall6(SB) 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc 6 | 7 | #include "textflag.h" 8 | 9 | // System call support for AMD64 BSD 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 21 | JMP syscall·Syscall9(SB) 22 | 23 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 24 | JMP syscall·RawSyscall(SB) 25 | 26 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 27 | JMP syscall·RawSyscall6(SB) 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (freebsd || netbsd || openbsd) && gc 6 | 7 | #include "textflag.h" 8 | 9 | // System call support for ARM BSD 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-28 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 21 | B syscall·Syscall9(SB) 22 | 23 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 24 | B syscall·RawSyscall(SB) 25 | 26 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 27 | B syscall·RawSyscall6(SB) 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin || freebsd || netbsd || openbsd) && gc 6 | 7 | #include "textflag.h" 8 | 9 | // System call support for ARM64 BSD 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 21 | JMP syscall·Syscall9(SB) 22 | 23 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 24 | JMP syscall·RawSyscall(SB) 25 | 26 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 27 | JMP syscall·RawSyscall6(SB) 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin || freebsd || netbsd || openbsd) && gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ppc64, BSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin || freebsd || netbsd || openbsd) && gc 6 | 7 | #include "textflag.h" 8 | 9 | // System call support for RISCV64 BSD 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 21 | JMP syscall·Syscall9(SB) 22 | 23 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 24 | JMP syscall·RawSyscall(SB) 25 | 26 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 27 | JMP syscall·RawSyscall6(SB) 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 14 | // instead of the glibc-specific "CALL 0x10(GS)". 15 | #define INVOKE_SYSCALL INT $0x80 16 | 17 | // Just jump to package syscall's implementation for all these functions. 18 | // The runtime may know about them. 19 | 20 | TEXT ·Syscall(SB),NOSPLIT,$0-28 21 | JMP syscall·Syscall(SB) 22 | 23 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·Syscall6(SB) 25 | 26 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 27 | CALL runtime·entersyscall(SB) 28 | MOVL trap+0(FP), AX // syscall entry 29 | MOVL a1+4(FP), BX 30 | MOVL a2+8(FP), CX 31 | MOVL a3+12(FP), DX 32 | MOVL $0, SI 33 | MOVL $0, DI 34 | INVOKE_SYSCALL 35 | MOVL AX, r1+16(FP) 36 | MOVL DX, r2+20(FP) 37 | CALL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVL trap+0(FP), AX // syscall entry 48 | MOVL a1+4(FP), BX 49 | MOVL a2+8(FP), CX 50 | MOVL a3+12(FP), DX 51 | MOVL $0, SI 52 | MOVL $0, DI 53 | INVOKE_SYSCALL 54 | MOVL AX, r1+16(FP) 55 | MOVL DX, r2+20(FP) 56 | RET 57 | 58 | TEXT ·socketcall(SB),NOSPLIT,$0-36 59 | JMP syscall·socketcall(SB) 60 | 61 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 62 | JMP syscall·rawsocketcall(SB) 63 | 64 | TEXT ·seek(SB),NOSPLIT,$0-28 65 | JMP syscall·seek(SB) 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 23 | CALL runtime·entersyscall(SB) 24 | MOVQ a1+8(FP), DI 25 | MOVQ a2+16(FP), SI 26 | MOVQ a3+24(FP), DX 27 | MOVQ $0, R10 28 | MOVQ $0, R8 29 | MOVQ $0, R9 30 | MOVQ trap+0(FP), AX // syscall entry 31 | SYSCALL 32 | MOVQ AX, r1+32(FP) 33 | MOVQ DX, r2+40(FP) 34 | CALL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | JMP syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | JMP syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVQ a1+8(FP), DI 45 | MOVQ a2+16(FP), SI 46 | MOVQ a3+24(FP), DX 47 | MOVQ $0, R10 48 | MOVQ $0, R8 49 | MOVQ $0, R9 50 | MOVQ trap+0(FP), AX // syscall entry 51 | SYSCALL 52 | MOVQ AX, r1+32(FP) 53 | MOVQ DX, r2+40(FP) 54 | RET 55 | 56 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 57 | JMP syscall·gettimeofday(SB) 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 23 | BL runtime·entersyscall(SB) 24 | MOVW trap+0(FP), R7 25 | MOVW a1+4(FP), R0 26 | MOVW a2+8(FP), R1 27 | MOVW a3+12(FP), R2 28 | MOVW $0, R3 29 | MOVW $0, R4 30 | MOVW $0, R5 31 | SWI $0 32 | MOVW R0, r1+16(FP) 33 | MOVW $0, R0 34 | MOVW R0, r2+20(FP) 35 | BL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 39 | B syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 42 | B syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 45 | MOVW trap+0(FP), R7 // syscall entry 46 | MOVW a1+4(FP), R0 47 | MOVW a2+8(FP), R1 48 | MOVW a3+12(FP), R2 49 | SWI $0 50 | MOVW R0, r1+16(FP) 51 | MOVW $0, R0 52 | MOVW R0, r2+20(FP) 53 | RET 54 | 55 | TEXT ·seek(SB),NOSPLIT,$0-28 56 | B syscall·seek(SB) 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && arm64 && gc 6 | 7 | #include "textflag.h" 8 | 9 | // Just jump to package syscall's implementation for all these functions. 10 | // The runtime may know about them. 11 | 12 | TEXT ·Syscall(SB),NOSPLIT,$0-56 13 | B syscall·Syscall(SB) 14 | 15 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 16 | B syscall·Syscall6(SB) 17 | 18 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 19 | BL runtime·entersyscall(SB) 20 | MOVD a1+8(FP), R0 21 | MOVD a2+16(FP), R1 22 | MOVD a3+24(FP), R2 23 | MOVD $0, R3 24 | MOVD $0, R4 25 | MOVD $0, R5 26 | MOVD trap+0(FP), R8 // syscall entry 27 | SVC 28 | MOVD R0, r1+32(FP) // r1 29 | MOVD R1, r2+40(FP) // r2 30 | BL runtime·exitsyscall(SB) 31 | RET 32 | 33 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 34 | B syscall·RawSyscall(SB) 35 | 36 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 37 | B syscall·RawSyscall6(SB) 38 | 39 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 40 | MOVD a1+8(FP), R0 41 | MOVD a2+16(FP), R1 42 | MOVD a3+24(FP), R2 43 | MOVD $0, R3 44 | MOVD $0, R4 45 | MOVD $0, R5 46 | MOVD trap+0(FP), R8 // syscall entry 47 | SVC 48 | MOVD R0, r1+32(FP) 49 | MOVD R1, r2+40(FP) 50 | RET 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_loong64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && loong64 && gc 6 | 7 | #include "textflag.h" 8 | 9 | 10 | // Just jump to package syscall's implementation for all these functions. 11 | // The runtime may know about them. 12 | 13 | TEXT ·Syscall(SB),NOSPLIT,$0-56 14 | JMP syscall·Syscall(SB) 15 | 16 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 17 | JMP syscall·Syscall6(SB) 18 | 19 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 20 | JAL runtime·entersyscall(SB) 21 | MOVV a1+8(FP), R4 22 | MOVV a2+16(FP), R5 23 | MOVV a3+24(FP), R6 24 | MOVV R0, R7 25 | MOVV R0, R8 26 | MOVV R0, R9 27 | MOVV trap+0(FP), R11 // syscall entry 28 | SYSCALL 29 | MOVV R4, r1+32(FP) 30 | MOVV R0, r2+40(FP) // r2 is not used. Always set to 0 31 | JAL runtime·exitsyscall(SB) 32 | RET 33 | 34 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 35 | JMP syscall·RawSyscall(SB) 36 | 37 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 38 | JMP syscall·RawSyscall6(SB) 39 | 40 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 41 | MOVV a1+8(FP), R4 42 | MOVV a2+16(FP), R5 43 | MOVV a3+24(FP), R6 44 | MOVV R0, R7 45 | MOVV R0, R8 46 | MOVV R0, R9 47 | MOVV trap+0(FP), R11 // syscall entry 48 | SYSCALL 49 | MOVV R4, r1+32(FP) 50 | MOVV R0, r2+40(FP) // r2 is not used. Always set to 0 51 | RET 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (mips64 || mips64le) && gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for mips64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 23 | JAL runtime·entersyscall(SB) 24 | MOVV a1+8(FP), R4 25 | MOVV a2+16(FP), R5 26 | MOVV a3+24(FP), R6 27 | MOVV R0, R7 28 | MOVV R0, R8 29 | MOVV R0, R9 30 | MOVV trap+0(FP), R2 // syscall entry 31 | SYSCALL 32 | MOVV R2, r1+32(FP) 33 | MOVV R3, r2+40(FP) 34 | JAL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | JMP syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | JMP syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVV a1+8(FP), R4 45 | MOVV a2+16(FP), R5 46 | MOVV a3+24(FP), R6 47 | MOVV R0, R7 48 | MOVV R0, R8 49 | MOVV R0, R9 50 | MOVV trap+0(FP), R2 // syscall entry 51 | SYSCALL 52 | MOVV R2, r1+32(FP) 53 | MOVV R3, r2+40(FP) 54 | RET 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (mips || mipsle) && gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for mips, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 26 | JAL runtime·entersyscall(SB) 27 | MOVW a1+4(FP), R4 28 | MOVW a2+8(FP), R5 29 | MOVW a3+12(FP), R6 30 | MOVW R0, R7 31 | MOVW trap+0(FP), R2 // syscall entry 32 | SYSCALL 33 | MOVW R2, r1+16(FP) // r1 34 | MOVW R3, r2+20(FP) // r2 35 | JAL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 39 | JMP syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 42 | JMP syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 45 | MOVW a1+4(FP), R4 46 | MOVW a2+8(FP), R5 47 | MOVW a3+12(FP), R6 48 | MOVW trap+0(FP), R2 // syscall entry 49 | SYSCALL 50 | MOVW R2, r1+16(FP) 51 | MOVW R3, r2+20(FP) 52 | RET 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (ppc64 || ppc64le) && gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for ppc64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 17 | BL runtime·entersyscall(SB) 18 | MOVD a1+8(FP), R3 19 | MOVD a2+16(FP), R4 20 | MOVD a3+24(FP), R5 21 | MOVD R0, R6 22 | MOVD R0, R7 23 | MOVD R0, R8 24 | MOVD trap+0(FP), R9 // syscall entry 25 | SYSCALL R9 26 | MOVD R3, r1+32(FP) 27 | MOVD R4, r2+40(FP) 28 | BL runtime·exitsyscall(SB) 29 | RET 30 | 31 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 32 | MOVD a1+8(FP), R3 33 | MOVD a2+16(FP), R4 34 | MOVD a3+24(FP), R5 35 | MOVD R0, R6 36 | MOVD R0, R7 37 | MOVD R0, R8 38 | MOVD trap+0(FP), R9 // syscall entry 39 | SYSCALL R9 40 | MOVD R3, r1+32(FP) 41 | MOVD R4, r2+40(FP) 42 | RET 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_riscv64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build riscv64 && gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for linux/riscv64. 11 | // 12 | // Where available, just jump to package syscall's implementation of 13 | // these functions. 14 | 15 | TEXT ·Syscall(SB),NOSPLIT,$0-56 16 | JMP syscall·Syscall(SB) 17 | 18 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 19 | JMP syscall·Syscall6(SB) 20 | 21 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 22 | CALL runtime·entersyscall(SB) 23 | MOV a1+8(FP), A0 24 | MOV a2+16(FP), A1 25 | MOV a3+24(FP), A2 26 | MOV trap+0(FP), A7 // syscall entry 27 | ECALL 28 | MOV A0, r1+32(FP) // r1 29 | MOV A1, r2+40(FP) // r2 30 | CALL runtime·exitsyscall(SB) 31 | RET 32 | 33 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 34 | JMP syscall·RawSyscall(SB) 35 | 36 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 37 | JMP syscall·RawSyscall6(SB) 38 | 39 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 40 | MOV a1+8(FP), A0 41 | MOV a2+16(FP), A1 42 | MOV a3+24(FP), A2 43 | MOV trap+0(FP), A7 // syscall entry 44 | ECALL 45 | MOV A0, r1+32(FP) 46 | MOV A1, r2+40(FP) 47 | RET 48 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && s390x && gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for s390x, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | BR syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | BR syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 23 | BL runtime·entersyscall(SB) 24 | MOVD a1+8(FP), R2 25 | MOVD a2+16(FP), R3 26 | MOVD a3+24(FP), R4 27 | MOVD $0, R5 28 | MOVD $0, R6 29 | MOVD $0, R7 30 | MOVD trap+0(FP), R1 // syscall entry 31 | SYSCALL 32 | MOVD R2, r1+32(FP) 33 | MOVD R3, r2+40(FP) 34 | BL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | BR syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | BR syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVD a1+8(FP), R2 45 | MOVD a2+16(FP), R3 46 | MOVD a3+24(FP), R4 47 | MOVD $0, R5 48 | MOVD $0, R6 49 | MOVD $0, R7 50 | MOVD trap+0(FP), R1 // syscall entry 51 | SYSCALL 52 | MOVD R2, r1+32(FP) 53 | MOVD R3, r2+40(FP) 54 | RET 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for mips64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | HCI_CHANNEL_LOGGING = 4 27 | ) 28 | 29 | // Socketoption Level 30 | const ( 31 | SOL_BLUETOOTH = 0x112 32 | SOL_HCI = 0x0 33 | SOL_L2CAP = 0x6 34 | SOL_RFCOMM = 0x12 35 | SOL_SCO = 0x11 36 | ) 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix && ppc 6 | 7 | // Functions to access/create device major and minor numbers matching the 8 | // encoding used by AIX. 9 | 10 | package unix 11 | 12 | // Major returns the major component of a Linux device number. 13 | func Major(dev uint64) uint32 { 14 | return uint32((dev >> 16) & 0xffff) 15 | } 16 | 17 | // Minor returns the minor component of a Linux device number. 18 | func Minor(dev uint64) uint32 { 19 | return uint32(dev & 0xffff) 20 | } 21 | 22 | // Mkdev returns a Linux device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | return uint64(((major) << 16) | (minor)) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix && ppc64 6 | 7 | // Functions to access/create device major and minor numbers matching the 8 | // encoding used AIX. 9 | 10 | package unix 11 | 12 | // Major returns the major component of a Linux device number. 13 | func Major(dev uint64) uint32 { 14 | return uint32((dev & 0x3fffffff00000000) >> 32) 15 | } 16 | 17 | // Minor returns the minor component of a Linux device number. 18 | func Minor(dev uint64) uint32 { 19 | return uint32((dev & 0x00000000ffffffff) >> 0) 20 | } 21 | 22 | // Mkdev returns a Linux device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | var DEVNO64 uint64 26 | DEVNO64 = 0x8000000000000000 27 | return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := (uint64(major) & 0x00000fff) << 8 38 | dev |= (uint64(major) & 0xfffff000) << 32 39 | dev |= (uint64(minor) & 0x000000ff) << 0 40 | dev |= (uint64(minor) & 0xffffff00) << 12 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in NetBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a NetBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x000fff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_zos.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build zos && s390x 6 | 7 | // Functions to access/create device major and minor numbers matching the 8 | // encoding used by z/OS. 9 | // 10 | // The information below is extracted and adapted from macros. 11 | 12 | package unix 13 | 14 | // Major returns the major component of a z/OS device number. 15 | func Major(dev uint64) uint32 { 16 | return uint32((dev >> 16) & 0x0000FFFF) 17 | } 18 | 19 | // Minor returns the minor component of a z/OS device number. 20 | func Minor(dev uint64) uint32 { 21 | return uint32(dev & 0x0000FFFF) 22 | } 23 | 24 | // Mkdev returns a z/OS device number generated from the given major and minor 25 | // components. 26 | func Mkdev(major, minor uint32) uint64 { 27 | return (uint64(major) << 16) | uint64(minor) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | //go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | //go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | 29 | func Unsetenv(key string) error { 30 | return syscall.Unsetenv(key) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build dragonfly || freebsd || linux || netbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by fcntl_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | func fcntl(fd int, cmd, arg int) (int, error) { 16 | valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg)) 17 | var err error 18 | if errno != 0 { 19 | err = errno 20 | } 21 | return int(valptr), err 22 | } 23 | 24 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 25 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 26 | return fcntl(int(fd), cmd, arg) 27 | } 28 | 29 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 30 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 31 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 32 | if errno == 0 { 33 | return nil 34 | } 35 | return errno 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import "unsafe" 8 | 9 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 10 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 11 | return fcntl(int(fd), cmd, arg) 12 | } 13 | 14 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 15 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 16 | _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk)))) 17 | return err 18 | } 19 | 20 | // FcntlFstore performs a fcntl syscall for the F_PREALLOCATE command. 21 | func FcntlFstore(fd uintptr, cmd int, fstore *Fstore_t) error { 22 | _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(fstore)))) 23 | return err 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) || (linux && ppc) 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fdset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | 7 | package unix 8 | 9 | // Set adds fd to the set fds. 10 | func (fds *FdSet) Set(fd int) { 11 | fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS)) 12 | } 13 | 14 | // Clear removes fd from the set fds. 15 | func (fds *FdSet) Clear(fd int) { 16 | fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS)) 17 | } 18 | 19 | // IsSet returns whether fd is in the set fds. 20 | func (fds *FdSet) IsSet(fd int) bool { 21 | return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0 22 | } 23 | 24 | // Zero clears the set fds. 25 | func (fds *FdSet) Zero() { 26 | for i := range fds.Bits { 27 | fds.Bits[i] = 0 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gccgo && !aix && !hurd 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 15 | 16 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 17 | 18 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 19 | syscall.Entersyscall() 20 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 21 | syscall.Exitsyscall() 22 | return r, 0 23 | } 24 | 25 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 26 | syscall.Entersyscall() 27 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 28 | syscall.Exitsyscall() 29 | return r, 0, syscall.Errno(errno) 30 | } 31 | 32 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 33 | syscall.Entersyscall() 34 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 35 | syscall.Exitsyscall() 36 | return r, 0, syscall.Errno(errno) 37 | } 38 | 39 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 40 | syscall.Entersyscall() 41 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 42 | syscall.Exitsyscall() 43 | return r, 0, syscall.Errno(errno) 44 | } 45 | 46 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 47 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 48 | return r, 0 49 | } 50 | 51 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 52 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 53 | return r, 0, syscall.Errno(errno) 54 | } 55 | 56 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 57 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 58 | return r, 0, syscall.Errno(errno) 59 | } 60 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gccgo && !aix && !hurd 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 24 | __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall"); 25 | 26 | struct ret 27 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 28 | { 29 | struct ret r; 30 | 31 | errno = 0; 32 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 33 | r.err = errno; 34 | return r; 35 | } 36 | 37 | uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 38 | __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError"); 39 | 40 | uintptr_t 41 | gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 42 | { 43 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 44 | } 45 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gccgo && linux && amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl_signed.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || solaris 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | // ioctl itself should not be exposed directly, but additional get/set 14 | // functions for specific types are permissible. 15 | 16 | // IoctlSetInt performs an ioctl operation which sets an integer value 17 | // on fd, using the specified request number. 18 | func IoctlSetInt(fd int, req int, value int) error { 19 | return ioctl(fd, req, uintptr(value)) 20 | } 21 | 22 | // IoctlSetPointerInt performs an ioctl operation which sets an 23 | // integer value on fd, using the specified request number. The ioctl 24 | // argument is called with a pointer to the integer value, rather than 25 | // passing the integer value directly. 26 | func IoctlSetPointerInt(fd int, req int, value int) error { 27 | v := int32(value) 28 | return ioctlPtr(fd, req, unsafe.Pointer(&v)) 29 | } 30 | 31 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 32 | // 33 | // To change fd's window size, the req argument should be TIOCSWINSZ. 34 | func IoctlSetWinsize(fd int, req int, value *Winsize) error { 35 | // TODO: if we get the chance, remove the req parameter and 36 | // hardcode TIOCSWINSZ. 37 | return ioctlPtr(fd, req, unsafe.Pointer(value)) 38 | } 39 | 40 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 41 | // 42 | // The req value will usually be TCSETA or TIOCSETA. 43 | func IoctlSetTermios(fd int, req int, value *Termios) error { 44 | // TODO: if we get the chance, remove the req parameter. 45 | return ioctlPtr(fd, req, unsafe.Pointer(value)) 46 | } 47 | 48 | // IoctlGetInt performs an ioctl operation which gets an integer value 49 | // from fd, using the specified request number. 50 | // 51 | // A few ioctl requests use the return value as an output parameter; 52 | // for those, IoctlRetInt should be used instead of this function. 53 | func IoctlGetInt(fd int, req int) (int, error) { 54 | var value int 55 | err := ioctlPtr(fd, req, unsafe.Pointer(&value)) 56 | return value, err 57 | } 58 | 59 | func IoctlGetWinsize(fd int, req int) (*Winsize, error) { 60 | var value Winsize 61 | err := ioctlPtr(fd, req, unsafe.Pointer(&value)) 62 | return &value, err 63 | } 64 | 65 | func IoctlGetTermios(fd int, req int) (*Termios, error) { 66 | var value Termios 67 | err := ioctlPtr(fd, req, unsafe.Pointer(&value)) 68 | return &value, err 69 | } 70 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl_unsigned.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | // ioctl itself should not be exposed directly, but additional get/set 14 | // functions for specific types are permissible. 15 | 16 | // IoctlSetInt performs an ioctl operation which sets an integer value 17 | // on fd, using the specified request number. 18 | func IoctlSetInt(fd int, req uint, value int) error { 19 | return ioctl(fd, req, uintptr(value)) 20 | } 21 | 22 | // IoctlSetPointerInt performs an ioctl operation which sets an 23 | // integer value on fd, using the specified request number. The ioctl 24 | // argument is called with a pointer to the integer value, rather than 25 | // passing the integer value directly. 26 | func IoctlSetPointerInt(fd int, req uint, value int) error { 27 | v := int32(value) 28 | return ioctlPtr(fd, req, unsafe.Pointer(&v)) 29 | } 30 | 31 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 32 | // 33 | // To change fd's window size, the req argument should be TIOCSWINSZ. 34 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 35 | // TODO: if we get the chance, remove the req parameter and 36 | // hardcode TIOCSWINSZ. 37 | return ioctlPtr(fd, req, unsafe.Pointer(value)) 38 | } 39 | 40 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 41 | // 42 | // The req value will usually be TCSETA or TIOCSETA. 43 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 44 | // TODO: if we get the chance, remove the req parameter. 45 | return ioctlPtr(fd, req, unsafe.Pointer(value)) 46 | } 47 | 48 | // IoctlGetInt performs an ioctl operation which gets an integer value 49 | // from fd, using the specified request number. 50 | // 51 | // A few ioctl requests use the return value as an output parameter; 52 | // for those, IoctlRetInt should be used instead of this function. 53 | func IoctlGetInt(fd int, req uint) (int, error) { 54 | var value int 55 | err := ioctlPtr(fd, req, unsafe.Pointer(&value)) 56 | return value, err 57 | } 58 | 59 | func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { 60 | var value Winsize 61 | err := ioctlPtr(fd, req, unsafe.Pointer(&value)) 62 | return &value, err 63 | } 64 | 65 | func IoctlGetTermios(fd int, req uint) (*Termios, error) { 66 | var value Termios 67 | err := ioctlPtr(fd, req, unsafe.Pointer(&value)) 68 | return &value, err 69 | } 70 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl_zos.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build zos && s390x 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | // ioctl itself should not be exposed directly, but additional get/set 15 | // functions for specific types are permissible. 16 | 17 | // IoctlSetInt performs an ioctl operation which sets an integer value 18 | // on fd, using the specified request number. 19 | func IoctlSetInt(fd int, req int, value int) error { 20 | return ioctl(fd, req, uintptr(value)) 21 | } 22 | 23 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 24 | // 25 | // To change fd's window size, the req argument should be TIOCSWINSZ. 26 | func IoctlSetWinsize(fd int, req int, value *Winsize) error { 27 | // TODO: if we get the chance, remove the req parameter and 28 | // hardcode TIOCSWINSZ. 29 | return ioctlPtr(fd, req, unsafe.Pointer(value)) 30 | } 31 | 32 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 33 | // 34 | // The req value is expected to be TCSETS, TCSETSW, or TCSETSF 35 | func IoctlSetTermios(fd int, req int, value *Termios) error { 36 | if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) { 37 | return ENOSYS 38 | } 39 | err := Tcsetattr(fd, int(req), value) 40 | runtime.KeepAlive(value) 41 | return err 42 | } 43 | 44 | // IoctlGetInt performs an ioctl operation which gets an integer value 45 | // from fd, using the specified request number. 46 | // 47 | // A few ioctl requests use the return value as an output parameter; 48 | // for those, IoctlRetInt should be used instead of this function. 49 | func IoctlGetInt(fd int, req int) (int, error) { 50 | var value int 51 | err := ioctlPtr(fd, req, unsafe.Pointer(&value)) 52 | return value, err 53 | } 54 | 55 | func IoctlGetWinsize(fd int, req int) (*Winsize, error) { 56 | var value Winsize 57 | err := ioctlPtr(fd, req, unsafe.Pointer(&value)) 58 | return &value, err 59 | } 60 | 61 | // IoctlGetTermios performs an ioctl on fd with a *Termios. 62 | // 63 | // The req value is expected to be TCGETS 64 | func IoctlGetTermios(fd int, req int) (*Termios, error) { 65 | var value Termios 66 | if req != TCGETS { 67 | return &value, ENOSYS 68 | } 69 | err := Tcgetattr(fd, &value) 70 | return &value, err 71 | } 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mmap_nomremap.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || openbsd || solaris 6 | 7 | package unix 8 | 9 | var mapper = &mmapper{ 10 | active: make(map[*byte][]byte), 11 | mmap: mmap, 12 | munmap: munmap, 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mremap.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux || netbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | type mremapMmapper struct { 12 | mmapper 13 | mremap func(oldaddr uintptr, oldlength uintptr, newlength uintptr, flags int, newaddr uintptr) (xaddr uintptr, err error) 14 | } 15 | 16 | var mapper = &mremapMmapper{ 17 | mmapper: mmapper{ 18 | active: make(map[*byte][]byte), 19 | mmap: mmap, 20 | munmap: munmap, 21 | }, 22 | mremap: mremap, 23 | } 24 | 25 | func (m *mremapMmapper) Mremap(oldData []byte, newLength int, flags int) (data []byte, err error) { 26 | if newLength <= 0 || len(oldData) == 0 || len(oldData) != cap(oldData) || flags&mremapFixed != 0 { 27 | return nil, EINVAL 28 | } 29 | 30 | pOld := &oldData[cap(oldData)-1] 31 | m.Lock() 32 | defer m.Unlock() 33 | bOld := m.active[pOld] 34 | if bOld == nil || &bOld[0] != &oldData[0] { 35 | return nil, EINVAL 36 | } 37 | newAddr, errno := m.mremap(uintptr(unsafe.Pointer(&bOld[0])), uintptr(len(bOld)), uintptr(newLength), flags, 0) 38 | if errno != nil { 39 | return nil, errno 40 | } 41 | bNew := unsafe.Slice((*byte)(unsafe.Pointer(newAddr)), newLength) 42 | pNew := &bNew[cap(bNew)-1] 43 | if flags&mremapDontunmap == 0 { 44 | delete(m.active, pOld) 45 | } 46 | m.active[pNew] = bNew 47 | return bNew, nil 48 | } 49 | 50 | func Mremap(oldData []byte, newLength int, flags int) (data []byte, err error) { 51 | return mapper.Mremap(oldData, newLength, flags) 52 | } 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/pagesize_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris 6 | 7 | // For Unix, get the pagesize from the runtime. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getpagesize() int { 14 | return syscall.Getpagesize() 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ptrace_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build darwin && !ios 6 | 7 | package unix 8 | 9 | func ptrace(request int, pid int, addr uintptr, data uintptr) error { 10 | return ptrace1(request, pid, addr, data) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ptrace_ios.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build ios 6 | 7 | package unix 8 | 9 | func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { 10 | return ENOTSUP 11 | } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin && race) || (linux && race) || (freebsd && race) 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || (darwin && !race) || (linux && !race) || (freebsd && !race) || netbsd || openbsd || solaris || dragonfly || zos 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/readdirent_getdents.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || dragonfly || freebsd || linux || netbsd || openbsd 6 | 7 | package unix 8 | 9 | // ReadDirent reads directory entries from fd and writes them into buf. 10 | func ReadDirent(fd int, buf []byte) (n int, err error) { 11 | return Getdents(fd, buf) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/readdirent_getdirentries.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build darwin 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // ReadDirent reads directory entries from fd and writes them into buf. 12 | func ReadDirent(fd int, buf []byte) (n int, err error) { 13 | // Final argument is (basep *uintptr) and the syscall doesn't take nil. 14 | // 64 bits should be enough. (32 bits isn't even on 386). Since the 15 | // actual system call is getdirentries64, 64 is a good guess. 16 | // TODO(rsc): Can we use a single global basep for all calls? 17 | var base = (*uintptr)(unsafe.Pointer(new(uint64))) 18 | return Getdirentries(fd, buf, base) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | // Round the length of a raw sockaddr up to align it properly. 8 | func cmsgAlignOf(salen int) int { 9 | salign := SizeofPtr 10 | if SizeofPtr == 8 && !supportsABI(_dragonflyABIChangeVersion) { 11 | // 64-bit Dragonfly before the September 2019 ABI changes still requires 12 | // 32-bit aligned access to network subsystem. 13 | salign = 4 14 | } 15 | return (salen + salign - 1) & ^(salign - 1) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || freebsd || linux || netbsd || openbsd || solaris || zos 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | ) 12 | 13 | // Round the length of a raw sockaddr up to align it properly. 14 | func cmsgAlignOf(salen int) int { 15 | salign := SizeofPtr 16 | 17 | // dragonfly needs to check ABI version at runtime, see cmsgAlignOf in 18 | // sockcmsg_dragonfly.go 19 | switch runtime.GOOS { 20 | case "aix": 21 | // There is no alignment on AIX. 22 | salign = 1 23 | case "darwin", "ios", "illumos", "solaris": 24 | // NOTE: It seems like 64-bit Darwin, Illumos and Solaris 25 | // kernels still require 32-bit aligned access to network 26 | // subsystem. 27 | if SizeofPtr == 8 { 28 | salign = 4 29 | } 30 | case "netbsd", "openbsd": 31 | // NetBSD and OpenBSD armv7 require 64-bit alignment. 32 | if runtime.GOARCH == "arm" { 33 | salign = 8 34 | } 35 | // NetBSD aarch64 requires 128-bit alignment. 36 | if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm64" { 37 | salign = 16 38 | } 39 | case "zos": 40 | // z/OS socket macros use [32-bit] sizeof(int) alignment, 41 | // not pointer width. 42 | salign = SizeofInt 43 | } 44 | 45 | return (salen + salign - 1) & ^(salign - 1) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix && ppc 6 | 7 | package unix 8 | 9 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 10 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 11 | 12 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func (iov *Iovec) SetLen(length int) { 23 | iov.Len = uint32(length) 24 | } 25 | 26 | func (msghdr *Msghdr) SetControllen(length int) { 27 | msghdr.Controllen = uint32(length) 28 | } 29 | 30 | func (msghdr *Msghdr) SetIovlen(length int) { 31 | msghdr.Iovlen = int32(length) 32 | } 33 | 34 | func (cmsg *Cmsghdr) SetLen(length int) { 35 | cmsg.Len = uint32(length) 36 | } 37 | 38 | func Fstat(fd int, stat *Stat_t) error { 39 | return fstat(fd, stat) 40 | } 41 | 42 | func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { 43 | return fstatat(dirfd, path, stat, flags) 44 | } 45 | 46 | func Lstat(path string, stat *Stat_t) error { 47 | return lstat(path, stat) 48 | } 49 | 50 | func Stat(path string, statptr *Stat_t) error { 51 | return stat(path, statptr) 52 | } 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix && ppc64 6 | 7 | package unix 8 | 9 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 10 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek 11 | 12 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int64(sec), Usec: int32(usec)} 20 | } 21 | 22 | func (iov *Iovec) SetLen(length int) { 23 | iov.Len = uint64(length) 24 | } 25 | 26 | func (msghdr *Msghdr) SetControllen(length int) { 27 | msghdr.Controllen = uint32(length) 28 | } 29 | 30 | func (msghdr *Msghdr) SetIovlen(length int) { 31 | msghdr.Iovlen = int32(length) 32 | } 33 | 34 | func (cmsg *Cmsghdr) SetLen(length int) { 35 | cmsg.Len = uint32(length) 36 | } 37 | 38 | // In order to only have Timespec structure, type of Stat_t's fields 39 | // Atim, Mtim and Ctim is changed from StTimespec to Timespec during 40 | // ztypes generation. 41 | // On ppc64, Timespec.Nsec is an int64 while StTimespec.Nsec is an 42 | // int32, so the fields' value must be modified. 43 | func fixStatTimFields(stat *Stat_t) { 44 | stat.Atim.Nsec >>= 32 45 | stat.Mtim.Nsec >>= 32 46 | stat.Ctim.Nsec >>= 32 47 | } 48 | 49 | func Fstat(fd int, stat *Stat_t) error { 50 | err := fstat(fd, stat) 51 | if err != nil { 52 | return err 53 | } 54 | fixStatTimFields(stat) 55 | return nil 56 | } 57 | 58 | func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { 59 | err := fstatat(dirfd, path, stat, flags) 60 | if err != nil { 61 | return err 62 | } 63 | fixStatTimFields(stat) 64 | return nil 65 | } 66 | 67 | func Lstat(path string, stat *Stat_t) error { 68 | err := lstat(path, stat) 69 | if err != nil { 70 | return err 71 | } 72 | fixStatTimFields(stat) 73 | return nil 74 | } 75 | 76 | func Stat(path string, statptr *Stat_t) error { 77 | err := stat(path, statptr) 78 | if err != nil { 79 | return err 80 | } 81 | fixStatTimFields(statptr) 82 | return nil 83 | } 84 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && darwin 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func setTimespec(sec, nsec int64) Timespec { 12 | return Timespec{Sec: sec, Nsec: nsec} 13 | } 14 | 15 | func setTimeval(sec, usec int64) Timeval { 16 | return Timeval{Sec: sec, Usec: int32(usec)} 17 | } 18 | 19 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 20 | k.Ident = uint64(fd) 21 | k.Filter = int16(mode) 22 | k.Flags = uint16(flags) 23 | } 24 | 25 | func (iov *Iovec) SetLen(length int) { 26 | iov.Len = uint64(length) 27 | } 28 | 29 | func (msghdr *Msghdr) SetControllen(length int) { 30 | msghdr.Controllen = uint32(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetIovlen(length int) { 34 | msghdr.Iovlen = int32(length) 35 | } 36 | 37 | func (cmsg *Cmsghdr) SetLen(length int) { 38 | cmsg.Len = uint32(length) 39 | } 40 | 41 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 42 | 43 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 44 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 45 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 46 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 47 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 48 | //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace 49 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 50 | //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm64 && darwin 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func setTimespec(sec, nsec int64) Timespec { 12 | return Timespec{Sec: sec, Nsec: nsec} 13 | } 14 | 15 | func setTimeval(sec, usec int64) Timeval { 16 | return Timeval{Sec: sec, Usec: int32(usec)} 17 | } 18 | 19 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 20 | k.Ident = uint64(fd) 21 | k.Filter = int16(mode) 22 | k.Flags = uint16(flags) 23 | } 24 | 25 | func (iov *Iovec) SetLen(length int) { 26 | iov.Len = uint64(length) 27 | } 28 | 29 | func (msghdr *Msghdr) SetControllen(length int) { 30 | msghdr.Controllen = uint32(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetIovlen(length int) { 34 | msghdr.Iovlen = int32(length) 35 | } 36 | 37 | func (cmsg *Cmsghdr) SetLen(length int) { 38 | cmsg.Len = uint32(length) 39 | } 40 | 41 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 42 | 43 | //sys Fstat(fd int, stat *Stat_t) (err error) 44 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 45 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) 46 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT 47 | //sys Lstat(path string, stat *Stat_t) (err error) 48 | //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace 49 | //sys Stat(path string, stat *Stat_t) (err error) 50 | //sys Statfs(path string, stat *Statfs_t) (err error) 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build darwin 6 | 7 | package unix 8 | 9 | import _ "unsafe" 10 | 11 | // Implemented in the runtime package (runtime/sys_darwin.go) 12 | func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 13 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 14 | func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 15 | func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // 32-bit only 16 | func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 17 | func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 18 | func syscall_syscallPtr(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 19 | 20 | //go:linkname syscall_syscall syscall.syscall 21 | //go:linkname syscall_syscall6 syscall.syscall6 22 | //go:linkname syscall_syscall6X syscall.syscall6X 23 | //go:linkname syscall_syscall9 syscall.syscall9 24 | //go:linkname syscall_rawSyscall syscall.rawSyscall 25 | //go:linkname syscall_rawSyscall6 syscall.rawSyscall6 26 | //go:linkname syscall_syscallPtr syscall.syscallPtr 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetIovlen(length int) { 37 | msghdr.Iovlen = int32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | 44 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 45 | var writtenOut uint64 = 0 46 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 47 | 48 | written = int(writtenOut) 49 | 50 | if e1 != 0 { 51 | err = e1 52 | } 53 | return 54 | } 55 | 56 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build 386 && freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetIovlen(length int) { 37 | msghdr.Iovlen = int32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | 44 | func (d *PtraceIoDesc) SetLen(length int) { 45 | d.Len = uint32(length) 46 | } 47 | 48 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 49 | var writtenOut uint64 = 0 50 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 51 | 52 | written = int(writtenOut) 53 | 54 | if e1 != 0 { 55 | err = e1 56 | } 57 | return 58 | } 59 | 60 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 61 | 62 | func PtraceGetFsBase(pid int, fsbase *int64) (err error) { 63 | return ptracePtr(PT_GETFSBASE, pid, unsafe.Pointer(fsbase), 0) 64 | } 65 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetIovlen(length int) { 37 | msghdr.Iovlen = int32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | 44 | func (d *PtraceIoDesc) SetLen(length int) { 45 | d.Len = uint64(length) 46 | } 47 | 48 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 49 | var writtenOut uint64 = 0 50 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 51 | 52 | written = int(writtenOut) 53 | 54 | if e1 != 0 { 55 | err = e1 56 | } 57 | return 58 | } 59 | 60 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 61 | 62 | func PtraceGetFsBase(pid int, fsbase *int64) (err error) { 63 | return ptracePtr(PT_GETFSBASE, pid, unsafe.Pointer(fsbase), 0) 64 | } 65 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm && freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetIovlen(length int) { 37 | msghdr.Iovlen = int32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | 44 | func (d *PtraceIoDesc) SetLen(length int) { 45 | d.Len = uint32(length) 46 | } 47 | 48 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 49 | var writtenOut uint64 = 0 50 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 51 | 52 | written = int(writtenOut) 53 | 54 | if e1 != 0 { 55 | err = e1 56 | } 57 | return 58 | } 59 | 60 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 61 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm64 && freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetIovlen(length int) { 37 | msghdr.Iovlen = int32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | 44 | func (d *PtraceIoDesc) SetLen(length int) { 45 | d.Len = uint64(length) 46 | } 47 | 48 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 49 | var writtenOut uint64 = 0 50 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 51 | 52 | written = int(writtenOut) 53 | 54 | if e1 != 0 { 55 | err = e1 56 | } 57 | return 58 | } 59 | 60 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 61 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build riscv64 && freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetIovlen(length int) { 37 | msghdr.Iovlen = int32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | 44 | func (d *PtraceIoDesc) SetLen(length int) { 45 | d.Len = uint64(length) 46 | } 47 | 48 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 49 | var writtenOut uint64 = 0 50 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 51 | 52 | written = int(writtenOut) 53 | 54 | if e1 != 0 { 55 | err = e1 56 | } 57 | return 58 | } 59 | 60 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 61 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_hurd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build hurd 6 | 7 | package unix 8 | 9 | /* 10 | #include 11 | int ioctl(int, unsigned long int, uintptr_t); 12 | */ 13 | import "C" 14 | 15 | func ioctl(fd int, req uint, arg uintptr) (err error) { 16 | r0, er := C.ioctl(C.int(fd), C.ulong(req), C.uintptr_t(arg)) 17 | if r0 == -1 && er != nil { 18 | err = er 19 | } 20 | return 21 | } 22 | 23 | func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { 24 | r0, er := C.ioctl(C.int(fd), C.ulong(req), C.uintptr_t(uintptr(arg))) 25 | if r0 == -1 && er != nil { 26 | err = er 27 | } 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_hurd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build 386 && hurd 6 | 7 | package unix 8 | 9 | const ( 10 | TIOCGETA = 0x62251713 11 | ) 12 | 13 | type Winsize struct { 14 | Row uint16 15 | Col uint16 16 | Xpixel uint16 17 | Ypixel uint16 18 | } 19 | 20 | type Termios struct { 21 | Iflag uint32 22 | Oflag uint32 23 | Cflag uint32 24 | Lflag uint32 25 | Cc [20]uint8 26 | Ispeed int32 27 | Ospeed int32 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_illumos.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // illumos system calls not present on Solaris. 6 | 7 | //go:build amd64 && illumos 8 | 9 | package unix 10 | 11 | import ( 12 | "unsafe" 13 | ) 14 | 15 | func bytes2iovec(bs [][]byte) []Iovec { 16 | iovecs := make([]Iovec, len(bs)) 17 | for i, b := range bs { 18 | iovecs[i].SetLen(len(b)) 19 | if len(b) > 0 { 20 | iovecs[i].Base = &b[0] 21 | } else { 22 | iovecs[i].Base = (*byte)(unsafe.Pointer(&_zero)) 23 | } 24 | } 25 | return iovecs 26 | } 27 | 28 | //sys readv(fd int, iovs []Iovec) (n int, err error) 29 | 30 | func Readv(fd int, iovs [][]byte) (n int, err error) { 31 | iovecs := bytes2iovec(iovs) 32 | n, err = readv(fd, iovecs) 33 | return n, err 34 | } 35 | 36 | //sys preadv(fd int, iovs []Iovec, off int64) (n int, err error) 37 | 38 | func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) { 39 | iovecs := bytes2iovec(iovs) 40 | n, err = preadv(fd, iovecs, off) 41 | return n, err 42 | } 43 | 44 | //sys writev(fd int, iovs []Iovec) (n int, err error) 45 | 46 | func Writev(fd int, iovs [][]byte) (n int, err error) { 47 | iovecs := bytes2iovec(iovs) 48 | n, err = writev(fd, iovecs) 49 | return n, err 50 | } 51 | 52 | //sys pwritev(fd int, iovs []Iovec, off int64) (n int, err error) 53 | 54 | func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) { 55 | iovecs := bytes2iovec(iovs) 56 | n, err = pwritev(fd, iovecs, off) 57 | return n, err 58 | } 59 | 60 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) = libsocket.accept4 61 | 62 | func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) { 63 | var rsa RawSockaddrAny 64 | var len _Socklen = SizeofSockaddrAny 65 | nfd, err = accept4(fd, &rsa, &len, flags) 66 | if err != nil { 67 | return 68 | } 69 | if len > SizeofSockaddrAny { 70 | panic("RawSockaddrAny too small") 71 | } 72 | sa, err = anyToSockaddr(fd, &rsa) 73 | if err != nil { 74 | Close(nfd) 75 | nfd = 0 76 | } 77 | return 78 | } 79 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_alarm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (386 || amd64 || mips || mipsle || mips64 || mipsle || ppc64 || ppc64le || ppc || s390x || sparc64) 6 | 7 | package unix 8 | 9 | // SYS_ALARM is not defined on arm or riscv, but is available for other GOARCH 10 | // values. 11 | 12 | //sys Alarm(seconds uint) (remaining uint, err error) 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && linux && gc 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //go:noescape 12 | func gettimeofday(tv *Timeval) (err syscall.Errno) 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && gc 6 | 7 | package unix 8 | 9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 11 | 12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 13 | // fail. 14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && gc && 386 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // Underlying system call writes to newoffset via pointer. 12 | // Implemented in assembly to avoid allocation. 13 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 14 | 15 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 16 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm && gc && linux 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // Underlying system call writes to newoffset via pointer. 12 | // Implemented in assembly to avoid allocation. 13 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && gccgo && 386 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | 22 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 23 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 24 | return int(fd), err 25 | } 26 | 27 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 28 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 29 | return int(fd), err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && gccgo && arm 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build 386 && netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (msghdr *Msghdr) SetIovlen(length int) { 32 | msghdr.Iovlen = int32(length) 33 | } 34 | 35 | func (cmsg *Cmsghdr) SetLen(length int) { 36 | cmsg.Len = uint32(length) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (msghdr *Msghdr) SetIovlen(length int) { 32 | msghdr.Iovlen = int32(length) 33 | } 34 | 35 | func (cmsg *Cmsghdr) SetLen(length int) { 36 | cmsg.Len = uint32(length) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm && netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (msghdr *Msghdr) SetIovlen(length int) { 32 | msghdr.Iovlen = int32(length) 33 | } 34 | 35 | func (cmsg *Cmsghdr) SetLen(length int) { 36 | cmsg.Len = uint32(length) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm64 && netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (msghdr *Msghdr) SetIovlen(length int) { 32 | msghdr.Iovlen = int32(length) 33 | } 34 | 35 | func (cmsg *Cmsghdr) SetLen(length int) { 36 | cmsg.Len = uint32(length) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build 386 && openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (msghdr *Msghdr) SetIovlen(length int) { 32 | msghdr.Iovlen = uint32(length) 33 | } 34 | 35 | func (cmsg *Cmsghdr) SetLen(length int) { 36 | cmsg.Len = uint32(length) 37 | } 38 | 39 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 40 | // of openbsd/386 the syscall is called sysctl instead of __sysctl. 41 | const SYS___SYSCTL = SYS_SYSCTL 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (msghdr *Msghdr) SetIovlen(length int) { 32 | msghdr.Iovlen = uint32(length) 33 | } 34 | 35 | func (cmsg *Cmsghdr) SetLen(length int) { 36 | cmsg.Len = uint32(length) 37 | } 38 | 39 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 40 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 41 | const SYS___SYSCTL = SYS_SYSCTL 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm && openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (msghdr *Msghdr) SetIovlen(length int) { 32 | msghdr.Iovlen = uint32(length) 33 | } 34 | 35 | func (cmsg *Cmsghdr) SetLen(length int) { 36 | cmsg.Len = uint32(length) 37 | } 38 | 39 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 40 | // of openbsd/arm the syscall is called sysctl instead of __sysctl. 41 | const SYS___SYSCTL = SYS_SYSCTL 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm64 && openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (msghdr *Msghdr) SetIovlen(length int) { 32 | msghdr.Iovlen = uint32(length) 33 | } 34 | 35 | func (cmsg *Cmsghdr) SetLen(length int) { 36 | cmsg.Len = uint32(length) 37 | } 38 | 39 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 40 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 41 | const SYS___SYSCTL = SYS_SYSCTL 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_libc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build openbsd 6 | 7 | package unix 8 | 9 | import _ "unsafe" 10 | 11 | // Implemented in the runtime package (runtime/sys_openbsd3.go) 12 | func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 13 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 14 | func syscall_syscall10(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2 uintptr, err Errno) 15 | func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 16 | func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 17 | 18 | //go:linkname syscall_syscall syscall.syscall 19 | //go:linkname syscall_syscall6 syscall.syscall6 20 | //go:linkname syscall_syscall10 syscall.syscall10 21 | //go:linkname syscall_rawSyscall syscall.rawSyscall 22 | //go:linkname syscall_rawSyscall6 syscall.rawSyscall6 23 | 24 | func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) { 25 | return syscall_syscall10(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, 0) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_mips64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | func setTimespec(sec, nsec int64) Timespec { 8 | return Timespec{Sec: sec, Nsec: nsec} 9 | } 10 | 11 | func setTimeval(sec, usec int64) Timeval { 12 | return Timeval{Sec: sec, Usec: usec} 13 | } 14 | 15 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 16 | k.Ident = uint64(fd) 17 | k.Filter = int16(mode) 18 | k.Flags = uint16(flags) 19 | } 20 | 21 | func (iov *Iovec) SetLen(length int) { 22 | iov.Len = uint64(length) 23 | } 24 | 25 | func (msghdr *Msghdr) SetControllen(length int) { 26 | msghdr.Controllen = uint32(length) 27 | } 28 | 29 | func (msghdr *Msghdr) SetIovlen(length int) { 30 | msghdr.Iovlen = uint32(length) 31 | } 32 | 33 | func (cmsg *Cmsghdr) SetLen(length int) { 34 | cmsg.Len = uint32(length) 35 | } 36 | 37 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 38 | // of OpenBSD the syscall is called sysctl instead of __sysctl. 39 | const SYS___SYSCTL = SYS_SYSCTL 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build ppc64 && openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (msghdr *Msghdr) SetIovlen(length int) { 32 | msghdr.Iovlen = uint32(length) 33 | } 34 | 35 | func (cmsg *Cmsghdr) SetLen(length int) { 36 | cmsg.Len = uint32(length) 37 | } 38 | 39 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 40 | // of openbsd/ppc64 the syscall is called sysctl instead of __sysctl. 41 | const SYS___SYSCTL = SYS_SYSCTL 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build riscv64 && openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (msghdr *Msghdr) SetIovlen(length int) { 32 | msghdr.Iovlen = uint32(length) 33 | } 34 | 35 | func (cmsg *Cmsghdr) SetLen(length int) { 36 | cmsg.Len = uint32(length) 37 | } 38 | 39 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 40 | // of openbsd/riscv64 the syscall is called sysctl instead of __sysctl. 41 | const SYS___SYSCTL = SYS_SYSCTL 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build amd64 && solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (msghdr *Msghdr) SetIovlen(length int) { 22 | msghdr.Iovlen = int32(length) 23 | } 24 | 25 | func (cmsg *Cmsghdr) SetLen(length int) { 26 | cmsg.Len = uint32(length) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin || dragonfly || freebsd || (linux && !ppc64 && !ppc64le) || netbsd || openbsd || solaris) && gc 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 12 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (ppc64le || ppc64) && gc 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 12 | return syscall.Syscall(trap, a1, a2, a3) 13 | } 14 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 15 | return syscall.Syscall6(trap, a1, a2, a3, a4, a5, a6) 16 | } 17 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | return syscall.RawSyscall(trap, a1, a2, a3) 19 | } 20 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 21 | return syscall.RawSyscall6(trap, a1, a2, a3, a4, a5, a6) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sysvshm_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux 6 | 7 | package unix 8 | 9 | import "runtime" 10 | 11 | // SysvShmCtl performs control operations on the shared memory segment 12 | // specified by id. 13 | func SysvShmCtl(id, cmd int, desc *SysvShmDesc) (result int, err error) { 14 | if runtime.GOARCH == "arm" || 15 | runtime.GOARCH == "mips64" || runtime.GOARCH == "mips64le" { 16 | cmd |= ipc_64 17 | } 18 | 19 | return shmctl(id, cmd, desc) 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sysvshm_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (darwin && !ios) || linux 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // SysvShmAttach attaches the Sysv shared memory segment associated with the 12 | // shared memory identifier id. 13 | func SysvShmAttach(id int, addr uintptr, flag int) ([]byte, error) { 14 | addr, errno := shmat(id, addr, flag) 15 | if errno != nil { 16 | return nil, errno 17 | } 18 | 19 | // Retrieve the size of the shared memory to enable slice creation 20 | var info SysvShmDesc 21 | 22 | _, err := SysvShmCtl(id, IPC_STAT, &info) 23 | if err != nil { 24 | // release the shared memory if we can't find the size 25 | 26 | // ignoring error from shmdt as there's nothing sensible to return here 27 | shmdt(addr) 28 | return nil, err 29 | } 30 | 31 | // Use unsafe to convert addr into a []byte. 32 | b := unsafe.Slice((*byte)(unsafe.Pointer(addr)), int(info.Segsz)) 33 | return b, nil 34 | } 35 | 36 | // SysvShmDetach unmaps the shared memory slice returned from SysvShmAttach. 37 | // 38 | // It is not safe to use the slice after calling this function. 39 | func SysvShmDetach(data []byte) error { 40 | if len(data) == 0 { 41 | return EINVAL 42 | } 43 | 44 | return shmdt(uintptr(unsafe.Pointer(&data[0]))) 45 | } 46 | 47 | // SysvShmGet returns the Sysv shared memory identifier associated with key. 48 | // If the IPC_CREAT flag is specified a new segment is created. 49 | func SysvShmGet(key, size, flag int) (id int, err error) { 50 | return shmget(key, size, flag) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sysvshm_unix_other.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build darwin && !ios 6 | 7 | package unix 8 | 9 | // SysvShmCtl performs control operations on the shared memory segment 10 | // specified by id. 11 | func SysvShmCtl(id, cmd int, desc *SysvShmDesc) (result int, err error) { 12 | return shmctl(id, cmd, desc) 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/timestruct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | 7 | package unix 8 | 9 | import "time" 10 | 11 | // TimespecToNsec returns the time stored in ts as nanoseconds. 12 | func TimespecToNsec(ts Timespec) int64 { return ts.Nano() } 13 | 14 | // NsecToTimespec converts a number of nanoseconds into a Timespec. 15 | func NsecToTimespec(nsec int64) Timespec { 16 | sec := nsec / 1e9 17 | nsec = nsec % 1e9 18 | if nsec < 0 { 19 | nsec += 1e9 20 | sec-- 21 | } 22 | return setTimespec(sec, nsec) 23 | } 24 | 25 | // TimeToTimespec converts t into a Timespec. 26 | // On some 32-bit systems the range of valid Timespec values are smaller 27 | // than that of time.Time values. So if t is out of the valid range of 28 | // Timespec, it returns a zero Timespec and ERANGE. 29 | func TimeToTimespec(t time.Time) (Timespec, error) { 30 | sec := t.Unix() 31 | nsec := int64(t.Nanosecond()) 32 | ts := setTimespec(sec, nsec) 33 | 34 | // Currently all targets have either int32 or int64 for Timespec.Sec. 35 | // If there were a new target with floating point type for it, we have 36 | // to consider the rounding error. 37 | if int64(ts.Sec) != sec { 38 | return Timespec{}, ERANGE 39 | } 40 | return ts, nil 41 | } 42 | 43 | // TimevalToNsec returns the time stored in tv as nanoseconds. 44 | func TimevalToNsec(tv Timeval) int64 { return tv.Nano() } 45 | 46 | // NsecToTimeval converts a number of nanoseconds into a Timeval. 47 | func NsecToTimeval(nsec int64) Timeval { 48 | nsec += 999 // round up to microsecond 49 | usec := nsec % 1e9 / 1e3 50 | sec := nsec / 1e9 51 | if usec < 0 { 52 | usec += 1e6 53 | sec-- 54 | } 55 | return setTimeval(sec, usec) 56 | } 57 | 58 | // Unix returns the time stored in ts as seconds plus nanoseconds. 59 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 60 | return int64(ts.Sec), int64(ts.Nsec) 61 | } 62 | 63 | // Unix returns the time stored in tv as seconds plus nanoseconds. 64 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 65 | return int64(tv.Sec), int64(tv.Usec) * 1000 66 | } 67 | 68 | // Nano returns the time stored in ts as nanoseconds. 69 | func (ts *Timespec) Nano() int64 { 70 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 71 | } 72 | 73 | // Nano returns the time stored in tv as nanoseconds. 74 | func (tv *Timeval) Nano() int64 { 75 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 76 | } 77 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/unveil_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import "fmt" 8 | 9 | // Unveil implements the unveil syscall. 10 | // For more information see unveil(2). 11 | // Note that the special case of blocking further 12 | // unveil calls is handled by UnveilBlock. 13 | func Unveil(path string, flags string) error { 14 | if err := supportsUnveil(); err != nil { 15 | return err 16 | } 17 | pathPtr, err := BytePtrFromString(path) 18 | if err != nil { 19 | return err 20 | } 21 | flagsPtr, err := BytePtrFromString(flags) 22 | if err != nil { 23 | return err 24 | } 25 | return unveil(pathPtr, flagsPtr) 26 | } 27 | 28 | // UnveilBlock blocks future unveil calls. 29 | // For more information see unveil(2). 30 | func UnveilBlock() error { 31 | if err := supportsUnveil(); err != nil { 32 | return err 33 | } 34 | return unveil(nil, nil) 35 | } 36 | 37 | // supportsUnveil checks for availability of the unveil(2) system call based 38 | // on the running OpenBSD version. 39 | func supportsUnveil() error { 40 | maj, min, err := majmin() 41 | if err != nil { 42 | return err 43 | } 44 | 45 | // unveil is not available before 6.4 46 | if maj < 6 || (maj == 6 && min <= 3) { 47 | return fmt.Errorf("cannot call Unveil on OpenBSD %d.%d", maj, min) 48 | } 49 | 50 | return nil 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("arm", "arm64"). DO NOT EDIT. 2 | 3 | //go:build linux && (arm || arm64) 4 | 5 | package unix 6 | 7 | import "unsafe" 8 | 9 | // PtraceRegsArm is the registers used by arm binaries. 10 | type PtraceRegsArm struct { 11 | Uregs [18]uint32 12 | } 13 | 14 | // PtraceGetRegsArm fetches the registers used by arm binaries. 15 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { 16 | return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout)) 17 | } 18 | 19 | // PtraceSetRegsArm sets the registers used by arm binaries. 20 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { 21 | return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs)) 22 | } 23 | 24 | // PtraceRegsArm64 is the registers used by arm64 binaries. 25 | type PtraceRegsArm64 struct { 26 | Regs [31]uint64 27 | Sp uint64 28 | Pc uint64 29 | Pstate uint64 30 | } 31 | 32 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries. 33 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { 34 | return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout)) 35 | } 36 | 37 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries. 38 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { 39 | return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs)) 40 | } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_linux_arm64.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtraceRegSet("arm64"). DO NOT EDIT. 2 | 3 | package unix 4 | 5 | import "unsafe" 6 | 7 | // PtraceGetRegSetArm64 fetches the registers used by arm64 binaries. 8 | func PtraceGetRegSetArm64(pid, addr int, regsout *PtraceRegsArm64) error { 9 | iovec := Iovec{(*byte)(unsafe.Pointer(regsout)), uint64(unsafe.Sizeof(*regsout))} 10 | return ptracePtr(PTRACE_GETREGSET, pid, uintptr(addr), unsafe.Pointer(&iovec)) 11 | } 12 | 13 | // PtraceSetRegSetArm64 sets the registers used by arm64 binaries. 14 | func PtraceSetRegSetArm64(pid, addr int, regs *PtraceRegsArm64) error { 15 | iovec := Iovec{(*byte)(unsafe.Pointer(regs)), uint64(unsafe.Sizeof(*regs))} 16 | return ptracePtr(PTRACE_SETREGSET, pid, uintptr(addr), unsafe.Pointer(&iovec)) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("mips", "mips64"). DO NOT EDIT. 2 | 3 | //go:build linux && (mips || mips64) 4 | 5 | package unix 6 | 7 | import "unsafe" 8 | 9 | // PtraceRegsMips is the registers used by mips binaries. 10 | type PtraceRegsMips struct { 11 | Regs [32]uint64 12 | Lo uint64 13 | Hi uint64 14 | Epc uint64 15 | Badvaddr uint64 16 | Status uint64 17 | Cause uint64 18 | } 19 | 20 | // PtraceGetRegsMips fetches the registers used by mips binaries. 21 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error { 22 | return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout)) 23 | } 24 | 25 | // PtraceSetRegsMips sets the registers used by mips binaries. 26 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error { 27 | return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs)) 28 | } 29 | 30 | // PtraceRegsMips64 is the registers used by mips64 binaries. 31 | type PtraceRegsMips64 struct { 32 | Regs [32]uint64 33 | Lo uint64 34 | Hi uint64 35 | Epc uint64 36 | Badvaddr uint64 37 | Status uint64 38 | Cause uint64 39 | } 40 | 41 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries. 42 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error { 43 | return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout)) 44 | } 45 | 46 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries. 47 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error { 48 | return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs)) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("mipsle", "mips64le"). DO NOT EDIT. 2 | 3 | //go:build linux && (mipsle || mips64le) 4 | 5 | package unix 6 | 7 | import "unsafe" 8 | 9 | // PtraceRegsMipsle is the registers used by mipsle binaries. 10 | type PtraceRegsMipsle struct { 11 | Regs [32]uint64 12 | Lo uint64 13 | Hi uint64 14 | Epc uint64 15 | Badvaddr uint64 16 | Status uint64 17 | Cause uint64 18 | } 19 | 20 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries. 21 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { 22 | return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout)) 23 | } 24 | 25 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries. 26 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { 27 | return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs)) 28 | } 29 | 30 | // PtraceRegsMips64le is the registers used by mips64le binaries. 31 | type PtraceRegsMips64le struct { 32 | Regs [32]uint64 33 | Lo uint64 34 | Hi uint64 35 | Epc uint64 36 | Badvaddr uint64 37 | Status uint64 38 | Cause uint64 39 | } 40 | 41 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries. 42 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { 43 | return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout)) 44 | } 45 | 46 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries. 47 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { 48 | return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs)) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_x86_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("386", "amd64"). DO NOT EDIT. 2 | 3 | //go:build linux && (386 || amd64) 4 | 5 | package unix 6 | 7 | import "unsafe" 8 | 9 | // PtraceRegs386 is the registers used by 386 binaries. 10 | type PtraceRegs386 struct { 11 | Ebx int32 12 | Ecx int32 13 | Edx int32 14 | Esi int32 15 | Edi int32 16 | Ebp int32 17 | Eax int32 18 | Xds int32 19 | Xes int32 20 | Xfs int32 21 | Xgs int32 22 | Orig_eax int32 23 | Eip int32 24 | Xcs int32 25 | Eflags int32 26 | Esp int32 27 | Xss int32 28 | } 29 | 30 | // PtraceGetRegs386 fetches the registers used by 386 binaries. 31 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { 32 | return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout)) 33 | } 34 | 35 | // PtraceSetRegs386 sets the registers used by 386 binaries. 36 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { 37 | return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs)) 38 | } 39 | 40 | // PtraceRegsAmd64 is the registers used by amd64 binaries. 41 | type PtraceRegsAmd64 struct { 42 | R15 uint64 43 | R14 uint64 44 | R13 uint64 45 | R12 uint64 46 | Rbp uint64 47 | Rbx uint64 48 | R11 uint64 49 | R10 uint64 50 | R9 uint64 51 | R8 uint64 52 | Rax uint64 53 | Rcx uint64 54 | Rdx uint64 55 | Rsi uint64 56 | Rdi uint64 57 | Orig_rax uint64 58 | Rip uint64 59 | Cs uint64 60 | Eflags uint64 61 | Rsp uint64 62 | Ss uint64 63 | Fs_base uint64 64 | Gs_base uint64 65 | Ds uint64 66 | Es uint64 67 | Fs uint64 68 | Gs uint64 69 | } 70 | 71 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries. 72 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { 73 | return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout)) 74 | } 75 | 76 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries. 77 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { 78 | return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs)) 79 | } 80 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | This project is covered by two different licenses: MIT and Apache. 3 | 4 | #### MIT License #### 5 | 6 | The following files were ported to Go from C files of libyaml, and thus 7 | are still covered by their original MIT license, with the additional 8 | copyright staring in 2011 when the project was ported over: 9 | 10 | apic.go emitterc.go parserc.go readerc.go scannerc.go 11 | writerc.go yamlh.go yamlprivateh.go 12 | 13 | Copyright (c) 2006-2010 Kirill Simonov 14 | Copyright (c) 2006-2011 Kirill Simonov 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining a copy of 17 | this software and associated documentation files (the "Software"), to deal in 18 | the Software without restriction, including without limitation the rights to 19 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 20 | of the Software, and to permit persons to whom the Software is furnished to do 21 | so, subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be included in all 24 | copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 | SOFTWARE. 33 | 34 | ### Apache License ### 35 | 36 | All the remaining project files are covered by the Apache license: 37 | 38 | Copyright (c) 2011-2019 Canonical Ltd 39 | 40 | Licensed under the Apache License, Version 2.0 (the "License"); 41 | you may not use this file except in compliance with the License. 42 | You may obtain a copy of the License at 43 | 44 | http://www.apache.org/licenses/LICENSE-2.0 45 | 46 | Unless required by applicable law or agreed to in writing, software 47 | distributed under the License is distributed on an "AS IS" BASIS, 48 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 49 | See the License for the specific language governing permissions and 50 | limitations under the License. 51 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2016 Canonical Ltd. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/writerc.go: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2011-2019 Canonical Ltd 3 | // Copyright (c) 2006-2010 Kirill Simonov 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files (the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | // of the Software, and to permit persons to whom the Software is furnished to do 10 | // so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | package yaml 24 | 25 | // Set the writer error and return false. 26 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 27 | emitter.error = yaml_WRITER_ERROR 28 | emitter.problem = problem 29 | return false 30 | } 31 | 32 | // Flush the output buffer. 33 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 34 | if emitter.write_handler == nil { 35 | panic("write handler not set") 36 | } 37 | 38 | // Check if the buffer is empty. 39 | if emitter.buffer_pos == 0 { 40 | return true 41 | } 42 | 43 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 44 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 45 | } 46 | emitter.buffer_pos = 0 47 | return true 48 | } 49 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/cespare/xxhash/v2 v2.3.0 2 | ## explicit; go 1.11 3 | github.com/cespare/xxhash/v2 4 | # github.com/davecgh/go-spew v1.1.1 5 | ## explicit 6 | github.com/davecgh/go-spew/spew 7 | # github.com/fmstephe/flib v0.0.1 8 | ## explicit; go 1.19 9 | github.com/fmstephe/flib/fmath 10 | github.com/fmstephe/flib/funsafe 11 | # github.com/pmezard/go-difflib v1.0.0 12 | ## explicit 13 | github.com/pmezard/go-difflib/difflib 14 | # github.com/stretchr/testify v1.8.0 15 | ## explicit; go 1.13 16 | github.com/stretchr/testify/assert 17 | github.com/stretchr/testify/require 18 | # golang.org/x/sys v0.18.0 19 | ## explicit; go 1.18 20 | golang.org/x/sys/unix 21 | # gopkg.in/yaml.v3 v3.0.1 22 | ## explicit 23 | gopkg.in/yaml.v3 24 | --------------------------------------------------------------------------------