├── doc ├── dates.txt ├── dump.txt ├── help.txt ├── links.txt ├── logo.txt ├── spec.txt ├── test.txt ├── todo.txt ├── units-frink.txt └── units-gnu.txt ├── go.mod ├── go.sum ├── license ├── numb.go ├── pkg ├── ast │ ├── ast.go │ └── ast_test.go ├── dimension │ ├── dimension.go │ ├── measure.go │ └── measure_test.go ├── funcs │ ├── arithmetic.go │ ├── funcs.go │ ├── logarithm.go │ └── trigonometry.go ├── parser │ ├── parser.go │ ├── parser_error_test.go │ └── parser_test.go ├── ratutils │ ├── ratutils.go │ └── ratutils_test.go ├── runtime │ ├── builtin.txt │ ├── runtime.go │ ├── runtime_test.go │ └── testdata │ │ ├── capital.txt │ │ ├── convert.txt │ │ ├── format.txt │ │ ├── functions.txt │ │ ├── operators.txt │ │ ├── units.txt │ │ └── xkcd.txt ├── scanner │ ├── scanner.go │ └── scanner_test.go ├── timeutil │ ├── parse.go │ ├── parse_test.go │ └── timezone.go ├── token │ └── token.go ├── unit │ ├── convert.go │ ├── def.go │ └── units.go └── value │ ├── format.go │ ├── number.go │ ├── time.go │ ├── unit.go │ ├── value.go │ └── value_test.go ├── readme.txt └── vendor ├── golang.org └── x │ ├── sys │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── internal │ │ └── unsafeheader │ │ │ └── unsafeheader.go │ ├── plan9 │ │ ├── asm.s │ │ ├── asm_plan9_386.s │ │ ├── asm_plan9_amd64.s │ │ ├── asm_plan9_arm.s │ │ ├── const_plan9.go │ │ ├── dir_plan9.go │ │ ├── env_plan9.go │ │ ├── errors_plan9.go │ │ ├── mkall.sh │ │ ├── mkerrors.sh │ │ ├── mksysnum_plan9.sh │ │ ├── pwd_go15_plan9.go │ │ ├── pwd_plan9.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── str.go │ │ ├── syscall.go │ │ ├── syscall_plan9.go │ │ ├── zsyscall_plan9_386.go │ │ ├── zsyscall_plan9_amd64.go │ │ ├── zsyscall_plan9_arm.go │ │ └── zsysnum_plan9.go │ ├── 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_linux_386.s │ │ ├── asm_linux_amd64.s │ │ ├── asm_linux_arm.s │ │ ├── asm_linux_arm64.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 │ │ ├── errors_freebsd_386.go │ │ ├── errors_freebsd_amd64.go │ │ ├── errors_freebsd_arm.go │ │ ├── errors_freebsd_arm64.go │ │ ├── fcntl.go │ │ ├── fcntl_darwin.go │ │ ├── fcntl_linux_32bit.go │ │ ├── fdset.go │ │ ├── fstatfs_zos.go │ │ ├── gccgo.go │ │ ├── gccgo_c.c │ │ ├── gccgo_linux_amd64.go │ │ ├── ioctl.go │ │ ├── ioctl_linux.go │ │ ├── ioctl_zos.go │ │ ├── mkall.sh │ │ ├── mkerrors.sh │ │ ├── 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 │ │ ├── str.go │ │ ├── syscall.go │ │ ├── syscall_aix.go │ │ ├── syscall_aix_ppc.go │ │ ├── syscall_aix_ppc64.go │ │ ├── syscall_bsd.go │ │ ├── syscall_darwin.1_12.go │ │ ├── syscall_darwin.1_13.go │ │ ├── syscall_darwin.go │ │ ├── syscall_darwin_386.go │ │ ├── syscall_darwin_amd64.go │ │ ├── syscall_darwin_arm.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_illumos.go │ │ ├── syscall_linux.go │ │ ├── syscall_linux_386.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_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_mips64.go │ │ ├── syscall_solaris.go │ │ ├── syscall_solaris_amd64.go │ │ ├── syscall_unix.go │ │ ├── syscall_unix_gc.go │ │ ├── syscall_unix_gc_ppc64x.go │ │ ├── syscall_zos_s390x.go │ │ ├── timestruct.go │ │ ├── unveil_openbsd.go │ │ ├── xattr_bsd.go │ │ ├── zerrors_aix_ppc.go │ │ ├── zerrors_aix_ppc64.go │ │ ├── zerrors_darwin_386.go │ │ ├── zerrors_darwin_amd64.go │ │ ├── zerrors_darwin_arm.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_linux.go │ │ ├── zerrors_linux_386.go │ │ ├── zerrors_linux_amd64.go │ │ ├── zerrors_linux_arm.go │ │ ├── zerrors_linux_arm64.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_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_386.1_13.go │ │ ├── zsyscall_darwin_386.1_13.s │ │ ├── zsyscall_darwin_386.go │ │ ├── zsyscall_darwin_386.s │ │ ├── zsyscall_darwin_amd64.1_13.go │ │ ├── zsyscall_darwin_amd64.1_13.s │ │ ├── zsyscall_darwin_amd64.go │ │ ├── zsyscall_darwin_amd64.s │ │ ├── zsyscall_darwin_arm.1_13.go │ │ ├── zsyscall_darwin_arm.1_13.s │ │ ├── zsyscall_darwin_arm.go │ │ ├── zsyscall_darwin_arm.s │ │ ├── zsyscall_darwin_arm64.1_13.go │ │ ├── zsyscall_darwin_arm64.1_13.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_illumos_amd64.go │ │ ├── zsyscall_linux.go │ │ ├── zsyscall_linux_386.go │ │ ├── zsyscall_linux_amd64.go │ │ ├── zsyscall_linux_arm.go │ │ ├── zsyscall_linux_arm64.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_amd64.go │ │ ├── zsyscall_openbsd_arm.go │ │ ├── zsyscall_openbsd_arm64.go │ │ ├── zsyscall_openbsd_mips64.go │ │ ├── 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 │ │ ├── zsysnum_darwin_386.go │ │ ├── zsysnum_darwin_amd64.go │ │ ├── zsysnum_darwin_arm.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_linux_386.go │ │ ├── zsysnum_linux_amd64.go │ │ ├── zsysnum_linux_arm.go │ │ ├── zsysnum_linux_arm64.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_zos_s390x.go │ │ ├── ztypes_aix_ppc.go │ │ ├── ztypes_aix_ppc64.go │ │ ├── ztypes_darwin_386.go │ │ ├── ztypes_darwin_amd64.go │ │ ├── ztypes_darwin_arm.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_illumos_amd64.go │ │ ├── ztypes_linux.go │ │ ├── ztypes_linux_386.go │ │ ├── ztypes_linux_amd64.go │ │ ├── ztypes_linux_arm.go │ │ ├── ztypes_linux_arm64.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_solaris_amd64.go │ │ └── ztypes_zos_s390x.go │ └── windows │ │ ├── aliases.go │ │ ├── dll_windows.go │ │ ├── empty.s │ │ ├── env_windows.go │ │ ├── eventlog.go │ │ ├── exec_windows.go │ │ ├── memory_windows.go │ │ ├── mkerrors.bash │ │ ├── mkknownfolderids.bash │ │ ├── mksyscall.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── security_windows.go │ │ ├── service.go │ │ ├── setupapierrors_windows.go │ │ ├── str.go │ │ ├── syscall.go │ │ ├── syscall_windows.go │ │ ├── types_windows.go │ │ ├── types_windows_386.go │ │ ├── types_windows_amd64.go │ │ ├── types_windows_arm.go │ │ ├── types_windows_arm64.go │ │ ├── zerrors_windows.go │ │ ├── zknownfolderids_windows.go │ │ └── zsyscall_windows.go │ └── term │ ├── AUTHORS │ ├── CONTRIBUTING.md │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── term.go │ ├── term_plan9.go │ ├── term_unix.go │ ├── term_unix_aix.go │ ├── term_unix_bsd.go │ ├── term_unix_linux.go │ ├── term_unix_solaris.go │ ├── term_unix_zos.go │ ├── term_unsupported.go │ ├── term_windows.go │ └── terminal.go └── modules.txt /doc/dates.txt: -------------------------------------------------------------------------------- 1 | # adding subtracting 2 | 3 | 10 June + 3 weeks | 1 July 4 | April 1, 2019 − 3 months 5 days | 25 December 2018 5 | Yesterday + 1 week | 11 June 6 | Today − 1 month | 5 May 7 | 3:35 am + 7 hours 15 minutes | 10:50 am 8 | 12/02/1988 + 32 years | 12 February 2020 9 | 01.05.2005 + 3 years 2 months 3 weeks | 22 July 2008 10 | 3 weeks after March 14, 2019 | 4 April 2019 11 | 12 | # intervals 13 | 14 | March 20 to June 5 | 11 weeks 15 | 16 | March 20 to June 5 in days | 77 days 17 | Days between March 20 and June 5 | 77 days 18 | 19 | 17:30 to 20:45 | 3 hours 15 min 20 | 1978 to 2021 | 42 years 21 | 22 | # points 23 | today + 3 weeks | 24 December (for example) 24 | now + 3 hours 15 minutes | 7:00 pm (for example) 25 | days until December 25 | 22 days 26 | 27 | # workdays 28 | 29 | workdays in 3 weeks | 15 workdays 30 | 10 March to 17 March in workdays | 5 workdays 31 | workdays from April 12 to June 15 | 45 workdays 32 | $500/workday × 4 weeks | $10,000.00 33 | 34 | 35 | # unspecified years 36 | # In December 2019 37 | 38 | // next year is assumed, as the nearest January is in the future 39 | January 12 + 3 weeks | 2 February 2020 40 | 41 | // this year is assumed, as the month is still recently in the past 42 | November 1 - 5 days | 27 October 2019 43 | -------------------------------------------------------------------------------- /doc/dump.txt: -------------------------------------------------------------------------------- 1 | # implicit multiplication rules 2 | 3 | Implicit multiplication applies only if 4 | the right-hand side is a word: 5 | 6 | 10 kg 7 | (1000 + 1) nights 8 | foo(123) metre 9 | 1 thousand puppies 10 | 11 | Having global implicit multiplication 12 | leads to ambiguity between function calls 13 | and grouping parantheses: 14 | 15 | foo(bar) 16 | # foo * (bar) multiplication 17 | # foo(bar) ... or function call? 18 | 19 | which `frink` had to resolve by 20 | introducing square brackets for function calls. 21 | 22 | Besides, implicit multiplication's sole purpose is 23 | to make unit operations look more "natural". 24 | 25 | 26 | 27 | # implicit multiplication precedence 28 | 29 | While some projects (like `insect`, `mathjs`) 30 | have a higher precedence 31 | for implicit multiplication than division 32 | to prevent certain confusion, like: 33 | 34 | # how many pieces do i get if I split 35 | # 1 metre rope so that each has 20 cm 36 | 1 m / 20 cm = 5 37 | 38 | this still causes misunderstandings when dealing 39 | with multidimensional units: 40 | 41 | # how much time does it take to download 42 | # 10 GB file over 10 MB/s broadband 43 | 10GB / 10MB/s 44 | 45 | Another example: 46 | 47 | feet : 1/3 yard 48 | # 1 / (3 yard) = 0.33 yard^-1 (incorrect) 49 | # (1 / 3) yard = 0.33 yard (correct 50 | 51 | Hence numb's implicit multiplication precedence is 52 | the same as the explicit multiplication and division 53 | (as in `frink`). 54 | -------------------------------------------------------------------------------- /doc/links.txt: -------------------------------------------------------------------------------- 1 | https://en.wikipedia.org/wiki/Burning_of_Parliament 2 | https://en.wikipedia.org/wiki/Conversion_of_units 3 | https://en.wikipedia.org/wiki/Dimensional_analysis 4 | https://en.wikipedia.org/wiki/Dimensionless_quantity 5 | https://en.wikipedia.org/wiki/Imperial_units 6 | https://en.wikipedia.org/wiki/Imperial_units 7 | https://en.wikipedia.org/wiki/International_yard_and_pound 8 | https://en.wikipedia.org/wiki/List_of_humorous_units_of_measurement 9 | https://en.wikipedia.org/wiki/List_of_unusual_units_of_measurement 10 | https://en.wikipedia.org/wiki/Mass_versus_weight 11 | https://en.wikipedia.org/wiki/Module:Convert/data 12 | https://en.wikipedia.org/wiki/Non-SI_units_mentioned_in_the_SI 13 | https://en.wikipedia.org/wiki/Nth_root 14 | https://en.wikipedia.org/wiki/Pint 15 | https://en.wikipedia.org/wiki/Pint 16 | https://en.wikipedia.org/wiki/United_States_customary_units 17 | 18 | https://github.com/Qalculate/libqalculate 19 | https://github.com/antonmedv/numbr 20 | https://github.com/araddon/dateparse 21 | https://github.com/hgrecco/pint 22 | https://github.com/josdejong/mathjs 23 | https://github.com/josdejong/mathjs/issues/792 24 | https://github.com/nikolaeu/numi/wiki/Documentation 25 | https://github.com/sharkdp/insect 26 | 27 | https://pypi.org/project/numericalunits/ 28 | https://support.google.com/websearch/answer/3284611 29 | https://www.gnu.org/software/bc/ 30 | https://www.gnu.org/software/units/ 31 | https://frinklang.org/ 32 | http://stateoftheunit.com/ 33 | https://documentation.soulver.app/ 34 | 35 | https://news.ycombinator.com/item?id=25657311 # discussion: gnu units 36 | https://news.ycombinator.com/item?id=26624386 # discussion: numi 37 | -------------------------------------------------------------------------------- /doc/logo.txt: -------------------------------------------------------------------------------- 1 | rectangles (figlet): 2 | _ 3 | ___ _ _ _____| |_ 4 | | | | | | . | 5 | |_|_|___|_|_|_|___| 6 | 7 | variations: 8 | 9 | ┌┐ 10 | ┌─┬┬┬──┤└┐ 11 | └┴┴─┴┴┴┴─┘ 12 | 13 | ╓┐ 14 | ╓─╥┬╥──╢└┐ 15 | ╙┴╨─╨┴┴╨─┘ 16 | 17 | ┌┐ 18 | ┌─┬┬┬──┤└╮ 19 | └┴┴─┴┴┴┴─╯ 20 | 21 | ┌┐ 22 | ╭─┬┬┬──┤└╮ 23 | ╰┴┴─┴┴┴┴─╯ 24 | 25 | ╭╮ 26 | ╭─┬┬┬──┤└╮ 27 | ╰┴┴─┴┴┴┴─╯ 28 | -------------------------------------------------------------------------------- /doc/spec.txt: -------------------------------------------------------------------------------- 1 | expr : expr `in` fmt 2 | expr : expr ; implicit multiplication 3 | expr : expr op expr 4 | expr : `+` | `-` expr 5 | expr : `(` expr `)` 6 | expr : num 7 | expr : id 8 | expr : id (`=` expr 9 | expr : id `:` expr 10 | expr : id `(` args `)` ; function call 11 | 12 | args : expr | args `,` expr 13 | 14 | op : `+` | `-` | `*` | `to` ... 15 | 16 | id : idw | ids 17 | idw : L (L | N | `_`)* 18 | ids : Cs | `%` 19 | 20 | fmt : L (L | `/` | `_`)* 21 | 22 | num : int | hex | oct | bin 23 | int : [0-9]+ 24 | hex : `0x` [0-f]+ 25 | oct : `0o` [0-7]+ 26 | bin : `0b` [01]+ 27 | 28 | L : unicode letter 29 | N : unicode number 30 | Cs : unicode currency symbol 31 | -------------------------------------------------------------------------------- /doc/test.txt: -------------------------------------------------------------------------------- 1 | go test ./... -coverprofile=cover.out 2 | # cross-package 3 | go test ./... -coverpkg $(go list ./pkg... | tr '\n' ',') -coverprofile=cover.out 4 | go tool cover -html=cover.out -o coverage.html 5 | -------------------------------------------------------------------------------- /doc/todo.txt: -------------------------------------------------------------------------------- 1 | - refine output formatter 2 | - documentation 3 | - revise help.txt 4 | - embedded documentation 5 | - list units/functions documentation 6 | - .help 7 | - more time parsers (rfc/iso/etc) 8 | - functions 9 | - round to decimals # round(1.234, 2) -> 1.2 10 | - financial 11 | - tool to update currencies 12 | - rational power? # 2^0.5 13 | - complex numbers? 14 | - syntax for arrays? 15 | makes easier to write function that break units. 16 | for ex: hour/min/sec, foot/inch 17 | - syntax for lambdas? 18 | to write custom functions & declare non-linear units 19 | - handling dimensionless units properly? 20 | -------------------------------------------------------------------------------- /doc/units-gnu.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkanaev/numb/58a45ba0e56608ad897a15fe6e52198aeb9dba06/doc/units-gnu.txt -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/nkanaev/numb 2 | 3 | go 1.16 4 | 5 | require ( 6 | golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 // indirect 7 | golang.org/x/term v0.0.0-20210422114643-f5beecf764ed 8 | ) 9 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 2 | golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 h1:dXfMednGJh/SUUFjTLsWJz3P+TQt9qnR11GgeI3vWKs= 3 | golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 4 | golang.org/x/term v0.0.0-20210422114643-f5beecf764ed h1:Ei4bQjjpYUsS4efOUz+5Nz++IVkHk87n2zBA0NxBWc0= 5 | golang.org/x/term v0.0.0-20210422114643-f5beecf764ed/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 6 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Nazar Kanaev (nkanaev@live.com) 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 | -------------------------------------------------------------------------------- /pkg/ast/ast_test.go: -------------------------------------------------------------------------------- 1 | package ast 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/nkanaev/numb/pkg/token" 7 | "github.com/nkanaev/numb/pkg/value" 8 | ) 9 | 10 | func TestASTLiteral(t *testing.T) { 11 | root := &Literal{value.Int64(123)} 12 | val, err := root.Eval(nil) 13 | if err != nil { 14 | t.Fatal(err) 15 | } 16 | have := val.String() 17 | want := "123" 18 | if have != want { 19 | t.Fatalf("\nwant: %s\nhave: %s", want, have) 20 | } 21 | } 22 | 23 | func TestASTBinOPEval(t *testing.T) { 24 | testcases := []struct { 25 | str string 26 | tok token.Token 27 | }{ 28 | {"8", token.ADD}, 29 | {"4", token.SUB}, 30 | {"12", token.MUL}, 31 | {"3", token.QUO}, 32 | {"24", token.SHL}, 33 | {"1", token.SHR}, 34 | {"2", token.AND}, 35 | {"6", token.OR}, 36 | {"4", token.XOR}, 37 | {"0", token.REM}, 38 | {"36", token.EXP}, 39 | } 40 | for _, testcase := range testcases { 41 | root := &BinOP{ 42 | Lhs: &Literal{value.Int64(6)}, 43 | Rhs: &Literal{value.Int64(2)}, 44 | Op: testcase.tok, 45 | } 46 | val, err := root.Eval(nil) 47 | if err != nil { 48 | t.Fatal(err) 49 | } 50 | have := val.String() 51 | want := testcase.str 52 | if have != want { 53 | t.Errorf("\nexpr: %s\nwant: %s\nhave: %s", root, want, have) 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /pkg/dimension/dimension.go: -------------------------------------------------------------------------------- 1 | package dimension 2 | 3 | type Basis uint 4 | 5 | const ( 6 | Mass Basis = iota 7 | Length 8 | Time 9 | Current 10 | Temperature 11 | LuminousIntensity 12 | AmountOfSubstance 13 | Digital 14 | Currency 15 | 16 | end_basis 17 | ) 18 | 19 | type Dimension [9]int 20 | 21 | func (d1 Dimension) Exp(x int) Dimension { 22 | for b := Basis(0); b < end_basis; b++ { 23 | d1[b] *= x 24 | } 25 | return d1 26 | } 27 | 28 | func (d1 Dimension) Add(d2 Dimension) Dimension { 29 | for b := Basis(0); b < end_basis; b++ { 30 | d1[b] += d2[b] 31 | } 32 | return d1 33 | } 34 | 35 | func (d1 Dimension) Equals(d2 Dimension) bool { 36 | for b := Basis(0); b < end_basis; b++ { 37 | if d1[b] != d2[b] { 38 | return false 39 | } 40 | } 41 | return true 42 | } 43 | 44 | func (d1 Dimension) IsPure() bool { 45 | return d1.Equals(DIMENSIONLESS) 46 | } 47 | 48 | func (d1 Dimension) Measure() string { 49 | for name, dim := range Measures { 50 | if dim == d1 { 51 | return name 52 | } 53 | } 54 | return "unknown" 55 | } 56 | 57 | var ( 58 | DIMENSIONLESS = Dimension{} 59 | LENGTH = Dimension{Length: 1} 60 | TIME = Dimension{Time: 1} 61 | MASS = Dimension{Mass: 1} 62 | ELECTRIC_CURRENT = Dimension{Current: 1} 63 | TEMPERATURE = Dimension{Temperature: 1} 64 | LUMINOUS_INTENSITY = Dimension{LuminousIntensity: 1} 65 | AMOUNT_OF_SUBSTANCE = Dimension{AmountOfSubstance: 1} 66 | DIGITAL = Dimension{Digital: 1} 67 | CURRENCY = Dimension{Currency: 1} 68 | ) 69 | -------------------------------------------------------------------------------- /pkg/dimension/measure_test.go: -------------------------------------------------------------------------------- 1 | package dimension 2 | 3 | import "testing" 4 | 5 | func TestMeasuresUnique(t *testing.T) { 6 | track := make(map[Dimension]string) 7 | for name, dim := range Measures { 8 | if oldname, seen := track[dim]; seen { 9 | t.Errorf("measure `%s` has the same dimension as `%s`", name, oldname) 10 | } else { 11 | track[dim] = name 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /pkg/funcs/funcs.go: -------------------------------------------------------------------------------- 1 | package funcs 2 | 3 | import "github.com/nkanaev/numb/pkg/value" 4 | 5 | type Func func(...value.Value) (value.Value, error) 6 | 7 | var db = map[string]Func{ 8 | "sin": Sin, 9 | "cos": Cos, 10 | "tan": Tan, 11 | "asin": Asin, 12 | "acos": Acos, 13 | "atan": Atan, 14 | 15 | "log": Log, 16 | "log2": Log2, 17 | "log10": Log10, 18 | "sqrt": Sqrt, 19 | 20 | "ceil": Ceil, 21 | "floor": Floor, 22 | "trunc": Trunc, 23 | "round": Round, 24 | "abs": Abs, 25 | 26 | "gcd": GCD, 27 | "lcm": LCM, 28 | } 29 | 30 | func Get(x string) *Func { 31 | if fn, ok := db[x]; ok { 32 | return &fn 33 | } 34 | return nil 35 | } 36 | 37 | func nop(args ...value.Value) value.Value { 38 | return value.Int64(1) 39 | } 40 | -------------------------------------------------------------------------------- /pkg/funcs/logarithm.go: -------------------------------------------------------------------------------- 1 | package funcs 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | 7 | "github.com/nkanaev/numb/pkg/value" 8 | ) 9 | 10 | func logF(fn func(float64) float64, args ...value.Value) (value.Value, error) { 11 | if len(args) != 1 { 12 | return nil, fmt.Errorf("expected 1 argument, got %d", len(args)) 13 | } 14 | arg := args[0] 15 | 16 | num, ok := arg.(value.Number) 17 | if !ok { 18 | return nil, fmt.Errorf("expected number, got %s", value.Type(arg)) 19 | } 20 | 21 | f64, exact := num.Num.Float64() 22 | if !exact && math.IsInf(f64, 0) { 23 | return nil, fmt.Errorf("%s magnitude is too large", arg) 24 | } 25 | 26 | return value.Float64(fn(f64)), nil 27 | } 28 | 29 | func Log(args ...value.Value) (value.Value, error) { 30 | return logF(math.Log, args...) 31 | } 32 | 33 | func Log2(args ...value.Value) (value.Value, error) { 34 | return logF(math.Log2, args...) 35 | } 36 | 37 | func Log10(args ...value.Value) (value.Value, error) { 38 | return logF(math.Log10, args...) 39 | } 40 | 41 | func Sqrt(args ...value.Value) (value.Value, error) { 42 | return logF(math.Sqrt, args...) 43 | } 44 | -------------------------------------------------------------------------------- /pkg/funcs/trigonometry.go: -------------------------------------------------------------------------------- 1 | package funcs 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | "math/big" 7 | 8 | "github.com/nkanaev/numb/pkg/unit" 9 | "github.com/nkanaev/numb/pkg/value" 10 | ) 11 | 12 | func trigOp(fn func(float64) float64, inUnit, outUnit bool, args ...value.Value) (value.Value, error) { 13 | if len(args) != 1 { 14 | return nil, fmt.Errorf("expected 1 argument, got %d", len(args)) 15 | } 16 | arg := args[0] 17 | 18 | var num *big.Rat 19 | switch arg.(type) { 20 | case value.Number: 21 | num = arg.(value.Number).Num 22 | case value.Unit: 23 | if !inUnit { 24 | return nil, fmt.Errorf("expected number, got %s", value.Type(arg)) 25 | } 26 | arg := arg.(value.Unit) 27 | var err error 28 | num, err = unit.Convert(arg.Num, arg.Units, unit.Must("rad")) 29 | if err != nil { 30 | return nil, err 31 | } 32 | default: 33 | return nil, fmt.Errorf("unsupported type: %s", value.Type(arg)) 34 | } 35 | 36 | f64, exact := num.Float64() 37 | if !exact && math.IsInf(f64, 0) { 38 | return nil, fmt.Errorf("%s magnitude is too large", arg) 39 | } 40 | 41 | if outUnit { 42 | return value.Unit{ 43 | Num: new(big.Rat).SetFloat64(fn(f64)), 44 | Units: unit.Must("rad"), 45 | }, nil 46 | } 47 | return value.Float64(fn(f64)), nil 48 | } 49 | 50 | func Sin(args ...value.Value) (value.Value, error) { 51 | return trigOp(math.Sin, true, false, args...) 52 | } 53 | 54 | func Cos(args ...value.Value) (value.Value, error) { 55 | return trigOp(math.Cos, true, false, args...) 56 | } 57 | 58 | func Tan(args ...value.Value) (value.Value, error) { 59 | return trigOp(math.Tan, true, false, args...) 60 | } 61 | 62 | func Asin(args ...value.Value) (value.Value, error) { 63 | return trigOp(math.Asin, false, true, args...) 64 | } 65 | 66 | func Acos(args ...value.Value) (value.Value, error) { 67 | return trigOp(math.Acos, false, true, args...) 68 | } 69 | 70 | func Atan(args ...value.Value) (value.Value, error) { 71 | return trigOp(math.Atan, false, true, args...) 72 | } 73 | -------------------------------------------------------------------------------- /pkg/parser/parser_error_test.go: -------------------------------------------------------------------------------- 1 | package parser 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | ) 7 | 8 | type poserror interface { 9 | error 10 | Pos() (int, int) 11 | } 12 | 13 | var errortestcases = map[string]struct { 14 | expr, err string 15 | start, end int 16 | }{ 17 | "lsh": { 18 | expr: "1 = 2", err: "expected >", start: 4, 22 | }, 23 | "dangling_curly": { 24 | expr: " {123", err: "date :: }", start: 3, 25 | }, 26 | "notident": { 27 | expr: "!varname", err: "unexpected", start: 1, 28 | }, 29 | "notassign": { 30 | expr: "x === 2", err: "unexpected", start: 4, 31 | }, 32 | "invaliddate": { 33 | expr: "{notadate}", err: "unknown time format", start: 1, end: 10, 34 | }, 35 | // leftover after parsing expression 36 | "notend": { 37 | expr: "foo(bar) 123", err: "invalid syntax", start: 10, 38 | }, 39 | "unclosedfunction": { 40 | expr: "gcd(1, 2", err: "end of line :: )", start: 9, 41 | }, 42 | "functionargumentemptyarg1": { 43 | expr: "foo(,bar)", err: "missing expression before comma", start: 5, 44 | }, 45 | "functionargumentemptyarg2": { 46 | expr: "foo(bar,,baz)", err: "missing expression before comma", start: 9, 47 | }, 48 | "invalidformat": { 49 | expr: "123 in ???", err: "unexpected symbol :: ?", start: 8, 50 | }, 51 | } 52 | 53 | func TestParserErrors(t *testing.T) { 54 | for name, tc := range errortestcases { 55 | tc := tc 56 | t.Run(name, func(t *testing.T) { 57 | t.Parallel() 58 | 59 | node, err := Parse(tc.expr) 60 | if err == nil { 61 | t.Fatalf( 62 | "expected error, got result\nexpr: %s\nerr: %s\nresult: %s", 63 | tc.expr, tc.err, node, 64 | ) 65 | } 66 | poserr, ok := err.(poserror) 67 | if !ok { 68 | t.Fatalf("error missing pos info: %s", err.Error()) 69 | } 70 | start, end := poserr.Pos() 71 | 72 | // NOTE: error positions are 0-indexed, but tests use 1-indexed 73 | start, end = start+1, end+1 74 | if tc.start != 0 && tc.start != start { 75 | t.Fatalf( 76 | "error start position does not match\n"+ 77 | "error: %s\nexpr: %#v\nwant: %d\nhave: %d", 78 | err, tc.expr, tc.start, start, 79 | ) 80 | } 81 | if tc.end != 0 && tc.end != end { 82 | t.Fatalf( 83 | "error start position does not match\n"+ 84 | "error: %s\nexpr: %s\nwant: %d\nhave: %d", 85 | err, tc.expr, tc.end, end, 86 | ) 87 | } 88 | for _, mention := range strings.Split(tc.err, "::") { 89 | mention := strings.TrimSpace(mention) 90 | if strings.Index(err.Error(), mention) == -1 { 91 | t.Fatalf("error `%s` does not mention `%s`", err, mention) 92 | } 93 | } 94 | }) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /pkg/parser/parser_test.go: -------------------------------------------------------------------------------- 1 | package parser 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | 7 | "github.com/nkanaev/numb/pkg/ast" 8 | "github.com/nkanaev/numb/pkg/ratutils" 9 | "github.com/nkanaev/numb/pkg/token" 10 | "github.com/nkanaev/numb/pkg/value" 11 | ) 12 | 13 | var tests = map[string]struct { 14 | name string 15 | expr string 16 | want ast.Node 17 | }{ 18 | "BinOp": { 19 | expr: "1 + 2", 20 | want: &ast.BinOP{ 21 | Lhs: &ast.Literal{value.Int64(1)}, 22 | Rhs: &ast.Literal{value.Int64(2)}, 23 | Op: token.ADD, 24 | }, 25 | }, 26 | "Paren": { 27 | expr: "(1 + 2) * 3", 28 | want: &ast.BinOP{ 29 | Lhs: &ast.ParenExpr{ 30 | Expr: &ast.BinOP{ 31 | Lhs: &ast.Literal{value.Int64(1)}, 32 | Rhs: &ast.Literal{value.Int64(2)}, 33 | Op: token.ADD, 34 | }, 35 | }, 36 | Rhs: &ast.Literal{value.Int64(3)}, 37 | Op: token.MUL, 38 | }, 39 | }, 40 | "Unary": { 41 | expr: "-100", 42 | want: &ast.Unary{Op: token.SUB, Expr: &ast.Literal{value.Int64(100)}}, 43 | }, 44 | "BitOps": { 45 | expr: "0b101 and 0b111", 46 | want: &ast.BinOP{ 47 | Lhs: &ast.Literal{value.Number{Num: ratutils.Must("5"), Fmt: value.BIN}}, 48 | Rhs: &ast.Literal{value.Number{Num: ratutils.Must("7"), Fmt: value.BIN}}, 49 | Op: token.AND, 50 | }, 51 | }, 52 | "Assignment": { 53 | expr: "foo = 123", 54 | want: &ast.Assign{ 55 | Name: "foo", 56 | Expr: &ast.Literal{value.Int64(123)}, 57 | }, 58 | }, 59 | "Var": { 60 | expr: "foo + 123", 61 | want: &ast.BinOP{ 62 | Lhs: &ast.Var{Name: "foo"}, 63 | Rhs: &ast.Literal{value.Int64(123)}, 64 | Op: token.ADD, 65 | }, 66 | }, 67 | "Format": { 68 | expr: "10 + 1 in hex", 69 | want: &ast.Format{ 70 | Expr: &ast.BinOP{ 71 | Lhs: &ast.Literal{value.Int64(10)}, 72 | Rhs: &ast.Literal{value.Int64(1)}, 73 | Op: token.ADD, 74 | }, 75 | Fmt: "hex", 76 | }, 77 | }, 78 | "FunCall": { 79 | expr: "sin(2 radian)", 80 | want: &ast.FunCall{ 81 | Name: "sin", 82 | Args: []ast.Node{ 83 | &ast.BinOP{ 84 | Lhs: &ast.Literal{value.Int64(2)}, 85 | Rhs: &ast.Var{Name: "radian"}, 86 | Op: token.MUL, 87 | Implicit: true, 88 | }, 89 | }, 90 | }, 91 | }, 92 | } 93 | 94 | func TestParser(t *testing.T) { 95 | for _, tc := range tests { 96 | tc := tc 97 | t.Run(tc.name, func(t *testing.T) { 98 | t.Parallel() 99 | 100 | expr := tc.expr 101 | want := tc.want 102 | have, err := Parse(expr) 103 | if err != nil { 104 | t.Fatal(err) 105 | } 106 | if !reflect.DeepEqual(want, have) { 107 | t.Errorf("\nexpr: %s\nwant: %#v\nhave: %#v", expr, want, have) 108 | } 109 | }) 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /pkg/ratutils/ratutils.go: -------------------------------------------------------------------------------- 1 | package ratutils 2 | 3 | import ( 4 | "log" 5 | "math/big" 6 | ) 7 | 8 | var ZEROINT = big.NewInt(0) 9 | var ZERO = big.NewRat(0, 1) 10 | var ONE = big.NewRat(1, 1) 11 | var TEN = big.NewRat(10, 1) 12 | var HUNDRED = big.NewRat(100, 1) 13 | 14 | func ExpInt(x *big.Rat, n int) *big.Rat { 15 | if n == 0 { 16 | return ONE 17 | } 18 | r := new(big.Rat).Set(x) 19 | absn := n 20 | if n < 0 { 21 | absn = -absn 22 | } 23 | for i := 1; i < absn; i++ { 24 | r.Mul(r, x) 25 | } 26 | if n < 0 { 27 | r.Quo(ONE, r) 28 | } 29 | return r 30 | } 31 | 32 | func Exp(b, n int64) *big.Rat { 33 | if n == 0 { 34 | return ONE 35 | } 36 | int := big.NewInt(b) 37 | rat := big.NewRat(1, 1) 38 | if n > 0 { 39 | rat.Num().Set(int.Exp(int, big.NewInt(n), nil)) 40 | } else { 41 | rat.Denom().Set(int.Exp(int, big.NewInt(-n), nil)) 42 | } 43 | return rat 44 | } 45 | 46 | func MulInt(a *big.Rat, n int64) *big.Rat { 47 | x := new(big.Rat).Set(a) 48 | x.Mul(x, big.NewRat(n, 1)) 49 | return x 50 | } 51 | 52 | func DivRat(a, x *big.Rat) *big.Rat { 53 | num := new(big.Rat).Set(a) 54 | num.Quo(num, x) 55 | return num 56 | } 57 | 58 | func DivInt(a *big.Rat, x int64) *big.Rat { 59 | num := new(big.Rat).Set(a) 60 | num.Quo(num, big.NewRat(x, 1)) 61 | return num 62 | } 63 | 64 | func Mod(a, n *big.Rat) *big.Rat { 65 | // r = a - n * trunc(a / n) 66 | return new(big.Rat).Sub(a, new(big.Rat).Mul(n, Trunc(new(big.Rat).Quo(a, n)))) 67 | } 68 | 69 | func Trunc(x *big.Rat) *big.Rat { 70 | if x.IsInt() { 71 | return x 72 | } 73 | i := new(big.Int).Quo(x.Num(), x.Denom()) 74 | r := new(big.Rat) 75 | r.Num().Set(i) 76 | return r 77 | } 78 | 79 | func TruncInt(x *big.Rat) *big.Int { 80 | return Trunc(x).Num() 81 | } 82 | 83 | func Must(x string) *big.Rat { 84 | rat, ok := new(big.Rat).SetString(x) 85 | if !ok { 86 | log.Fatal("unable to parse: " + x) 87 | } 88 | return rat 89 | } 90 | -------------------------------------------------------------------------------- /pkg/ratutils/ratutils_test.go: -------------------------------------------------------------------------------- 1 | package ratutils 2 | 3 | import "testing" 4 | 5 | func TestRatMod(t *testing.T) { 6 | tcases := []struct { 7 | a, n, want string 8 | }{ 9 | {"10", "2.4", "0.4"}, 10 | {"10", "2.2", "1.2"}, 11 | {"10", "2", "0"}, 12 | {"10", "3", "1"}, 13 | } 14 | for _, tcase := range tcases { 15 | want := Must(tcase.want) 16 | have := Mod(Must(tcase.a), Must(tcase.n)) 17 | if want.Cmp(have) != 0 { 18 | t.Errorf("%s %% %s != %s (must be %s)", tcase.a, tcase.n, have, want) 19 | } 20 | } 21 | } 22 | 23 | func TestExp(t *testing.T) { 24 | pos := Exp(10, 3).String() 25 | if pos != "1000/1" { 26 | t.Errorf("10 ^ 3 = 1000 (got %s)", pos) 27 | } 28 | neg := Exp(10, -3).String() 29 | if neg != "1/1000" { 30 | t.Errorf("10 ^ -3 = 1/1000 (got %s)", neg) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /pkg/runtime/runtime.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | import ( 4 | "bufio" 5 | _ "embed" 6 | "fmt" 7 | "io" 8 | "os" 9 | "strconv" 10 | "strings" 11 | 12 | "github.com/nkanaev/numb/pkg/parser" 13 | "github.com/nkanaev/numb/pkg/value" 14 | ) 15 | 16 | //go:embed builtin.txt 17 | var builtin string 18 | 19 | type Formatter interface { 20 | Format(tsep string, prec int) string 21 | } 22 | 23 | type Runtime struct { 24 | Prec int 25 | Tsep string 26 | Env map[string]value.Value 27 | } 28 | 29 | func NewRuntime() *Runtime { 30 | return &Runtime{ 31 | Prec: 2, 32 | Env: make(map[string]value.Value), 33 | } 34 | } 35 | 36 | func Clean(line string) string { 37 | return strings.SplitN(line, "|", 2)[0] 38 | } 39 | 40 | func (r *Runtime) Eval(line string) (string, error) { 41 | line = Clean(line) 42 | 43 | trimmedline := strings.TrimSpace(line) 44 | if len(trimmedline) == 0 { 45 | return line, nil 46 | } 47 | 48 | firstchar := trimmedline[0] 49 | switch firstchar { 50 | case '.': 51 | return r.EvalConfig(line[1:]) 52 | case '#': 53 | return line, nil 54 | default: 55 | val, err := parser.Eval(line, r.Env) 56 | if err != nil { 57 | return "", err 58 | } 59 | if val, ok := val.(Formatter); ok { 60 | return val.Format(r.Tsep, r.Prec), nil 61 | } 62 | return val.String(), nil 63 | } 64 | } 65 | 66 | func (r *Runtime) EvalConfig(line string) (string, error) { 67 | parts := strings.SplitN(line, " ", 2) 68 | cmd := parts[0] 69 | switch cmd { 70 | case "load": 71 | for _, path := range parts[1:] { 72 | r.LoadFile(path) 73 | } 74 | case "prec": 75 | if len(parts) != 2 { 76 | return strconv.Itoa(r.Prec), nil 77 | } 78 | prec, err := strconv.Atoi(parts[1]) 79 | if err != nil { 80 | return "", err 81 | } 82 | r.Prec = prec 83 | case "tsep": 84 | r.Tsep = " " 85 | case "notsep": 86 | r.Tsep = "" 87 | } 88 | return "", nil 89 | } 90 | 91 | func (r *Runtime) LoadBuiltins() { 92 | r.Load(strings.NewReader(builtin), "") 93 | } 94 | 95 | func (r *Runtime) LoadFile(path string) { 96 | file, err := os.Open(path) 97 | if err != nil { 98 | fail("loadfile: %s", err.Error()) 99 | } 100 | defer file.Close() 101 | r.Load(file, path) 102 | } 103 | 104 | func (r *Runtime) Load(reader io.Reader, filename string) { 105 | scanner := bufio.NewScanner(reader) 106 | linenum := 0 107 | for scanner.Scan() { 108 | linenum += 1 109 | _, err := r.Eval(scanner.Text()) 110 | if err != nil { 111 | fail("load %s (line %d): %s", filename, linenum, err) 112 | } 113 | } 114 | } 115 | 116 | func fail(format string, v ...interface{}) { 117 | fmt.Fprintf(os.Stderr, format, v...) 118 | os.Stderr.WriteString("\n") 119 | os.Exit(1) 120 | } 121 | -------------------------------------------------------------------------------- /pkg/runtime/testdata/capital.txt: -------------------------------------------------------------------------------- 1 | # capital 2 | 3 | buy = 20 | 20 4 | sell = 219 | 219 5 | gain = sell - buy | 199 6 | performance = gain / buy * 100 | 995 7 | 8 | amount = 500 | 500 9 | capital_invested = amount * buy | 10000 10 | capital_returned = amount * sell | 109500 11 | capital_gain = amount * gain | 99500 12 | -------------------------------------------------------------------------------- /pkg/runtime/testdata/convert.txt: -------------------------------------------------------------------------------- 1 | # convert errors 2 | 1 to kg | !unsupported 3 | kg to cm | !incompatible 4 | 1 kg to 2 kg | !unit with a value 5 | -------------------------------------------------------------------------------- /pkg/runtime/testdata/format.txt: -------------------------------------------------------------------------------- 1 | # default 2 | 0.33 | 0.33 3 | 0xff | 0xff 4 | 0o12 | 0o12 5 | 0b10 | 0b10 6 | 1e4 | 1e4 7 | 1e-4 | 1e-4 8 | 9 | # dec 10 | 10/3 | 3.33 11 | 10/3 in dec | 3.33 12 | 13 | # sci 14 | 1.2 in sci | 1.2e0 15 | 10/3 in sci | 3.33e0 16 | 1000 in sci | 1e3 17 | 10^100 in sci | 1e100 18 | 12345 in sci | 1.23e4 19 | 0.01 in sci | 1e-2 20 | 0.01234 in sci | 1.23e-2 21 | 22 | # rat 23 | 10/3 in rat | 10/3 24 | 10000 in rat | 10000/1 25 | 1/1000 in rat | 1/1000 26 | 27 | # hex 28 | 10/3 in hex | 0x3 29 | 30 | # oct 31 | 10/3 in oct | 0o3 32 | 33 | # bin 34 | 10/3 in bin | 0b11 35 | -------------------------------------------------------------------------------- /pkg/runtime/testdata/functions.txt: -------------------------------------------------------------------------------- 1 | # abs 2 | abs(-1) | 1 3 | abs(-1.2) | 1.2 4 | abs(1) | 1 5 | abs(1.2) | 1.2 6 | 7 | # sin 8 | sin(1) | 0.84 9 | sin(1 rad) | 0.84 10 | sin(90 deg) | 1 11 | 12 | # ceil 13 | ceil(2) | 2 14 | ceil(2.3) | 3 15 | ceil(2.9) | 3 16 | ceil(-2) | -2 17 | ceil(-2.3) | -2 18 | ceil(-2.6) | -2 19 | ceil(-0.1) | 0 20 | ceil(0.1) | 1 21 | 22 | # floor 23 | floor(2) | 2 24 | floor(2.3) | 2 25 | floor(2.9) | 2 26 | floor(-2) | -2 27 | floor(-2.3) | -3 28 | floor(-2.6) | -3 29 | floor(-0.1) | -1 30 | floor(0.1) | 0 31 | 32 | # trunc 33 | trunc(2) | 2 34 | trunc(2.3) | 2 35 | trunc(2.9) | 2 36 | trunc(-2) | -2 37 | trunc(-2.3) | -2 38 | trunc(-2.6) | -2 39 | trunc(-0.1) | 0 40 | trunc(0.1) | 0 41 | 42 | # round 43 | round(0) | 0 44 | round(1) | 1 45 | round(-1) | -1 46 | round(1.3) | 1 47 | round(1.5) | 2 48 | round(-1.3) | -1 49 | round(-1.5) | -2 50 | round(1.5 kg) | 2 kg 51 | round(1.4 kg) | 1 kg 52 | round(1.23, 1) | !one argument 53 | -------------------------------------------------------------------------------- /pkg/runtime/testdata/operators.txt: -------------------------------------------------------------------------------- 1 | # unary 2 | -100 | -100 3 | 4 | # parentheses 5 | 1 + (2 * 3) | 7 6 | (1 + 2) * 3 | 9 7 | 8 | # simple 9 | 1 + 2 | 3 10 | 3 * 4 | 12 11 | 3 - 10 | -7 12 | 10 - 3 | 7 13 | 10 / 3 | 3.33 14 | 15 | # bit 16 | 0b101 and 0b111 | 0b101 17 | 0b101 or 0b111 | 0b111 18 | 0b101 xor 0b111 | 0b10 19 | 20 | # exp 21 | 10 ^ 3 | 1000 22 | 10 ^-2 | 0.01 23 | 10 ^-1 | 0.1 24 | 10 ^-4 in rat | 1/10000 25 | 26 | # precedence 27 | 2 + 3 * 4 | 14 28 | 2 * 3 + 4 | 10 29 | 30 | # modulus (truncated) 31 | 8 mod 3 | 2 32 | 8 mod -3 | 2 33 | -8 mod 3 | -2 34 | -8 mod -3 | -2 35 | 10 mod 2.4 | 0.4 36 | 10 mod 2.2 | 1.2 37 | -------------------------------------------------------------------------------- /pkg/runtime/testdata/units.txt: -------------------------------------------------------------------------------- 1 | # misc 2 | 3 | 1 ns | 1 ns 4 | 1 ms | 1 ms 5 | kg | 1 kg 6 | 1 Kg | 1 kg 7 | 1 kIloGram | 1 kilogram 8 | 9 | # suffixes 10 | 11 | puppy : 3 kg 12 | potato : 10 oz 13 | kgs | 1 kg 14 | kilograms | 1 kilogram 15 | 2 potatoes | 2 potato 16 | 3 puppies | 3 puppy 17 | 1 kilopotato | 1 kilopotato 18 | 1 kilopotatoes| 1 kilopotato 19 | 20 | # conversion 21 | 22 | 7 feet to meter | 2.13 meter 23 | 7 ft to m | 2.13 m 24 | 25 | # currency 26 | 27 | USD : CURRENCY 28 | $ : CURRENCY 29 | 30 | # operations 31 | 32 | 100 / m | 100 m^-1 33 | -------------------------------------------------------------------------------- /pkg/runtime/testdata/xkcd.txt: -------------------------------------------------------------------------------- 1 | # xkcd2585 2 | s01 = 17 mph | 17 mi/h 3 | s02 = round(s01 to meters/sec) | 8 meter/sec 4 | s03 = round(s02 to knots) | 16 knot 5 | s04 = round(s03 to fathoms/sec) | 5 fathom/sec 6 | s05 = round(s04 to furlongs/min) | 3 furlong/min 7 | s06 = round(s05 to fathoms/sec) | 6 fathom/sec 8 | s07 = round(s06 to kph) | 40 km/h 9 | s08 = round(s07 to knots) | 22 knot 10 | s09 = round(s08 to kph) | 41 km/h 11 | s10 = round(s09 to furlongs/hr) | 204 furlong/hr 12 | s11 = round(s10 to mph) | 26 mi/h 13 | s12 = round(s11 to m/s) | 12 m/s 14 | s13 = round(s12 to furlongs/min) | 4 furlong/min 15 | s14 = round(s13 to yards/sec) | 15 yard/sec 16 | s15 = round(s14 to fathoms/sec) | 8 fathom/sec 17 | s16 = round(s15 to m/s) | 15 m/s 18 | s17 = round(s16 to mph) | 34 mi/h 19 | s18 = round(s17 to furlongs/min) | 5 furlong/min 20 | s19 = round(s18 to knots) | 33 knot 21 | s20 = round(s19 to yards/sec) | 19 yard/sec 22 | s21 = round(s20 to fathoms/sec) | 10 fathom/sec 23 | s22 = round(s21 to knots) | 36 knot 24 | s23 = round(s22 to furlongs/min) | 6 furlong/min 25 | s24 = round(s23 to mph) | 45 mi/h 26 | -------------------------------------------------------------------------------- /pkg/timeutil/parse_test.go: -------------------------------------------------------------------------------- 1 | package timeutil 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | func TestParse(t *testing.T) { 9 | year := time.Now().Year() 10 | 11 | tz := time.Local 12 | tcases := []struct { 13 | Date string 14 | Want time.Time 15 | }{ 16 | // YYYY MM DD 17 | {"2019-05-06", time.Date(2019, time.May, 6, 0, 0, 0, 0, tz)}, 18 | {"2019/05/06", time.Date(2019, time.May, 6, 0, 0, 0, 0, tz)}, 19 | {"2019.05.06", time.Date(2019, time.May, 6, 0, 0, 0, 0, tz)}, 20 | 21 | // DD MM YYYY 22 | {"06/05/2019", time.Date(2019, time.May, 6, 0, 0, 0, 0, tz)}, 23 | {"06.05.2019", time.Date(2019, time.May, 6, 0, 0, 0, 0, tz)}, 24 | {"6/5/2019", time.Date(2019, time.May, 6, 0, 0, 0, 0, tz)}, 25 | {"6.5.2019", time.Date(2019, time.May, 6, 0, 0, 0, 0, tz)}, 26 | {"06 Jun 2019", time.Date(2019, time.June, 6, 0, 0, 0, 0, tz)}, 27 | {"6 Jun 2019", time.Date(2019, time.June, 6, 0, 0, 0, 0, tz)}, 28 | {"06 June 2019", time.Date(2019, time.June, 6, 0, 0, 0, 0, tz)}, 29 | {"6 June 2019", time.Date(2019, time.June, 6, 0, 0, 0, 0, tz)}, 30 | {"06 june 2019", time.Date(2019, time.June, 6, 0, 0, 0, 0, tz)}, 31 | {"6 june 2019", time.Date(2019, time.June, 6, 0, 0, 0, 0, tz)}, 32 | {"6/June/2019", time.Date(2019, time.June, 6, 0, 0, 0, 0, tz)}, 33 | {"2019/June/6", time.Date(2019, time.June, 6, 0, 0, 0, 0, tz)}, 34 | 35 | // YYYY MM DD HH MM 36 | {"2019-05-06T13:30", time.Date(2019, time.May, 6, 13, 30, 0, 0, tz)}, 37 | {"2019/05/06 13:30", time.Date(2019, time.May, 6, 13, 30, 0, 0, tz)}, 38 | {"06 Jun 2019 13:30", time.Date(2019, time.June, 6, 13, 30, 0, 0, tz)}, 39 | {"6 Jun 2019 13:30", time.Date(2019, time.June, 6, 13, 30, 0, 0, tz)}, 40 | {"06 June 2019 13:30", time.Date(2019, time.June, 6, 13, 30, 0, 0, tz)}, 41 | {"6 June 2019 13:30", time.Date(2019, time.June, 6, 13, 30, 0, 0, tz)}, 42 | {"06 june 2019 13:30", time.Date(2019, time.June, 6, 13, 30, 0, 0, tz)}, 43 | {"6 june 2019 13:30", time.Date(2019, time.June, 6, 13, 30, 0, 0, tz)}, 44 | 45 | // MM DD 46 | {"may 6", time.Date(year, time.May, 6, 0, 0, 0, 0, tz)}, 47 | {"6 may", time.Date(year, time.May, 6, 0, 0, 0, 0, tz)}, 48 | 49 | // timestamp 50 | {"1557097200", time.Date(2019, time.May, 6, 0, 0, 0, 0, tz)}, 51 | {"1557097200000", time.Date(2019, time.May, 6, 0, 0, 0, 0, tz)}, 52 | {"1557097200000000", time.Date(2019, time.May, 6, 0, 0, 0, 0, tz)}, 53 | {"1557097200000000000", time.Date(2019, time.May, 6, 0, 0, 0, 0, tz)}, 54 | } 55 | 56 | for _, tcase := range tcases { 57 | date := tcase.Date 58 | want := tcase.Want 59 | have, err := Parse(date) 60 | if err != nil { 61 | t.Errorf("failed for `%s` (%s)", date, err) 62 | } 63 | if !want.Equal(have) { 64 | t.Errorf( 65 | "invalid date\ndate: %s\nwant: %q\nhave: %q", 66 | date, want, have, 67 | ) 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /pkg/timeutil/timezone.go: -------------------------------------------------------------------------------- 1 | package timeutil 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "strings" 7 | "time" 8 | "unicode" 9 | ) 10 | 11 | func FindLocation(name string) (*time.Location, error) { 12 | if strings.EqualFold(name, "utc") { 13 | return time.UTC, nil 14 | } 15 | if strings.EqualFold(name, "local") { 16 | return time.Local, nil 17 | } 18 | 19 | var zoneDirs = []string{ 20 | "/usr/share/zoneinfo", 21 | "/usr/share/lib/zoneinfo", 22 | "/usr/lib/locale/TZ", 23 | } 24 | for _, dir := range zoneDirs { 25 | if loc := findLocationFromDir(name, dir, ""); loc != nil { 26 | return loc, nil 27 | } 28 | } 29 | return nil, nil 30 | } 31 | 32 | func findLocationFromDir(name, rootdir, subdir string) *time.Location { 33 | files, _ := ioutil.ReadDir(rootdir + "/" + subdir) 34 | 35 | for _, f := range files { 36 | if !unicode.IsUpper(rune(f.Name()[0])) { 37 | continue 38 | } 39 | 40 | if f.IsDir() && len(subdir) == 0 { 41 | if loc := findLocationFromDir(name, rootdir, subdir+"/"+f.Name()); loc != nil { 42 | return loc 43 | } 44 | } else { 45 | tzname := strings.TrimLeft(subdir+"/"+f.Name(), "/") 46 | if tzNameMatches(name, tzname) { 47 | if tzdata, err := os.ReadFile(rootdir + "/" + tzname); err == nil { 48 | if tzinfo, err := time.LoadLocationFromTZData(tzname, tzdata); err == nil { 49 | return tzinfo 50 | } 51 | } 52 | } 53 | } 54 | } 55 | return nil 56 | } 57 | 58 | func normalizeTZName(name string) string { 59 | name = strings.ReplaceAll(name, "_", "") 60 | name = strings.ReplaceAll(name, "-", "") 61 | name = strings.ToLower(name) 62 | return name 63 | } 64 | 65 | func tzNameMatches(name, tzname string) bool { 66 | name = normalizeTZName(name) 67 | tzname = normalizeTZName(tzname) 68 | 69 | if strings.ContainsRune(tzname, '/') && !strings.ContainsRune(name, '/') { 70 | chunks := strings.Split(tzname, "/") 71 | tzname := chunks[len(chunks)-1] 72 | if strings.EqualFold(name, tzname) { 73 | return true 74 | } 75 | } 76 | 77 | return strings.EqualFold(name, tzname) 78 | } 79 | -------------------------------------------------------------------------------- /pkg/token/token.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import "strings" 4 | 5 | type Token int 6 | 7 | const ( 8 | Illegal Token = iota 9 | END 10 | 11 | operator_beg 12 | OR // or 13 | XOR // xor 14 | AND // and 15 | REM // mod 16 | 17 | IN // in 18 | TO // to 19 | 20 | chars_beg 21 | SHL // << 22 | SHR // >> 23 | ADD // + 24 | SUB // - 25 | MUL // * 26 | QUO // / 27 | EXP // ^ 28 | operator_end 29 | 30 | LPAREN // ( 31 | RPAREN // ) 32 | COMMA // , 33 | ASSIGN // = 34 | COLON // : 35 | chars_end 36 | 37 | NUM_DEC // 10, 10.1 38 | NUM_HEX // 0xdeadbeef 39 | NUM_OCT // 0o127 40 | NUM_BIN // 0b101 41 | NUM_SCI // 1e2, 1.2e-7 42 | IDENT // foobar 43 | FORMAT // dec, hex, America/New_York 44 | DATE // {11/12/2021} 45 | ) 46 | 47 | var tokenToString = map[Token]string{ 48 | Illegal: "ILLEGAL", 49 | END: "END", 50 | 51 | OR: "OR", 52 | XOR: "XOR", 53 | AND: "AND", 54 | SHL: "<<", 55 | SHR: ">>", 56 | 57 | ADD: "+", 58 | SUB: "-", 59 | MUL: "*", 60 | QUO: "/", 61 | REM: "mod", 62 | EXP: "^", 63 | 64 | LPAREN: "(", 65 | RPAREN: ")", 66 | COMMA: ",", 67 | COLON: ":", 68 | ASSIGN: "=", 69 | 70 | NUM_DEC: "NUM_DEC", 71 | NUM_HEX: "NUM_HEX", 72 | NUM_OCT: "NUM_OCT", 73 | NUM_BIN: "NUM_BIN", 74 | NUM_SCI: "NUM_SCI", 75 | IDENT: "IDENT", 76 | FORMAT: "FORMAT", 77 | 78 | IN: "in", 79 | TO: "to", 80 | } 81 | 82 | func (t Token) String() string { 83 | return tokenToString[t] 84 | } 85 | 86 | const ( 87 | LowestPrec = 0 88 | ) 89 | 90 | func (t Token) Precedence() int { 91 | switch t { 92 | case ASSIGN, COLON: 93 | return 1 94 | case IN, TO: 95 | return 2 96 | case ADD, SUB, OR, XOR: 97 | return 3 98 | case MUL, QUO, REM, SHL, SHR, AND: 99 | return 4 100 | case EXP: 101 | return 5 102 | } 103 | return LowestPrec 104 | } 105 | 106 | var StringToOperator = map[string]Token{} 107 | 108 | var SpecialChars string 109 | 110 | func init() { 111 | for x := operator_beg + 1; x < operator_end; x++ { 112 | StringToOperator[strings.ToLower(x.String())] = x 113 | } 114 | 115 | for x := chars_beg + 1; x < chars_end; x++ { 116 | SpecialChars += x.String() 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /pkg/unit/convert.go: -------------------------------------------------------------------------------- 1 | package unit 2 | 3 | import ( 4 | "fmt" 5 | "math/big" 6 | ) 7 | 8 | type ConformanceError struct { 9 | a, b Units 10 | } 11 | 12 | func (c ConformanceError) Error() string { 13 | return fmt.Sprintf( 14 | "incompatible units, %s (%s) does not conform %s (%s)", 15 | c.a.String(), c.a.Dimension().Measure(), 16 | c.b.String(), c.b.Dimension().Measure()) 17 | } 18 | 19 | func Convert(n *big.Rat, from, to Units) (*big.Rat, error) { 20 | if from.Dimension().IsPure() { 21 | return from.normalize(n), nil 22 | } 23 | if !from.Conforms(to) { 24 | return nil, ConformanceError{from, to} 25 | } 26 | if from.String() == to.String() { 27 | return n, nil 28 | } 29 | return to.denormalize(from.normalize(n)), nil 30 | } 31 | 32 | func Normalize(n *big.Rat, x Units) *big.Rat { 33 | return x.normalize(n) 34 | } 35 | -------------------------------------------------------------------------------- /pkg/value/value.go: -------------------------------------------------------------------------------- 1 | package value 2 | 3 | import ( 4 | "math/big" 5 | 6 | "github.com/nkanaev/numb/pkg/token" 7 | ) 8 | 9 | type ValueType int 10 | 11 | const ( 12 | TYPE_UNKNOWN ValueType = iota 13 | TYPE_NUMBER 14 | TYPE_UNIT 15 | TYPE_TIME 16 | ) 17 | 18 | func (t ValueType) String() string { 19 | switch t { 20 | case TYPE_NUMBER: 21 | return "number" 22 | case TYPE_UNIT: 23 | return "unit" 24 | case TYPE_TIME: 25 | return "time" 26 | default: 27 | return "unknown" 28 | } 29 | } 30 | 31 | func Type(x Value) ValueType { 32 | switch x.(type) { 33 | case Number: 34 | return TYPE_NUMBER 35 | case Unit: 36 | return TYPE_UNIT 37 | case Time: 38 | return TYPE_TIME 39 | default: 40 | return TYPE_UNKNOWN 41 | } 42 | } 43 | 44 | type Value interface { 45 | BinOP(token.Token, Value) (Value, error) 46 | UnOP(token.Token) (Value, error) 47 | In(string) (Value, error) 48 | String() string 49 | } 50 | 51 | func Int64(x int64) Number { 52 | return Number{Num: new(big.Rat).SetInt64(x)} 53 | } 54 | 55 | func Float64(x float64) Number { 56 | return Number{Num: new(big.Rat).SetFloat64(x)} 57 | } 58 | 59 | var ( 60 | defaultSep = "" 61 | defaultPrec = 2 62 | ) 63 | -------------------------------------------------------------------------------- /pkg/value/value_test.go: -------------------------------------------------------------------------------- 1 | package value 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/nkanaev/numb/pkg/ratutils" 7 | ) 8 | 9 | func TestFormat(t *testing.T) { 10 | testcases := []struct { 11 | have string 12 | prec int 13 | sep string 14 | want string 15 | }{ 16 | {"1", 2, ",", "1"}, 17 | {"123", 2, ",", "123"}, 18 | {"1234", 2, ",", "1,234"}, 19 | {"1234567", 2, ",", "1,234,567"}, 20 | {"1234567", 2, ",", "1,234,567"}, 21 | {"-100", 2, ",", "-100"}, 22 | {"-1000", 2, ",", "-1,000"}, 23 | {"-100.1234", 2, ",", "-100.12"}, 24 | {"-1000.1234", 2, ",", "-1,000.12"}, 25 | {"1.01", 2, "", "1.01"}, 26 | {"1.01", 4, "", "1.01"}, 27 | {"1.1234", 2, "", "1.12"}, 28 | {"1.001", 2, "", "1.0"}, 29 | {"0.001", 2, "", "0.0"}, 30 | {"0.001", 1, "", "0.0"}, 31 | {"0.001", 0, "", "0"}, 32 | {"100000.01", 2, ",", "100,000.01"}, 33 | {"1234567890.01", 2, "_", "1_234_567_890.01"}, 34 | {"1000000000.01", 2, "", "1000000000.01"}, 35 | } 36 | for _, tc := range testcases { 37 | have := formatDec(ratutils.Must(tc.have), tc.sep, tc.prec) 38 | if have != tc.want { 39 | t.Errorf("val=%#v sep=%#v prec=%d\nwant: %s\nhave: %s", tc.have, tc.sep, tc.prec, tc.want, have) 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | ╭╮ 2 | ╭─┬┬┬──┤└╮ 3 | ╰┴┴─┴┴┴┴─╯ 4 | 5 | numb is a tool for working with numbers, units and dates. 6 | 7 | examples: 8 | 9 | $ numb 10 | Enter `q` to quit 11 | > 3735928559 >> 16 in hex 12 | 0xdead 13 | > 1920/1080 in rat 14 | 16/9 15 | > sin(pi/3) 16 | 0.87 17 | > 3 millilightsecond to mile 18 | 558.85 mile 19 | > 10 mile/hour to metre/sec 20 | 4.47 metre/sec 21 | > total_grains = 2^64 - 1 22 | 18446744073709551615 23 | > 3 GB / (15 Mbps) to minute 24 | 26.67 minute 25 | > time in London 26 | 13:04 27 | > today + 10 days 28 | 05 Jun 2022 29 | > today - {1999-09-09} to months 30 | 272.54 month 31 | 32 | install: 33 | 34 | # build with Go >= 1.16 35 | $ go install github.com/nkanaev/numb@latest 36 | 37 | more: 38 | 39 | doc/help.txt manual, examples 40 | doc/spec.txt syntax, grammar 41 | doc/dump.txt various design notes 42 | doc/todo.txt todo list 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /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/internal/unsafeheader/unsafeheader.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 | // Package unsafeheader contains header declarations for the Go runtime's 6 | // slice and string implementations. 7 | // 8 | // This package allows x/sys to use types equivalent to 9 | // reflect.SliceHeader and reflect.StringHeader without introducing 10 | // a dependency on the (relatively heavy) "reflect" package. 11 | package unsafeheader 12 | 13 | import ( 14 | "unsafe" 15 | ) 16 | 17 | // Slice is the runtime representation of a slice. 18 | // It cannot be used safely or portably and its representation may change in a later release. 19 | type Slice struct { 20 | Data unsafe.Pointer 21 | Len int 22 | Cap int 23 | } 24 | 25 | // String is the runtime representation of a string. 26 | // It cannot be used safely or portably and its representation may change in a later release. 27 | type String struct { 28 | Data unsafe.Pointer 29 | Len int 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/asm.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 | #include "textflag.h" 6 | 7 | TEXT ·use(SB),NOSPLIT,$0 8 | RET 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/asm_plan9_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 | #include "textflag.h" 6 | 7 | // 8 | // System call support for 386, Plan 9 9 | // 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-32 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 21 | JMP syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·RawSyscall6(SB) 25 | 26 | TEXT ·seek(SB),NOSPLIT,$0-36 27 | JMP syscall·seek(SB) 28 | 29 | TEXT ·exit(SB),NOSPLIT,$4-4 30 | JMP syscall·exit(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/asm_plan9_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 | #include "textflag.h" 6 | 7 | // 8 | // System call support for amd64, Plan 9 9 | // 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-64 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | JMP syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | JMP syscall·RawSyscall6(SB) 25 | 26 | TEXT ·seek(SB),NOSPLIT,$0-56 27 | JMP syscall·seek(SB) 28 | 29 | TEXT ·exit(SB),NOSPLIT,$8-8 30 | JMP syscall·exit(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/asm_plan9_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 | #include "textflag.h" 6 | 7 | // System call support for plan9 on arm 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-32 13 | JMP syscall·Syscall(SB) 14 | 15 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 16 | JMP syscall·Syscall6(SB) 17 | 18 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 19 | JMP syscall·RawSyscall(SB) 20 | 21 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·RawSyscall6(SB) 23 | 24 | TEXT ·seek(SB),NOSPLIT,$0-36 25 | JMP syscall·exit(SB) 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/const_plan9.go: -------------------------------------------------------------------------------- 1 | package plan9 2 | 3 | // Plan 9 Constants 4 | 5 | // Open modes 6 | const ( 7 | O_RDONLY = 0 8 | O_WRONLY = 1 9 | O_RDWR = 2 10 | O_TRUNC = 16 11 | O_CLOEXEC = 32 12 | O_EXCL = 0x1000 13 | ) 14 | 15 | // Rfork flags 16 | const ( 17 | RFNAMEG = 1 << 0 18 | RFENVG = 1 << 1 19 | RFFDG = 1 << 2 20 | RFNOTEG = 1 << 3 21 | RFPROC = 1 << 4 22 | RFMEM = 1 << 5 23 | RFNOWAIT = 1 << 6 24 | RFCNAMEG = 1 << 10 25 | RFCENVG = 1 << 11 26 | RFCFDG = 1 << 12 27 | RFREND = 1 << 13 28 | RFNOMNT = 1 << 14 29 | ) 30 | 31 | // Qid.Type bits 32 | const ( 33 | QTDIR = 0x80 34 | QTAPPEND = 0x40 35 | QTEXCL = 0x20 36 | QTMOUNT = 0x10 37 | QTAUTH = 0x08 38 | QTTMP = 0x04 39 | QTFILE = 0x00 40 | ) 41 | 42 | // Dir.Mode bits 43 | const ( 44 | DMDIR = 0x80000000 45 | DMAPPEND = 0x40000000 46 | DMEXCL = 0x20000000 47 | DMMOUNT = 0x10000000 48 | DMAUTH = 0x08000000 49 | DMTMP = 0x04000000 50 | DMREAD = 0x4 51 | DMWRITE = 0x2 52 | DMEXEC = 0x1 53 | ) 54 | 55 | const ( 56 | STATMAX = 65535 57 | ERRMAX = 128 58 | STATFIXLEN = 49 59 | ) 60 | 61 | // Mount and bind flags 62 | const ( 63 | MREPL = 0x0000 64 | MBEFORE = 0x0001 65 | MAFTER = 0x0002 66 | MORDER = 0x0003 67 | MCREATE = 0x0004 68 | MCACHE = 0x0010 69 | MMASK = 0x0017 70 | ) 71 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/env_plan9.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 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 | // Plan 9 environment variables. 6 | 7 | package plan9 8 | 9 | import ( 10 | "syscall" 11 | ) 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/plan9/errors_plan9.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 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 plan9 6 | 7 | import "syscall" 8 | 9 | // Constants 10 | const ( 11 | // Invented values to support what package os expects. 12 | O_CREAT = 0x02000 13 | O_APPEND = 0x00400 14 | O_NOCTTY = 0x00000 15 | O_NONBLOCK = 0x00000 16 | O_SYNC = 0x00000 17 | O_ASYNC = 0x00000 18 | 19 | S_IFMT = 0x1f000 20 | S_IFIFO = 0x1000 21 | S_IFCHR = 0x2000 22 | S_IFDIR = 0x4000 23 | S_IFBLK = 0x6000 24 | S_IFREG = 0x8000 25 | S_IFLNK = 0xa000 26 | S_IFSOCK = 0xc000 27 | ) 28 | 29 | // Errors 30 | var ( 31 | EINVAL = syscall.NewError("bad arg in system call") 32 | ENOTDIR = syscall.NewError("not a directory") 33 | EISDIR = syscall.NewError("file is a directory") 34 | ENOENT = syscall.NewError("file does not exist") 35 | EEXIST = syscall.NewError("file already exists") 36 | EMFILE = syscall.NewError("no free file descriptors") 37 | EIO = syscall.NewError("i/o error") 38 | ENAMETOOLONG = syscall.NewError("file name too long") 39 | EINTR = syscall.NewError("interrupted") 40 | EPERM = syscall.NewError("permission denied") 41 | EBUSY = syscall.NewError("no free devices") 42 | ETIMEDOUT = syscall.NewError("connection timed out") 43 | EPLAN9 = syscall.NewError("not supported by plan 9") 44 | 45 | // The following errors do not correspond to any 46 | // Plan 9 system messages. Invented to support 47 | // what package os and others expect. 48 | EACCES = syscall.NewError("access permission denied") 49 | EAFNOSUPPORT = syscall.NewError("address family not supported by protocol") 50 | ) 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/mksysnum_plan9.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | 6 | COMMAND="mksysnum_plan9.sh $@" 7 | 8 | cat <= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/zsysnum_plan9.go: -------------------------------------------------------------------------------- 1 | // mksysnum_plan9.sh /opt/plan9/sys/src/libc/9syscall/sys.h 2 | // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT 3 | 4 | package plan9 5 | 6 | const ( 7 | SYS_SYSR1 = 0 8 | SYS_BIND = 2 9 | SYS_CHDIR = 3 10 | SYS_CLOSE = 4 11 | SYS_DUP = 5 12 | SYS_ALARM = 6 13 | SYS_EXEC = 7 14 | SYS_EXITS = 8 15 | SYS_FAUTH = 10 16 | SYS_SEGBRK = 12 17 | SYS_OPEN = 14 18 | SYS_OSEEK = 16 19 | SYS_SLEEP = 17 20 | SYS_RFORK = 19 21 | SYS_PIPE = 21 22 | SYS_CREATE = 22 23 | SYS_FD2PATH = 23 24 | SYS_BRK_ = 24 25 | SYS_REMOVE = 25 26 | SYS_NOTIFY = 28 27 | SYS_NOTED = 29 28 | SYS_SEGATTACH = 30 29 | SYS_SEGDETACH = 31 30 | SYS_SEGFREE = 32 31 | SYS_SEGFLUSH = 33 32 | SYS_RENDEZVOUS = 34 33 | SYS_UNMOUNT = 35 34 | SYS_SEMACQUIRE = 37 35 | SYS_SEMRELEASE = 38 36 | SYS_SEEK = 39 37 | SYS_FVERSION = 40 38 | SYS_ERRSTR = 41 39 | SYS_STAT = 42 40 | SYS_FSTAT = 43 41 | SYS_WSTAT = 44 42 | SYS_FWSTAT = 45 43 | SYS_MOUNT = 46 44 | SYS_AWAIT = 47 45 | SYS_PREAD = 50 46 | SYS_PWRITE = 51 47 | SYS_TSEMACQUIRE = 52 48 | SYS_NSEC = 53 49 | ) 50 | -------------------------------------------------------------------------------- /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) && go1.9 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | // +build go1.9 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | type Signal = syscall.Signal 14 | type Errno = syscall.Errno 15 | type SysProcAttr = syscall.SysProcAttr 16 | -------------------------------------------------------------------------------- /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 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 12 | // 13 | 14 | TEXT ·syscall6(SB),NOSPLIT,$0-88 15 | JMP syscall·syscall6(SB) 16 | 17 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 18 | JMP syscall·rawSyscall6(SB) 19 | -------------------------------------------------------------------------------- /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 (darwin || freebsd || netbsd || openbsd) && gc 6 | // +build darwin freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for 386 BSD 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 ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /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 | // +build darwin dragonfly freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for AMD64 BSD 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_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 (darwin || freebsd || netbsd || openbsd) && gc 6 | // +build darwin freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for ARM BSD 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 ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /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 | // +build darwin freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for ARM64 BSD 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_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 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for 386, Linux 12 | // 13 | 14 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 15 | // instead of the glibc-specific "CALL 0x10(GS)". 16 | #define INVOKE_SYSCALL INT $0x80 17 | 18 | // Just jump to package syscall's implementation for all these functions. 19 | // The runtime may know about them. 20 | 21 | TEXT ·Syscall(SB),NOSPLIT,$0-28 22 | JMP syscall·Syscall(SB) 23 | 24 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 25 | JMP syscall·Syscall6(SB) 26 | 27 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 28 | CALL runtime·entersyscall(SB) 29 | MOVL trap+0(FP), AX // syscall entry 30 | MOVL a1+4(FP), BX 31 | MOVL a2+8(FP), CX 32 | MOVL a3+12(FP), DX 33 | MOVL $0, SI 34 | MOVL $0, DI 35 | INVOKE_SYSCALL 36 | MOVL AX, r1+16(FP) 37 | MOVL DX, r2+20(FP) 38 | CALL runtime·exitsyscall(SB) 39 | RET 40 | 41 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 42 | JMP syscall·RawSyscall(SB) 43 | 44 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 45 | JMP syscall·RawSyscall6(SB) 46 | 47 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 48 | MOVL trap+0(FP), AX // syscall entry 49 | MOVL a1+4(FP), BX 50 | MOVL a2+8(FP), CX 51 | MOVL a3+12(FP), DX 52 | MOVL $0, SI 53 | MOVL $0, DI 54 | INVOKE_SYSCALL 55 | MOVL AX, r1+16(FP) 56 | MOVL DX, r2+20(FP) 57 | RET 58 | 59 | TEXT ·socketcall(SB),NOSPLIT,$0-36 60 | JMP syscall·socketcall(SB) 61 | 62 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 63 | JMP syscall·rawsocketcall(SB) 64 | 65 | TEXT ·seek(SB),NOSPLIT,$0-28 66 | JMP syscall·seek(SB) 67 | -------------------------------------------------------------------------------- /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 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for AMD64, Linux 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | JMP syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | JMP syscall·Syscall6(SB) 22 | 23 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 24 | CALL runtime·entersyscall(SB) 25 | MOVQ a1+8(FP), DI 26 | MOVQ a2+16(FP), SI 27 | MOVQ a3+24(FP), DX 28 | MOVQ $0, R10 29 | MOVQ $0, R8 30 | MOVQ $0, R9 31 | MOVQ trap+0(FP), AX // syscall entry 32 | SYSCALL 33 | MOVQ AX, r1+32(FP) 34 | MOVQ DX, r2+40(FP) 35 | CALL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 39 | JMP syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 42 | JMP syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 45 | MOVQ a1+8(FP), DI 46 | MOVQ a2+16(FP), SI 47 | MOVQ a3+24(FP), DX 48 | MOVQ $0, R10 49 | MOVQ $0, R8 50 | MOVQ $0, R9 51 | MOVQ trap+0(FP), AX // syscall entry 52 | SYSCALL 53 | MOVQ AX, r1+32(FP) 54 | MOVQ DX, r2+40(FP) 55 | RET 56 | 57 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 58 | JMP syscall·gettimeofday(SB) 59 | -------------------------------------------------------------------------------- /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 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for arm, Linux 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 24 | BL runtime·entersyscall(SB) 25 | MOVW trap+0(FP), R7 26 | MOVW a1+4(FP), R0 27 | MOVW a2+8(FP), R1 28 | MOVW a3+12(FP), R2 29 | MOVW $0, R3 30 | MOVW $0, R4 31 | MOVW $0, R5 32 | SWI $0 33 | MOVW R0, r1+16(FP) 34 | MOVW $0, R0 35 | MOVW R0, r2+20(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 40 | B syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 43 | B syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 46 | MOVW trap+0(FP), R7 // syscall entry 47 | MOVW a1+4(FP), R0 48 | MOVW a2+8(FP), R1 49 | MOVW a3+12(FP), R2 50 | SWI $0 51 | MOVW R0, r1+16(FP) 52 | MOVW $0, R0 53 | MOVW R0, r2+20(FP) 54 | RET 55 | 56 | TEXT ·seek(SB),NOSPLIT,$0-28 57 | B syscall·seek(SB) 58 | -------------------------------------------------------------------------------- /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 | // +build linux 7 | // +build arm64 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // Just jump to package syscall's implementation for all these functions. 13 | // The runtime may know about them. 14 | 15 | TEXT ·Syscall(SB),NOSPLIT,$0-56 16 | B syscall·Syscall(SB) 17 | 18 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 19 | B syscall·Syscall6(SB) 20 | 21 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 22 | BL runtime·entersyscall(SB) 23 | MOVD a1+8(FP), R0 24 | MOVD a2+16(FP), R1 25 | MOVD a3+24(FP), R2 26 | MOVD $0, R3 27 | MOVD $0, R4 28 | MOVD $0, R5 29 | MOVD trap+0(FP), R8 // syscall entry 30 | SVC 31 | MOVD R0, r1+32(FP) // r1 32 | MOVD R1, r2+40(FP) // r2 33 | BL runtime·exitsyscall(SB) 34 | RET 35 | 36 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 37 | B syscall·RawSyscall(SB) 38 | 39 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 40 | B syscall·RawSyscall6(SB) 41 | 42 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 43 | MOVD a1+8(FP), R0 44 | MOVD a2+16(FP), R1 45 | MOVD a3+24(FP), R2 46 | MOVD $0, R3 47 | MOVD $0, R4 48 | MOVD $0, R5 49 | MOVD trap+0(FP), R8 // syscall entry 50 | SVC 51 | MOVD R0, r1+32(FP) 52 | MOVD R1, r2+40(FP) 53 | RET 54 | -------------------------------------------------------------------------------- /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 | // +build linux 7 | // +build mips64 mips64le 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for mips64, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·Syscall(SB),NOSPLIT,$0-56 20 | JMP syscall·Syscall(SB) 21 | 22 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 23 | JMP syscall·Syscall6(SB) 24 | 25 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 26 | JAL runtime·entersyscall(SB) 27 | MOVV a1+8(FP), R4 28 | MOVV a2+16(FP), R5 29 | MOVV a3+24(FP), R6 30 | MOVV R0, R7 31 | MOVV R0, R8 32 | MOVV R0, R9 33 | MOVV trap+0(FP), R2 // syscall entry 34 | SYSCALL 35 | MOVV R2, r1+32(FP) 36 | MOVV R3, r2+40(FP) 37 | JAL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 47 | MOVV a1+8(FP), R4 48 | MOVV a2+16(FP), R5 49 | MOVV a3+24(FP), R6 50 | MOVV R0, R7 51 | MOVV R0, R8 52 | MOVV R0, R9 53 | MOVV trap+0(FP), R2 // syscall entry 54 | SYSCALL 55 | MOVV R2, r1+32(FP) 56 | MOVV R3, r2+40(FP) 57 | RET 58 | -------------------------------------------------------------------------------- /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 | // +build linux 7 | // +build mips mipsle 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for mips, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·Syscall(SB),NOSPLIT,$0-28 20 | JMP syscall·Syscall(SB) 21 | 22 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 23 | JMP syscall·Syscall6(SB) 24 | 25 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 26 | JMP syscall·Syscall9(SB) 27 | 28 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 29 | JAL runtime·entersyscall(SB) 30 | MOVW a1+4(FP), R4 31 | MOVW a2+8(FP), R5 32 | MOVW a3+12(FP), R6 33 | MOVW R0, R7 34 | MOVW trap+0(FP), R2 // syscall entry 35 | SYSCALL 36 | MOVW R2, r1+16(FP) // r1 37 | MOVW R3, r2+20(FP) // r2 38 | JAL runtime·exitsyscall(SB) 39 | RET 40 | 41 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 42 | JMP syscall·RawSyscall(SB) 43 | 44 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 45 | JMP syscall·RawSyscall6(SB) 46 | 47 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 48 | MOVW a1+4(FP), R4 49 | MOVW a2+8(FP), R5 50 | MOVW a3+12(FP), R6 51 | MOVW trap+0(FP), R2 // syscall entry 52 | SYSCALL 53 | MOVW R2, r1+16(FP) 54 | MOVW R3, r2+20(FP) 55 | RET 56 | -------------------------------------------------------------------------------- /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 | // +build linux 7 | // +build ppc64 ppc64le 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for ppc64, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 20 | BL runtime·entersyscall(SB) 21 | MOVD a1+8(FP), R3 22 | MOVD a2+16(FP), R4 23 | MOVD a3+24(FP), R5 24 | MOVD R0, R6 25 | MOVD R0, R7 26 | MOVD R0, R8 27 | MOVD trap+0(FP), R9 // syscall entry 28 | SYSCALL R9 29 | MOVD R3, r1+32(FP) 30 | MOVD R4, r2+40(FP) 31 | BL runtime·exitsyscall(SB) 32 | RET 33 | 34 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 35 | MOVD a1+8(FP), R3 36 | MOVD a2+16(FP), R4 37 | MOVD a3+24(FP), R5 38 | MOVD R0, R6 39 | MOVD R0, R7 40 | MOVD R0, R8 41 | MOVD trap+0(FP), R9 // syscall entry 42 | SYSCALL R9 43 | MOVD R3, r1+32(FP) 44 | MOVD R4, r2+40(FP) 45 | RET 46 | -------------------------------------------------------------------------------- /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 | // +build riscv64 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for linux/riscv64. 13 | // 14 | // Where available, just jump to package syscall's implementation of 15 | // these functions. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | JMP syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | JMP syscall·Syscall6(SB) 22 | 23 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 24 | CALL runtime·entersyscall(SB) 25 | MOV a1+8(FP), A0 26 | MOV a2+16(FP), A1 27 | MOV a3+24(FP), A2 28 | MOV trap+0(FP), A7 // syscall entry 29 | ECALL 30 | MOV A0, r1+32(FP) // r1 31 | MOV A1, r2+40(FP) // r2 32 | CALL runtime·exitsyscall(SB) 33 | RET 34 | 35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 36 | JMP syscall·RawSyscall(SB) 37 | 38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 39 | JMP syscall·RawSyscall6(SB) 40 | 41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 42 | MOV a1+8(FP), A0 43 | MOV a2+16(FP), A1 44 | MOV a3+24(FP), A2 45 | MOV trap+0(FP), A7 // syscall entry 46 | ECALL 47 | MOV A0, r1+32(FP) 48 | MOV A1, r2+40(FP) 49 | RET 50 | -------------------------------------------------------------------------------- /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 | // +build linux 7 | // +build s390x 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for s390x, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·Syscall(SB),NOSPLIT,$0-56 20 | BR syscall·Syscall(SB) 21 | 22 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 23 | BR syscall·Syscall6(SB) 24 | 25 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 26 | BL runtime·entersyscall(SB) 27 | MOVD a1+8(FP), R2 28 | MOVD a2+16(FP), R3 29 | MOVD a3+24(FP), R4 30 | MOVD $0, R5 31 | MOVD $0, R6 32 | MOVD $0, R7 33 | MOVD trap+0(FP), R1 // syscall entry 34 | SYSCALL 35 | MOVD R2, r1+32(FP) 36 | MOVD R3, r2+40(FP) 37 | BL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 41 | BR syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 44 | BR syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 47 | MOVD a1+8(FP), R2 48 | MOVD a2+16(FP), R3 49 | MOVD a3+24(FP), R4 50 | MOVD $0, R5 51 | MOVD $0, R6 52 | MOVD $0, R7 53 | MOVD trap+0(FP), R1 // syscall entry 54 | SYSCALL 55 | MOVD R2, r1+32(FP) 56 | MOVD R3, r2+40(FP) 57 | RET 58 | -------------------------------------------------------------------------------- /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 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for mips64, OpenBSD 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | JMP syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | JMP syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | JMP syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | JMP syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | JMP syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /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 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 12 | // 13 | 14 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 15 | JMP syscall·sysvicall6(SB) 16 | 17 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 18 | JMP syscall·rawSysvicall6(SB) 19 | -------------------------------------------------------------------------------- /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 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | const ( 11 | R_OK = 0x4 12 | W_OK = 0x2 13 | X_OK = 0x1 14 | ) 15 | -------------------------------------------------------------------------------- /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 | // +build aix,ppc 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev >> 16) & 0xffff) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32(dev & 0xffff) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | return uint64(((major) << 16) | (minor)) 27 | } 28 | -------------------------------------------------------------------------------- /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 | // +build aix,ppc64 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev & 0x3fffffff00000000) >> 32) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32((dev & 0x00000000ffffffff) >> 0) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | var DEVNO64 uint64 27 | DEVNO64 = 0x8000000000000000 28 | return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64) 29 | } 30 | -------------------------------------------------------------------------------- /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 | // +build zos,s390x 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by z/OS. 10 | // 11 | // The information below is extracted and adapted from macros. 12 | 13 | package unix 14 | 15 | // Major returns the major component of a z/OS device number. 16 | func Major(dev uint64) uint32 { 17 | return uint32((dev >> 16) & 0x0000FFFF) 18 | } 19 | 20 | // Minor returns the minor component of a z/OS device number. 21 | func Minor(dev uint64) uint32 { 22 | return uint32(dev & 0x0000FFFF) 23 | } 24 | 25 | // Mkdev returns a z/OS device number generated from the given major and minor 26 | // components. 27 | func Mkdev(major, minor uint32) uint64 { 28 | return (uint64(major) << 16) | uint64(minor) 29 | } 30 | -------------------------------------------------------------------------------- /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 | // +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64 7 | 8 | package unix 9 | 10 | const isBigEndian = true 11 | -------------------------------------------------------------------------------- /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 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh 6 | // +build 386 amd64 amd64p32 alpha arm arm64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh 7 | 8 | package unix 9 | 10 | const isBigEndian = false 11 | -------------------------------------------------------------------------------- /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 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | // Unix environment variables. 9 | 10 | package unix 11 | 12 | import "syscall" 13 | 14 | func Getenv(key string) (value string, found bool) { 15 | return syscall.Getenv(key) 16 | } 17 | 18 | func Setenv(key, value string) error { 19 | return syscall.Setenv(key, value) 20 | } 21 | 22 | func Clearenv() { 23 | syscall.Clearenv() 24 | } 25 | 26 | func Environ() []string { 27 | return syscall.Environ() 28 | } 29 | 30 | func Unsetenv(key string) error { 31 | return syscall.Unsetenv(key) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/errors_freebsd_arm64.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 | // Constants that were deprecated or moved to enums in the FreeBSD headers. Keep 6 | // them here for backwards compatibility. 7 | 8 | package unix 9 | 10 | const ( 11 | DLT_HHDLC = 0x79 12 | IPV6_MIN_MEMBERSHIPS = 0x1f 13 | IP_MAX_SOURCE_FILTER = 0x400 14 | IP_MIN_MEMBERSHIPS = 0x1f 15 | RT_CACHING_CONTEXT = 0x1 16 | RT_NORTREF = 0x2 17 | ) 18 | -------------------------------------------------------------------------------- /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 || openbsd 6 | // +build dragonfly freebsd linux netbsd openbsd 7 | 8 | package unix 9 | 10 | import "unsafe" 11 | 12 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 13 | // systems by fcntl_linux_32bit.go to be SYS_FCNTL64. 14 | var fcntl64Syscall uintptr = SYS_FCNTL 15 | 16 | func fcntl(fd int, cmd, arg int) (int, error) { 17 | valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg)) 18 | var err error 19 | if errno != 0 { 20 | err = errno 21 | } 22 | return int(valptr), err 23 | } 24 | 25 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 26 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 27 | return fcntl(int(fd), cmd, arg) 28 | } 29 | 30 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 31 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 32 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 33 | if errno == 0 { 34 | return nil 35 | } 36 | return errno 37 | } 38 | -------------------------------------------------------------------------------- /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 | // +build linux,386 linux,arm linux,mips linux,mipsle linux,ppc 7 | 8 | package unix 9 | 10 | func init() { 11 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 12 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 13 | fcntl64Syscall = SYS_FCNTL64 14 | } 15 | -------------------------------------------------------------------------------- /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 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 7 | 8 | package unix 9 | 10 | // Set adds fd to the set fds. 11 | func (fds *FdSet) Set(fd int) { 12 | fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS)) 13 | } 14 | 15 | // Clear removes fd from the set fds. 16 | func (fds *FdSet) Clear(fd int) { 17 | fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS)) 18 | } 19 | 20 | // IsSet returns whether fd is in the set fds. 21 | func (fds *FdSet) IsSet(fd int) bool { 22 | return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0 23 | } 24 | 25 | // Zero clears the set fds. 26 | func (fds *FdSet) Zero() { 27 | for i := range fds.Bits { 28 | fds.Bits[i] = 0 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /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 6 | // +build gccgo,!aix 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // We can't use the gc-syntax .s files for gccgo. On the plus side 13 | // much of the functionality can be written directly in Go. 14 | 15 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 16 | 17 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 18 | 19 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 20 | syscall.Entersyscall() 21 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 22 | syscall.Exitsyscall() 23 | return r, 0 24 | } 25 | 26 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 27 | syscall.Entersyscall() 28 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 29 | syscall.Exitsyscall() 30 | return r, 0, syscall.Errno(errno) 31 | } 32 | 33 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 34 | syscall.Entersyscall() 35 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 36 | syscall.Exitsyscall() 37 | return r, 0, syscall.Errno(errno) 38 | } 39 | 40 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 41 | syscall.Entersyscall() 42 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 43 | syscall.Exitsyscall() 44 | return r, 0, syscall.Errno(errno) 45 | } 46 | 47 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 48 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 49 | return r, 0 50 | } 51 | 52 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 53 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 54 | return r, 0, syscall.Errno(errno) 55 | } 56 | 57 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 58 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 59 | return r, 0, syscall.Errno(errno) 60 | } 61 | -------------------------------------------------------------------------------- /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 | // +build gccgo 6 | // +build !aix 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define _STRINGIFY2_(x) #x 13 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 14 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 15 | 16 | // Call syscall from C code because the gccgo support for calling from 17 | // Go to C does not support varargs functions. 18 | 19 | struct ret { 20 | uintptr_t r; 21 | uintptr_t err; 22 | }; 23 | 24 | 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) 25 | __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall"); 26 | 27 | struct ret 28 | 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) 29 | { 30 | struct ret r; 31 | 32 | errno = 0; 33 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 34 | r.err = errno; 35 | return r; 36 | } 37 | 38 | 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) 39 | __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError"); 40 | 41 | uintptr_t 42 | 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) 43 | { 44 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 45 | } 46 | -------------------------------------------------------------------------------- /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 | // +build gccgo,linux,amd64 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //extern gettimeofday 13 | func realGettimeofday(*Timeval, *byte) int32 14 | 15 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 16 | r := realGettimeofday(tv, nil) 17 | if r < 0 { 18 | return syscall.GetErrno() 19 | } 20 | return 0 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl.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 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | "unsafe" 13 | ) 14 | 15 | // ioctl itself should not be exposed directly, but additional get/set 16 | // functions for specific types are permissible. 17 | 18 | // IoctlSetInt performs an ioctl operation which sets an integer value 19 | // on fd, using the specified request number. 20 | func IoctlSetInt(fd int, req uint, value int) error { 21 | return ioctl(fd, req, uintptr(value)) 22 | } 23 | 24 | // IoctlSetPointerInt performs an ioctl operation which sets an 25 | // integer value on fd, using the specified request number. The ioctl 26 | // argument is called with a pointer to the integer value, rather than 27 | // passing the integer value directly. 28 | func IoctlSetPointerInt(fd int, req uint, value int) error { 29 | v := int32(value) 30 | return ioctl(fd, req, uintptr(unsafe.Pointer(&v))) 31 | } 32 | 33 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 34 | // 35 | // To change fd's window size, the req argument should be TIOCSWINSZ. 36 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 37 | // TODO: if we get the chance, remove the req parameter and 38 | // hardcode TIOCSWINSZ. 39 | err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) 40 | runtime.KeepAlive(value) 41 | return err 42 | } 43 | 44 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 45 | // 46 | // The req value will usually be TCSETA or TIOCSETA. 47 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 48 | // TODO: if we get the chance, remove the req parameter. 49 | err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) 50 | runtime.KeepAlive(value) 51 | return err 52 | } 53 | 54 | // IoctlGetInt performs an ioctl operation which gets an integer value 55 | // from fd, using the specified request number. 56 | // 57 | // A few ioctl requests use the return value as an output parameter; 58 | // for those, IoctlRetInt should be used instead of this function. 59 | func IoctlGetInt(fd int, req uint) (int, error) { 60 | var value int 61 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 62 | return value, err 63 | } 64 | 65 | func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { 66 | var value Winsize 67 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 68 | return &value, err 69 | } 70 | 71 | func IoctlGetTermios(fd int, req uint) (*Termios, error) { 72 | var value Termios 73 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 74 | return &value, err 75 | } 76 | -------------------------------------------------------------------------------- /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 | // +build zos,s390x 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | "unsafe" 13 | ) 14 | 15 | // ioctl itself should not be exposed directly, but additional get/set 16 | // functions for specific types are permissible. 17 | 18 | // IoctlSetInt performs an ioctl operation which sets an integer value 19 | // on fd, using the specified request number. 20 | func IoctlSetInt(fd int, req uint, value int) error { 21 | return ioctl(fd, req, uintptr(value)) 22 | } 23 | 24 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 25 | // 26 | // To change fd's window size, the req argument should be TIOCSWINSZ. 27 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 28 | // TODO: if we get the chance, remove the req parameter and 29 | // hardcode TIOCSWINSZ. 30 | err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) 31 | runtime.KeepAlive(value) 32 | return err 33 | } 34 | 35 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 36 | // 37 | // The req value is expected to be TCSETS, TCSETSW, or TCSETSF 38 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 39 | if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) { 40 | return ENOSYS 41 | } 42 | err := Tcsetattr(fd, int(req), value) 43 | runtime.KeepAlive(value) 44 | return err 45 | } 46 | 47 | // IoctlGetInt performs an ioctl operation which gets an integer value 48 | // from fd, using the specified request number. 49 | // 50 | // A few ioctl requests use the return value as an output parameter; 51 | // for those, IoctlRetInt should be used instead of this function. 52 | func IoctlGetInt(fd int, req uint) (int, error) { 53 | var value int 54 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 55 | return value, err 56 | } 57 | 58 | func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { 59 | var value Winsize 60 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 61 | return &value, err 62 | } 63 | 64 | // IoctlGetTermios performs an ioctl on fd with a *Termios. 65 | // 66 | // The req value is expected to be TCGETS 67 | func IoctlGetTermios(fd int, req uint) (*Termios, error) { 68 | var value Termios 69 | if req != TCGETS { 70 | return &value, ENOSYS 71 | } 72 | err := Tcgetattr(fd, &value) 73 | return &value, err 74 | } 75 | -------------------------------------------------------------------------------- /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 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 7 | 8 | // For Unix, get the pagesize from the runtime. 9 | 10 | package unix 11 | 12 | import "syscall" 13 | 14 | func Getpagesize() int { 15 | return syscall.Getpagesize() 16 | } 17 | -------------------------------------------------------------------------------- /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 | // +build darwin,!ios 7 | 8 | package unix 9 | 10 | func ptrace(request int, pid int, addr uintptr, data uintptr) error { 11 | return ptrace1(request, pid, addr, data) 12 | } 13 | -------------------------------------------------------------------------------- /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 | // +build ios 7 | 8 | package unix 9 | 10 | func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { 11 | return ENOTSUP 12 | } 13 | -------------------------------------------------------------------------------- /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 | // +build darwin,race linux,race freebsd,race 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | "unsafe" 13 | ) 14 | 15 | const raceenabled = true 16 | 17 | func raceAcquire(addr unsafe.Pointer) { 18 | runtime.RaceAcquire(addr) 19 | } 20 | 21 | func raceReleaseMerge(addr unsafe.Pointer) { 22 | runtime.RaceReleaseMerge(addr) 23 | } 24 | 25 | func raceReadRange(addr unsafe.Pointer, len int) { 26 | runtime.RaceReadRange(addr, len) 27 | } 28 | 29 | func raceWriteRange(addr unsafe.Pointer, len int) { 30 | runtime.RaceWriteRange(addr, len) 31 | } 32 | -------------------------------------------------------------------------------- /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 | // +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly zos 7 | 8 | package unix 9 | 10 | import ( 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = false 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | } 18 | 19 | func raceReleaseMerge(addr unsafe.Pointer) { 20 | } 21 | 22 | func raceReadRange(addr unsafe.Pointer, len int) { 23 | } 24 | 25 | func raceWriteRange(addr unsafe.Pointer, len int) { 26 | } 27 | -------------------------------------------------------------------------------- /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 | // +build aix dragonfly freebsd linux netbsd openbsd 7 | 8 | package unix 9 | 10 | // ReadDirent reads directory entries from fd and writes them into buf. 11 | func ReadDirent(fd int, buf []byte) (n int, err error) { 12 | return Getdents(fd, buf) 13 | } 14 | -------------------------------------------------------------------------------- /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 | // +build darwin 7 | 8 | package unix 9 | 10 | import "unsafe" 11 | 12 | // ReadDirent reads directory entries from fd and writes them into buf. 13 | func ReadDirent(fd int, buf []byte) (n int, err error) { 14 | // Final argument is (basep *uintptr) and the syscall doesn't take nil. 15 | // 64 bits should be enough. (32 bits isn't even on 386). Since the 16 | // actual system call is getdirentries64, 64 is a good guess. 17 | // TODO(rsc): Can we use a single global basep for all calls? 18 | var base = (*uintptr)(unsafe.Pointer(new(uint64))) 19 | return Getdirentries(fd, buf, base) 20 | } 21 | -------------------------------------------------------------------------------- /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_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 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 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *(*Ucred)(h.data(0)) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /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 | // +build aix darwin freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | ) 13 | 14 | // Round the length of a raw sockaddr up to align it properly. 15 | func cmsgAlignOf(salen int) int { 16 | salign := SizeofPtr 17 | 18 | // dragonfly needs to check ABI version at runtime, see cmsgAlignOf in 19 | // sockcmsg_dragonfly.go 20 | switch runtime.GOOS { 21 | case "aix": 22 | // There is no alignment on AIX. 23 | salign = 1 24 | case "darwin", "ios", "illumos", "solaris": 25 | // NOTE: It seems like 64-bit Darwin, Illumos and Solaris 26 | // kernels still require 32-bit aligned access to network 27 | // subsystem. 28 | if SizeofPtr == 8 { 29 | salign = 4 30 | } 31 | case "netbsd", "openbsd": 32 | // NetBSD and OpenBSD armv7 require 64-bit alignment. 33 | if runtime.GOARCH == "arm" { 34 | salign = 8 35 | } 36 | // NetBSD aarch64 requires 128-bit alignment. 37 | if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm64" { 38 | salign = 16 39 | } 40 | case "zos": 41 | // z/OS socket macros use [32-bit] sizeof(int) alignment, 42 | // not pointer width. 43 | salign = SizeofInt 44 | } 45 | 46 | return (salen + salign - 1) & ^(salign - 1) 47 | } 48 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.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 aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 7 | 8 | package unix 9 | 10 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 11 | if val < 0 { 12 | return "-" + uitoa(uint(-val)) 13 | } 14 | return uitoa(uint(val)) 15 | } 16 | 17 | func uitoa(val uint) string { 18 | var buf [32]byte // big enough for int64 19 | i := len(buf) - 1 20 | for val >= 10 { 21 | buf[i] = byte(val%10 + '0') 22 | i-- 23 | val /= 10 24 | } 25 | buf[i] = byte(val + '0') 26 | return string(buf[i:]) 27 | } 28 | -------------------------------------------------------------------------------- /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 | // +build aix,ppc 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func Fstat(fd int, stat *Stat_t) error { 41 | return fstat(fd, stat) 42 | } 43 | 44 | func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { 45 | return fstatat(dirfd, path, stat, flags) 46 | } 47 | 48 | func Lstat(path string, stat *Stat_t) error { 49 | return lstat(path, stat) 50 | } 51 | 52 | func Stat(path string, statptr *Stat_t) error { 53 | return stat(path, statptr) 54 | } 55 | -------------------------------------------------------------------------------- /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 | // +build aix,ppc64 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: sec, Nsec: nsec} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int64(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // In order to only have Timespec structure, type of Stat_t's fields 41 | // Atim, Mtim and Ctim is changed from StTimespec to Timespec during 42 | // ztypes generation. 43 | // On ppc64, Timespec.Nsec is an int64 while StTimespec.Nsec is an 44 | // int32, so the fields' value must be modified. 45 | func fixStatTimFields(stat *Stat_t) { 46 | stat.Atim.Nsec >>= 32 47 | stat.Mtim.Nsec >>= 32 48 | stat.Ctim.Nsec >>= 32 49 | } 50 | 51 | func Fstat(fd int, stat *Stat_t) error { 52 | err := fstat(fd, stat) 53 | if err != nil { 54 | return err 55 | } 56 | fixStatTimFields(stat) 57 | return nil 58 | } 59 | 60 | func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { 61 | err := fstatat(dirfd, path, stat, flags) 62 | if err != nil { 63 | return err 64 | } 65 | fixStatTimFields(stat) 66 | return nil 67 | } 68 | 69 | func Lstat(path string, stat *Stat_t) error { 70 | err := lstat(path, stat) 71 | if err != nil { 72 | return err 73 | } 74 | fixStatTimFields(stat) 75 | return nil 76 | } 77 | 78 | func Stat(path string, statptr *Stat_t) error { 79 | err := stat(path, statptr) 80 | if err != nil { 81 | return err 82 | } 83 | fixStatTimFields(statptr) 84 | return nil 85 | } 86 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin.1_12.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 && go1.12 && !go1.13 6 | // +build darwin,go1.12,!go1.13 7 | 8 | package unix 9 | 10 | import ( 11 | "unsafe" 12 | ) 13 | 14 | const _SYS_GETDIRENTRIES64 = 344 15 | 16 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { 17 | // To implement this using libSystem we'd need syscall_syscallPtr for 18 | // fdopendir. However, syscallPtr was only added in Go 1.13, so we fall 19 | // back to raw syscalls for this func on Go 1.12. 20 | var p unsafe.Pointer 21 | if len(buf) > 0 { 22 | p = unsafe.Pointer(&buf[0]) 23 | } else { 24 | p = unsafe.Pointer(&_zero) 25 | } 26 | r0, _, e1 := Syscall6(_SYS_GETDIRENTRIES64, uintptr(fd), uintptr(p), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) 27 | n = int(r0) 28 | if e1 != 0 { 29 | return n, errnoErr(e1) 30 | } 31 | return n, nil 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_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 && darwin 6 | // +build 386,darwin 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 18 | } 19 | 20 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 21 | k.Ident = uint32(fd) 22 | k.Filter = int16(mode) 23 | k.Flags = uint16(flags) 24 | } 25 | 26 | func (iov *Iovec) SetLen(length int) { 27 | iov.Len = uint32(length) 28 | } 29 | 30 | func (msghdr *Msghdr) SetControllen(length int) { 31 | msghdr.Controllen = uint32(length) 32 | } 33 | 34 | func (msghdr *Msghdr) SetIovlen(length int) { 35 | msghdr.Iovlen = int32(length) 36 | } 37 | 38 | func (cmsg *Cmsghdr) SetLen(length int) { 39 | cmsg.Len = uint32(length) 40 | } 41 | 42 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 43 | 44 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 45 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 46 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 47 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 48 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 49 | //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace 50 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 51 | //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 52 | -------------------------------------------------------------------------------- /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 | // +build amd64,darwin 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: sec, Nsec: nsec} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: sec, Usec: int32(usec)} 18 | } 19 | 20 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 21 | k.Ident = uint64(fd) 22 | k.Filter = int16(mode) 23 | k.Flags = uint16(flags) 24 | } 25 | 26 | func (iov *Iovec) SetLen(length int) { 27 | iov.Len = uint64(length) 28 | } 29 | 30 | func (msghdr *Msghdr) SetControllen(length int) { 31 | msghdr.Controllen = uint32(length) 32 | } 33 | 34 | func (msghdr *Msghdr) SetIovlen(length int) { 35 | msghdr.Iovlen = int32(length) 36 | } 37 | 38 | func (cmsg *Cmsghdr) SetLen(length int) { 39 | cmsg.Len = uint32(length) 40 | } 41 | 42 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 43 | 44 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 45 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 46 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 47 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 48 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 49 | //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace 50 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 51 | //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.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 | package unix 6 | 7 | import "syscall" 8 | 9 | func ptrace1(request int, pid int, addr uintptr, data uintptr) error { 10 | return ENOTSUP 11 | } 12 | 13 | func setTimespec(sec, nsec int64) Timespec { 14 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 15 | } 16 | 17 | func setTimeval(sec, usec int64) Timeval { 18 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 19 | } 20 | 21 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 22 | k.Ident = uint32(fd) 23 | k.Filter = int16(mode) 24 | k.Flags = uint16(flags) 25 | } 26 | 27 | func (iov *Iovec) SetLen(length int) { 28 | iov.Len = uint32(length) 29 | } 30 | 31 | func (msghdr *Msghdr) SetControllen(length int) { 32 | msghdr.Controllen = uint32(length) 33 | } 34 | 35 | func (msghdr *Msghdr) SetIovlen(length int) { 36 | msghdr.Iovlen = int32(length) 37 | } 38 | 39 | func (cmsg *Cmsghdr) SetLen(length int) { 40 | cmsg.Len = uint32(length) 41 | } 42 | 43 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 44 | 45 | //sys Fstat(fd int, stat *Stat_t) (err error) 46 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 47 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) 48 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT 49 | //sys Lstat(path string, stat *Stat_t) (err error) 50 | //sys Stat(path string, stat *Stat_t) (err error) 51 | //sys Statfs(path string, stat *Statfs_t) (err error) 52 | -------------------------------------------------------------------------------- /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 | // +build arm64,darwin 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: sec, Nsec: nsec} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: sec, Usec: int32(usec)} 18 | } 19 | 20 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 21 | k.Ident = uint64(fd) 22 | k.Filter = int16(mode) 23 | k.Flags = uint16(flags) 24 | } 25 | 26 | func (iov *Iovec) SetLen(length int) { 27 | iov.Len = uint64(length) 28 | } 29 | 30 | func (msghdr *Msghdr) SetControllen(length int) { 31 | msghdr.Controllen = uint32(length) 32 | } 33 | 34 | func (msghdr *Msghdr) SetIovlen(length int) { 35 | msghdr.Iovlen = int32(length) 36 | } 37 | 38 | func (cmsg *Cmsghdr) SetLen(length int) { 39 | cmsg.Len = uint32(length) 40 | } 41 | 42 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 43 | 44 | //sys Fstat(fd int, stat *Stat_t) (err error) 45 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 46 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) 47 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT 48 | //sys Lstat(path string, stat *Stat_t) (err error) 49 | //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace 50 | //sys Stat(path string, stat *Stat_t) (err error) 51 | //sys Statfs(path string, stat *Statfs_t) (err error) 52 | -------------------------------------------------------------------------------- /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 && go1.12 6 | // +build darwin,go1.12 7 | 8 | package unix 9 | 10 | import "unsafe" 11 | 12 | // Implemented in the runtime package (runtime/sys_darwin.go) 13 | func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 14 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 15 | func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 16 | func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // 32-bit only 17 | func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 18 | func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 19 | func syscall_syscallPtr(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 20 | 21 | //go:linkname syscall_syscall syscall.syscall 22 | //go:linkname syscall_syscall6 syscall.syscall6 23 | //go:linkname syscall_syscall6X syscall.syscall6X 24 | //go:linkname syscall_syscall9 syscall.syscall9 25 | //go:linkname syscall_rawSyscall syscall.rawSyscall 26 | //go:linkname syscall_rawSyscall6 syscall.rawSyscall6 27 | //go:linkname syscall_syscallPtr syscall.syscallPtr 28 | 29 | // Find the entry point for f. See comments in runtime/proc.go for the 30 | // function of the same name. 31 | //go:nosplit 32 | func funcPC(f func()) uintptr { 33 | return **(**uintptr)(unsafe.Pointer(&f)) 34 | } 35 | -------------------------------------------------------------------------------- /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 | // +build amd64,dragonfly 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: nsec} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: usec} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint64(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint64(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | -------------------------------------------------------------------------------- /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 | // +build 386,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint32(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint32(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceGetFsBase(pid int, fsbase *int64) (err error) { 60 | return ptrace(PTRACE_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) 61 | } 62 | 63 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 64 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)} 65 | err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 66 | return int(ioDesc.Len), err 67 | } 68 | -------------------------------------------------------------------------------- /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 | // +build amd64,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: nsec} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: usec} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint64(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint64(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceGetFsBase(pid int, fsbase *int64) (err error) { 60 | return ptrace(PTRACE_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) 61 | } 62 | 63 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 64 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)} 65 | err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 66 | return int(ioDesc.Len), err 67 | } 68 | -------------------------------------------------------------------------------- /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 | // +build arm,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: int32(nsec)} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: int32(usec)} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint32(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint32(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 60 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)} 61 | err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 62 | return int(ioDesc.Len), err 63 | } 64 | -------------------------------------------------------------------------------- /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 | // +build arm64,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: nsec} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: usec} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint64(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint64(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 60 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)} 61 | err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 62 | return int(ioDesc.Len), err 63 | } 64 | -------------------------------------------------------------------------------- /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 | // +build amd64,linux,gc 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /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 | // +build linux,gc 7 | 8 | package unix 9 | 10 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 11 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 12 | 13 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 14 | // fail. 15 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 16 | -------------------------------------------------------------------------------- /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 | // +build linux,gc,386 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // Underlying system call writes to newoffset via pointer. 13 | // Implemented in assembly to avoid allocation. 14 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 15 | 16 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 18 | -------------------------------------------------------------------------------- /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 | // +build arm,gc,linux 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // Underlying system call writes to newoffset via pointer. 13 | // Implemented in assembly to avoid allocation. 14 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 15 | -------------------------------------------------------------------------------- /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 | // +build linux,gccgo,386 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 16 | var newoffset int64 17 | offsetLow := uint32(offset & 0xffffffff) 18 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 19 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 20 | return newoffset, err 21 | } 22 | 23 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 24 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 25 | return int(fd), err 26 | } 27 | 28 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 29 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 30 | return int(fd), err 31 | } 32 | -------------------------------------------------------------------------------- /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 | // +build linux,gccgo,arm 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 16 | var newoffset int64 17 | offsetLow := uint32(offset & 0xffffffff) 18 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 19 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 20 | return newoffset, err 21 | } 22 | -------------------------------------------------------------------------------- /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 | // +build 386,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /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 | // +build amd64,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /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 | // +build arm,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /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 | // +build arm64,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /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 | // +build 386,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/386 the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /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 | // +build amd64,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: usec} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /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 | // +build arm,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/arm the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /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 | // +build arm64,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: usec} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /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 (cmsg *Cmsghdr) SetLen(length int) { 30 | cmsg.Len = uint32(length) 31 | } 32 | 33 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 34 | // of OpenBSD the syscall is called sysctl instead of __sysctl. 35 | const SYS___SYSCTL = SYS_SYSCTL 36 | -------------------------------------------------------------------------------- /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 | // +build amd64,solaris 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: usec} 16 | } 17 | 18 | func (iov *Iovec) SetLen(length int) { 19 | iov.Len = uint64(length) 20 | } 21 | 22 | func (msghdr *Msghdr) SetIovlen(length int) { 23 | msghdr.Iovlen = int32(length) 24 | } 25 | 26 | func (cmsg *Cmsghdr) SetLen(length int) { 27 | cmsg.Len = uint32(length) 28 | } 29 | -------------------------------------------------------------------------------- /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 || netbsd || openbsd || solaris) && gc && !ppc64le && !ppc64 6 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 7 | // +build gc 8 | // +build !ppc64le 9 | // +build !ppc64 10 | 11 | package unix 12 | 13 | import "syscall" 14 | 15 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 17 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 18 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 19 | -------------------------------------------------------------------------------- /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 | // +build linux 7 | // +build ppc64le ppc64 8 | // +build gc 9 | 10 | package unix 11 | 12 | import "syscall" 13 | 14 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 15 | return syscall.Syscall(trap, a1, a2, a3) 16 | } 17 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | return syscall.Syscall6(trap, a1, a2, a3, a4, a5, a6) 19 | } 20 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 21 | return syscall.RawSyscall(trap, a1, a2, a3) 22 | } 23 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 24 | return syscall.RawSyscall6(trap, a1, a2, a3, a4, a5, a6) 25 | } 26 | -------------------------------------------------------------------------------- /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 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | import "time" 11 | 12 | // TimespecToNSec returns the time stored in ts as nanoseconds. 13 | func TimespecToNsec(ts Timespec) int64 { return ts.Nano() } 14 | 15 | // NsecToTimespec converts a number of nanoseconds into a Timespec. 16 | func NsecToTimespec(nsec int64) Timespec { 17 | sec := nsec / 1e9 18 | nsec = nsec % 1e9 19 | if nsec < 0 { 20 | nsec += 1e9 21 | sec-- 22 | } 23 | return setTimespec(sec, nsec) 24 | } 25 | 26 | // TimeToTimespec converts t into a Timespec. 27 | // On some 32-bit systems the range of valid Timespec values are smaller 28 | // than that of time.Time values. So if t is out of the valid range of 29 | // Timespec, it returns a zero Timespec and ERANGE. 30 | func TimeToTimespec(t time.Time) (Timespec, error) { 31 | sec := t.Unix() 32 | nsec := int64(t.Nanosecond()) 33 | ts := setTimespec(sec, nsec) 34 | 35 | // Currently all targets have either int32 or int64 for Timespec.Sec. 36 | // If there were a new target with floating point type for it, we have 37 | // to consider the rounding error. 38 | if int64(ts.Sec) != sec { 39 | return Timespec{}, ERANGE 40 | } 41 | return ts, nil 42 | } 43 | 44 | // TimevalToNsec returns the time stored in tv as nanoseconds. 45 | func TimevalToNsec(tv Timeval) int64 { return tv.Nano() } 46 | 47 | // NsecToTimeval converts a number of nanoseconds into a Timeval. 48 | func NsecToTimeval(nsec int64) Timeval { 49 | nsec += 999 // round up to microsecond 50 | usec := nsec % 1e9 / 1e3 51 | sec := nsec / 1e9 52 | if usec < 0 { 53 | usec += 1e6 54 | sec-- 55 | } 56 | return setTimeval(sec, usec) 57 | } 58 | 59 | // Unix returns the time stored in ts as seconds plus nanoseconds. 60 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 61 | return int64(ts.Sec), int64(ts.Nsec) 62 | } 63 | 64 | // Unix returns the time stored in tv as seconds plus nanoseconds. 65 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 66 | return int64(tv.Sec), int64(tv.Usec) * 1000 67 | } 68 | 69 | // Nano returns the time stored in ts as nanoseconds. 70 | func (ts *Timespec) Nano() int64 { 71 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 72 | } 73 | 74 | // Nano returns the time stored in tv as nanoseconds. 75 | func (tv *Timeval) Nano() int64 { 76 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 77 | } 78 | -------------------------------------------------------------------------------- /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 ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | // Unveil implements the unveil syscall. 13 | // For more information see unveil(2). 14 | // Note that the special case of blocking further 15 | // unveil calls is handled by UnveilBlock. 16 | func Unveil(path string, flags string) error { 17 | pathPtr, err := syscall.BytePtrFromString(path) 18 | if err != nil { 19 | return err 20 | } 21 | flagsPtr, err := syscall.BytePtrFromString(flags) 22 | if err != nil { 23 | return err 24 | } 25 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0) 26 | if e != 0 { 27 | return e 28 | } 29 | return nil 30 | } 31 | 32 | // UnveilBlock blocks future unveil calls. 33 | // For more information see unveil(2). 34 | func UnveilBlock() error { 35 | // Both pointers must be nil. 36 | var pathUnsafe, flagsUnsafe unsafe.Pointer 37 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 0) 38 | if e != 0 { 39 | return e 40 | } 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /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 | // +build linux 5 | // +build arm arm64 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegsArm is the registers used by arm binaries. 12 | type PtraceRegsArm struct { 13 | Uregs [18]uint32 14 | } 15 | 16 | // PtraceGetRegsArm fetches the registers used by arm binaries. 17 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { 18 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 19 | } 20 | 21 | // PtraceSetRegsArm sets the registers used by arm binaries. 22 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { 23 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 24 | } 25 | 26 | // PtraceRegsArm64 is the registers used by arm64 binaries. 27 | type PtraceRegsArm64 struct { 28 | Regs [31]uint64 29 | Sp uint64 30 | Pc uint64 31 | Pstate uint64 32 | } 33 | 34 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries. 35 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { 36 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 37 | } 38 | 39 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries. 40 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { 41 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 42 | } 43 | -------------------------------------------------------------------------------- /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 ptrace(PTRACE_GETREGSET, pid, uintptr(addr), uintptr(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 ptrace(PTRACE_SETREGSET, pid, uintptr(addr), uintptr(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 | // +build linux 5 | // +build mips mips64 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegsMips is the registers used by mips binaries. 12 | type PtraceRegsMips struct { 13 | Regs [32]uint64 14 | Lo uint64 15 | Hi uint64 16 | Epc uint64 17 | Badvaddr uint64 18 | Status uint64 19 | Cause uint64 20 | } 21 | 22 | // PtraceGetRegsMips fetches the registers used by mips binaries. 23 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error { 24 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 25 | } 26 | 27 | // PtraceSetRegsMips sets the registers used by mips binaries. 28 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error { 29 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 30 | } 31 | 32 | // PtraceRegsMips64 is the registers used by mips64 binaries. 33 | type PtraceRegsMips64 struct { 34 | Regs [32]uint64 35 | Lo uint64 36 | Hi uint64 37 | Epc uint64 38 | Badvaddr uint64 39 | Status uint64 40 | Cause uint64 41 | } 42 | 43 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries. 44 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error { 45 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 46 | } 47 | 48 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries. 49 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error { 50 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 51 | } 52 | -------------------------------------------------------------------------------- /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 | // +build linux 5 | // +build mipsle mips64le 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegsMipsle is the registers used by mipsle binaries. 12 | type PtraceRegsMipsle struct { 13 | Regs [32]uint64 14 | Lo uint64 15 | Hi uint64 16 | Epc uint64 17 | Badvaddr uint64 18 | Status uint64 19 | Cause uint64 20 | } 21 | 22 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries. 23 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { 24 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 25 | } 26 | 27 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries. 28 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { 29 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 30 | } 31 | 32 | // PtraceRegsMips64le is the registers used by mips64le binaries. 33 | type PtraceRegsMips64le struct { 34 | Regs [32]uint64 35 | Lo uint64 36 | Hi uint64 37 | Epc uint64 38 | Badvaddr uint64 39 | Status uint64 40 | Cause uint64 41 | } 42 | 43 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries. 44 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { 45 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 46 | } 47 | 48 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries. 49 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { 50 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 51 | } 52 | -------------------------------------------------------------------------------- /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 | // +build linux 5 | // +build 386 amd64 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegs386 is the registers used by 386 binaries. 12 | type PtraceRegs386 struct { 13 | Ebx int32 14 | Ecx int32 15 | Edx int32 16 | Esi int32 17 | Edi int32 18 | Ebp int32 19 | Eax int32 20 | Xds int32 21 | Xes int32 22 | Xfs int32 23 | Xgs int32 24 | Orig_eax int32 25 | Eip int32 26 | Xcs int32 27 | Eflags int32 28 | Esp int32 29 | Xss int32 30 | } 31 | 32 | // PtraceGetRegs386 fetches the registers used by 386 binaries. 33 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { 34 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 35 | } 36 | 37 | // PtraceSetRegs386 sets the registers used by 386 binaries. 38 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { 39 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 40 | } 41 | 42 | // PtraceRegsAmd64 is the registers used by amd64 binaries. 43 | type PtraceRegsAmd64 struct { 44 | R15 uint64 45 | R14 uint64 46 | R13 uint64 47 | R12 uint64 48 | Rbp uint64 49 | Rbx uint64 50 | R11 uint64 51 | R10 uint64 52 | R9 uint64 53 | R8 uint64 54 | Rax uint64 55 | Rcx uint64 56 | Rdx uint64 57 | Rsi uint64 58 | Rdi uint64 59 | Orig_rax uint64 60 | Rip uint64 61 | Cs uint64 62 | Eflags uint64 63 | Rsp uint64 64 | Ss uint64 65 | Fs_base uint64 66 | Gs_base uint64 67 | Ds uint64 68 | Es uint64 69 | Fs uint64 70 | Gs uint64 71 | } 72 | 73 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries. 74 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { 75 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 76 | } 77 | 78 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries. 79 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { 80 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 81 | } 82 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_13.go: -------------------------------------------------------------------------------- 1 | // go run mksyscall.go -l32 -tags darwin,386,go1.13 syscall_darwin.1_13.go 2 | // Code generated by the command above; see README.md. DO NOT EDIT. 3 | 4 | //go:build darwin && 386 && go1.13 5 | // +build darwin,386,go1.13 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | var _ syscall.Errno 15 | 16 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 17 | 18 | func closedir(dir uintptr) (err error) { 19 | _, _, e1 := syscall_syscall(funcPC(libc_closedir_trampoline), uintptr(dir), 0, 0) 20 | if e1 != 0 { 21 | err = errnoErr(e1) 22 | } 23 | return 24 | } 25 | 26 | func libc_closedir_trampoline() 27 | 28 | //go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" 29 | 30 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 31 | 32 | func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { 33 | r0, _, _ := syscall_syscall(funcPC(libc_readdir_r_trampoline), uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result))) 34 | res = Errno(r0) 35 | return 36 | } 37 | 38 | func libc_readdir_r_trampoline() 39 | 40 | //go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_13.s: -------------------------------------------------------------------------------- 1 | // go run mkasm_darwin.go 386 2 | // Code generated by the command above; DO NOT EDIT. 3 | 4 | //go:build go1.13 5 | // +build go1.13 6 | 7 | #include "textflag.h" 8 | TEXT ·libc_fdopendir_trampoline(SB),NOSPLIT,$0-0 9 | JMP libc_fdopendir(SB) 10 | TEXT ·libc_closedir_trampoline(SB),NOSPLIT,$0-0 11 | JMP libc_closedir(SB) 12 | TEXT ·libc_readdir_r_trampoline(SB),NOSPLIT,$0-0 13 | JMP libc_readdir_r(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.go: -------------------------------------------------------------------------------- 1 | // go run mksyscall.go -tags darwin,amd64,go1.13 syscall_darwin.1_13.go 2 | // Code generated by the command above; see README.md. DO NOT EDIT. 3 | 4 | //go:build darwin && amd64 && go1.13 5 | // +build darwin,amd64,go1.13 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | var _ syscall.Errno 15 | 16 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 17 | 18 | func closedir(dir uintptr) (err error) { 19 | _, _, e1 := syscall_syscall(funcPC(libc_closedir_trampoline), uintptr(dir), 0, 0) 20 | if e1 != 0 { 21 | err = errnoErr(e1) 22 | } 23 | return 24 | } 25 | 26 | func libc_closedir_trampoline() 27 | 28 | //go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" 29 | 30 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 31 | 32 | func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { 33 | r0, _, _ := syscall_syscall(funcPC(libc_readdir_r_trampoline), uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result))) 34 | res = Errno(r0) 35 | return 36 | } 37 | 38 | func libc_readdir_r_trampoline() 39 | 40 | //go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.s: -------------------------------------------------------------------------------- 1 | // go run mkasm_darwin.go amd64 2 | // Code generated by the command above; DO NOT EDIT. 3 | 4 | //go:build go1.13 5 | // +build go1.13 6 | 7 | #include "textflag.h" 8 | TEXT ·libc_fdopendir_trampoline(SB),NOSPLIT,$0-0 9 | JMP libc_fdopendir(SB) 10 | TEXT ·libc_closedir_trampoline(SB),NOSPLIT,$0-0 11 | JMP libc_closedir(SB) 12 | TEXT ·libc_readdir_r_trampoline(SB),NOSPLIT,$0-0 13 | JMP libc_readdir_r(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_13.go: -------------------------------------------------------------------------------- 1 | // go run mksyscall.go -l32 -tags darwin,arm,go1.13 syscall_darwin.1_13.go 2 | // Code generated by the command above; see README.md. DO NOT EDIT. 3 | 4 | //go:build darwin && arm && go1.13 5 | // +build darwin,arm,go1.13 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | var _ syscall.Errno 15 | 16 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 17 | 18 | func closedir(dir uintptr) (err error) { 19 | _, _, e1 := syscall_syscall(funcPC(libc_closedir_trampoline), uintptr(dir), 0, 0) 20 | if e1 != 0 { 21 | err = errnoErr(e1) 22 | } 23 | return 24 | } 25 | 26 | func libc_closedir_trampoline() 27 | 28 | //go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" 29 | 30 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 31 | 32 | func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { 33 | r0, _, _ := syscall_syscall(funcPC(libc_readdir_r_trampoline), uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result))) 34 | res = Errno(r0) 35 | return 36 | } 37 | 38 | func libc_readdir_r_trampoline() 39 | 40 | //go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_13.s: -------------------------------------------------------------------------------- 1 | // go run mkasm_darwin.go arm 2 | // Code generated by the command above; DO NOT EDIT. 3 | 4 | //go:build go1.13 5 | // +build go1.13 6 | 7 | #include "textflag.h" 8 | TEXT ·libc_fdopendir_trampoline(SB),NOSPLIT,$0-0 9 | JMP libc_fdopendir(SB) 10 | TEXT ·libc_closedir_trampoline(SB),NOSPLIT,$0-0 11 | JMP libc_closedir(SB) 12 | TEXT ·libc_readdir_r_trampoline(SB),NOSPLIT,$0-0 13 | JMP libc_readdir_r(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go: -------------------------------------------------------------------------------- 1 | // go run mksyscall.go -tags darwin,arm64,go1.13 syscall_darwin.1_13.go 2 | // Code generated by the command above; see README.md. DO NOT EDIT. 3 | 4 | //go:build darwin && arm64 && go1.13 5 | // +build darwin,arm64,go1.13 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | var _ syscall.Errno 15 | 16 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 17 | 18 | func closedir(dir uintptr) (err error) { 19 | _, _, e1 := syscall_syscall(funcPC(libc_closedir_trampoline), uintptr(dir), 0, 0) 20 | if e1 != 0 { 21 | err = errnoErr(e1) 22 | } 23 | return 24 | } 25 | 26 | func libc_closedir_trampoline() 27 | 28 | //go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" 29 | 30 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 31 | 32 | func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { 33 | r0, _, _ := syscall_syscall(funcPC(libc_readdir_r_trampoline), uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result))) 34 | res = Errno(r0) 35 | return 36 | } 37 | 38 | func libc_readdir_r_trampoline() 39 | 40 | //go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.s: -------------------------------------------------------------------------------- 1 | // go run mkasm_darwin.go arm64 2 | // Code generated by the command above; DO NOT EDIT. 3 | 4 | //go:build go1.13 5 | // +build go1.13 6 | 7 | #include "textflag.h" 8 | TEXT ·libc_fdopendir_trampoline(SB),NOSPLIT,$0-0 9 | JMP libc_fdopendir(SB) 10 | TEXT ·libc_closedir_trampoline(SB),NOSPLIT,$0-0 11 | JMP libc_closedir(SB) 12 | TEXT ·libc_readdir_r_trampoline(SB),NOSPLIT,$0-0 13 | JMP libc_readdir_r(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go: -------------------------------------------------------------------------------- 1 | // cgo -godefs types_illumos.go | go run mkpost.go 2 | // Code generated by the command above; see README.md. DO NOT EDIT. 3 | 4 | //go:build amd64 && illumos 5 | // +build amd64,illumos 6 | 7 | package unix 8 | 9 | const ( 10 | TUNNEWPPA = 0x540001 11 | TUNSETPPA = 0x540002 12 | 13 | I_STR = 0x5308 14 | I_POP = 0x5303 15 | I_PUSH = 0x5302 16 | I_PLINK = 0x5316 17 | I_PUNLINK = 0x5317 18 | 19 | IF_UNITSEL = -0x7ffb8cca 20 | ) 21 | 22 | type strbuf struct { 23 | Maxlen int32 24 | Len int32 25 | Buf *int8 26 | } 27 | 28 | type Strioctl struct { 29 | Cmd int32 30 | Timout int32 31 | Len int32 32 | Dp *int8 33 | } 34 | 35 | type Lifreq struct { 36 | Name [32]int8 37 | Lifru1 [4]byte 38 | Type uint32 39 | Lifru [336]byte 40 | } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/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 | // +build windows 6 | // +build go1.9 7 | 8 | package windows 9 | 10 | import "syscall" 11 | 12 | type Errno = syscall.Errno 13 | type SysProcAttr = syscall.SysProcAttr 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/empty.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 | // +build !go1.12 6 | 7 | // This file is here to allow bodyless functions with go:linkname for Go 1.11 8 | // and earlier (see https://golang.org/issue/23311). 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/env_windows.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 | // Windows environment variables. 6 | 7 | package windows 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getenv(key string) (value string, found bool) { 15 | return syscall.Getenv(key) 16 | } 17 | 18 | func Setenv(key, value string) error { 19 | return syscall.Setenv(key, value) 20 | } 21 | 22 | func Clearenv() { 23 | syscall.Clearenv() 24 | } 25 | 26 | func Environ() []string { 27 | return syscall.Environ() 28 | } 29 | 30 | // Returns a default environment associated with the token, rather than the current 31 | // process. If inheritExisting is true, then this environment also inherits the 32 | // environment of the current process. 33 | func (token Token) Environ(inheritExisting bool) (env []string, err error) { 34 | var block *uint16 35 | err = CreateEnvironmentBlock(&block, token, inheritExisting) 36 | if err != nil { 37 | return nil, err 38 | } 39 | defer DestroyEnvironmentBlock(block) 40 | blockp := uintptr(unsafe.Pointer(block)) 41 | for { 42 | entry := UTF16PtrToString((*uint16)(unsafe.Pointer(blockp))) 43 | if len(entry) == 0 { 44 | break 45 | } 46 | env = append(env, entry) 47 | blockp += 2 * (uintptr(len(entry)) + 1) 48 | } 49 | return env, nil 50 | } 51 | 52 | func Unsetenv(key string) error { 53 | return syscall.Unsetenv(key) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/eventlog.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 | // +build windows 6 | 7 | package windows 8 | 9 | const ( 10 | EVENTLOG_SUCCESS = 0 11 | EVENTLOG_ERROR_TYPE = 1 12 | EVENTLOG_WARNING_TYPE = 2 13 | EVENTLOG_INFORMATION_TYPE = 4 14 | EVENTLOG_AUDIT_SUCCESS = 8 15 | EVENTLOG_AUDIT_FAILURE = 16 16 | ) 17 | 18 | //sys RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) [failretval==0] = advapi32.RegisterEventSourceW 19 | //sys DeregisterEventSource(handle Handle) (err error) = advapi32.DeregisterEventSource 20 | //sys ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) = advapi32.ReportEventW 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/memory_windows.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 | package windows 6 | 7 | const ( 8 | MEM_COMMIT = 0x00001000 9 | MEM_RESERVE = 0x00002000 10 | MEM_DECOMMIT = 0x00004000 11 | MEM_RELEASE = 0x00008000 12 | MEM_RESET = 0x00080000 13 | MEM_TOP_DOWN = 0x00100000 14 | MEM_WRITE_WATCH = 0x00200000 15 | MEM_PHYSICAL = 0x00400000 16 | MEM_RESET_UNDO = 0x01000000 17 | MEM_LARGE_PAGES = 0x20000000 18 | 19 | PAGE_NOACCESS = 0x00000001 20 | PAGE_READONLY = 0x00000002 21 | PAGE_READWRITE = 0x00000004 22 | PAGE_WRITECOPY = 0x00000008 23 | PAGE_EXECUTE = 0x00000010 24 | PAGE_EXECUTE_READ = 0x00000020 25 | PAGE_EXECUTE_READWRITE = 0x00000040 26 | PAGE_EXECUTE_WRITECOPY = 0x00000080 27 | PAGE_GUARD = 0x00000100 28 | PAGE_NOCACHE = 0x00000200 29 | PAGE_WRITECOMBINE = 0x00000400 30 | PAGE_TARGETS_INVALID = 0x40000000 31 | PAGE_TARGETS_NO_UPDATE = 0x40000000 32 | 33 | QUOTA_LIMITS_HARDWS_MIN_DISABLE = 0x00000002 34 | QUOTA_LIMITS_HARDWS_MIN_ENABLE = 0x00000001 35 | QUOTA_LIMITS_HARDWS_MAX_DISABLE = 0x00000008 36 | QUOTA_LIMITS_HARDWS_MAX_ENABLE = 0x00000004 37 | ) 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/mkerrors.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2019 The Go Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style 5 | # license that can be found in the LICENSE file. 6 | 7 | set -e 8 | shopt -s nullglob 9 | 10 | winerror="$(printf '%s\n' "/mnt/c/Program Files (x86)/Windows Kits/"/*/Include/*/shared/winerror.h | sort -Vr | head -n 1)" 11 | [[ -n $winerror ]] || { echo "Unable to find winerror.h" >&2; exit 1; } 12 | ntstatus="$(printf '%s\n' "/mnt/c/Program Files (x86)/Windows Kits/"/*/Include/*/shared/ntstatus.h | sort -Vr | head -n 1)" 13 | [[ -n $ntstatus ]] || { echo "Unable to find ntstatus.h" >&2; exit 1; } 14 | 15 | declare -A errors 16 | 17 | { 18 | echo "// Code generated by 'mkerrors.bash'; DO NOT EDIT." 19 | echo 20 | echo "package windows" 21 | echo "import \"syscall\"" 22 | echo "const (" 23 | 24 | while read -r line; do 25 | unset vtype 26 | if [[ $line =~ ^#define\ +([A-Z0-9_]+k?)\ +([A-Z0-9_]+\()?([A-Z][A-Z0-9_]+k?)\)? ]]; then 27 | key="${BASH_REMATCH[1]}" 28 | value="${BASH_REMATCH[3]}" 29 | elif [[ $line =~ ^#define\ +([A-Z0-9_]+k?)\ +([A-Z0-9_]+\()?((0x)?[0-9A-Fa-f]+)L?\)? ]]; then 30 | key="${BASH_REMATCH[1]}" 31 | value="${BASH_REMATCH[3]}" 32 | vtype="${BASH_REMATCH[2]}" 33 | elif [[ $line =~ ^#define\ +([A-Z0-9_]+k?)\ +\(\(([A-Z]+)\)((0x)?[0-9A-Fa-f]+)L?\) ]]; then 34 | key="${BASH_REMATCH[1]}" 35 | value="${BASH_REMATCH[3]}" 36 | vtype="${BASH_REMATCH[2]}" 37 | else 38 | continue 39 | fi 40 | [[ -n $key && -n $value ]] || continue 41 | [[ -z ${errors["$key"]} ]] || continue 42 | errors["$key"]="$value" 43 | if [[ -v vtype ]]; then 44 | if [[ $key == FACILITY_* || $key == NO_ERROR ]]; then 45 | vtype="" 46 | elif [[ $vtype == *HANDLE* || $vtype == *HRESULT* ]]; then 47 | vtype="Handle" 48 | else 49 | vtype="syscall.Errno" 50 | fi 51 | last_vtype="$vtype" 52 | else 53 | vtype="" 54 | if [[ $last_vtype == Handle && $value == NO_ERROR ]]; then 55 | value="S_OK" 56 | elif [[ $last_vtype == syscall.Errno && $value == NO_ERROR ]]; then 57 | value="ERROR_SUCCESS" 58 | fi 59 | fi 60 | 61 | echo "$key $vtype = $value" 62 | done < "$winerror" 63 | 64 | while read -r line; do 65 | [[ $line =~ ^#define\ (STATUS_[^\s]+)\ +\(\(NTSTATUS\)((0x)?[0-9a-fA-F]+)L?\) ]] || continue 66 | echo "${BASH_REMATCH[1]} NTStatus = ${BASH_REMATCH[2]}" 67 | done < "$ntstatus" 68 | 69 | echo ")" 70 | } | gofmt > "zerrors_windows.go" 71 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/mkknownfolderids.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2019 The Go Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style 5 | # license that can be found in the LICENSE file. 6 | 7 | set -e 8 | shopt -s nullglob 9 | 10 | knownfolders="$(printf '%s\n' "/mnt/c/Program Files (x86)/Windows Kits/"/*/Include/*/um/KnownFolders.h | sort -Vr | head -n 1)" 11 | [[ -n $knownfolders ]] || { echo "Unable to find KnownFolders.h" >&2; exit 1; } 12 | 13 | { 14 | echo "// Code generated by 'mkknownfolderids.bash'; DO NOT EDIT." 15 | echo 16 | echo "package windows" 17 | echo "type KNOWNFOLDERID GUID" 18 | echo "var (" 19 | while read -r line; do 20 | [[ $line =~ DEFINE_KNOWN_FOLDER\((FOLDERID_[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+)\) ]] || continue 21 | printf "%s = &KNOWNFOLDERID{0x%08x, 0x%04x, 0x%04x, [8]byte{0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x}}\n" \ 22 | "${BASH_REMATCH[1]}" $(( "${BASH_REMATCH[2]}" )) $(( "${BASH_REMATCH[3]}" )) $(( "${BASH_REMATCH[4]}" )) \ 23 | $(( "${BASH_REMATCH[5]}" )) $(( "${BASH_REMATCH[6]}" )) $(( "${BASH_REMATCH[7]}" )) $(( "${BASH_REMATCH[8]}" )) \ 24 | $(( "${BASH_REMATCH[9]}" )) $(( "${BASH_REMATCH[10]}" )) $(( "${BASH_REMATCH[11]}" )) $(( "${BASH_REMATCH[12]}" )) 25 | done < "$knownfolders" 26 | echo ")" 27 | } | gofmt > "zknownfolderids_windows.go" 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/mksyscall.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 | // +build generate 6 | 7 | package windows 8 | 9 | //go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/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 | // +build windows,race 6 | 7 | package windows 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/windows/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 | // +build windows,!race 6 | 7 | package windows 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/windows/str.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 | // +build windows 6 | 7 | package windows 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + itoa(-val) 12 | } 13 | var buf [32]byte // big enough for int64 14 | i := len(buf) - 1 15 | for val >= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 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 windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | 24 | type JOBOBJECT_BASIC_LIMIT_INFORMATION struct { 25 | PerProcessUserTimeLimit int64 26 | PerJobUserTimeLimit int64 27 | LimitFlags uint32 28 | MinimumWorkingSetSize uintptr 29 | MaximumWorkingSetSize uintptr 30 | ActiveProcessLimit uint32 31 | Affinity uintptr 32 | PriorityClass uint32 33 | SchedulingClass uint32 34 | _ uint32 // pad to 8 byte boundary 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 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 windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | 24 | type JOBOBJECT_BASIC_LIMIT_INFORMATION struct { 25 | PerProcessUserTimeLimit int64 26 | PerJobUserTimeLimit int64 27 | LimitFlags uint32 28 | MinimumWorkingSetSize uintptr 29 | MaximumWorkingSetSize uintptr 30 | ActiveProcessLimit uint32 31 | Affinity uintptr 32 | PriorityClass uint32 33 | SchedulingClass uint32 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_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 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | 24 | type JOBOBJECT_BASIC_LIMIT_INFORMATION struct { 25 | PerProcessUserTimeLimit int64 26 | PerJobUserTimeLimit int64 27 | LimitFlags uint32 28 | MinimumWorkingSetSize uintptr 29 | MaximumWorkingSetSize uintptr 30 | ActiveProcessLimit uint32 31 | Affinity uintptr 32 | PriorityClass uint32 33 | SchedulingClass uint32 34 | _ uint32 // pad to 8 byte boundary 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 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 windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | 24 | type JOBOBJECT_BASIC_LIMIT_INFORMATION struct { 25 | PerProcessUserTimeLimit int64 26 | PerJobUserTimeLimit int64 27 | LimitFlags uint32 28 | MinimumWorkingSetSize uintptr 29 | MaximumWorkingSetSize uintptr 30 | ActiveProcessLimit uint32 31 | Affinity uintptr 32 | PriorityClass uint32 33 | SchedulingClass uint32 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Go 2 | 3 | Go is an open source project. 4 | 5 | It is the work of hundreds of contributors. We appreciate your help! 6 | 7 | ## Filing issues 8 | 9 | When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions: 10 | 11 | 1. What version of Go are you using (`go version`)? 12 | 2. What operating system and processor architecture are you using? 13 | 3. What did you do? 14 | 4. What did you expect to see? 15 | 5. What did you see instead? 16 | 17 | General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. 18 | The gophers there will answer or ask you to file an issue if you've tripped over a bug. 19 | 20 | ## Contributing code 21 | 22 | Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) 23 | before sending patches. 24 | 25 | Unless otherwise noted, the Go source files are distributed under 26 | the BSD-style license found in the LICENSE file. 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/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/term/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/term/README.md: -------------------------------------------------------------------------------- 1 | # Go terminal/console support 2 | 3 | [![Go Reference](https://pkg.go.dev/badge/golang.org/x/term.svg)](https://pkg.go.dev/golang.org/x/term) 4 | 5 | This repository provides Go terminal and console support packages. 6 | 7 | ## Download/Install 8 | 9 | The easiest way to install is to run `go get -u golang.org/x/term`. You can 10 | also manually git clone the repository to `$GOPATH/src/golang.org/x/term`. 11 | 12 | ## Report Issues / Send Patches 13 | 14 | This repository uses Gerrit for code changes. To learn how to submit changes to 15 | this repository, see https://golang.org/doc/contribute.html. 16 | 17 | The main issue tracker for the term repository is located at 18 | https://github.com/golang/go/issues. Prefix your issue with "x/term:" in the 19 | subject line, so it is easy to find. 20 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/go.mod: -------------------------------------------------------------------------------- 1 | module golang.org/x/term 2 | 3 | go 1.11 4 | 5 | require golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 6 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/go.sum: -------------------------------------------------------------------------------- 1 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= 2 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/term.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 term provides support functions for dealing with terminals, as 6 | // commonly found on UNIX systems. 7 | // 8 | // Putting a terminal into raw mode is the most common requirement: 9 | // 10 | // oldState, err := term.MakeRaw(int(os.Stdin.Fd())) 11 | // if err != nil { 12 | // panic(err) 13 | // } 14 | // defer term.Restore(int(os.Stdin.Fd()), oldState) 15 | package term 16 | 17 | // State contains the state of a terminal. 18 | type State struct { 19 | state 20 | } 21 | 22 | // IsTerminal returns whether the given file descriptor is a terminal. 23 | func IsTerminal(fd int) bool { 24 | return isTerminal(fd) 25 | } 26 | 27 | // MakeRaw puts the terminal connected to the given file descriptor into raw 28 | // mode and returns the previous state of the terminal so that it can be 29 | // restored. 30 | func MakeRaw(fd int) (*State, error) { 31 | return makeRaw(fd) 32 | } 33 | 34 | // GetState returns the current state of a terminal which may be useful to 35 | // restore the terminal after a signal. 36 | func GetState(fd int) (*State, error) { 37 | return getState(fd) 38 | } 39 | 40 | // Restore restores the terminal connected to the given file descriptor to a 41 | // previous state. 42 | func Restore(fd int, oldState *State) error { 43 | return restore(fd, oldState) 44 | } 45 | 46 | // GetSize returns the visible dimensions of the given terminal. 47 | // 48 | // These dimensions don't include any scrollback buffer height. 49 | func GetSize(fd int) (width, height int, err error) { 50 | return getSize(fd) 51 | } 52 | 53 | // ReadPassword reads a line of input from a terminal without local echo. This 54 | // is commonly used for inputting passwords and other sensitive data. The slice 55 | // returned does not include the \n. 56 | func ReadPassword(fd int) ([]byte, error) { 57 | return readPassword(fd) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/term_plan9.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 term 6 | 7 | import ( 8 | "fmt" 9 | "runtime" 10 | 11 | "golang.org/x/sys/plan9" 12 | ) 13 | 14 | type state struct{} 15 | 16 | func isTerminal(fd int) bool { 17 | path, err := plan9.Fd2path(fd) 18 | if err != nil { 19 | return false 20 | } 21 | return path == "/dev/cons" || path == "/mnt/term/dev/cons" 22 | } 23 | 24 | func makeRaw(fd int) (*State, error) { 25 | return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 26 | } 27 | 28 | func getState(fd int) (*State, error) { 29 | return nil, fmt.Errorf("terminal: GetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 30 | } 31 | 32 | func restore(fd int, state *State) error { 33 | return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 34 | } 35 | 36 | func getSize(fd int) (width, height int, err error) { 37 | return 0, 0, fmt.Errorf("terminal: GetSize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 38 | } 39 | 40 | func readPassword(fd int) ([]byte, error) { 41 | return nil, fmt.Errorf("terminal: ReadPassword not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/term_unix_aix.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 6 | // +build aix 7 | 8 | package term 9 | 10 | import "golang.org/x/sys/unix" 11 | 12 | const ioctlReadTermios = unix.TCGETS 13 | const ioctlWriteTermios = unix.TCSETS 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/term_unix_bsd.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 darwin || dragonfly || freebsd || netbsd || openbsd 6 | // +build darwin dragonfly freebsd netbsd openbsd 7 | 8 | package term 9 | 10 | import "golang.org/x/sys/unix" 11 | 12 | const ioctlReadTermios = unix.TIOCGETA 13 | const ioctlWriteTermios = unix.TIOCSETA 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/term_unix_linux.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 term 6 | 7 | import "golang.org/x/sys/unix" 8 | 9 | const ioctlReadTermios = unix.TCGETS 10 | const ioctlWriteTermios = unix.TCSETS 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/term_unix_solaris.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 term 6 | 7 | import "golang.org/x/sys/unix" 8 | 9 | const ioctlReadTermios = unix.TCGETS 10 | const ioctlWriteTermios = unix.TCSETS 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/term_unix_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 6 | // +build zos 7 | 8 | package term 9 | 10 | import "golang.org/x/sys/unix" 11 | 12 | const ioctlReadTermios = unix.TCGETS 13 | const ioctlWriteTermios = unix.TCSETS 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/term_unsupported.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 && !zos && !windows && !solaris && !plan9 6 | // +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!zos,!windows,!solaris,!plan9 7 | 8 | package term 9 | 10 | import ( 11 | "fmt" 12 | "runtime" 13 | ) 14 | 15 | type state struct{} 16 | 17 | func isTerminal(fd int) bool { 18 | return false 19 | } 20 | 21 | func makeRaw(fd int) (*State, error) { 22 | return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 23 | } 24 | 25 | func getState(fd int) (*State, error) { 26 | return nil, fmt.Errorf("terminal: GetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 27 | } 28 | 29 | func restore(fd int, state *State) error { 30 | return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 31 | } 32 | 33 | func getSize(fd int) (width, height int, err error) { 34 | return 0, 0, fmt.Errorf("terminal: GetSize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 35 | } 36 | 37 | func readPassword(fd int) ([]byte, error) { 38 | return nil, fmt.Errorf("terminal: ReadPassword not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/term/term_windows.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 term 6 | 7 | import ( 8 | "os" 9 | 10 | "golang.org/x/sys/windows" 11 | ) 12 | 13 | type state struct { 14 | mode uint32 15 | } 16 | 17 | func isTerminal(fd int) bool { 18 | var st uint32 19 | err := windows.GetConsoleMode(windows.Handle(fd), &st) 20 | return err == nil 21 | } 22 | 23 | func makeRaw(fd int) (*State, error) { 24 | var st uint32 25 | if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil { 26 | return nil, err 27 | } 28 | raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT) 29 | if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil { 30 | return nil, err 31 | } 32 | return &State{state{st}}, nil 33 | } 34 | 35 | func getState(fd int) (*State, error) { 36 | var st uint32 37 | if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil { 38 | return nil, err 39 | } 40 | return &State{state{st}}, nil 41 | } 42 | 43 | func restore(fd int, state *State) error { 44 | return windows.SetConsoleMode(windows.Handle(fd), state.mode) 45 | } 46 | 47 | func getSize(fd int) (width, height int, err error) { 48 | var info windows.ConsoleScreenBufferInfo 49 | if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil { 50 | return 0, 0, err 51 | } 52 | return int(info.Window.Right - info.Window.Left + 1), int(info.Window.Bottom - info.Window.Top + 1), nil 53 | } 54 | 55 | func readPassword(fd int) ([]byte, error) { 56 | var st uint32 57 | if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil { 58 | return nil, err 59 | } 60 | old := st 61 | 62 | st &^= (windows.ENABLE_ECHO_INPUT | windows.ENABLE_LINE_INPUT) 63 | st |= (windows.ENABLE_PROCESSED_OUTPUT | windows.ENABLE_PROCESSED_INPUT) 64 | if err := windows.SetConsoleMode(windows.Handle(fd), st); err != nil { 65 | return nil, err 66 | } 67 | 68 | defer windows.SetConsoleMode(windows.Handle(fd), old) 69 | 70 | var h windows.Handle 71 | p, _ := windows.GetCurrentProcess() 72 | if err := windows.DuplicateHandle(p, windows.Handle(fd), p, &h, 0, false, windows.DUPLICATE_SAME_ACCESS); err != nil { 73 | return nil, err 74 | } 75 | 76 | f := os.NewFile(uintptr(h), "stdin") 77 | defer f.Close() 78 | return readPasswordLine(f) 79 | } 80 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 2 | ## explicit 3 | golang.org/x/sys/internal/unsafeheader 4 | golang.org/x/sys/plan9 5 | golang.org/x/sys/unix 6 | golang.org/x/sys/windows 7 | # golang.org/x/term v0.0.0-20210422114643-f5beecf764ed 8 | ## explicit 9 | golang.org/x/term 10 | --------------------------------------------------------------------------------