update go-ffmpreg to v0.2.5 (pulls in latest tetratelabs/wazero) (#3203)

This commit is contained in:
kim
2024-08-15 00:08:55 +00:00
committed by GitHub
parent 6fe96a5611
commit 09f24e0446
75 changed files with 1772 additions and 1913 deletions

View File

@ -1,23 +0,0 @@
//go:build !(darwin || linux || freebsd) || tinygo
package platform
func remapCodeSegmentAMD64(code []byte, size int) ([]byte, error) {
b, err := mmapCodeSegmentAMD64(size)
if err != nil {
return nil, err
}
copy(b, code)
mustMunmapCodeSegment(code)
return b, nil
}
func remapCodeSegmentARM64(code []byte, size int) ([]byte, error) {
b, err := mmapCodeSegmentARM64(size)
if err != nil {
return nil, err
}
copy(b, code)
mustMunmapCodeSegment(code)
return b, nil
}

View File

@ -1,21 +0,0 @@
//go:build (darwin || linux || freebsd) && !tinygo
package platform
func remapCodeSegmentAMD64(code []byte, size int) ([]byte, error) {
return remapCodeSegment(code, size, mmapProtAMD64)
}
func remapCodeSegmentARM64(code []byte, size int) ([]byte, error) {
return remapCodeSegment(code, size, mmapProtARM64)
}
func remapCodeSegment(code []byte, size, prot int) ([]byte, error) {
b, err := mmapCodeSegment(size, prot)
if err != nil {
return nil, err
}
copy(b, code)
mustMunmapCodeSegment(code)
return b, nil
}

View File

@ -36,28 +36,6 @@ func MmapCodeSegment(size int) ([]byte, error) {
}
}
// RemapCodeSegment reallocates the memory mapping of an existing code segment
// to increase its size. The previous code mapping is unmapped and must not be
// reused after the function returns.
//
// This is similar to mremap(2) on linux, and emulated on platforms which do not
// have this syscall.
//
// See https://man7.org/linux/man-pages/man2/mremap.2.html
func RemapCodeSegment(code []byte, size int) ([]byte, error) {
if size < len(code) {
panic("BUG: RemapCodeSegment with size less than code")
}
if code == nil {
return MmapCodeSegment(size)
}
if runtime.GOARCH == "amd64" {
return remapCodeSegmentAMD64(code, size)
} else {
return remapCodeSegmentARM64(code, size)
}
}
// MunmapCodeSegment unmaps the given memory region.
func MunmapCodeSegment(code []byte) error {
if len(code) == 0 {
@ -65,17 +43,3 @@ func MunmapCodeSegment(code []byte) error {
}
return munmapCodeSegment(code)
}
// mustMunmapCodeSegment panics instead of returning an error to the
// application.
//
// # Why panic?
//
// It is less disruptive to the application to leak the previous block if it
// could be unmapped than to leak the new block and return an error.
// Realistically, either scenarios are pretty hard to debug, so we panic.
func mustMunmapCodeSegment(code []byte) {
if err := munmapCodeSegment(code); err != nil {
panic(err)
}
}