├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── av ├── av.go ├── avconv │ └── avconv.go ├── avutil │ └── avutil.go ├── pktque │ ├── buf.go │ ├── filters.go │ └── timeline.go ├── pubsub │ └── queue.go └── transcode │ └── transcode.go ├── codec ├── aacparser │ └── parser.go ├── codec.go ├── fake │ └── fake.go └── h264parser │ ├── fuzz_h264parser.go │ ├── parser.go │ └── parser_test.go ├── doc.go ├── examples ├── http_flv_and_rtmp_server │ └── main.go ├── open_probe_file │ └── main.go ├── rtmp_publish │ └── main.go ├── rtmp_server_channels │ └── main.go └── rtmp_server_proxy │ └── main.go ├── format ├── aac │ └── aac.go ├── flv │ ├── flv.go │ └── flvio │ │ ├── amf0.go │ │ └── flvio.go ├── format.go ├── mp4 │ ├── demuxer.go │ ├── handler.go │ ├── mp4io │ │ ├── atoms.go │ │ ├── gen │ │ │ └── gen.go │ │ └── mp4io.go │ ├── muxer.go │ └── stream.go ├── rtmp │ └── rtmp.go ├── rtsp │ ├── client.go │ ├── conn.go │ ├── sdp │ │ ├── parser.go │ │ └── parser_test.go │ └── stream.go └── ts │ ├── demuxer.go │ ├── handler.go │ ├── muxer.go │ ├── stream.go │ └── tsio │ ├── checksum.go │ └── tsio.go ├── go.mod ├── go.sum ├── utils └── bits │ ├── bits.go │ ├── bits_test.go │ ├── bufio │ └── bufio.go │ ├── golomb_reader.go │ └── pio │ ├── pio.go │ ├── reader.go │ ├── vec.go │ ├── vec_test.go │ └── writer.go └── vendor ├── github.com ├── VKCOM │ └── joy4 │ │ ├── LICENSE │ │ ├── av │ │ ├── av.go │ │ ├── avutil │ │ │ └── avutil.go │ │ ├── pktque │ │ │ ├── buf.go │ │ │ ├── filters.go │ │ │ └── timeline.go │ │ ├── pubsub │ │ │ └── queue.go │ │ └── transcode │ │ │ └── transcode.go │ │ ├── codec │ │ ├── aacparser │ │ │ └── parser.go │ │ ├── codec.go │ │ ├── fake │ │ │ └── fake.go │ │ └── h264parser │ │ │ ├── fuzz_h264parser.go │ │ │ └── parser.go │ │ ├── format │ │ ├── aac │ │ │ └── aac.go │ │ ├── flv │ │ │ ├── flv.go │ │ │ └── flvio │ │ │ │ ├── amf0.go │ │ │ │ └── flvio.go │ │ ├── format.go │ │ ├── mp4 │ │ │ ├── demuxer.go │ │ │ ├── handler.go │ │ │ ├── mp4io │ │ │ │ ├── atoms.go │ │ │ │ └── mp4io.go │ │ │ ├── muxer.go │ │ │ └── stream.go │ │ ├── rtmp │ │ │ └── rtmp.go │ │ ├── rtsp │ │ │ ├── client.go │ │ │ ├── conn.go │ │ │ ├── sdp │ │ │ │ └── parser.go │ │ │ └── stream.go │ │ └── ts │ │ │ ├── demuxer.go │ │ │ ├── handler.go │ │ │ ├── muxer.go │ │ │ ├── stream.go │ │ │ └── tsio │ │ │ ├── checksum.go │ │ │ └── tsio.go │ │ └── utils │ │ └── bits │ │ ├── bits.go │ │ ├── golomb_reader.go │ │ └── pio │ │ ├── pio.go │ │ ├── reader.go │ │ ├── vec.go │ │ └── writer.go ├── davecgh │ └── go-spew │ │ ├── LICENSE │ │ └── spew │ │ ├── bypass.go │ │ ├── bypasssafe.go │ │ ├── common.go │ │ ├── config.go │ │ ├── doc.go │ │ ├── dump.go │ │ ├── format.go │ │ └── spew.go ├── konsorten │ └── go-windows-terminal-sequences │ │ ├── LICENSE │ │ ├── README.md │ │ ├── go.mod │ │ └── sequences.go ├── pkg │ └── errors │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── appveyor.yml │ │ ├── errors.go │ │ └── stack.go ├── pmezard │ └── go-difflib │ │ ├── LICENSE │ │ └── difflib │ │ └── difflib.go ├── sirupsen │ └── logrus │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── alt_exit.go │ │ ├── appveyor.yml │ │ ├── doc.go │ │ ├── entry.go │ │ ├── exported.go │ │ ├── formatter.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── hooks.go │ │ ├── json_formatter.go │ │ ├── logger.go │ │ ├── logrus.go │ │ ├── terminal_check_appengine.go │ │ ├── terminal_check_bsd.go │ │ ├── terminal_check_no_terminal.go │ │ ├── terminal_check_notappengine.go │ │ ├── terminal_check_solaris.go │ │ ├── terminal_check_unix.go │ │ ├── terminal_check_windows.go │ │ ├── text_formatter.go │ │ └── writer.go └── stretchr │ └── testify │ ├── LICENSE │ └── assert │ ├── assertion_format.go │ ├── assertion_format.go.tmpl │ ├── assertion_forward.go │ ├── assertion_forward.go.tmpl │ ├── assertions.go │ ├── doc.go │ ├── errors.go │ ├── forward_assertions.go │ └── http_assertions.go ├── golang.org └── x │ └── sys │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ └── unix │ ├── .gitignore │ ├── README.md │ ├── affinity_linux.go │ ├── aliases.go │ ├── asm_aix_ppc64.s │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_amd64.s │ ├── asm_freebsd_386.s │ ├── asm_freebsd_amd64.s │ ├── asm_freebsd_arm.s │ ├── asm_freebsd_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_s390x.s │ ├── asm_netbsd_386.s │ ├── asm_netbsd_amd64.s │ ├── asm_netbsd_arm.s │ ├── asm_netbsd_arm64.s │ ├── asm_openbsd_386.s │ ├── asm_openbsd_amd64.s │ ├── asm_openbsd_arm.s │ ├── asm_solaris_amd64.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 │ ├── dirent.go │ ├── endian_big.go │ ├── endian_little.go │ ├── env_unix.go │ ├── errors_freebsd_386.go │ ├── errors_freebsd_amd64.go │ ├── errors_freebsd_arm.go │ ├── fcntl.go │ ├── fcntl_darwin.go │ ├── fcntl_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── ioctl.go │ ├── mkall.sh │ ├── mkasm_darwin.go │ ├── mkerrors.sh │ ├── mkpost.go │ ├── mksyscall.go │ ├── mksyscall_aix_ppc.go │ ├── mksyscall_aix_ppc64.go │ ├── mksyscall_solaris.go │ ├── mksysctl_openbsd.pl │ ├── mksysnum.go │ ├── openbsd_pledge.go │ ├── openbsd_unveil.go │ ├── pagesize_unix.go │ ├── race.go │ ├── race0.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_aix.go │ ├── syscall_aix_ppc.go │ ├── syscall_aix_ppc64.go │ ├── syscall_bsd.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_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_gccgo_386.go │ ├── syscall_linux_gccgo_arm.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_mipsx.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_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_unix.go │ ├── syscall_unix_gc.go │ ├── syscall_unix_gc_ppc64x.go │ ├── timestruct.go │ ├── types_aix.go │ ├── types_darwin.go │ ├── types_dragonfly.go │ ├── types_freebsd.go │ ├── types_netbsd.go │ ├── types_openbsd.go │ ├── types_solaris.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_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_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_solaris_amd64.go │ ├── zptrace386_linux.go │ ├── zptracearm_linux.go │ ├── zptracemips_linux.go │ ├── zptracemipsle_linux.go │ ├── zsyscall_aix_ppc.go │ ├── zsyscall_aix_ppc64.go │ ├── zsyscall_aix_ppc64_gc.go │ ├── zsyscall_aix_ppc64_gccgo.go │ ├── zsyscall_darwin_386.1_11.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_386.s │ ├── zsyscall_darwin_amd64.1_11.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_amd64.s │ ├── zsyscall_darwin_arm.1_11.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm.s │ ├── zsyscall_darwin_arm64.1_11.go │ ├── 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_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_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_solaris_amd64.go │ ├── zsysctl_openbsd_386.go │ ├── zsysctl_openbsd_amd64.go │ ├── zsysctl_openbsd_arm.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_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 │ ├── 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_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_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_solaris_amd64.go └── modules.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Files generated by JetBrains IDEs, e.g. IntelliJ IDEA 2 | .idea/ 3 | *.iml -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | branches: 3 | only: 4 | - master 5 | os: 6 | - linux 7 | 8 | addons: 9 | apt: 10 | packages: 11 | - libavformat-dev 12 | - libavresample-dev 13 | - libavcodec-dev 14 | - libswscale-dev 15 | - libavutil-dev 16 | 17 | script: 18 | - go build ./... 19 | - go test ./... 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JOY4 2 | 3 | > Golang audio/video library and streaming server 4 | 5 | JOY4 is powerful library written in golang, well-designed interface makes a few lines of code can do a lot of things such as reading, writing, transcoding among variety media formats, or setting up high-performance live streaming server. 6 | 7 | # Features 8 | 9 | Well-designed and easy-to-use interfaces: 10 | 11 | - Muxer / Demuxer ([doc](https://godoc.org/github.com/VKCOM/joy4/av#Demuxer) [example](https://github.com/VKCOM/joy4/blob/master/examples/open_probe_file/main.go)) 12 | - Audio Decoder ([doc](https://godoc.org/github.com/VKCOM/joy4/av#AudioDecoder) [example](https://github.com/VKCOM/joy4/blob/master/examples/audio_decode/main.go)) 13 | - Transcoding ([doc](https://godoc.org/github.com/VKCOM/joy4/av/transcode) [example](https://github.com/VKCOM/joy4/blob/master/examples/transcode/main.go)) 14 | - Streaming server ([example](https://github.com/VKCOM/joy4/blob/master/examples/http_flv_and_rtmp_server/main.go)) 15 | 16 | Support container formats: 17 | 18 | - MP4 19 | - MPEG-TS 20 | - FLV 21 | - AAC (ADTS) 22 | 23 | RTSP Client 24 | - High level camera bug tolerance 25 | - Support STAP-A 26 | 27 | RTMP Client 28 | - Support publishing to nginx-rtmp-server 29 | - Support playing 30 | 31 | RTMP / HTTP-FLV Server 32 | - Support publishing clients: OBS / ffmpeg / Flash Player (>8) 33 | - Support playing clients: Flash Player 11 / VLC / ffplay / mpv 34 | - High performance 35 | 36 | 37 | Publisher-subscriber packet buffer queue ([doc](https://godoc.org/github.com/VKCOM/joy4/av/pubsub)) 38 | 39 | - Customize publisher buffer time and subscriber read position 40 | 41 | 42 | - Multiple channels live streaming ([example](https://github.com/VKCOM/joy4/blob/master/examples/rtmp_server_channels/main.go)) 43 | 44 | Packet filters ([doc](https://godoc.org/github.com/VKCOM/joy4/av/pktque)) 45 | 46 | - Wait first keyframe 47 | - Fix timestamp 48 | - Make A/V sync 49 | - Customize ([example](https://github.com/VKCOM/joy4/blob/master/examples/rtmp_server_channels/main.go#L19)) 50 | 51 | FFMPEG Golang-style binding ([doc](https://godoc.org/github.com/VKCOM/joy4/cgo/ffmpeg)) 52 | - Audio Encoder / Decoder 53 | - Video Decoder 54 | - Audio Resampler 55 | 56 | Support codec and container parsers: 57 | 58 | - H264 SPS/PPS/AVCDecoderConfigure parser ([doc](https://godoc.org/github.com/VKCOM/joy4/codec/h264parser)) 59 | - AAC ADTSHeader/MPEG4AudioConfig parser ([doc](https://godoc.org/github.com/VKCOM/joy4/codec/aacparser)) 60 | - MP4 Atoms parser ([doc](https://godoc.org/github.com/VKCOM/joy4/format/mp4/mp4io)) 61 | - FLV AMF0 object parser ([doc](https://godoc.org/github.com/VKCOM/joy4/format/flv/flvio)) 62 | 63 | # Requirements 64 | 65 | Go version >= 1.6 66 | 67 | ffmpeg version >= 3.0 (optional) 68 | 69 | # TODO 70 | 71 | HLS / MPEG-DASH Server 72 | 73 | ffmpeg.VideoEncoder / ffmpeg.SWScale 74 | 75 | # License 76 | 77 | MIT 78 | -------------------------------------------------------------------------------- /av/pktque/buf.go: -------------------------------------------------------------------------------- 1 | package pktque 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | ) 6 | 7 | type Buf struct { 8 | Head, Tail BufPos 9 | pkts []av.Packet 10 | Size int 11 | Count int 12 | } 13 | 14 | func NewBuf() *Buf { 15 | return &Buf{ 16 | pkts: make([]av.Packet, 64), 17 | } 18 | } 19 | 20 | func (self *Buf) Pop() av.Packet { 21 | if self.Count == 0 { 22 | panic("pktque.Buf: Pop() when count == 0") 23 | } 24 | 25 | i := int(self.Head) & (len(self.pkts) - 1) 26 | pkt := self.pkts[i] 27 | self.pkts[i] = av.Packet{} 28 | self.Size -= len(pkt.Data) 29 | self.Head++ 30 | self.Count-- 31 | 32 | return pkt 33 | } 34 | 35 | func (self *Buf) grow() { 36 | newpkts := make([]av.Packet, len(self.pkts)*2) 37 | for i := self.Head; i.LT(self.Tail); i++ { 38 | newpkts[int(i)&(len(newpkts)-1)] = self.pkts[int(i)&(len(self.pkts)-1)] 39 | } 40 | self.pkts = newpkts 41 | } 42 | 43 | func (self *Buf) Push(pkt av.Packet) { 44 | if self.Count == len(self.pkts) { 45 | self.grow() 46 | } 47 | self.pkts[int(self.Tail)&(len(self.pkts)-1)] = pkt 48 | self.Tail++ 49 | self.Count++ 50 | self.Size += len(pkt.Data) 51 | } 52 | 53 | func (self *Buf) Get(pos BufPos) av.Packet { 54 | return self.pkts[int(pos)&(len(self.pkts)-1)] 55 | } 56 | 57 | func (self *Buf) IsValidPos(pos BufPos) bool { 58 | return pos.GE(self.Head) && pos.LT(self.Tail) 59 | } 60 | 61 | type BufPos int 62 | 63 | func (self BufPos) LT(pos BufPos) bool { 64 | return self-pos < 0 65 | } 66 | 67 | func (self BufPos) GE(pos BufPos) bool { 68 | return self-pos >= 0 69 | } 70 | 71 | func (self BufPos) GT(pos BufPos) bool { 72 | return self-pos > 0 73 | } 74 | -------------------------------------------------------------------------------- /av/pktque/timeline.go: -------------------------------------------------------------------------------- 1 | package pktque 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | /* 8 | pop push 9 | 10 | seg seg seg 11 | |--------| |---------| |---| 12 | 20ms 40ms 5ms 13 | ----------------- time --------------------> 14 | headtm tailtm 15 | */ 16 | 17 | type tlSeg struct { 18 | tm, dur time.Duration 19 | } 20 | 21 | type Timeline struct { 22 | segs []tlSeg 23 | headtm time.Duration 24 | } 25 | 26 | func (self *Timeline) Push(tm time.Duration, dur time.Duration) { 27 | if len(self.segs) > 0 { 28 | tail := self.segs[len(self.segs)-1] 29 | diff := tm - (tail.tm + tail.dur) 30 | if diff < 0 { 31 | tm -= diff 32 | } 33 | } 34 | self.segs = append(self.segs, tlSeg{tm, dur}) 35 | } 36 | 37 | func (self *Timeline) Pop(dur time.Duration) (tm time.Duration) { 38 | if len(self.segs) == 0 { 39 | return self.headtm 40 | } 41 | 42 | tm = self.segs[0].tm 43 | for dur > 0 && len(self.segs) > 0 { 44 | seg := &self.segs[0] 45 | sub := dur 46 | if seg.dur < sub { 47 | sub = seg.dur 48 | } 49 | seg.dur -= sub 50 | dur -= sub 51 | seg.tm += sub 52 | self.headtm += sub 53 | if seg.dur == 0 { 54 | copy(self.segs[0:], self.segs[1:]) 55 | self.segs = self.segs[:len(self.segs)-1] 56 | } 57 | } 58 | 59 | return 60 | } 61 | -------------------------------------------------------------------------------- /codec/codec.go: -------------------------------------------------------------------------------- 1 | package codec 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/codec/fake" 6 | "time" 7 | ) 8 | 9 | type PCMUCodecData struct { 10 | typ av.CodecType 11 | } 12 | 13 | func (self PCMUCodecData) Type() av.CodecType { 14 | return self.typ 15 | } 16 | 17 | func (self PCMUCodecData) SampleRate() int { 18 | return 8000 19 | } 20 | 21 | func (self PCMUCodecData) ChannelLayout() av.ChannelLayout { 22 | return av.CH_MONO 23 | } 24 | 25 | func (self PCMUCodecData) SampleFormat() av.SampleFormat { 26 | return av.S16 27 | } 28 | 29 | func (self PCMUCodecData) PacketDuration(data []byte) (time.Duration, error) { 30 | return time.Duration(len(data)) * time.Second / time.Duration(8000), nil 31 | } 32 | 33 | func NewPCMMulawCodecData() av.AudioCodecData { 34 | return PCMUCodecData{ 35 | typ: av.PCM_MULAW, 36 | } 37 | } 38 | 39 | func NewPCMAlawCodecData() av.AudioCodecData { 40 | return PCMUCodecData{ 41 | typ: av.PCM_ALAW, 42 | } 43 | } 44 | 45 | type SpeexCodecData struct { 46 | fake.CodecData 47 | } 48 | 49 | func (self SpeexCodecData) PacketDuration(data []byte) (time.Duration, error) { 50 | // libavcodec/libspeexdec.c 51 | // samples = samplerate/50 52 | // duration = 0.02s 53 | return time.Millisecond * 20, nil 54 | } 55 | 56 | func NewSpeexCodecData(sr int, cl av.ChannelLayout) SpeexCodecData { 57 | codec := SpeexCodecData{} 58 | codec.CodecType_ = av.SPEEX 59 | codec.SampleFormat_ = av.S16 60 | codec.SampleRate_ = sr 61 | codec.ChannelLayout_ = cl 62 | return codec 63 | } 64 | -------------------------------------------------------------------------------- /codec/fake/fake.go: -------------------------------------------------------------------------------- 1 | package fake 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | ) 6 | 7 | type CodecData struct { 8 | CodecType_ av.CodecType 9 | SampleRate_ int 10 | SampleFormat_ av.SampleFormat 11 | ChannelLayout_ av.ChannelLayout 12 | } 13 | 14 | func (self CodecData) Type() av.CodecType { 15 | return self.CodecType_ 16 | } 17 | 18 | func (self CodecData) SampleFormat() av.SampleFormat { 19 | return self.SampleFormat_ 20 | } 21 | 22 | func (self CodecData) ChannelLayout() av.ChannelLayout { 23 | return self.ChannelLayout_ 24 | } 25 | 26 | func (self CodecData) SampleRate() int { 27 | return self.SampleRate_ 28 | } 29 | -------------------------------------------------------------------------------- /codec/h264parser/fuzz_h264parser.go: -------------------------------------------------------------------------------- 1 | package h264parser 2 | //go-fuzz-build -func=Fuzz_ParseSPS -o=Fuzz_ParseSPS.zip github.com/VKCOM/joy4/codec/h264parser 3 | //go-fuzz -dumpcover -bin=Fuzz_ParseSPS.zip -workdir=joy4/codec/h264parser/corpus_ParseSPS 4 | 5 | func Fuzz_SplitNALUs(data []byte) int { 6 | nalus, _ := SplitNALUs(data) 7 | 8 | if len(nalus) ==0 { 9 | return 0 10 | } 11 | return 1 12 | } 13 | 14 | func Fuzz_ParseSPS(data []byte) int { 15 | _, err := ParseSPS(data) 16 | 17 | if err!=nil { 18 | return 0 19 | } 20 | return 1 21 | } 22 | 23 | func Fuzz_ParseSliceHeaderFromNALU(data []byte) int { 24 | _, err := ParseSPS(data) 25 | 26 | if err!=nil { 27 | return 0 28 | } 29 | return 1 30 | } 31 | 32 | -------------------------------------------------------------------------------- /codec/h264parser/parser_test.go: -------------------------------------------------------------------------------- 1 | package h264parser 2 | 3 | import ( 4 | "encoding/hex" 5 | "testing" 6 | "github.com/stretchr/testify/assert" 7 | "io/ioutil" 8 | "path" 9 | "runtime" 10 | "os" 11 | ) 12 | 13 | func addToCorpus(data []byte, name string) { 14 | _, filename, _, _ := runtime.Caller(1) 15 | filepath := path.Join(path.Dir(filename), "fuzz_corpus/corpus/"+name) 16 | ioutil.WriteFile(filepath, data, os.ModePerm) 17 | } 18 | 19 | func TestParserAnnex(t *testing.T) { 20 | avccFrame, _ := hex.DecodeString( 21 | "00000001223322330000000122332233223300000133000001000001", 22 | ) 23 | //addToCorpus(avccFrame, "annex") 24 | 25 | nalus, typ := SplitNALUs(avccFrame) 26 | t.Log(typ, len(nalus)) 27 | assert.Equal(t, NALU_ANNEXB, typ) 28 | } 29 | 30 | func TestParserAvcc(t *testing.T) { 31 | avccFrame, _ := hex.DecodeString( 32 | "00000008aabbccaabbccaabb00000001aa", 33 | ) 34 | //addToCorpus(avccFrame, "avcc") 35 | 36 | nalus, typ := SplitNALUs(avccFrame) 37 | t.Log(typ, len(nalus)) 38 | assert.Equal(t, NALU_AVCC, typ) 39 | } 40 | 41 | func TestParserNoCrash(t *testing.T) { 42 | avccFrame, err := hex.DecodeString( 43 | "00000004", 44 | ) 45 | assert.NoError(t, err) 46 | //addToCorpus(avccFrame, "avcc_no_fail") 47 | 48 | nalus, typ := SplitNALUs(avccFrame) 49 | t.Log(typ, len(nalus)) 50 | assert.Equal(t, NALU_AVCC, typ) 51 | } 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | // Package joy4 is a Golang audio/video library and streaming server. 2 | // JOY4 is powerful library written in golang, well-designed interface makes a few lines 3 | // of code can do a lot of things such as reading, writing, transcoding among 4 | // variety media formats, or setting up high-performance live streaming server. 5 | package joy4 6 | -------------------------------------------------------------------------------- /examples/http_flv_and_rtmp_server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av/avutil" 5 | "github.com/VKCOM/joy4/av/pubsub" 6 | "github.com/VKCOM/joy4/format" 7 | "github.com/VKCOM/joy4/format/flv" 8 | "github.com/VKCOM/joy4/format/rtmp" 9 | "io" 10 | "net/http" 11 | "sync" 12 | ) 13 | 14 | func init() { 15 | format.RegisterAll() 16 | } 17 | 18 | type writeFlusher struct { 19 | httpflusher http.Flusher 20 | io.Writer 21 | } 22 | 23 | func (self writeFlusher) Flush() error { 24 | self.httpflusher.Flush() 25 | return nil 26 | } 27 | 28 | func main() { 29 | server := &rtmp.Server{} 30 | 31 | l := &sync.RWMutex{} 32 | type Channel struct { 33 | que *pubsub.Queue 34 | } 35 | channels := map[string]*Channel{} 36 | 37 | server.HandlePlay = func(conn *rtmp.Conn) { 38 | l.RLock() 39 | ch := channels[conn.URL.Path] 40 | l.RUnlock() 41 | 42 | if ch != nil { 43 | cursor := ch.que.Latest() 44 | avutil.CopyFile(conn, cursor) 45 | } 46 | } 47 | 48 | server.HandlePublish = func(conn *rtmp.Conn) { 49 | streams, _ := conn.Streams() 50 | 51 | l.Lock() 52 | ch := channels[conn.URL.Path] 53 | if ch == nil { 54 | ch = &Channel{} 55 | ch.que = pubsub.NewQueue() 56 | ch.que.WriteHeader(streams) 57 | channels[conn.URL.Path] = ch 58 | } else { 59 | ch = nil 60 | } 61 | l.Unlock() 62 | if ch == nil { 63 | return 64 | } 65 | 66 | avutil.CopyPackets(ch.que, conn) 67 | 68 | l.Lock() 69 | delete(channels, conn.URL.Path) 70 | l.Unlock() 71 | ch.que.Close() 72 | } 73 | 74 | http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 75 | l.RLock() 76 | ch := channels[r.URL.Path] 77 | l.RUnlock() 78 | 79 | if ch != nil { 80 | w.Header().Set("Content-Type", "video/x-flv") 81 | w.Header().Set("Transfer-Encoding", "chunked") 82 | w.Header().Set("Access-Control-Allow-Origin", "*") 83 | w.WriteHeader(200) 84 | flusher := w.(http.Flusher) 85 | flusher.Flush() 86 | 87 | muxer := flv.NewMuxerWriteFlusher(writeFlusher{httpflusher: flusher, Writer: w}) 88 | cursor := ch.que.Latest() 89 | 90 | avutil.CopyFile(muxer, cursor) 91 | } else { 92 | http.NotFound(w, r) 93 | } 94 | }) 95 | 96 | go http.ListenAndServe(":8089", nil) 97 | 98 | server.ListenAndServe() 99 | 100 | // ffmpeg -re -i movie.flv -c copy -f flv rtmp://localhost/movie 101 | // ffmpeg -f avfoundation -i "0:0" .... -f flv rtmp://localhost/screen 102 | // ffplay http://localhost:8089/movie 103 | // ffplay http://localhost:8089/screen 104 | } 105 | -------------------------------------------------------------------------------- /examples/open_probe_file/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/av/avutil" 6 | "github.com/VKCOM/joy4/format" 7 | "github.com/sirupsen/logrus" 8 | ) 9 | 10 | func init() { 11 | format.RegisterAll() 12 | } 13 | 14 | func main() { 15 | file, _ := avutil.Open("projectindex.flv") 16 | 17 | streams, _ := file.Streams() 18 | for _, stream := range streams { 19 | if stream.Type().IsAudio() { 20 | astream := stream.(av.AudioCodecData) 21 | logrus.Info(astream.Type(), astream.SampleRate(), astream.SampleFormat(), astream.ChannelLayout()) 22 | } else if stream.Type().IsVideo() { 23 | vstream := stream.(av.VideoCodecData) 24 | logrus.Info(vstream.Type(), vstream.Width(), vstream.Height()) 25 | } 26 | } 27 | 28 | for i := 0; i < 10; i++ { 29 | var pkt av.Packet 30 | var err error 31 | if pkt, err = file.ReadPacket(); err != nil { 32 | break 33 | } 34 | logrus.Info("pkt", i, streams[pkt.Idx].Type(), "len", len(pkt.Data), "keyframe", pkt.IsKeyFrame) 35 | } 36 | 37 | file.Close() 38 | } 39 | -------------------------------------------------------------------------------- /examples/rtmp_publish/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av/avutil" 5 | "github.com/VKCOM/joy4/av/pktque" 6 | "github.com/VKCOM/joy4/format" 7 | "github.com/VKCOM/joy4/format/rtmp" 8 | ) 9 | 10 | func init() { 11 | format.RegisterAll() 12 | } 13 | 14 | // as same as: ffmpeg -re -i projectindex.flv -c copy -f flv rtmp://localhost:1936/app/publish 15 | 16 | func main() { 17 | file, _ := avutil.Open("projectindex.flv") 18 | conn, _ := rtmp.Dial("rtmp://localhost:1936/app/publish") 19 | // conn, _ := avutil.Create("rtmp://localhost:1936/app/publish") 20 | 21 | demuxer := &pktque.FilterDemuxer{Demuxer: file, Filter: &pktque.Walltime{}} 22 | avutil.CopyFile(conn, demuxer) 23 | 24 | file.Close() 25 | conn.Close() 26 | } 27 | -------------------------------------------------------------------------------- /examples/rtmp_server_proxy/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/VKCOM/joy4/av/avutil" 6 | "github.com/VKCOM/joy4/format" 7 | "github.com/VKCOM/joy4/format/rtmp" 8 | "strings" 9 | ) 10 | 11 | func init() { 12 | format.RegisterAll() 13 | } 14 | 15 | func main() { 16 | server := &rtmp.Server{} 17 | 18 | server.HandlePlay = func(conn *rtmp.Conn) { 19 | segs := strings.Split(conn.URL.Path, "/") 20 | url := fmt.Sprintf("%s://%s", segs[1], strings.Join(segs[2:], "/")) 21 | src, _ := avutil.Open(url) 22 | avutil.CopyFile(conn, src) 23 | } 24 | 25 | server.ListenAndServe() 26 | 27 | // ffplay rtmp://localhost/rtsp/192.168.1.1/camera1 28 | // ffplay rtmp://localhost/rtmp/live.hkstv.hk.lxdns.com/live/hks 29 | } 30 | -------------------------------------------------------------------------------- /format/aac/aac.go: -------------------------------------------------------------------------------- 1 | package aac 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "github.com/VKCOM/joy4/av" 7 | "github.com/VKCOM/joy4/av/avutil" 8 | "github.com/VKCOM/joy4/codec/aacparser" 9 | "io" 10 | "time" 11 | ) 12 | 13 | type Muxer struct { 14 | w io.Writer 15 | config aacparser.MPEG4AudioConfig 16 | adtshdr []byte 17 | } 18 | 19 | func NewMuxer(w io.Writer) *Muxer { 20 | return &Muxer{ 21 | adtshdr: make([]byte, aacparser.ADTSHeaderLength), 22 | w: w, 23 | } 24 | } 25 | 26 | func (self *Muxer) WriteHeader(streams []av.CodecData) (err error) { 27 | if len(streams) > 1 || streams[0].Type() != av.AAC { 28 | err = fmt.Errorf("aac: must be only one aac stream") 29 | return 30 | } 31 | self.config = streams[0].(aacparser.CodecData).Config 32 | if self.config.ObjectType > aacparser.AOT_AAC_LTP { 33 | err = fmt.Errorf("aac: AOT %d is not allowed in ADTS", self.config.ObjectType) 34 | } 35 | return 36 | } 37 | 38 | func (self *Muxer) WritePacket(pkt av.Packet) (err error) { 39 | aacparser.FillADTSHeader(self.adtshdr, self.config, 1024, len(pkt.Data)) 40 | if _, err = self.w.Write(self.adtshdr); err != nil { 41 | return 42 | } 43 | if _, err = self.w.Write(pkt.Data); err != nil { 44 | return 45 | } 46 | return 47 | } 48 | 49 | func (self *Muxer) WriteTrailer() (err error) { 50 | return 51 | } 52 | 53 | type Demuxer struct { 54 | r *bufio.Reader 55 | config aacparser.MPEG4AudioConfig 56 | codecdata av.CodecData 57 | ts time.Duration 58 | } 59 | 60 | func NewDemuxer(r io.Reader) *Demuxer { 61 | return &Demuxer{ 62 | r: bufio.NewReader(r), 63 | } 64 | } 65 | 66 | func (self *Demuxer) Streams() (streams []av.CodecData, err error) { 67 | if self.codecdata == nil { 68 | var adtshdr []byte 69 | var config aacparser.MPEG4AudioConfig 70 | if adtshdr, err = self.r.Peek(9); err != nil { 71 | return 72 | } 73 | if config, _, _, _, err = aacparser.ParseADTSHeader(adtshdr); err != nil { 74 | return 75 | } 76 | if self.codecdata, err = aacparser.NewCodecDataFromMPEG4AudioConfig(config); err != nil { 77 | return 78 | } 79 | } 80 | streams = []av.CodecData{self.codecdata} 81 | return 82 | } 83 | 84 | func (self *Demuxer) ReadPacket() (pkt av.Packet, err error) { 85 | var adtshdr []byte 86 | var config aacparser.MPEG4AudioConfig 87 | var hdrlen, framelen, samples int 88 | if adtshdr, err = self.r.Peek(9); err != nil { 89 | return 90 | } 91 | if config, hdrlen, framelen, samples, err = aacparser.ParseADTSHeader(adtshdr); err != nil { 92 | return 93 | } 94 | 95 | pkt.Data = make([]byte, framelen) 96 | if _, err = io.ReadFull(self.r, pkt.Data); err != nil { 97 | return 98 | } 99 | pkt.Data = pkt.Data[hdrlen:] 100 | 101 | pkt.Time = self.ts 102 | self.ts += time.Duration(samples) * time.Second / time.Duration(config.SampleRate) 103 | return 104 | } 105 | 106 | func Handler(h *avutil.RegisterHandler) { 107 | h.Ext = ".aac" 108 | 109 | h.ReaderDemuxer = func(r io.Reader) av.Demuxer { 110 | return NewDemuxer(r) 111 | } 112 | 113 | h.WriterMuxer = func(w io.Writer) av.Muxer { 114 | return NewMuxer(w) 115 | } 116 | 117 | h.Probe = func(b []byte) bool { 118 | _, _, _, _, err := aacparser.ParseADTSHeader(b) 119 | return err == nil 120 | } 121 | 122 | h.CodecTypes = []av.CodecType{av.AAC} 123 | } 124 | -------------------------------------------------------------------------------- /format/format.go: -------------------------------------------------------------------------------- 1 | package format 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av/avutil" 5 | "github.com/VKCOM/joy4/format/aac" 6 | "github.com/VKCOM/joy4/format/flv" 7 | "github.com/VKCOM/joy4/format/mp4" 8 | "github.com/VKCOM/joy4/format/rtmp" 9 | "github.com/VKCOM/joy4/format/rtsp" 10 | "github.com/VKCOM/joy4/format/ts" 11 | ) 12 | 13 | func RegisterAll() { 14 | avutil.DefaultHandlers.Add(mp4.Handler) 15 | avutil.DefaultHandlers.Add(ts.Handler) 16 | avutil.DefaultHandlers.Add(rtmp.Handler) 17 | avutil.DefaultHandlers.Add(rtsp.Handler) 18 | avutil.DefaultHandlers.Add(flv.Handler) 19 | avutil.DefaultHandlers.Add(aac.Handler) 20 | } 21 | -------------------------------------------------------------------------------- /format/mp4/handler.go: -------------------------------------------------------------------------------- 1 | package mp4 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/av/avutil" 6 | "io" 7 | ) 8 | 9 | var CodecTypes = []av.CodecType{av.H264, av.AAC} 10 | 11 | func Handler(h *avutil.RegisterHandler) { 12 | h.Ext = ".mp4" 13 | 14 | h.Probe = func(b []byte) bool { 15 | switch string(b[4:8]) { 16 | case "moov", "ftyp", "free", "mdat", "moof": 17 | return true 18 | } 19 | return false 20 | } 21 | 22 | h.ReaderDemuxer = func(r io.Reader) av.Demuxer { 23 | return NewDemuxer(r.(io.ReadSeeker)) 24 | } 25 | 26 | h.WriterMuxer = func(w io.Writer) av.Muxer { 27 | return NewMuxer(w.(io.WriteSeeker)) 28 | } 29 | 30 | h.CodecTypes = CodecTypes 31 | } 32 | -------------------------------------------------------------------------------- /format/mp4/stream.go: -------------------------------------------------------------------------------- 1 | package mp4 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/format/mp4/mp4io" 6 | "time" 7 | ) 8 | 9 | type Stream struct { 10 | av.CodecData 11 | 12 | trackAtom *mp4io.Track 13 | idx int 14 | 15 | lastpkt *av.Packet 16 | 17 | timeScale int64 18 | duration int64 19 | 20 | muxer *Muxer 21 | demuxer *Demuxer 22 | 23 | sample *mp4io.SampleTable 24 | sampleIndex int 25 | 26 | sampleOffsetInChunk int64 27 | syncSampleIndex int 28 | 29 | dts int64 30 | sttsEntryIndex int 31 | sampleIndexInSttsEntry int 32 | 33 | cttsEntryIndex int 34 | sampleIndexInCttsEntry int 35 | 36 | chunkGroupIndex int 37 | chunkIndex int 38 | sampleIndexInChunk int 39 | 40 | sttsEntry *mp4io.TimeToSampleEntry 41 | cttsEntry *mp4io.CompositionOffsetEntry 42 | } 43 | 44 | func timeToTs(tm time.Duration, timeScale int64) int64 { 45 | return int64(tm * time.Duration(timeScale) / time.Second) 46 | } 47 | 48 | func tsToTime(ts int64, timeScale int64) time.Duration { 49 | return time.Duration(ts) * time.Second / time.Duration(timeScale) 50 | } 51 | 52 | func (self *Stream) timeToTs(tm time.Duration) int64 { 53 | return int64(tm * time.Duration(self.timeScale) / time.Second) 54 | } 55 | 56 | func (self *Stream) tsToTime(ts int64) time.Duration { 57 | return time.Duration(ts) * time.Second / time.Duration(self.timeScale) 58 | } 59 | -------------------------------------------------------------------------------- /format/rtsp/conn.go: -------------------------------------------------------------------------------- 1 | package rtsp 2 | 3 | import ( 4 | "net" 5 | "time" 6 | ) 7 | 8 | type connWithTimeout struct { 9 | Timeout time.Duration 10 | net.Conn 11 | } 12 | 13 | func (self connWithTimeout) Read(p []byte) (n int, err error) { 14 | if self.Timeout > 0 { 15 | self.Conn.SetReadDeadline(time.Now().Add(self.Timeout)) 16 | } 17 | return self.Conn.Read(p) 18 | } 19 | 20 | func (self connWithTimeout) Write(p []byte) (n int, err error) { 21 | if self.Timeout > 0 { 22 | self.Conn.SetWriteDeadline(time.Now().Add(self.Timeout)) 23 | } 24 | return self.Conn.Write(p) 25 | } 26 | -------------------------------------------------------------------------------- /format/rtsp/sdp/parser.go: -------------------------------------------------------------------------------- 1 | package sdp 2 | 3 | import ( 4 | "encoding/base64" 5 | "encoding/hex" 6 | "github.com/VKCOM/joy4/av" 7 | "github.com/sirupsen/logrus" 8 | "strconv" 9 | "strings" 10 | ) 11 | 12 | type Session struct { 13 | Uri string 14 | } 15 | 16 | type Media struct { 17 | AVType string 18 | Type av.CodecType 19 | TimeScale int 20 | Control string 21 | Rtpmap int 22 | Config []byte 23 | SpropParameterSets [][]byte 24 | PayloadType int 25 | SizeLength int 26 | IndexLength int 27 | } 28 | 29 | func Parse(content string) (sess Session, medias []Media) { 30 | var media *Media 31 | 32 | for _, line := range strings.Split(content, "\n") { 33 | line = strings.TrimSpace(line) 34 | typeval := strings.SplitN(line, "=", 2) 35 | if len(typeval) == 2 { 36 | fields := strings.SplitN(typeval[1], " ", 2) 37 | 38 | switch typeval[0] { 39 | case "m": 40 | if len(fields) > 0 { 41 | switch fields[0] { 42 | case "audio", "video": 43 | medias = append(medias, Media{AVType: fields[0]}) 44 | media = &medias[len(medias)-1] 45 | mfields := strings.Split(fields[1], " ") 46 | if len(mfields) >= 3 { 47 | media.PayloadType, _ = strconv.Atoi(mfields[2]) 48 | } 49 | } 50 | } 51 | 52 | case "u": 53 | sess.Uri = typeval[1] 54 | 55 | case "a": 56 | if media != nil { 57 | for _, field := range fields { 58 | keyval := strings.SplitN(field, ":", 2) 59 | if len(keyval) >= 2 { 60 | key := keyval[0] 61 | val := keyval[1] 62 | switch key { 63 | case "control": 64 | media.Control = val 65 | case "rtpmap": 66 | media.Rtpmap, _ = strconv.Atoi(val) 67 | } 68 | } 69 | keyval = strings.Split(field, "/") 70 | if len(keyval) >= 2 { 71 | key := keyval[0] 72 | switch strings.ToUpper(key) { 73 | case "MPEG4-GENERIC": 74 | media.Type = av.AAC 75 | case "H264": 76 | media.Type = av.H264 77 | } 78 | if i, err := strconv.Atoi(keyval[1]); err == nil { 79 | media.TimeScale = i 80 | } 81 | if false { 82 | logrus.Info("sdp:", keyval[1], media.TimeScale) 83 | } 84 | } 85 | keyval = strings.Split(field, ";") 86 | if len(keyval) > 1 { 87 | for _, field := range keyval { 88 | keyval := strings.SplitN(field, "=", 2) 89 | if len(keyval) == 2 { 90 | key := strings.TrimSpace(keyval[0]) 91 | val := keyval[1] 92 | switch key { 93 | case "config": 94 | media.Config, _ = hex.DecodeString(val) 95 | case "sizelength": 96 | media.SizeLength, _ = strconv.Atoi(val) 97 | case "indexlength": 98 | media.IndexLength, _ = strconv.Atoi(val) 99 | case "sprop-parameter-sets": 100 | fields := strings.Split(val, ",") 101 | for _, field := range fields { 102 | val, _ := base64.StdEncoding.DecodeString(field) 103 | media.SpropParameterSets = append(media.SpropParameterSets, val) 104 | } 105 | } 106 | } 107 | } 108 | } 109 | } 110 | } 111 | 112 | } 113 | } 114 | } 115 | return 116 | } 117 | -------------------------------------------------------------------------------- /format/rtsp/sdp/parser_test.go: -------------------------------------------------------------------------------- 1 | package sdp 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestParse(t *testing.T) { 8 | _,infos := Parse(` 9 | v=0 10 | o=- 1459325504777324 1 IN IP4 192.168.0.123 11 | s=RTSP/RTP stream from Network Video Server 12 | i=mpeg4cif 13 | t=0 0 14 | a=tool:LIVE555 Streaming Media v2009.09.28 15 | a=type:broadcast 16 | a=control:* 17 | a=range:npt=0- 18 | a=x-qt-text-nam:RTSP/RTP stream from Network Video Server 19 | a=x-qt-text-inf:mpeg4cif 20 | m=video 0 RTP/AVP 96 21 | c=IN IP4 0.0.0.0 22 | b=AS:300 23 | a=rtpmap:96 H264/90000 24 | a=fmtp:96 profile-level-id=420029; packetization-mode=1; sprop-parameter-sets=Z00AHpWoKA9k,aO48gA== 25 | a=x-dimensions: 720, 480 26 | a=x-framerate: 15 27 | a=control:track1 28 | m=audio 0 RTP/AVP 96 29 | c=IN IP4 0.0.0.0 30 | b=AS:256 31 | a=rtpmap:96 MPEG4-GENERIC/16000/2 32 | a=fmtp:96 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408 33 | a=control:track2 34 | m=audio 0 RTP/AVP 0 35 | c=IN IP4 0.0.0.0 36 | b=AS:50 37 | a=recvonly 38 | a=control:rtsp://109.195.127.207:554/mpeg4cif/trackID=2 39 | a=rtpmap:0 PCMU/8000 40 | a=Media_header:MEDIAINFO=494D4B48010100000400010010710110401F000000FA000000000000000000000000000000000000; 41 | a=appversion:1.0 42 | `) 43 | t.Logf("%v", infos) 44 | } 45 | -------------------------------------------------------------------------------- /format/rtsp/stream.go: -------------------------------------------------------------------------------- 1 | package rtsp 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/format/rtsp/sdp" 6 | "time" 7 | ) 8 | 9 | type Stream struct { 10 | av.CodecData 11 | Sdp sdp.Media 12 | client *Client 13 | 14 | // h264 15 | fuStarted bool 16 | fuBuffer []byte 17 | sps []byte 18 | pps []byte 19 | spsChanged bool 20 | ppsChanged bool 21 | 22 | gotpkt bool 23 | pkt av.Packet 24 | timestamp uint32 25 | firsttimestamp uint32 26 | 27 | lasttime time.Duration 28 | } 29 | -------------------------------------------------------------------------------- /format/ts/handler.go: -------------------------------------------------------------------------------- 1 | package ts 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/av/avutil" 6 | "io" 7 | ) 8 | 9 | func Handler(h *avutil.RegisterHandler) { 10 | h.Ext = ".ts" 11 | 12 | h.Probe = func(b []byte) bool { 13 | return b[0] == 0x47 && b[188] == 0x47 14 | } 15 | 16 | h.ReaderDemuxer = func(r io.Reader) av.Demuxer { 17 | return NewDemuxer(r) 18 | } 19 | 20 | h.WriterMuxer = func(w io.Writer) av.Muxer { 21 | return NewMuxer(w) 22 | } 23 | 24 | h.CodecTypes = CodecTypes 25 | } 26 | -------------------------------------------------------------------------------- /format/ts/stream.go: -------------------------------------------------------------------------------- 1 | package ts 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/format/ts/tsio" 6 | "time" 7 | ) 8 | 9 | type Stream struct { 10 | av.CodecData 11 | 12 | demuxer *Demuxer 13 | muxer *Muxer 14 | 15 | pid uint16 16 | streamId uint8 17 | streamType uint8 18 | 19 | tsw *tsio.TSWriter 20 | idx int 21 | 22 | iskeyframe bool 23 | pts, dts time.Duration 24 | data []byte 25 | datalen int 26 | } 27 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/VKCOM/joy4 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/pkg/errors v0.8.1 7 | github.com/sirupsen/logrus v1.4.2 8 | github.com/stretchr/testify v1.2.2 9 | ) 10 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/VKCOM/joy4 v0.0.0-20190627144217-c4b6e26f04b4 h1:TtOJC2gJIKGulTufusX0T81UNmp/N9Hrq4KxK7U3sQY= 2 | github.com/VKCOM/joy4 v0.0.0-20190627144217-c4b6e26f04b4/go.mod h1:v4F8EMng9H8WBAiRGb7YMDn+N1QIURoBa6K/+B/rZ1c= 3 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 4 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 5 | github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= 6 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 7 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 8 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 9 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 10 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 11 | github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= 12 | github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= 13 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 14 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= 15 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 16 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= 17 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 18 | -------------------------------------------------------------------------------- /utils/bits/bits.go: -------------------------------------------------------------------------------- 1 | package bits 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | type Reader struct { 8 | R io.Reader 9 | n int 10 | bits uint64 11 | } 12 | 13 | func (self *Reader) ReadBits64(n int) (bits uint64, err error) { 14 | if self.n < n { 15 | var b [8]byte 16 | var got int 17 | want := (n - self.n + 7) / 8 18 | if got, err = self.R.Read(b[:want]); err != nil { 19 | return 20 | } 21 | if got < want { 22 | err = io.EOF 23 | return 24 | } 25 | for i := 0; i < got; i++ { 26 | self.bits <<= 8 27 | self.bits |= uint64(b[i]) 28 | } 29 | self.n += got * 8 30 | } 31 | bits = self.bits >> uint(self.n-n) 32 | self.bits ^= bits << uint(self.n-n) 33 | self.n -= n 34 | return 35 | } 36 | 37 | func (self *Reader) ReadBits(n int) (bits uint, err error) { 38 | var bits64 uint64 39 | if bits64, err = self.ReadBits64(n); err != nil { 40 | return 41 | } 42 | bits = uint(bits64) 43 | return 44 | } 45 | 46 | func (self *Reader) Read(p []byte) (n int, err error) { 47 | for n < len(p) { 48 | want := 8 49 | if len(p)-n < want { 50 | want = len(p) - n 51 | } 52 | var bits uint64 53 | if bits, err = self.ReadBits64(want * 8); err != nil { 54 | break 55 | } 56 | for i := 0; i < want; i++ { 57 | p[n+i] = byte(bits >> uint((want-i-1)*8)) 58 | } 59 | n += want 60 | } 61 | return 62 | } 63 | 64 | type Writer struct { 65 | W io.Writer 66 | n int 67 | bits uint64 68 | } 69 | 70 | func (self *Writer) WriteBits64(bits uint64, n int) (err error) { 71 | if self.n+n > 64 { 72 | move := uint(64 - self.n) 73 | mask := bits >> move 74 | self.bits = (self.bits << move) | mask 75 | self.n = 64 76 | if err = self.FlushBits(); err != nil { 77 | return 78 | } 79 | n -= int(move) 80 | bits ^= (mask << move) 81 | } 82 | self.bits = (self.bits << uint(n)) | bits 83 | self.n += n 84 | return 85 | } 86 | 87 | func (self *Writer) WriteBits(bits uint, n int) (err error) { 88 | return self.WriteBits64(uint64(bits), n) 89 | } 90 | 91 | func (self *Writer) Write(p []byte) (n int, err error) { 92 | for n < len(p) { 93 | if err = self.WriteBits64(uint64(p[n]), 8); err != nil { 94 | return 95 | } 96 | n++ 97 | } 98 | return 99 | } 100 | 101 | func (self *Writer) FlushBits() (err error) { 102 | if self.n > 0 { 103 | var b [8]byte 104 | bits := self.bits 105 | if self.n%8 != 0 { 106 | bits <<= uint(8 - (self.n % 8)) 107 | } 108 | want := (self.n + 7) / 8 109 | for i := 0; i < want; i++ { 110 | b[i] = byte(bits >> uint((want-i-1)*8)) 111 | } 112 | if _, err = self.W.Write(b[:want]); err != nil { 113 | return 114 | } 115 | self.n = 0 116 | } 117 | return 118 | } 119 | -------------------------------------------------------------------------------- /utils/bits/bits_test.go: -------------------------------------------------------------------------------- 1 | package bits 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | ) 7 | 8 | func TestBitsReader(t *testing.T) { 9 | rdata := []byte{0xf3, 0xb3, 0x45, 0x60} 10 | rbuf := bytes.NewReader(rdata[:]) 11 | r := &Reader{R: rbuf} 12 | var u32 uint 13 | if u32, _ = r.ReadBits(4); u32 != 0xf { 14 | t.FailNow() 15 | } 16 | if u32, _ = r.ReadBits(4); u32 != 0x3 { 17 | t.FailNow() 18 | } 19 | if u32, _ = r.ReadBits(2); u32 != 0x2 { 20 | t.FailNow() 21 | } 22 | if u32, _ = r.ReadBits(2); u32 != 0x3 { 23 | t.FailNow() 24 | } 25 | b := make([]byte, 2) 26 | if r.Read(b); b[0] != 0x34 || b[1] != 0x56 { 27 | t.FailNow() 28 | } 29 | } 30 | 31 | func TestBitsWriter(t *testing.T) { 32 | wbuf := &bytes.Buffer{} 33 | w := &Writer{W: wbuf} 34 | w.WriteBits(0xf, 4) 35 | w.WriteBits(0x3, 4) 36 | w.WriteBits(0x2, 2) 37 | w.WriteBits(0x3, 2) 38 | n, _ := w.Write([]byte{0x34, 0x56}) 39 | if n != 2 { 40 | t.FailNow() 41 | } 42 | w.FlushBits() 43 | wdata := wbuf.Bytes() 44 | if wdata[0] != 0xf3 || wdata[1] != 0xb3 || wdata[2] != 0x45 || wdata[3] != 0x60 { 45 | t.FailNow() 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /utils/bits/bufio/bufio.go: -------------------------------------------------------------------------------- 1 | package bufio 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | type Reader struct { 8 | buf [][]byte 9 | R io.ReadSeeker 10 | } 11 | 12 | func NewReaderSize(r io.ReadSeeker, size int) *Reader { 13 | buf := make([]byte, size*2) 14 | return &Reader{ 15 | R: r, 16 | buf: [][]byte{buf[0:size], buf[size:]}, 17 | } 18 | } 19 | 20 | func (self *Reader) ReadAt(b []byte, off int64) (n int, err error) { 21 | return 22 | } 23 | -------------------------------------------------------------------------------- /utils/bits/golomb_reader.go: -------------------------------------------------------------------------------- 1 | package bits 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | type GolombBitReader struct { 8 | R io.Reader 9 | buf [1]byte 10 | left byte 11 | } 12 | 13 | func (self *GolombBitReader) ReadBit() (res uint, err error) { 14 | if self.left == 0 { 15 | if _, err = self.R.Read(self.buf[:]); err != nil { 16 | return 17 | } 18 | self.left = 8 19 | } 20 | self.left-- 21 | res = uint(self.buf[0]>>self.left) & 1 22 | return 23 | } 24 | 25 | func (self *GolombBitReader) ReadBits(n int) (res uint, err error) { 26 | for i := 0; i < n; i++ { 27 | var bit uint 28 | if bit, err = self.ReadBit(); err != nil { 29 | return 30 | } 31 | res |= bit << uint(n-i-1) 32 | } 33 | return 34 | } 35 | 36 | func (self *GolombBitReader) ReadExponentialGolombCode() (res uint, err error) { 37 | i := 0 38 | for { 39 | var bit uint 40 | if bit, err = self.ReadBit(); err != nil { 41 | return 42 | } 43 | if !(bit == 0 && i < 32) { 44 | break 45 | } 46 | i++ 47 | } 48 | if res, err = self.ReadBits(i); err != nil { 49 | return 50 | } 51 | res += (1 << uint(i)) - 1 52 | return 53 | } 54 | 55 | func (self *GolombBitReader) ReadSE() (res uint, err error) { 56 | if res, err = self.ReadExponentialGolombCode(); err != nil { 57 | return 58 | } 59 | if res&0x01 != 0 { 60 | res = (res + 1) / 2 61 | } else { 62 | res = -res / 2 63 | } 64 | return 65 | } 66 | -------------------------------------------------------------------------------- /utils/bits/pio/pio.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | var RecommendBufioSize = 1024 * 64 4 | -------------------------------------------------------------------------------- /utils/bits/pio/reader.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | func U8(b []byte) (i uint8) { 4 | return b[0] 5 | } 6 | 7 | func U16BE(b []byte) (i uint16) { 8 | i = uint16(b[0]) 9 | i <<= 8 10 | i |= uint16(b[1]) 11 | return 12 | } 13 | 14 | func I16BE(b []byte) (i int16) { 15 | i = int16(b[0]) 16 | i <<= 8 17 | i |= int16(b[1]) 18 | return 19 | } 20 | 21 | func I24BE(b []byte) (i int32) { 22 | i = int32(int8(b[0])) 23 | i <<= 8 24 | i |= int32(b[1]) 25 | i <<= 8 26 | i |= int32(b[2]) 27 | return 28 | } 29 | 30 | func U24BE(b []byte) (i uint32) { 31 | i = uint32(b[0]) 32 | i <<= 8 33 | i |= uint32(b[1]) 34 | i <<= 8 35 | i |= uint32(b[2]) 36 | return 37 | } 38 | 39 | func I32BE(b []byte) (i int32) { 40 | i = int32(int8(b[0])) 41 | i <<= 8 42 | i |= int32(b[1]) 43 | i <<= 8 44 | i |= int32(b[2]) 45 | i <<= 8 46 | i |= int32(b[3]) 47 | return 48 | } 49 | 50 | func U32LE(b []byte) (i uint32) { 51 | i = uint32(b[3]) 52 | i <<= 8 53 | i |= uint32(b[2]) 54 | i <<= 8 55 | i |= uint32(b[1]) 56 | i <<= 8 57 | i |= uint32(b[0]) 58 | return 59 | } 60 | 61 | func U32BE(b []byte) (i uint32) { 62 | i = uint32(b[0]) 63 | i <<= 8 64 | i |= uint32(b[1]) 65 | i <<= 8 66 | i |= uint32(b[2]) 67 | i <<= 8 68 | i |= uint32(b[3]) 69 | return 70 | } 71 | 72 | func U40BE(b []byte) (i uint64) { 73 | i = uint64(b[0]) 74 | i <<= 8 75 | i |= uint64(b[1]) 76 | i <<= 8 77 | i |= uint64(b[2]) 78 | i <<= 8 79 | i |= uint64(b[3]) 80 | i <<= 8 81 | i |= uint64(b[4]) 82 | return 83 | } 84 | 85 | func U64BE(b []byte) (i uint64) { 86 | i = uint64(b[0]) 87 | i <<= 8 88 | i |= uint64(b[1]) 89 | i <<= 8 90 | i |= uint64(b[2]) 91 | i <<= 8 92 | i |= uint64(b[3]) 93 | i <<= 8 94 | i |= uint64(b[4]) 95 | i <<= 8 96 | i |= uint64(b[5]) 97 | i <<= 8 98 | i |= uint64(b[6]) 99 | i <<= 8 100 | i |= uint64(b[7]) 101 | return 102 | } 103 | 104 | func I64BE(b []byte) (i int64) { 105 | i = int64(int8(b[0])) 106 | i <<= 8 107 | i |= int64(b[1]) 108 | i <<= 8 109 | i |= int64(b[2]) 110 | i <<= 8 111 | i |= int64(b[3]) 112 | i <<= 8 113 | i |= int64(b[4]) 114 | i <<= 8 115 | i |= int64(b[5]) 116 | i <<= 8 117 | i |= int64(b[6]) 118 | i <<= 8 119 | i |= int64(b[7]) 120 | return 121 | } 122 | -------------------------------------------------------------------------------- /utils/bits/pio/vec.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | func VecLen(vec [][]byte) (n int) { 4 | for _, b := range vec { 5 | n += len(b) 6 | } 7 | return 8 | } 9 | 10 | func VecSliceTo(in [][]byte, out [][]byte, s int, e int) (n int) { 11 | if s < 0 { 12 | s = 0 13 | } 14 | 15 | if e >= 0 && e < s { 16 | panic("pio: VecSlice start > end") 17 | } 18 | 19 | i := 0 20 | off := 0 21 | for s > 0 && i < len(in) { 22 | left := len(in[i]) 23 | read := s 24 | if left < read { 25 | read = left 26 | } 27 | left -= read 28 | off += read 29 | s -= read 30 | e -= read 31 | if left == 0 { 32 | i++ 33 | off = 0 34 | } 35 | } 36 | if s > 0 { 37 | panic("pio: VecSlice start out of range") 38 | } 39 | 40 | for e != 0 && i < len(in) { 41 | left := len(in[i]) - off 42 | read := left 43 | if e > 0 && e < read { 44 | read = e 45 | } 46 | out[n] = in[i][off : off+read] 47 | n++ 48 | left -= read 49 | e -= read 50 | off += read 51 | if left == 0 { 52 | i++ 53 | off = 0 54 | } 55 | } 56 | if e > 0 { 57 | panic("pio: VecSlice end out of range") 58 | } 59 | 60 | return 61 | } 62 | 63 | func VecSlice(in [][]byte, s int, e int) (out [][]byte) { 64 | out = make([][]byte, len(in)) 65 | n := VecSliceTo(in, out, s, e) 66 | out = out[:n] 67 | return 68 | } 69 | -------------------------------------------------------------------------------- /utils/bits/pio/vec_test.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | import ( 4 | "github.com/sirupsen/logrus" 5 | ) 6 | 7 | func ExampleVec() { 8 | vec := [][]byte{[]byte{1, 2, 3}, []byte{4, 5, 6, 7, 8, 9}, []byte{10, 11, 12, 13}} 9 | println(VecLen(vec)) 10 | 11 | vec = VecSlice(vec, 1, -1) 12 | logrus.Info(vec) 13 | 14 | vec = VecSlice(vec, 2, -1) 15 | logrus.Info(vec) 16 | 17 | vec = VecSlice(vec, 8, 8) 18 | logrus.Info(vec) 19 | 20 | // Output: 21 | } 22 | -------------------------------------------------------------------------------- /utils/bits/pio/writer.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | func PutU8(b []byte, v uint8) { 4 | b[0] = v 5 | } 6 | 7 | func PutI16BE(b []byte, v int16) { 8 | b[0] = byte(v >> 8) 9 | b[1] = byte(v) 10 | } 11 | 12 | func PutU16BE(b []byte, v uint16) { 13 | b[0] = byte(v >> 8) 14 | b[1] = byte(v) 15 | } 16 | 17 | func PutI24BE(b []byte, v int32) { 18 | b[0] = byte(v >> 16) 19 | b[1] = byte(v >> 8) 20 | b[2] = byte(v) 21 | } 22 | 23 | func PutU24BE(b []byte, v uint32) { 24 | b[0] = byte(v >> 16) 25 | b[1] = byte(v >> 8) 26 | b[2] = byte(v) 27 | } 28 | 29 | func PutI32BE(b []byte, v int32) { 30 | b[0] = byte(v >> 24) 31 | b[1] = byte(v >> 16) 32 | b[2] = byte(v >> 8) 33 | b[3] = byte(v) 34 | } 35 | 36 | func PutU32BE(b []byte, v uint32) { 37 | b[0] = byte(v >> 24) 38 | b[1] = byte(v >> 16) 39 | b[2] = byte(v >> 8) 40 | b[3] = byte(v) 41 | } 42 | 43 | func PutU32LE(b []byte, v uint32) { 44 | b[3] = byte(v >> 24) 45 | b[2] = byte(v >> 16) 46 | b[1] = byte(v >> 8) 47 | b[0] = byte(v) 48 | } 49 | 50 | func PutU40BE(b []byte, v uint64) { 51 | b[0] = byte(v >> 32) 52 | b[1] = byte(v >> 24) 53 | b[2] = byte(v >> 16) 54 | b[3] = byte(v >> 8) 55 | b[4] = byte(v) 56 | } 57 | 58 | func PutU48BE(b []byte, v uint64) { 59 | b[0] = byte(v >> 40) 60 | b[1] = byte(v >> 32) 61 | b[2] = byte(v >> 24) 62 | b[3] = byte(v >> 16) 63 | b[4] = byte(v >> 8) 64 | b[5] = byte(v) 65 | } 66 | 67 | func PutU64BE(b []byte, v uint64) { 68 | b[0] = byte(v >> 56) 69 | b[1] = byte(v >> 48) 70 | b[2] = byte(v >> 40) 71 | b[3] = byte(v >> 32) 72 | b[4] = byte(v >> 24) 73 | b[5] = byte(v >> 16) 74 | b[6] = byte(v >> 8) 75 | b[7] = byte(v) 76 | } 77 | 78 | func PutI64BE(b []byte, v int64) { 79 | b[0] = byte(v >> 56) 80 | b[1] = byte(v >> 48) 81 | b[2] = byte(v >> 40) 82 | b[3] = byte(v >> 32) 83 | b[4] = byte(v >> 24) 84 | b[5] = byte(v >> 16) 85 | b[6] = byte(v >> 8) 86 | b[7] = byte(v) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/av/pktque/buf.go: -------------------------------------------------------------------------------- 1 | package pktque 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | ) 6 | 7 | type Buf struct { 8 | Head, Tail BufPos 9 | pkts []av.Packet 10 | Size int 11 | Count int 12 | } 13 | 14 | func NewBuf() *Buf { 15 | return &Buf{ 16 | pkts: make([]av.Packet, 64), 17 | } 18 | } 19 | 20 | func (self *Buf) Pop() av.Packet { 21 | if self.Count == 0 { 22 | panic("pktque.Buf: Pop() when count == 0") 23 | } 24 | 25 | i := int(self.Head) & (len(self.pkts) - 1) 26 | pkt := self.pkts[i] 27 | self.pkts[i] = av.Packet{} 28 | self.Size -= len(pkt.Data) 29 | self.Head++ 30 | self.Count-- 31 | 32 | return pkt 33 | } 34 | 35 | func (self *Buf) grow() { 36 | newpkts := make([]av.Packet, len(self.pkts)*2) 37 | for i := self.Head; i.LT(self.Tail); i++ { 38 | newpkts[int(i)&(len(newpkts)-1)] = self.pkts[int(i)&(len(self.pkts)-1)] 39 | } 40 | self.pkts = newpkts 41 | } 42 | 43 | func (self *Buf) Push(pkt av.Packet) { 44 | if self.Count == len(self.pkts) { 45 | self.grow() 46 | } 47 | self.pkts[int(self.Tail)&(len(self.pkts)-1)] = pkt 48 | self.Tail++ 49 | self.Count++ 50 | self.Size += len(pkt.Data) 51 | } 52 | 53 | func (self *Buf) Get(pos BufPos) av.Packet { 54 | return self.pkts[int(pos)&(len(self.pkts)-1)] 55 | } 56 | 57 | func (self *Buf) IsValidPos(pos BufPos) bool { 58 | return pos.GE(self.Head) && pos.LT(self.Tail) 59 | } 60 | 61 | type BufPos int 62 | 63 | func (self BufPos) LT(pos BufPos) bool { 64 | return self-pos < 0 65 | } 66 | 67 | func (self BufPos) GE(pos BufPos) bool { 68 | return self-pos >= 0 69 | } 70 | 71 | func (self BufPos) GT(pos BufPos) bool { 72 | return self-pos > 0 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/av/pktque/timeline.go: -------------------------------------------------------------------------------- 1 | package pktque 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | /* 8 | pop push 9 | 10 | seg seg seg 11 | |--------| |---------| |---| 12 | 20ms 40ms 5ms 13 | ----------------- time --------------------> 14 | headtm tailtm 15 | */ 16 | 17 | type tlSeg struct { 18 | tm, dur time.Duration 19 | } 20 | 21 | type Timeline struct { 22 | segs []tlSeg 23 | headtm time.Duration 24 | } 25 | 26 | func (self *Timeline) Push(tm time.Duration, dur time.Duration) { 27 | if len(self.segs) > 0 { 28 | tail := self.segs[len(self.segs)-1] 29 | diff := tm - (tail.tm + tail.dur) 30 | if diff < 0 { 31 | tm -= diff 32 | } 33 | } 34 | self.segs = append(self.segs, tlSeg{tm, dur}) 35 | } 36 | 37 | func (self *Timeline) Pop(dur time.Duration) (tm time.Duration) { 38 | if len(self.segs) == 0 { 39 | return self.headtm 40 | } 41 | 42 | tm = self.segs[0].tm 43 | for dur > 0 && len(self.segs) > 0 { 44 | seg := &self.segs[0] 45 | sub := dur 46 | if seg.dur < sub { 47 | sub = seg.dur 48 | } 49 | seg.dur -= sub 50 | dur -= sub 51 | seg.tm += sub 52 | self.headtm += sub 53 | if seg.dur == 0 { 54 | copy(self.segs[0:], self.segs[1:]) 55 | self.segs = self.segs[:len(self.segs)-1] 56 | } 57 | } 58 | 59 | return 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/codec/codec.go: -------------------------------------------------------------------------------- 1 | package codec 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/codec/fake" 6 | "time" 7 | ) 8 | 9 | type PCMUCodecData struct { 10 | typ av.CodecType 11 | } 12 | 13 | func (self PCMUCodecData) Type() av.CodecType { 14 | return self.typ 15 | } 16 | 17 | func (self PCMUCodecData) SampleRate() int { 18 | return 8000 19 | } 20 | 21 | func (self PCMUCodecData) ChannelLayout() av.ChannelLayout { 22 | return av.CH_MONO 23 | } 24 | 25 | func (self PCMUCodecData) SampleFormat() av.SampleFormat { 26 | return av.S16 27 | } 28 | 29 | func (self PCMUCodecData) PacketDuration(data []byte) (time.Duration, error) { 30 | return time.Duration(len(data)) * time.Second / time.Duration(8000), nil 31 | } 32 | 33 | func NewPCMMulawCodecData() av.AudioCodecData { 34 | return PCMUCodecData{ 35 | typ: av.PCM_MULAW, 36 | } 37 | } 38 | 39 | func NewPCMAlawCodecData() av.AudioCodecData { 40 | return PCMUCodecData{ 41 | typ: av.PCM_ALAW, 42 | } 43 | } 44 | 45 | type SpeexCodecData struct { 46 | fake.CodecData 47 | } 48 | 49 | func (self SpeexCodecData) PacketDuration(data []byte) (time.Duration, error) { 50 | // libavcodec/libspeexdec.c 51 | // samples = samplerate/50 52 | // duration = 0.02s 53 | return time.Millisecond * 20, nil 54 | } 55 | 56 | func NewSpeexCodecData(sr int, cl av.ChannelLayout) SpeexCodecData { 57 | codec := SpeexCodecData{} 58 | codec.CodecType_ = av.SPEEX 59 | codec.SampleFormat_ = av.S16 60 | codec.SampleRate_ = sr 61 | codec.ChannelLayout_ = cl 62 | return codec 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/codec/fake/fake.go: -------------------------------------------------------------------------------- 1 | package fake 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | ) 6 | 7 | type CodecData struct { 8 | CodecType_ av.CodecType 9 | SampleRate_ int 10 | SampleFormat_ av.SampleFormat 11 | ChannelLayout_ av.ChannelLayout 12 | } 13 | 14 | func (self CodecData) Type() av.CodecType { 15 | return self.CodecType_ 16 | } 17 | 18 | func (self CodecData) SampleFormat() av.SampleFormat { 19 | return self.SampleFormat_ 20 | } 21 | 22 | func (self CodecData) ChannelLayout() av.ChannelLayout { 23 | return self.ChannelLayout_ 24 | } 25 | 26 | func (self CodecData) SampleRate() int { 27 | return self.SampleRate_ 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/codec/h264parser/fuzz_h264parser.go: -------------------------------------------------------------------------------- 1 | package h264parser 2 | //go-fuzz-build -func=Fuzz_ParseSPS -o=Fuzz_ParseSPS.zip github.com/VKCOM/joy4/codec/h264parser 3 | //go-fuzz -dumpcover -bin=Fuzz_ParseSPS.zip -workdir=joy4/codec/h264parser/corpus_ParseSPS 4 | 5 | func Fuzz_SplitNALUs(data []byte) int { 6 | nalus, _ := SplitNALUs(data) 7 | 8 | if len(nalus) ==0 { 9 | return 0 10 | } 11 | return 1 12 | } 13 | 14 | func Fuzz_ParseSPS(data []byte) int { 15 | _, err := ParseSPS(data) 16 | 17 | if err!=nil { 18 | return 0 19 | } 20 | return 1 21 | } 22 | 23 | func Fuzz_ParseSliceHeaderFromNALU(data []byte) int { 24 | _, err := ParseSPS(data) 25 | 26 | if err!=nil { 27 | return 0 28 | } 29 | return 1 30 | } 31 | 32 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/format/aac/aac.go: -------------------------------------------------------------------------------- 1 | package aac 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "github.com/VKCOM/joy4/av" 7 | "github.com/VKCOM/joy4/av/avutil" 8 | "github.com/VKCOM/joy4/codec/aacparser" 9 | "io" 10 | "time" 11 | ) 12 | 13 | type Muxer struct { 14 | w io.Writer 15 | config aacparser.MPEG4AudioConfig 16 | adtshdr []byte 17 | } 18 | 19 | func NewMuxer(w io.Writer) *Muxer { 20 | return &Muxer{ 21 | adtshdr: make([]byte, aacparser.ADTSHeaderLength), 22 | w: w, 23 | } 24 | } 25 | 26 | func (self *Muxer) WriteHeader(streams []av.CodecData) (err error) { 27 | if len(streams) > 1 || streams[0].Type() != av.AAC { 28 | err = fmt.Errorf("aac: must be only one aac stream") 29 | return 30 | } 31 | self.config = streams[0].(aacparser.CodecData).Config 32 | if self.config.ObjectType > aacparser.AOT_AAC_LTP { 33 | err = fmt.Errorf("aac: AOT %d is not allowed in ADTS", self.config.ObjectType) 34 | } 35 | return 36 | } 37 | 38 | func (self *Muxer) WritePacket(pkt av.Packet) (err error) { 39 | aacparser.FillADTSHeader(self.adtshdr, self.config, 1024, len(pkt.Data)) 40 | if _, err = self.w.Write(self.adtshdr); err != nil { 41 | return 42 | } 43 | if _, err = self.w.Write(pkt.Data); err != nil { 44 | return 45 | } 46 | return 47 | } 48 | 49 | func (self *Muxer) WriteTrailer() (err error) { 50 | return 51 | } 52 | 53 | type Demuxer struct { 54 | r *bufio.Reader 55 | config aacparser.MPEG4AudioConfig 56 | codecdata av.CodecData 57 | ts time.Duration 58 | } 59 | 60 | func NewDemuxer(r io.Reader) *Demuxer { 61 | return &Demuxer{ 62 | r: bufio.NewReader(r), 63 | } 64 | } 65 | 66 | func (self *Demuxer) Streams() (streams []av.CodecData, err error) { 67 | if self.codecdata == nil { 68 | var adtshdr []byte 69 | var config aacparser.MPEG4AudioConfig 70 | if adtshdr, err = self.r.Peek(9); err != nil { 71 | return 72 | } 73 | if config, _, _, _, err = aacparser.ParseADTSHeader(adtshdr); err != nil { 74 | return 75 | } 76 | if self.codecdata, err = aacparser.NewCodecDataFromMPEG4AudioConfig(config); err != nil { 77 | return 78 | } 79 | } 80 | streams = []av.CodecData{self.codecdata} 81 | return 82 | } 83 | 84 | func (self *Demuxer) ReadPacket() (pkt av.Packet, err error) { 85 | var adtshdr []byte 86 | var config aacparser.MPEG4AudioConfig 87 | var hdrlen, framelen, samples int 88 | if adtshdr, err = self.r.Peek(9); err != nil { 89 | return 90 | } 91 | if config, hdrlen, framelen, samples, err = aacparser.ParseADTSHeader(adtshdr); err != nil { 92 | return 93 | } 94 | 95 | pkt.Data = make([]byte, framelen) 96 | if _, err = io.ReadFull(self.r, pkt.Data); err != nil { 97 | return 98 | } 99 | pkt.Data = pkt.Data[hdrlen:] 100 | 101 | pkt.Time = self.ts 102 | self.ts += time.Duration(samples) * time.Second / time.Duration(config.SampleRate) 103 | return 104 | } 105 | 106 | func Handler(h *avutil.RegisterHandler) { 107 | h.Ext = ".aac" 108 | 109 | h.ReaderDemuxer = func(r io.Reader) av.Demuxer { 110 | return NewDemuxer(r) 111 | } 112 | 113 | h.WriterMuxer = func(w io.Writer) av.Muxer { 114 | return NewMuxer(w) 115 | } 116 | 117 | h.Probe = func(b []byte) bool { 118 | _, _, _, _, err := aacparser.ParseADTSHeader(b) 119 | return err == nil 120 | } 121 | 122 | h.CodecTypes = []av.CodecType{av.AAC} 123 | } 124 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/format/format.go: -------------------------------------------------------------------------------- 1 | package format 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av/avutil" 5 | "github.com/VKCOM/joy4/format/aac" 6 | "github.com/VKCOM/joy4/format/flv" 7 | "github.com/VKCOM/joy4/format/mp4" 8 | "github.com/VKCOM/joy4/format/rtmp" 9 | "github.com/VKCOM/joy4/format/rtsp" 10 | "github.com/VKCOM/joy4/format/ts" 11 | ) 12 | 13 | func RegisterAll() { 14 | avutil.DefaultHandlers.Add(mp4.Handler) 15 | avutil.DefaultHandlers.Add(ts.Handler) 16 | avutil.DefaultHandlers.Add(rtmp.Handler) 17 | avutil.DefaultHandlers.Add(rtsp.Handler) 18 | avutil.DefaultHandlers.Add(flv.Handler) 19 | avutil.DefaultHandlers.Add(aac.Handler) 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/format/mp4/handler.go: -------------------------------------------------------------------------------- 1 | package mp4 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/av/avutil" 6 | "io" 7 | ) 8 | 9 | var CodecTypes = []av.CodecType{av.H264, av.AAC} 10 | 11 | func Handler(h *avutil.RegisterHandler) { 12 | h.Ext = ".mp4" 13 | 14 | h.Probe = func(b []byte) bool { 15 | switch string(b[4:8]) { 16 | case "moov", "ftyp", "free", "mdat", "moof": 17 | return true 18 | } 19 | return false 20 | } 21 | 22 | h.ReaderDemuxer = func(r io.Reader) av.Demuxer { 23 | return NewDemuxer(r.(io.ReadSeeker)) 24 | } 25 | 26 | h.WriterMuxer = func(w io.Writer) av.Muxer { 27 | return NewMuxer(w.(io.WriteSeeker)) 28 | } 29 | 30 | h.CodecTypes = CodecTypes 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/format/mp4/stream.go: -------------------------------------------------------------------------------- 1 | package mp4 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/format/mp4/mp4io" 6 | "time" 7 | ) 8 | 9 | type Stream struct { 10 | av.CodecData 11 | 12 | trackAtom *mp4io.Track 13 | idx int 14 | 15 | lastpkt *av.Packet 16 | 17 | timeScale int64 18 | duration int64 19 | 20 | muxer *Muxer 21 | demuxer *Demuxer 22 | 23 | sample *mp4io.SampleTable 24 | sampleIndex int 25 | 26 | sampleOffsetInChunk int64 27 | syncSampleIndex int 28 | 29 | dts int64 30 | sttsEntryIndex int 31 | sampleIndexInSttsEntry int 32 | 33 | cttsEntryIndex int 34 | sampleIndexInCttsEntry int 35 | 36 | chunkGroupIndex int 37 | chunkIndex int 38 | sampleIndexInChunk int 39 | 40 | sttsEntry *mp4io.TimeToSampleEntry 41 | cttsEntry *mp4io.CompositionOffsetEntry 42 | } 43 | 44 | func timeToTs(tm time.Duration, timeScale int64) int64 { 45 | return int64(tm * time.Duration(timeScale) / time.Second) 46 | } 47 | 48 | func tsToTime(ts int64, timeScale int64) time.Duration { 49 | return time.Duration(ts) * time.Second / time.Duration(timeScale) 50 | } 51 | 52 | func (self *Stream) timeToTs(tm time.Duration) int64 { 53 | return int64(tm * time.Duration(self.timeScale) / time.Second) 54 | } 55 | 56 | func (self *Stream) tsToTime(ts int64) time.Duration { 57 | return time.Duration(ts) * time.Second / time.Duration(self.timeScale) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/format/rtsp/conn.go: -------------------------------------------------------------------------------- 1 | package rtsp 2 | 3 | import ( 4 | "net" 5 | "time" 6 | ) 7 | 8 | type connWithTimeout struct { 9 | Timeout time.Duration 10 | net.Conn 11 | } 12 | 13 | func (self connWithTimeout) Read(p []byte) (n int, err error) { 14 | if self.Timeout > 0 { 15 | self.Conn.SetReadDeadline(time.Now().Add(self.Timeout)) 16 | } 17 | return self.Conn.Read(p) 18 | } 19 | 20 | func (self connWithTimeout) Write(p []byte) (n int, err error) { 21 | if self.Timeout > 0 { 22 | self.Conn.SetWriteDeadline(time.Now().Add(self.Timeout)) 23 | } 24 | return self.Conn.Write(p) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/format/rtsp/stream.go: -------------------------------------------------------------------------------- 1 | package rtsp 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/format/rtsp/sdp" 6 | "time" 7 | ) 8 | 9 | type Stream struct { 10 | av.CodecData 11 | Sdp sdp.Media 12 | client *Client 13 | 14 | // h264 15 | fuStarted bool 16 | fuBuffer []byte 17 | sps []byte 18 | pps []byte 19 | spsChanged bool 20 | ppsChanged bool 21 | 22 | gotpkt bool 23 | pkt av.Packet 24 | timestamp uint32 25 | firsttimestamp uint32 26 | 27 | lasttime time.Duration 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/format/ts/handler.go: -------------------------------------------------------------------------------- 1 | package ts 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/av/avutil" 6 | "io" 7 | ) 8 | 9 | func Handler(h *avutil.RegisterHandler) { 10 | h.Ext = ".ts" 11 | 12 | h.Probe = func(b []byte) bool { 13 | return b[0] == 0x47 && b[188] == 0x47 14 | } 15 | 16 | h.ReaderDemuxer = func(r io.Reader) av.Demuxer { 17 | return NewDemuxer(r) 18 | } 19 | 20 | h.WriterMuxer = func(w io.Writer) av.Muxer { 21 | return NewMuxer(w) 22 | } 23 | 24 | h.CodecTypes = CodecTypes 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/format/ts/stream.go: -------------------------------------------------------------------------------- 1 | package ts 2 | 3 | import ( 4 | "github.com/VKCOM/joy4/av" 5 | "github.com/VKCOM/joy4/format/ts/tsio" 6 | "time" 7 | ) 8 | 9 | type Stream struct { 10 | av.CodecData 11 | 12 | demuxer *Demuxer 13 | muxer *Muxer 14 | 15 | pid uint16 16 | streamId uint8 17 | streamType uint8 18 | 19 | tsw *tsio.TSWriter 20 | idx int 21 | 22 | iskeyframe bool 23 | pts, dts time.Duration 24 | data []byte 25 | datalen int 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/utils/bits/bits.go: -------------------------------------------------------------------------------- 1 | package bits 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | type Reader struct { 8 | R io.Reader 9 | n int 10 | bits uint64 11 | } 12 | 13 | func (self *Reader) ReadBits64(n int) (bits uint64, err error) { 14 | if self.n < n { 15 | var b [8]byte 16 | var got int 17 | want := (n - self.n + 7) / 8 18 | if got, err = self.R.Read(b[:want]); err != nil { 19 | return 20 | } 21 | if got < want { 22 | err = io.EOF 23 | return 24 | } 25 | for i := 0; i < got; i++ { 26 | self.bits <<= 8 27 | self.bits |= uint64(b[i]) 28 | } 29 | self.n += got * 8 30 | } 31 | bits = self.bits >> uint(self.n-n) 32 | self.bits ^= bits << uint(self.n-n) 33 | self.n -= n 34 | return 35 | } 36 | 37 | func (self *Reader) ReadBits(n int) (bits uint, err error) { 38 | var bits64 uint64 39 | if bits64, err = self.ReadBits64(n); err != nil { 40 | return 41 | } 42 | bits = uint(bits64) 43 | return 44 | } 45 | 46 | func (self *Reader) Read(p []byte) (n int, err error) { 47 | for n < len(p) { 48 | want := 8 49 | if len(p)-n < want { 50 | want = len(p) - n 51 | } 52 | var bits uint64 53 | if bits, err = self.ReadBits64(want * 8); err != nil { 54 | break 55 | } 56 | for i := 0; i < want; i++ { 57 | p[n+i] = byte(bits >> uint((want-i-1)*8)) 58 | } 59 | n += want 60 | } 61 | return 62 | } 63 | 64 | type Writer struct { 65 | W io.Writer 66 | n int 67 | bits uint64 68 | } 69 | 70 | func (self *Writer) WriteBits64(bits uint64, n int) (err error) { 71 | if self.n+n > 64 { 72 | move := uint(64 - self.n) 73 | mask := bits >> move 74 | self.bits = (self.bits << move) | mask 75 | self.n = 64 76 | if err = self.FlushBits(); err != nil { 77 | return 78 | } 79 | n -= int(move) 80 | bits ^= (mask << move) 81 | } 82 | self.bits = (self.bits << uint(n)) | bits 83 | self.n += n 84 | return 85 | } 86 | 87 | func (self *Writer) WriteBits(bits uint, n int) (err error) { 88 | return self.WriteBits64(uint64(bits), n) 89 | } 90 | 91 | func (self *Writer) Write(p []byte) (n int, err error) { 92 | for n < len(p) { 93 | if err = self.WriteBits64(uint64(p[n]), 8); err != nil { 94 | return 95 | } 96 | n++ 97 | } 98 | return 99 | } 100 | 101 | func (self *Writer) FlushBits() (err error) { 102 | if self.n > 0 { 103 | var b [8]byte 104 | bits := self.bits 105 | if self.n%8 != 0 { 106 | bits <<= uint(8 - (self.n % 8)) 107 | } 108 | want := (self.n + 7) / 8 109 | for i := 0; i < want; i++ { 110 | b[i] = byte(bits >> uint((want-i-1)*8)) 111 | } 112 | if _, err = self.W.Write(b[:want]); err != nil { 113 | return 114 | } 115 | self.n = 0 116 | } 117 | return 118 | } 119 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/utils/bits/golomb_reader.go: -------------------------------------------------------------------------------- 1 | package bits 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | type GolombBitReader struct { 8 | R io.Reader 9 | buf [1]byte 10 | left byte 11 | } 12 | 13 | func (self *GolombBitReader) ReadBit() (res uint, err error) { 14 | if self.left == 0 { 15 | if _, err = self.R.Read(self.buf[:]); err != nil { 16 | return 17 | } 18 | self.left = 8 19 | } 20 | self.left-- 21 | res = uint(self.buf[0]>>self.left) & 1 22 | return 23 | } 24 | 25 | func (self *GolombBitReader) ReadBits(n int) (res uint, err error) { 26 | for i := 0; i < n; i++ { 27 | var bit uint 28 | if bit, err = self.ReadBit(); err != nil { 29 | return 30 | } 31 | res |= bit << uint(n-i-1) 32 | } 33 | return 34 | } 35 | 36 | func (self *GolombBitReader) ReadExponentialGolombCode() (res uint, err error) { 37 | i := 0 38 | for { 39 | var bit uint 40 | if bit, err = self.ReadBit(); err != nil { 41 | return 42 | } 43 | if !(bit == 0 && i < 32) { 44 | break 45 | } 46 | i++ 47 | } 48 | if res, err = self.ReadBits(i); err != nil { 49 | return 50 | } 51 | res += (1 << uint(i)) - 1 52 | return 53 | } 54 | 55 | func (self *GolombBitReader) ReadSE() (res uint, err error) { 56 | if res, err = self.ReadExponentialGolombCode(); err != nil { 57 | return 58 | } 59 | if res&0x01 != 0 { 60 | res = (res + 1) / 2 61 | } else { 62 | res = -res / 2 63 | } 64 | return 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/utils/bits/pio/pio.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | var RecommendBufioSize = 1024 * 64 4 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/utils/bits/pio/reader.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | func U8(b []byte) (i uint8) { 4 | return b[0] 5 | } 6 | 7 | func U16BE(b []byte) (i uint16) { 8 | i = uint16(b[0]) 9 | i <<= 8 10 | i |= uint16(b[1]) 11 | return 12 | } 13 | 14 | func I16BE(b []byte) (i int16) { 15 | i = int16(b[0]) 16 | i <<= 8 17 | i |= int16(b[1]) 18 | return 19 | } 20 | 21 | func I24BE(b []byte) (i int32) { 22 | i = int32(int8(b[0])) 23 | i <<= 8 24 | i |= int32(b[1]) 25 | i <<= 8 26 | i |= int32(b[2]) 27 | return 28 | } 29 | 30 | func U24BE(b []byte) (i uint32) { 31 | i = uint32(b[0]) 32 | i <<= 8 33 | i |= uint32(b[1]) 34 | i <<= 8 35 | i |= uint32(b[2]) 36 | return 37 | } 38 | 39 | func I32BE(b []byte) (i int32) { 40 | i = int32(int8(b[0])) 41 | i <<= 8 42 | i |= int32(b[1]) 43 | i <<= 8 44 | i |= int32(b[2]) 45 | i <<= 8 46 | i |= int32(b[3]) 47 | return 48 | } 49 | 50 | func U32LE(b []byte) (i uint32) { 51 | i = uint32(b[3]) 52 | i <<= 8 53 | i |= uint32(b[2]) 54 | i <<= 8 55 | i |= uint32(b[1]) 56 | i <<= 8 57 | i |= uint32(b[0]) 58 | return 59 | } 60 | 61 | func U32BE(b []byte) (i uint32) { 62 | i = uint32(b[0]) 63 | i <<= 8 64 | i |= uint32(b[1]) 65 | i <<= 8 66 | i |= uint32(b[2]) 67 | i <<= 8 68 | i |= uint32(b[3]) 69 | return 70 | } 71 | 72 | func U40BE(b []byte) (i uint64) { 73 | i = uint64(b[0]) 74 | i <<= 8 75 | i |= uint64(b[1]) 76 | i <<= 8 77 | i |= uint64(b[2]) 78 | i <<= 8 79 | i |= uint64(b[3]) 80 | i <<= 8 81 | i |= uint64(b[4]) 82 | return 83 | } 84 | 85 | func U64BE(b []byte) (i uint64) { 86 | i = uint64(b[0]) 87 | i <<= 8 88 | i |= uint64(b[1]) 89 | i <<= 8 90 | i |= uint64(b[2]) 91 | i <<= 8 92 | i |= uint64(b[3]) 93 | i <<= 8 94 | i |= uint64(b[4]) 95 | i <<= 8 96 | i |= uint64(b[5]) 97 | i <<= 8 98 | i |= uint64(b[6]) 99 | i <<= 8 100 | i |= uint64(b[7]) 101 | return 102 | } 103 | 104 | func I64BE(b []byte) (i int64) { 105 | i = int64(int8(b[0])) 106 | i <<= 8 107 | i |= int64(b[1]) 108 | i <<= 8 109 | i |= int64(b[2]) 110 | i <<= 8 111 | i |= int64(b[3]) 112 | i <<= 8 113 | i |= int64(b[4]) 114 | i <<= 8 115 | i |= int64(b[5]) 116 | i <<= 8 117 | i |= int64(b[6]) 118 | i <<= 8 119 | i |= int64(b[7]) 120 | return 121 | } 122 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/utils/bits/pio/vec.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | func VecLen(vec [][]byte) (n int) { 4 | for _, b := range vec { 5 | n += len(b) 6 | } 7 | return 8 | } 9 | 10 | func VecSliceTo(in [][]byte, out [][]byte, s int, e int) (n int) { 11 | if s < 0 { 12 | s = 0 13 | } 14 | 15 | if e >= 0 && e < s { 16 | panic("pio: VecSlice start > end") 17 | } 18 | 19 | i := 0 20 | off := 0 21 | for s > 0 && i < len(in) { 22 | left := len(in[i]) 23 | read := s 24 | if left < read { 25 | read = left 26 | } 27 | left -= read 28 | off += read 29 | s -= read 30 | e -= read 31 | if left == 0 { 32 | i++ 33 | off = 0 34 | } 35 | } 36 | if s > 0 { 37 | panic("pio: VecSlice start out of range") 38 | } 39 | 40 | for e != 0 && i < len(in) { 41 | left := len(in[i]) - off 42 | read := left 43 | if e > 0 && e < read { 44 | read = e 45 | } 46 | out[n] = in[i][off : off+read] 47 | n++ 48 | left -= read 49 | e -= read 50 | off += read 51 | if left == 0 { 52 | i++ 53 | off = 0 54 | } 55 | } 56 | if e > 0 { 57 | panic("pio: VecSlice end out of range") 58 | } 59 | 60 | return 61 | } 62 | 63 | func VecSlice(in [][]byte, s int, e int) (out [][]byte) { 64 | out = make([][]byte, len(in)) 65 | n := VecSliceTo(in, out, s, e) 66 | out = out[:n] 67 | return 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/VKCOM/joy4/utils/bits/pio/writer.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | func PutU8(b []byte, v uint8) { 4 | b[0] = v 5 | } 6 | 7 | func PutI16BE(b []byte, v int16) { 8 | b[0] = byte(v >> 8) 9 | b[1] = byte(v) 10 | } 11 | 12 | func PutU16BE(b []byte, v uint16) { 13 | b[0] = byte(v >> 8) 14 | b[1] = byte(v) 15 | } 16 | 17 | func PutI24BE(b []byte, v int32) { 18 | b[0] = byte(v >> 16) 19 | b[1] = byte(v >> 8) 20 | b[2] = byte(v) 21 | } 22 | 23 | func PutU24BE(b []byte, v uint32) { 24 | b[0] = byte(v >> 16) 25 | b[1] = byte(v >> 8) 26 | b[2] = byte(v) 27 | } 28 | 29 | func PutI32BE(b []byte, v int32) { 30 | b[0] = byte(v >> 24) 31 | b[1] = byte(v >> 16) 32 | b[2] = byte(v >> 8) 33 | b[3] = byte(v) 34 | } 35 | 36 | func PutU32BE(b []byte, v uint32) { 37 | b[0] = byte(v >> 24) 38 | b[1] = byte(v >> 16) 39 | b[2] = byte(v >> 8) 40 | b[3] = byte(v) 41 | } 42 | 43 | func PutU32LE(b []byte, v uint32) { 44 | b[3] = byte(v >> 24) 45 | b[2] = byte(v >> 16) 46 | b[1] = byte(v >> 8) 47 | b[0] = byte(v) 48 | } 49 | 50 | func PutU40BE(b []byte, v uint64) { 51 | b[0] = byte(v >> 32) 52 | b[1] = byte(v >> 24) 53 | b[2] = byte(v >> 16) 54 | b[3] = byte(v >> 8) 55 | b[4] = byte(v) 56 | } 57 | 58 | func PutU48BE(b []byte, v uint64) { 59 | b[0] = byte(v >> 40) 60 | b[1] = byte(v >> 32) 61 | b[2] = byte(v >> 24) 62 | b[3] = byte(v >> 16) 63 | b[4] = byte(v >> 8) 64 | b[5] = byte(v) 65 | } 66 | 67 | func PutU64BE(b []byte, v uint64) { 68 | b[0] = byte(v >> 56) 69 | b[1] = byte(v >> 48) 70 | b[2] = byte(v >> 40) 71 | b[3] = byte(v >> 32) 72 | b[4] = byte(v >> 24) 73 | b[5] = byte(v >> 16) 74 | b[6] = byte(v >> 8) 75 | b[7] = byte(v) 76 | } 77 | 78 | func PutI64BE(b []byte, v int64) { 79 | b[0] = byte(v >> 56) 80 | b[1] = byte(v >> 48) 81 | b[2] = byte(v >> 40) 82 | b[3] = byte(v >> 32) 83 | b[4] = byte(v >> 24) 84 | b[5] = byte(v >> 16) 85 | b[6] = byte(v >> 8) 86 | b[7] = byte(v) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012-2016 Dave Collins 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2016 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is running on Google App Engine, compiled by GopherJS, or 17 | // "-tags safe" is added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // +build js appengine safe disableunsafe !go1.4 20 | 21 | package spew 22 | 23 | import "reflect" 24 | 25 | const ( 26 | // UnsafeDisabled is a build-time constant which specifies whether or 27 | // not access to the unsafe package is available. 28 | UnsafeDisabled = true 29 | ) 30 | 31 | // unsafeReflectValue typically converts the passed reflect.Value into a one 32 | // that bypasses the typical safety restrictions preventing access to 33 | // unaddressable and unexported data. However, doing this relies on access to 34 | // the unsafe package. This is a stub version which simply returns the passed 35 | // reflect.Value when the unsafe package is not available. 36 | func unsafeReflectValue(v reflect.Value) reflect.Value { 37 | return v 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2017 marvin + konsorten GmbH (open-source@konsorten.de) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/github.com/konsorten/go-windows-terminal-sequences/README.md: -------------------------------------------------------------------------------- 1 | # Windows Terminal Sequences 2 | 3 | This library allow for enabling Windows terminal color support for Go. 4 | 5 | See [Console Virtual Terminal Sequences](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) for details. 6 | 7 | ## Usage 8 | 9 | ```go 10 | import ( 11 | "syscall" 12 | 13 | sequences "github.com/konsorten/go-windows-terminal-sequences" 14 | ) 15 | 16 | func main() { 17 | sequences.EnableVirtualTerminalProcessing(syscall.Stdout, true) 18 | } 19 | 20 | ``` 21 | 22 | ## Authors 23 | 24 | The tool is sponsored by the [marvin + konsorten GmbH](http://www.konsorten.de). 25 | 26 | We thank all the authors who provided code to this library: 27 | 28 | * Felix Kollmann 29 | 30 | ## License 31 | 32 | (The MIT License) 33 | 34 | Copyright (c) 2018 marvin + konsorten GmbH (open-source@konsorten.de) 35 | 36 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 39 | 40 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 41 | -------------------------------------------------------------------------------- /vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/konsorten/go-windows-terminal-sequences 2 | -------------------------------------------------------------------------------- /vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package sequences 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | var ( 11 | kernel32Dll *syscall.LazyDLL = syscall.NewLazyDLL("Kernel32.dll") 12 | setConsoleMode *syscall.LazyProc = kernel32Dll.NewProc("SetConsoleMode") 13 | ) 14 | 15 | func EnableVirtualTerminalProcessing(stream syscall.Handle, enable bool) error { 16 | const ENABLE_VIRTUAL_TERMINAL_PROCESSING uint32 = 0x4 17 | 18 | var mode uint32 19 | err := syscall.GetConsoleMode(syscall.Stdout, &mode) 20 | if err != nil { 21 | return err 22 | } 23 | 24 | if enable { 25 | mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING 26 | } else { 27 | mode &^= ENABLE_VIRTUAL_TERMINAL_PROCESSING 28 | } 29 | 30 | ret, _, err := setConsoleMode.Call(uintptr(unsafe.Pointer(stream)), uintptr(mode)) 31 | if ret == 0 { 32 | return err 33 | } 34 | 35 | return nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go_import_path: github.com/pkg/errors 3 | go: 4 | - 1.4.x 5 | - 1.5.x 6 | - 1.6.x 7 | - 1.7.x 8 | - 1.8.x 9 | - 1.9.x 10 | - 1.10.x 11 | - 1.11.x 12 | - tip 13 | 14 | script: 15 | - go test -v ./... 16 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Dave Cheney 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/README.md: -------------------------------------------------------------------------------- 1 | # errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge) 2 | 3 | Package errors provides simple error handling primitives. 4 | 5 | `go get github.com/pkg/errors` 6 | 7 | The traditional error handling idiom in Go is roughly akin to 8 | ```go 9 | if err != nil { 10 | return err 11 | } 12 | ``` 13 | which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. 14 | 15 | ## Adding context to an error 16 | 17 | The errors.Wrap function returns a new error that adds context to the original error. For example 18 | ```go 19 | _, err := ioutil.ReadAll(r) 20 | if err != nil { 21 | return errors.Wrap(err, "read failed") 22 | } 23 | ``` 24 | ## Retrieving the cause of an error 25 | 26 | Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`. 27 | ```go 28 | type causer interface { 29 | Cause() error 30 | } 31 | ``` 32 | `errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example: 33 | ```go 34 | switch err := errors.Cause(err).(type) { 35 | case *MyError: 36 | // handle specifically 37 | default: 38 | // unknown error 39 | } 40 | ``` 41 | 42 | [Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). 43 | 44 | ## Contributing 45 | 46 | We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high. 47 | 48 | Before proposing a change, please discuss your change by raising an issue. 49 | 50 | ## License 51 | 52 | BSD-2-Clause 53 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: build-{build}.{branch} 2 | 3 | clone_folder: C:\gopath\src\github.com\pkg\errors 4 | shallow_clone: true # for startup speed 5 | 6 | environment: 7 | GOPATH: C:\gopath 8 | 9 | platform: 10 | - x64 11 | 12 | # http://www.appveyor.com/docs/installed-software 13 | install: 14 | # some helpful output for debugging builds 15 | - go version 16 | - go env 17 | # pre-installed MinGW at C:\MinGW is 32bit only 18 | # but MSYS2 at C:\msys64 has mingw64 19 | - set PATH=C:\msys64\mingw64\bin;%PATH% 20 | - gcc --version 21 | - g++ --version 22 | 23 | build_script: 24 | - go install -v ./... 25 | 26 | test_script: 27 | - set PATH=C:\gopath\bin;%PATH% 28 | - go test -v ./... 29 | 30 | #artifacts: 31 | # - path: '%GOPATH%\bin\*.exe' 32 | deploy: off 33 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/.gitignore: -------------------------------------------------------------------------------- 1 | logrus 2 | vendor 3 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go_import_path: github.com/sirupsen/logrus 3 | git: 4 | depth: 1 5 | env: 6 | - GO111MODULE=on 7 | - GO111MODULE=off 8 | go: [ 1.11.x, 1.12.x ] 9 | os: [ linux, osx ] 10 | matrix: 11 | exclude: 12 | - go: 1.12.x 13 | env: GO111MODULE=off 14 | - go: 1.11.x 15 | os: osx 16 | install: 17 | - ./travis/install.sh 18 | - if [[ "$GO111MODULE" == "on" ]]; then go mod download; fi 19 | - if [[ "$GO111MODULE" == "off" ]]; then go get github.com/stretchr/testify/assert golang.org/x/sys/unix github.com/konsorten/go-windows-terminal-sequences; fi 20 | script: 21 | - ./travis/cross_build.sh 22 | - export GOMAXPROCS=4 23 | - export GORACE=halt_on_error=1 24 | - go test -race -v ./... 25 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then go test -race -v -tags appengine ./... ; fi 26 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/alt_exit.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // The following code was sourced and modified from the 4 | // https://github.com/tebeka/atexit package governed by the following license: 5 | // 6 | // Copyright (c) 2012 Miki Tebeka . 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | // this software and associated documentation files (the "Software"), to deal in 10 | // the Software without restriction, including without limitation the rights to 11 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 12 | // the Software, and to permit persons to whom the Software is furnished to do so, 13 | // subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 20 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 21 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 22 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | import ( 26 | "fmt" 27 | "os" 28 | ) 29 | 30 | var handlers = []func(){} 31 | 32 | func runHandler(handler func()) { 33 | defer func() { 34 | if err := recover(); err != nil { 35 | fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err) 36 | } 37 | }() 38 | 39 | handler() 40 | } 41 | 42 | func runHandlers() { 43 | for _, handler := range handlers { 44 | runHandler(handler) 45 | } 46 | } 47 | 48 | // Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code) 49 | func Exit(code int) { 50 | runHandlers() 51 | os.Exit(code) 52 | } 53 | 54 | // RegisterExitHandler appends a Logrus Exit handler to the list of handlers, 55 | // call logrus.Exit to invoke all handlers. The handlers will also be invoked when 56 | // any Fatal log entry is made. 57 | // 58 | // This method is useful when a caller wishes to use logrus to log a fatal 59 | // message but also needs to gracefully shutdown. An example usecase could be 60 | // closing database connections, or sending a alert that the application is 61 | // closing. 62 | func RegisterExitHandler(handler func()) { 63 | handlers = append(handlers, handler) 64 | } 65 | 66 | // DeferExitHandler prepends a Logrus Exit handler to the list of handlers, 67 | // call logrus.Exit to invoke all handlers. The handlers will also be invoked when 68 | // any Fatal log entry is made. 69 | // 70 | // This method is useful when a caller wishes to use logrus to log a fatal 71 | // message but also needs to gracefully shutdown. An example usecase could be 72 | // closing database connections, or sending a alert that the application is 73 | // closing. 74 | func DeferExitHandler(handler func()) { 75 | handlers = append([]func(){handler}, handlers...) 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | platform: x64 3 | clone_folder: c:\gopath\src\github.com\sirupsen\logrus 4 | environment: 5 | GOPATH: c:\gopath 6 | branches: 7 | only: 8 | - master 9 | install: 10 | - set PATH=%GOPATH%\bin;c:\go\bin;%PATH% 11 | - go version 12 | build_script: 13 | - go get -t 14 | - go test 15 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package logrus is a structured logger for Go, completely API compatible with the standard library logger. 3 | 4 | 5 | The simplest way to use Logrus is simply the package-level exported logger: 6 | 7 | package main 8 | 9 | import ( 10 | log "github.com/sirupsen/logrus" 11 | ) 12 | 13 | func main() { 14 | log.WithFields(log.Fields{ 15 | "animal": "walrus", 16 | "number": 1, 17 | "size": 10, 18 | }).Info("A walrus appears") 19 | } 20 | 21 | Output: 22 | time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 23 | 24 | For a full guide visit https://github.com/sirupsen/logrus 25 | */ 26 | package logrus 27 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | // Default key names for the default fields 6 | const ( 7 | defaultTimestampFormat = time.RFC3339 8 | FieldKeyMsg = "msg" 9 | FieldKeyLevel = "level" 10 | FieldKeyTime = "time" 11 | FieldKeyLogrusError = "logrus_error" 12 | FieldKeyFunc = "func" 13 | FieldKeyFile = "file" 14 | ) 15 | 16 | // The Formatter interface is used to implement a custom Formatter. It takes an 17 | // `Entry`. It exposes all the fields, including the default ones: 18 | // 19 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 20 | // * `entry.Data["time"]`. The timestamp. 21 | // * `entry.Data["level"]. The level the entry was logged at. 22 | // 23 | // Any additional fields added with `WithField` or `WithFields` are also in 24 | // `entry.Data`. Format is expected to return an array of bytes which are then 25 | // logged to `logger.Out`. 26 | type Formatter interface { 27 | Format(*Entry) ([]byte, error) 28 | } 29 | 30 | // This is to not silently overwrite `time`, `msg`, `func` and `level` fields when 31 | // dumping it. If this code wasn't there doing: 32 | // 33 | // logrus.WithField("level", 1).Info("hello") 34 | // 35 | // Would just silently drop the user provided level. Instead with this code 36 | // it'll logged as: 37 | // 38 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 39 | // 40 | // It's not exported because it's still using Data in an opinionated way. It's to 41 | // avoid code duplication between the two default formatters. 42 | func prefixFieldClashes(data Fields, fieldMap FieldMap, reportCaller bool) { 43 | timeKey := fieldMap.resolve(FieldKeyTime) 44 | if t, ok := data[timeKey]; ok { 45 | data["fields."+timeKey] = t 46 | delete(data, timeKey) 47 | } 48 | 49 | msgKey := fieldMap.resolve(FieldKeyMsg) 50 | if m, ok := data[msgKey]; ok { 51 | data["fields."+msgKey] = m 52 | delete(data, msgKey) 53 | } 54 | 55 | levelKey := fieldMap.resolve(FieldKeyLevel) 56 | if l, ok := data[levelKey]; ok { 57 | data["fields."+levelKey] = l 58 | delete(data, levelKey) 59 | } 60 | 61 | logrusErrKey := fieldMap.resolve(FieldKeyLogrusError) 62 | if l, ok := data[logrusErrKey]; ok { 63 | data["fields."+logrusErrKey] = l 64 | delete(data, logrusErrKey) 65 | } 66 | 67 | // If reportCaller is not set, 'func' will not conflict. 68 | if reportCaller { 69 | funcKey := fieldMap.resolve(FieldKeyFunc) 70 | if l, ok := data[funcKey]; ok { 71 | data["fields."+funcKey] = l 72 | } 73 | fileKey := fieldMap.resolve(FieldKeyFile) 74 | if l, ok := data[fileKey]; ok { 75 | data["fields."+fileKey] = l 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/sirupsen/logrus 2 | 3 | require ( 4 | github.com/davecgh/go-spew v1.1.1 // indirect 5 | github.com/konsorten/go-windows-terminal-sequences v1.0.1 6 | github.com/pmezard/go-difflib v1.0.0 // indirect 7 | github.com/stretchr/objx v0.1.1 // indirect 8 | github.com/stretchr/testify v1.2.2 9 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894 10 | ) 11 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 2 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 3 | github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe h1:CHRGQ8V7OlCYtwaKPJi3iA7J+YdNKdo8j7nG5IgDhjs= 4 | github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 5 | github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= 6 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 7 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 8 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 9 | github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= 10 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 11 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= 12 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 13 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= 14 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 15 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= 16 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 17 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type LevelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks LevelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/terminal_check_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package logrus 4 | 5 | import ( 6 | "io" 7 | ) 8 | 9 | func checkIfTerminal(w io.Writer) bool { 10 | return true 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/terminal_check_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin dragonfly freebsd netbsd openbsd 2 | 3 | package logrus 4 | 5 | import "golang.org/x/sys/unix" 6 | 7 | const ioctlReadTermios = unix.TIOCGETA 8 | 9 | func isTerminal(fd int) bool { 10 | _, err := unix.IoctlGetTermios(fd, ioctlReadTermios) 11 | return err == nil 12 | } 13 | 14 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/terminal_check_no_terminal.go: -------------------------------------------------------------------------------- 1 | // +build js nacl plan9 2 | 3 | package logrus 4 | 5 | import ( 6 | "io" 7 | ) 8 | 9 | func checkIfTerminal(w io.Writer) bool { 10 | return false 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/terminal_check_notappengine.go: -------------------------------------------------------------------------------- 1 | // +build !appengine,!js,!windows,!nacl,!plan9 2 | 3 | package logrus 4 | 5 | import ( 6 | "io" 7 | "os" 8 | ) 9 | 10 | func checkIfTerminal(w io.Writer) bool { 11 | switch v := w.(type) { 12 | case *os.File: 13 | return isTerminal(int(v.Fd())) 14 | default: 15 | return false 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/terminal_check_solaris.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "golang.org/x/sys/unix" 5 | ) 6 | 7 | // IsTerminal returns true if the given file descriptor is a terminal. 8 | func isTerminal(fd int) bool { 9 | _, err := unix.IoctlGetTermio(fd, unix.TCGETA) 10 | return err == nil 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/terminal_check_unix.go: -------------------------------------------------------------------------------- 1 | // +build linux aix 2 | 3 | package logrus 4 | 5 | import "golang.org/x/sys/unix" 6 | 7 | const ioctlReadTermios = unix.TCGETS 8 | 9 | func isTerminal(fd int) bool { 10 | _, err := unix.IoctlGetTermios(fd, ioctlReadTermios) 11 | return err == nil 12 | } 13 | 14 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/terminal_check_windows.go: -------------------------------------------------------------------------------- 1 | // +build !appengine,!js,windows 2 | 3 | package logrus 4 | 5 | import ( 6 | "io" 7 | "os" 8 | "syscall" 9 | 10 | sequences "github.com/konsorten/go-windows-terminal-sequences" 11 | ) 12 | 13 | func initTerminal(w io.Writer) { 14 | switch v := w.(type) { 15 | case *os.File: 16 | sequences.EnableVirtualTerminalProcessing(syscall.Handle(v.Fd()), true) 17 | } 18 | } 19 | 20 | func checkIfTerminal(w io.Writer) bool { 21 | var ret bool 22 | switch v := w.(type) { 23 | case *os.File: 24 | var mode uint32 25 | err := syscall.GetConsoleMode(syscall.Handle(v.Fd()), &mode) 26 | ret = (err == nil) 27 | default: 28 | ret = false 29 | } 30 | if ret { 31 | initTerminal(w) 32 | } 33 | return ret 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | return logger.WriterLevel(InfoLevel) 11 | } 12 | 13 | func (logger *Logger) WriterLevel(level Level) *io.PipeWriter { 14 | return NewEntry(logger).WriterLevel(level) 15 | } 16 | 17 | func (entry *Entry) Writer() *io.PipeWriter { 18 | return entry.WriterLevel(InfoLevel) 19 | } 20 | 21 | func (entry *Entry) WriterLevel(level Level) *io.PipeWriter { 22 | reader, writer := io.Pipe() 23 | 24 | var printFunc func(args ...interface{}) 25 | 26 | switch level { 27 | case TraceLevel: 28 | printFunc = entry.Trace 29 | case DebugLevel: 30 | printFunc = entry.Debug 31 | case InfoLevel: 32 | printFunc = entry.Info 33 | case WarnLevel: 34 | printFunc = entry.Warn 35 | case ErrorLevel: 36 | printFunc = entry.Error 37 | case FatalLevel: 38 | printFunc = entry.Fatal 39 | case PanicLevel: 40 | printFunc = entry.Panic 41 | default: 42 | printFunc = entry.Print 43 | } 44 | 45 | go entry.writerScanner(reader, printFunc) 46 | runtime.SetFinalizer(writer, writerFinalizer) 47 | 48 | return writer 49 | } 50 | 51 | func (entry *Entry) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) { 52 | scanner := bufio.NewScanner(reader) 53 | for scanner.Scan() { 54 | printFunc(scanner.Text()) 55 | } 56 | if err := scanner.Err(); err != nil { 57 | entry.Errorf("Error while reading from Writer: %s", err) 58 | } 59 | reader.Close() 60 | } 61 | 62 | func writerFinalizer(writer *io.PipeWriter) { 63 | writer.Close() 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentFormat}} 2 | func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool { 3 | if h, ok := t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | if h, ok := a.t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs 17 | -------------------------------------------------------------------------------- /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/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /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 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build go1.9 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | type Signal = syscall.Signal 13 | type Errno = syscall.Errno 14 | type SysProcAttr = syscall.SysProcAttr 15 | -------------------------------------------------------------------------------- /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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 11 | // 12 | 13 | TEXT ·syscall6(SB),NOSPLIT,$0-88 14 | JMP syscall·syscall6(SB) 15 | 16 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSyscall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·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_darwin_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.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 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 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 ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_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 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 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 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·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_freebsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·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_freebsd_arm64.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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 14 | // instead of the glibc-specific "CALL 0x10(GS)". 15 | #define INVOKE_SYSCALL INT $0x80 16 | 17 | // Just jump to package syscall's implementation for all these functions. 18 | // The runtime may know about them. 19 | 20 | TEXT ·Syscall(SB),NOSPLIT,$0-28 21 | JMP syscall·Syscall(SB) 22 | 23 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·Syscall6(SB) 25 | 26 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 27 | CALL runtime·entersyscall(SB) 28 | MOVL trap+0(FP), AX // syscall entry 29 | MOVL a1+4(FP), BX 30 | MOVL a2+8(FP), CX 31 | MOVL a3+12(FP), DX 32 | MOVL $0, SI 33 | MOVL $0, DI 34 | INVOKE_SYSCALL 35 | MOVL AX, r1+16(FP) 36 | MOVL DX, r2+20(FP) 37 | CALL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVL trap+0(FP), AX // syscall entry 48 | MOVL a1+4(FP), BX 49 | MOVL a2+8(FP), CX 50 | MOVL a3+12(FP), DX 51 | MOVL $0, SI 52 | MOVL $0, DI 53 | INVOKE_SYSCALL 54 | MOVL AX, r1+16(FP) 55 | MOVL DX, r2+20(FP) 56 | RET 57 | 58 | TEXT ·socketcall(SB),NOSPLIT,$0-36 59 | JMP syscall·socketcall(SB) 60 | 61 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 62 | JMP syscall·rawsocketcall(SB) 63 | 64 | TEXT ·seek(SB),NOSPLIT,$0-28 65 | JMP syscall·seek(SB) 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 23 | CALL runtime·entersyscall(SB) 24 | MOVQ a1+8(FP), DI 25 | MOVQ a2+16(FP), SI 26 | MOVQ a3+24(FP), DX 27 | MOVQ $0, R10 28 | MOVQ $0, R8 29 | MOVQ $0, R9 30 | MOVQ trap+0(FP), AX // syscall entry 31 | SYSCALL 32 | MOVQ AX, r1+32(FP) 33 | MOVQ DX, r2+40(FP) 34 | CALL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | JMP syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | JMP syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVQ a1+8(FP), DI 45 | MOVQ a2+16(FP), SI 46 | MOVQ a3+24(FP), DX 47 | MOVQ $0, R10 48 | MOVQ $0, R8 49 | MOVQ $0, R9 50 | MOVQ trap+0(FP), AX // syscall entry 51 | SYSCALL 52 | MOVQ AX, r1+32(FP) 53 | MOVQ DX, r2+40(FP) 54 | RET 55 | 56 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 57 | JMP syscall·gettimeofday(SB) 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 23 | BL runtime·entersyscall(SB) 24 | MOVW trap+0(FP), R7 25 | MOVW a1+4(FP), R0 26 | MOVW a2+8(FP), R1 27 | MOVW a3+12(FP), R2 28 | MOVW $0, R3 29 | MOVW $0, R4 30 | MOVW $0, R5 31 | SWI $0 32 | MOVW R0, r1+16(FP) 33 | MOVW $0, R0 34 | MOVW R0, r2+20(FP) 35 | BL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 39 | B syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 42 | B syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 45 | MOVW trap+0(FP), R7 // syscall entry 46 | MOVW a1+4(FP), R0 47 | MOVW a2+8(FP), R1 48 | MOVW a3+12(FP), R2 49 | SWI $0 50 | MOVW R0, r1+16(FP) 51 | MOVW $0, R0 52 | MOVW R0, r2+20(FP) 53 | RET 54 | 55 | TEXT ·seek(SB),NOSPLIT,$0-28 56 | B syscall·seek(SB) 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 21 | BL runtime·entersyscall(SB) 22 | MOVD a1+8(FP), R0 23 | MOVD a2+16(FP), R1 24 | MOVD a3+24(FP), R2 25 | MOVD $0, R3 26 | MOVD $0, R4 27 | MOVD $0, R5 28 | MOVD trap+0(FP), R8 // syscall entry 29 | SVC 30 | MOVD R0, r1+32(FP) // r1 31 | MOVD R1, r2+40(FP) // r2 32 | BL runtime·exitsyscall(SB) 33 | RET 34 | 35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 36 | B syscall·RawSyscall(SB) 37 | 38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 39 | B syscall·RawSyscall6(SB) 40 | 41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 42 | MOVD a1+8(FP), R0 43 | MOVD a2+16(FP), R1 44 | MOVD a3+24(FP), R2 45 | MOVD $0, R3 46 | MOVD $0, R4 47 | MOVD $0, R5 48 | MOVD trap+0(FP), R8 // syscall entry 49 | SVC 50 | MOVD R0, r1+32(FP) 51 | MOVD R1, r2+40(FP) 52 | RET 53 | -------------------------------------------------------------------------------- /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 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | JAL runtime·entersyscall(SB) 26 | MOVV a1+8(FP), R4 27 | MOVV a2+16(FP), R5 28 | MOVV a3+24(FP), R6 29 | MOVV R0, R7 30 | MOVV R0, R8 31 | MOVV R0, R9 32 | MOVV trap+0(FP), R2 // syscall entry 33 | SYSCALL 34 | MOVV R2, r1+32(FP) 35 | MOVV R3, r2+40(FP) 36 | JAL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | JMP syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | JMP syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVV a1+8(FP), R4 47 | MOVV a2+16(FP), R5 48 | MOVV a3+24(FP), R6 49 | MOVV R0, R7 50 | MOVV R0, R8 51 | MOVV R0, R9 52 | MOVV trap+0(FP), R2 // syscall entry 53 | SYSCALL 54 | MOVV R2, r1+32(FP) 55 | MOVV R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /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 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 28 | JAL runtime·entersyscall(SB) 29 | MOVW a1+4(FP), R4 30 | MOVW a2+8(FP), R5 31 | MOVW a3+12(FP), R6 32 | MOVW R0, R7 33 | MOVW trap+0(FP), R2 // syscall entry 34 | SYSCALL 35 | MOVW R2, r1+16(FP) // r1 36 | MOVW R3, r2+20(FP) // r2 37 | JAL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVW a1+4(FP), R4 48 | MOVW a2+8(FP), R5 49 | MOVW a3+12(FP), R6 50 | MOVW trap+0(FP), R2 // syscall entry 51 | SYSCALL 52 | MOVW R2, r1+16(FP) 53 | MOVW R3, r2+20(FP) 54 | RET 55 | -------------------------------------------------------------------------------- /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 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 19 | BL runtime·entersyscall(SB) 20 | MOVD a1+8(FP), R3 21 | MOVD a2+16(FP), R4 22 | MOVD a3+24(FP), R5 23 | MOVD R0, R6 24 | MOVD R0, R7 25 | MOVD R0, R8 26 | MOVD trap+0(FP), R9 // syscall entry 27 | SYSCALL R9 28 | MOVD R3, r1+32(FP) 29 | MOVD R4, r2+40(FP) 30 | BL runtime·exitsyscall(SB) 31 | RET 32 | 33 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 34 | MOVD a1+8(FP), R3 35 | MOVD a2+16(FP), R4 36 | MOVD a3+24(FP), R5 37 | MOVD R0, R6 38 | MOVD R0, R7 39 | MOVD R0, R8 40 | MOVD trap+0(FP), R9 // syscall entry 41 | SYSCALL R9 42 | MOVD R3, r1+32(FP) 43 | MOVD R4, r2+40(FP) 44 | RET 45 | -------------------------------------------------------------------------------- /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 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R2 27 | MOVD a2+16(FP), R3 28 | MOVD a3+24(FP), R4 29 | MOVD $0, R5 30 | MOVD $0, R6 31 | MOVD $0, R7 32 | MOVD trap+0(FP), R1 // syscall entry 33 | SYSCALL 34 | MOVD R2, r1+32(FP) 35 | MOVD R3, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R2 47 | MOVD a2+16(FP), R3 48 | MOVD a3+24(FP), R4 49 | MOVD $0, R5 50 | MOVD $0, R6 51 | MOVD $0, R7 52 | MOVD trap+0(FP), R1 // syscall entry 53 | SYSCALL 54 | MOVD R2, r1+32(FP) 55 | MOVD R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·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_netbsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·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_netbsd_arm64.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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-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_openbsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-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_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /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 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build 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 | // +build aix 6 | // +build 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/dirent.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 aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // ParseDirent parses up to max directory entries in buf, 12 | // appending the names to names. It returns the number of 13 | // bytes consumed from buf, the number of entries added 14 | // to names, and the new names slice. 15 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 16 | return syscall.ParseDirent(buf, max, names) 17 | } 18 | -------------------------------------------------------------------------------- /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 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | 29 | func Unsetenv(key string) error { 30 | return syscall.Unsetenv(key) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 16 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 17 | valptr, _, errno := Syscall(fcntl64Syscall, 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 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 26 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 27 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 28 | if errno == 0 { 29 | return nil 30 | } 31 | return errno 32 | } 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 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 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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 | // +build gccgo 6 | // +build !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 | //extern gccgoRealSyscallNoError 16 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 17 | 18 | //extern gccgoRealSyscall 19 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 20 | 21 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 22 | syscall.Entersyscall() 23 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 24 | syscall.Exitsyscall() 25 | return r, 0 26 | } 27 | 28 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 29 | syscall.Entersyscall() 30 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 31 | syscall.Exitsyscall() 32 | return r, 0, syscall.Errno(errno) 33 | } 34 | 35 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 36 | syscall.Entersyscall() 37 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 38 | syscall.Exitsyscall() 39 | return r, 0, syscall.Errno(errno) 40 | } 41 | 42 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 43 | syscall.Entersyscall() 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 45 | syscall.Exitsyscall() 46 | return r, 0, syscall.Errno(errno) 47 | } 48 | 49 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 50 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 51 | return r, 0 52 | } 53 | 54 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 55 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 56 | return r, 0, syscall.Errno(errno) 57 | } 58 | 59 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 60 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 61 | return r, 0, syscall.Errno(errno) 62 | } 63 | -------------------------------------------------------------------------------- /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 25 | 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) 26 | { 27 | struct ret r; 28 | 29 | errno = 0; 30 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 31 | r.err = errno; 32 | return r; 33 | } 34 | 35 | uintptr_t 36 | 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) 37 | { 38 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 39 | } 40 | -------------------------------------------------------------------------------- /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 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl.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 aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "runtime" 10 | 11 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 12 | // 13 | // To change fd's window size, the req argument should be TIOCSWINSZ. 14 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 15 | // TODO: if we get the chance, remove the req parameter and 16 | // hardcode TIOCSWINSZ. 17 | err := ioctlSetWinsize(fd, req, value) 18 | runtime.KeepAlive(value) 19 | return err 20 | } 21 | 22 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 23 | // 24 | // The req value will usually be TCSETA or TIOCSETA. 25 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 26 | // TODO: if we get the chance, remove the req parameter. 27 | err := ioctlSetTermios(fd, req, value) 28 | runtime.KeepAlive(value) 29 | return err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkasm_darwin.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 ignore 6 | 7 | // mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go. 8 | //This program must be run after mksyscall.go. 9 | package main 10 | 11 | import ( 12 | "bytes" 13 | "fmt" 14 | "io/ioutil" 15 | "log" 16 | "os" 17 | "strings" 18 | ) 19 | 20 | func main() { 21 | in1, err := ioutil.ReadFile("syscall_darwin.go") 22 | if err != nil { 23 | log.Fatalf("can't open syscall_darwin.go: %s", err) 24 | } 25 | arch := os.Args[1] 26 | in2, err := ioutil.ReadFile(fmt.Sprintf("syscall_darwin_%s.go", arch)) 27 | if err != nil { 28 | log.Fatalf("can't open syscall_darwin_%s.go: %s", arch, err) 29 | } 30 | in3, err := ioutil.ReadFile(fmt.Sprintf("zsyscall_darwin_%s.go", arch)) 31 | if err != nil { 32 | log.Fatalf("can't open zsyscall_darwin_%s.go: %s", arch, err) 33 | } 34 | in := string(in1) + string(in2) + string(in3) 35 | 36 | trampolines := map[string]bool{} 37 | 38 | var out bytes.Buffer 39 | 40 | fmt.Fprintf(&out, "// go run mkasm_darwin.go %s\n", strings.Join(os.Args[1:], " ")) 41 | fmt.Fprintf(&out, "// Code generated by the command above; DO NOT EDIT.\n") 42 | fmt.Fprintf(&out, "\n") 43 | fmt.Fprintf(&out, "// +build go1.12\n") 44 | fmt.Fprintf(&out, "\n") 45 | fmt.Fprintf(&out, "#include \"textflag.h\"\n") 46 | for _, line := range strings.Split(in, "\n") { 47 | if !strings.HasPrefix(line, "func ") || !strings.HasSuffix(line, "_trampoline()") { 48 | continue 49 | } 50 | fn := line[5 : len(line)-13] 51 | if !trampolines[fn] { 52 | trampolines[fn] = true 53 | fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn) 54 | fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn) 55 | } 56 | } 57 | err = ioutil.WriteFile(fmt.Sprintf("zsyscall_darwin_%s.s", arch), out.Bytes(), 0644) 58 | if err != nil { 59 | log.Fatalf("can't write zsyscall_darwin_%s.s: %s", arch, err) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/openbsd_unveil.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 openbsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | // Unveil implements the unveil syscall. 15 | // For more information see unveil(2). 16 | // Note that the special case of blocking further 17 | // unveil calls is handled by UnveilBlock. 18 | func Unveil(path string, flags string) error { 19 | pathPtr, err := syscall.BytePtrFromString(path) 20 | if err != nil { 21 | return err 22 | } 23 | flagsPtr, err := syscall.BytePtrFromString(flags) 24 | if err != nil { 25 | return err 26 | } 27 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0) 28 | if e != 0 { 29 | return e 30 | } 31 | return nil 32 | } 33 | 34 | // UnveilBlock blocks future unveil calls. 35 | // For more information see unveil(2). 36 | func UnveilBlock() error { 37 | // Both pointers must be nil. 38 | var pathUnsafe, flagsUnsafe unsafe.Pointer 39 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 0) 40 | if e != 0 { 41 | return e 42 | } 43 | return nil 44 | } 45 | -------------------------------------------------------------------------------- /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 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // For Unix, get the pagesize from the runtime. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getpagesize() int { 14 | return syscall.Getpagesize() 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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 darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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)(cmsgData(h))) = *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/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 aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.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 aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // 15 | // The primary use of this package is inside other packages that provide a more 16 | // portable interface to the system, such as "os", "time" and "net". Use 17 | // those packages rather than this one if you can. 18 | // 19 | // For details of the functions and data types in this package consult 20 | // the manuals for the appropriate operating system. 21 | // 22 | // These calls return err == nil to indicate success; otherwise 23 | // err represents an operating system error describing the failure and 24 | // holds a value of type syscall.Errno. 25 | package unix // import "golang.org/x/sys/unix" 26 | 27 | import "strings" 28 | 29 | // ByteSliceFromString returns a NUL-terminated slice of bytes 30 | // containing the text of s. If s contains a NUL byte at any 31 | // location, it returns (nil, EINVAL). 32 | func ByteSliceFromString(s string) ([]byte, error) { 33 | if strings.IndexByte(s, 0) != -1 { 34 | return nil, EINVAL 35 | } 36 | a := make([]byte, len(s)+1) 37 | copy(a, s) 38 | return a, nil 39 | } 40 | 41 | // BytePtrFromString returns a pointer to a NUL-terminated array of 42 | // bytes containing the text of s. If s contains a NUL byte at any 43 | // location, it returns (nil, EINVAL). 44 | func BytePtrFromString(s string) (*byte, error) { 45 | a, err := ByteSliceFromString(s) 46 | if err != nil { 47 | return nil, err 48 | } 49 | return &a[0], nil 50 | } 51 | 52 | // Single-word zero for use when we need a valid pointer to 0 bytes. 53 | // See mkunix.pl. 54 | var _zero uintptr 55 | -------------------------------------------------------------------------------- /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 | // +build aix 6 | // +build 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 (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /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 | // +build aix 6 | // +build 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 (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /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 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 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 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 22 | func Gettimeofday(tv *Timeval) (err error) { 23 | // The tv passed to gettimeofday must be non-nil 24 | // but is otherwise unused. The answers come back 25 | // in the two registers. 26 | sec, usec, err := gettimeofday(tv) 27 | tv.Sec = int32(sec) 28 | tv.Usec = int32(usec) 29 | return err 30 | } 31 | 32 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 33 | k.Ident = uint32(fd) 34 | k.Filter = int16(mode) 35 | k.Flags = uint16(flags) 36 | } 37 | 38 | func (iov *Iovec) SetLen(length int) { 39 | iov.Len = uint32(length) 40 | } 41 | 42 | func (msghdr *Msghdr) SetControllen(length int) { 43 | msghdr.Controllen = uint32(length) 44 | } 45 | 46 | func (cmsg *Cmsghdr) SetLen(length int) { 47 | cmsg.Len = uint32(length) 48 | } 49 | 50 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 51 | 52 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 53 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 54 | const SYS___SYSCTL = SYS_SYSCTL 55 | 56 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 57 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 58 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 59 | //sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64 60 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 61 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 62 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 63 | //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 64 | -------------------------------------------------------------------------------- /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 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | func setTimespec(sec, nsec int64) Timespec { 14 | return Timespec{Sec: sec, Nsec: nsec} 15 | } 16 | 17 | func setTimeval(sec, usec int64) Timeval { 18 | return Timeval{Sec: sec, Usec: int32(usec)} 19 | } 20 | 21 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 22 | func Gettimeofday(tv *Timeval) (err error) { 23 | // The tv passed to gettimeofday must be non-nil 24 | // but is otherwise unused. The answers come back 25 | // in the two registers. 26 | sec, usec, err := gettimeofday(tv) 27 | tv.Sec = sec 28 | tv.Usec = usec 29 | return err 30 | } 31 | 32 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 33 | k.Ident = uint64(fd) 34 | k.Filter = int16(mode) 35 | k.Flags = uint16(flags) 36 | } 37 | 38 | func (iov *Iovec) SetLen(length int) { 39 | iov.Len = uint64(length) 40 | } 41 | 42 | func (msghdr *Msghdr) SetControllen(length int) { 43 | msghdr.Controllen = uint32(length) 44 | } 45 | 46 | func (cmsg *Cmsghdr) SetLen(length int) { 47 | cmsg.Len = uint32(length) 48 | } 49 | 50 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 51 | 52 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 53 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 54 | const SYS___SYSCTL = SYS_SYSCTL 55 | 56 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 57 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 58 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 59 | //sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64 60 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 61 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 62 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 63 | //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 64 | -------------------------------------------------------------------------------- /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 ( 8 | "syscall" 9 | ) 10 | 11 | func setTimespec(sec, nsec int64) Timespec { 12 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 13 | } 14 | 15 | func setTimeval(sec, usec int64) Timeval { 16 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 17 | } 18 | 19 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 20 | func Gettimeofday(tv *Timeval) (err error) { 21 | // The tv passed to gettimeofday must be non-nil 22 | // but is otherwise unused. The answers come back 23 | // in the two registers. 24 | sec, usec, err := gettimeofday(tv) 25 | tv.Sec = int32(sec) 26 | tv.Usec = int32(usec) 27 | return err 28 | } 29 | 30 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 31 | k.Ident = uint32(fd) 32 | k.Filter = int16(mode) 33 | k.Flags = uint16(flags) 34 | } 35 | 36 | func (iov *Iovec) SetLen(length int) { 37 | iov.Len = uint32(length) 38 | } 39 | 40 | func (msghdr *Msghdr) SetControllen(length int) { 41 | msghdr.Controllen = uint32(length) 42 | } 43 | 44 | func (cmsg *Cmsghdr) SetLen(length int) { 45 | cmsg.Len = uint32(length) 46 | } 47 | 48 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 49 | 50 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 51 | // of darwin/arm the syscall is called sysctl instead of __sysctl. 52 | const SYS___SYSCTL = SYS_SYSCTL 53 | 54 | //sys Fstat(fd int, stat *Stat_t) (err error) 55 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 56 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) 57 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT 58 | //sys Lstat(path string, stat *Stat_t) (err error) 59 | //sys Stat(path string, stat *Stat_t) (err error) 60 | //sys Statfs(path string, stat *Statfs_t) (err error) 61 | 62 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { 63 | return 0, ENOSYS 64 | } 65 | -------------------------------------------------------------------------------- /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 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | func setTimespec(sec, nsec int64) Timespec { 14 | return Timespec{Sec: sec, Nsec: nsec} 15 | } 16 | 17 | func setTimeval(sec, usec int64) Timeval { 18 | return Timeval{Sec: sec, Usec: int32(usec)} 19 | } 20 | 21 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 22 | func Gettimeofday(tv *Timeval) (err error) { 23 | // The tv passed to gettimeofday must be non-nil 24 | // but is otherwise unused. The answers come back 25 | // in the two registers. 26 | sec, usec, err := gettimeofday(tv) 27 | tv.Sec = sec 28 | tv.Usec = usec 29 | return err 30 | } 31 | 32 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 33 | k.Ident = uint64(fd) 34 | k.Filter = int16(mode) 35 | k.Flags = uint16(flags) 36 | } 37 | 38 | func (iov *Iovec) SetLen(length int) { 39 | iov.Len = uint64(length) 40 | } 41 | 42 | func (msghdr *Msghdr) SetControllen(length int) { 43 | msghdr.Controllen = uint32(length) 44 | } 45 | 46 | func (cmsg *Cmsghdr) SetLen(length int) { 47 | cmsg.Len = uint32(length) 48 | } 49 | 50 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 51 | 52 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 53 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 54 | const SYS___SYSCTL = SYS_SYSCTL 55 | 56 | //sys Fstat(fd int, stat *Stat_t) (err error) 57 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 58 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) 59 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT 60 | //sys Lstat(path string, stat *Stat_t) (err error) 61 | //sys Stat(path string, stat *Stat_t) (err error) 62 | //sys Statfs(path string, stat *Statfs_t) (err error) 63 | 64 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { 65 | return 0, ENOSYS 66 | } 67 | -------------------------------------------------------------------------------- /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 | // +build darwin,go1.12 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // Implemented in the runtime package (runtime/sys_darwin.go) 12 | func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 13 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 14 | func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 15 | func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // 32-bit only 16 | func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 17 | func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 18 | 19 | //go:linkname syscall_syscall syscall.syscall 20 | //go:linkname syscall_syscall6 syscall.syscall6 21 | //go:linkname syscall_syscall6X syscall.syscall6X 22 | //go:linkname syscall_syscall9 syscall.syscall9 23 | //go:linkname syscall_rawSyscall syscall.rawSyscall 24 | //go:linkname syscall_rawSyscall6 syscall.rawSyscall6 25 | 26 | // Find the entry point for f. See comments in runtime/proc.go for the 27 | // function of the same name. 28 | //go:nosplit 29 | func funcPC(f func()) uintptr { 30 | return **(**uintptr)(unsafe.Pointer(&f)) 31 | } 32 | -------------------------------------------------------------------------------- /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 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /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 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /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 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /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 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /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 | // +build arm64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /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 | // +build amd64,linux 6 | // +build !gccgo 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 | // +build linux,!gccgo 6 | 7 | package unix 8 | 9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 11 | 12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 13 | // fail. 14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo,386 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // Underlying system call writes to newoffset via pointer. 12 | // Implemented in assembly to avoid allocation. 13 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 14 | 15 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 16 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_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 | // +build linux,gccgo,386 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | 22 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 23 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 24 | return int(fd), err 25 | } 26 | 27 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 28 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 29 | return int(fd), err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,gccgo,arm 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /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 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /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 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /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 | // +build arm64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /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 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/386 the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /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 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /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 | // +build arm,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/arm the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /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 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | -------------------------------------------------------------------------------- /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 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo,!ppc64le,!ppc64 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /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 | // +build linux 6 | // +build ppc64le ppc64 7 | // +build !gccgo 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 14 | return syscall.Syscall(trap, a1, a2, a3) 15 | } 16 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 17 | return syscall.Syscall6(trap, a1, a2, a3, a4, a5, a6) 18 | } 19 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 20 | return syscall.RawSyscall(trap, a1, a2, a3) 21 | } 22 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 23 | return syscall.RawSyscall6(trap, a1, a2, a3, a4, a5, a6) 24 | } 25 | -------------------------------------------------------------------------------- /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 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "time" 10 | 11 | // TimespecToNsec converts a Timespec value into a number of 12 | // nanoseconds since the Unix epoch. 13 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 14 | 15 | // NsecToTimespec takes a number of nanoseconds since the Unix epoch 16 | // and returns the corresponding Timespec value. 17 | func NsecToTimespec(nsec int64) Timespec { 18 | sec := nsec / 1e9 19 | nsec = nsec % 1e9 20 | if nsec < 0 { 21 | nsec += 1e9 22 | sec-- 23 | } 24 | return setTimespec(sec, nsec) 25 | } 26 | 27 | // TimeToTimespec converts t into a Timespec. 28 | // On some 32-bit systems the range of valid Timespec values are smaller 29 | // than that of time.Time values. So if t is out of the valid range of 30 | // Timespec, it returns a zero Timespec and ERANGE. 31 | func TimeToTimespec(t time.Time) (Timespec, error) { 32 | sec := t.Unix() 33 | nsec := int64(t.Nanosecond()) 34 | ts := setTimespec(sec, nsec) 35 | 36 | // Currently all targets have either int32 or int64 for Timespec.Sec. 37 | // If there were a new target with floating point type for it, we have 38 | // to consider the rounding error. 39 | if int64(ts.Sec) != sec { 40 | return Timespec{}, ERANGE 41 | } 42 | return ts, nil 43 | } 44 | 45 | // TimevalToNsec converts a Timeval value into a number of nanoseconds 46 | // since the Unix epoch. 47 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 48 | 49 | // NsecToTimeval takes a number of nanoseconds since the Unix epoch 50 | // and returns the corresponding Timeval value. 51 | func NsecToTimeval(nsec int64) Timeval { 52 | nsec += 999 // round up to microsecond 53 | usec := nsec % 1e9 / 1e3 54 | sec := nsec / 1e9 55 | if usec < 0 { 56 | usec += 1e6 57 | sec-- 58 | } 59 | return setTimeval(sec, usec) 60 | } 61 | 62 | // Unix returns ts as the number of seconds and nanoseconds elapsed since the 63 | // Unix epoch. 64 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 65 | return int64(ts.Sec), int64(ts.Nsec) 66 | } 67 | 68 | // Unix returns tv as the number of seconds and nanoseconds elapsed since the 69 | // Unix epoch. 70 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 71 | return int64(tv.Sec), int64(tv.Usec) * 1000 72 | } 73 | 74 | // Nano returns ts as the number of nanoseconds elapsed since the Unix epoch. 75 | func (ts *Timespec) Nano() int64 { 76 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 77 | } 78 | 79 | // Nano returns tv as the number of nanoseconds elapsed since the Unix epoch. 80 | func (tv *Timeval) Nano() int64 { 81 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 82 | } 83 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace386_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(386, amd64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build 386 amd64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegs386 is the registers used by 386 binaries. 11 | type PtraceRegs386 struct { 12 | Ebx int32 13 | Ecx int32 14 | Edx int32 15 | Esi int32 16 | Edi int32 17 | Ebp int32 18 | Eax int32 19 | Xds int32 20 | Xes int32 21 | Xfs int32 22 | Xgs int32 23 | Orig_eax int32 24 | Eip int32 25 | Xcs int32 26 | Eflags int32 27 | Esp int32 28 | Xss int32 29 | } 30 | 31 | // PtraceGetRegs386 fetches the registers used by 386 binaries. 32 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { 33 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 34 | } 35 | 36 | // PtraceSetRegs386 sets the registers used by 386 binaries. 37 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { 38 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 39 | } 40 | 41 | // PtraceRegsAmd64 is the registers used by amd64 binaries. 42 | type PtraceRegsAmd64 struct { 43 | R15 uint64 44 | R14 uint64 45 | R13 uint64 46 | R12 uint64 47 | Rbp uint64 48 | Rbx uint64 49 | R11 uint64 50 | R10 uint64 51 | R9 uint64 52 | R8 uint64 53 | Rax uint64 54 | Rcx uint64 55 | Rdx uint64 56 | Rsi uint64 57 | Rdi uint64 58 | Orig_rax uint64 59 | Rip uint64 60 | Cs uint64 61 | Eflags uint64 62 | Rsp uint64 63 | Ss uint64 64 | Fs_base uint64 65 | Gs_base uint64 66 | Ds uint64 67 | Es uint64 68 | Fs uint64 69 | Gs uint64 70 | } 71 | 72 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries. 73 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { 74 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 75 | } 76 | 77 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries. 78 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { 79 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracearm_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(arm, arm64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build arm arm64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsArm is the registers used by arm binaries. 11 | type PtraceRegsArm struct { 12 | Uregs [18]uint32 13 | } 14 | 15 | // PtraceGetRegsArm fetches the registers used by arm binaries. 16 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { 17 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 18 | } 19 | 20 | // PtraceSetRegsArm sets the registers used by arm binaries. 21 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { 22 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 23 | } 24 | 25 | // PtraceRegsArm64 is the registers used by arm64 binaries. 26 | type PtraceRegsArm64 struct { 27 | Regs [31]uint64 28 | Sp uint64 29 | Pc uint64 30 | Pstate uint64 31 | } 32 | 33 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries. 34 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { 35 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 36 | } 37 | 38 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries. 39 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { 40 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemips_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mips, mips64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mips mips64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMips is the registers used by mips binaries. 11 | type PtraceRegsMips struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMips fetches the registers used by mips binaries. 22 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMips sets the registers used by mips binaries. 27 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64 is the registers used by mips64 binaries. 32 | type PtraceRegsMips64 struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries. 43 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries. 48 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemipsle_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mipsle, mips64le). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mipsle mips64le 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMipsle is the registers used by mipsle binaries. 11 | type PtraceRegsMipsle struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries. 22 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries. 27 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64le is the registers used by mips64le binaries. 32 | type PtraceRegsMips64le struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries. 43 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries. 48 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/VKCOM/joy4 v0.0.0-20190627144217-c4b6e26f04b4 2 | github.com/VKCOM/joy4/av 3 | github.com/VKCOM/joy4/av/avutil 4 | github.com/VKCOM/joy4/av/pktque 5 | github.com/VKCOM/joy4/av/transcode 6 | github.com/VKCOM/joy4/codec/fake 7 | github.com/VKCOM/joy4/utils/bits 8 | github.com/VKCOM/joy4/utils/bits/pio 9 | github.com/VKCOM/joy4/av/pubsub 10 | github.com/VKCOM/joy4/format 11 | github.com/VKCOM/joy4/format/flv 12 | github.com/VKCOM/joy4/format/rtmp 13 | github.com/VKCOM/joy4/format/aac 14 | github.com/VKCOM/joy4/format/mp4 15 | github.com/VKCOM/joy4/format/rtsp 16 | github.com/VKCOM/joy4/format/ts 17 | github.com/VKCOM/joy4/codec/aacparser 18 | github.com/VKCOM/joy4/codec 19 | github.com/VKCOM/joy4/codec/h264parser 20 | github.com/VKCOM/joy4/format/flv/flvio 21 | github.com/VKCOM/joy4/format/mp4/mp4io 22 | github.com/VKCOM/joy4/format/rtsp/sdp 23 | github.com/VKCOM/joy4/format/ts/tsio 24 | # github.com/davecgh/go-spew v1.1.1 25 | github.com/davecgh/go-spew/spew 26 | # github.com/konsorten/go-windows-terminal-sequences v1.0.1 27 | github.com/konsorten/go-windows-terminal-sequences 28 | # github.com/pkg/errors v0.8.1 29 | github.com/pkg/errors 30 | # github.com/pmezard/go-difflib v1.0.0 31 | github.com/pmezard/go-difflib/difflib 32 | # github.com/sirupsen/logrus v1.4.2 33 | github.com/sirupsen/logrus 34 | # github.com/stretchr/testify v1.2.2 35 | github.com/stretchr/testify/assert 36 | # golang.org/x/sys v0.0.0-20190422165155-953cdadca894 37 | golang.org/x/sys/unix 38 | --------------------------------------------------------------------------------