mirror of
https://github.com/gentoo-mirror/gentoo-zh.git
synced 2025-04-19 15:58:56 -04:00
net-misc/baidupcs-go: fix compile error when using go 1.23 or later
This commit is contained in:
parent
61346675fe
commit
d78b958048
40
net-misc/baidupcs-go/baidupcs-go-3.9.5-r1.ebuild
Normal file
40
net-misc/baidupcs-go/baidupcs-go-3.9.5-r1.ebuild
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# Copyright 2020-2023 Gentoo Authors
|
||||||
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
|
EAPI=8
|
||||||
|
|
||||||
|
MY_PN="BaiduPCS-Go"
|
||||||
|
|
||||||
|
inherit go-module
|
||||||
|
|
||||||
|
if [[ ${PV} == *9999 ]]; then
|
||||||
|
inherit git-r3
|
||||||
|
EGIT_REPO_URI="https://github.com/qjfoidnh/${MY_PN}.git"
|
||||||
|
src_unpack() {
|
||||||
|
git-r3_src_unpack
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SRC_URI="https://github.com/qjfoidnh/${MY_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
|
||||||
|
https://github.com/liangyongxiang/gentoo-go-deps/releases/download/${P}/${P}-deps.tar.xz"
|
||||||
|
KEYWORDS="~amd64 ~x86"
|
||||||
|
S="${WORKDIR}/${MY_PN}-${PV}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
DESCRIPTION="The terminal utility for Baidu Network Disk (Golang Version)."
|
||||||
|
HOMEPAGE="https://github.com/qjfoidnh/BaiduPCS-Go"
|
||||||
|
|
||||||
|
LICENSE="Apache-2.0"
|
||||||
|
SLOT="0"
|
||||||
|
|
||||||
|
PATCHES="
|
||||||
|
${FILESDIR}/${PN}-${PV}-0001-fix-go-1.23.0-build.patch
|
||||||
|
"
|
||||||
|
|
||||||
|
src_compile()
|
||||||
|
{
|
||||||
|
ego build -o bin/${PN} -trimpath
|
||||||
|
}
|
||||||
|
|
||||||
|
src_install() {
|
||||||
|
dobin bin/${PN}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
diff --git a/BaiduPCS-Go b/BaiduPCS-Go
|
||||||
|
new file mode 100755
|
||||||
|
index 0000000..d029fb4
|
||||||
|
Binary files /dev/null and b/BaiduPCS-Go differ
|
||||||
|
diff --git a/pcsutil/cachepool/malloc.go b/pcsutil/cachepool/malloc.go
|
||||||
|
index 307a2d4..612fdd9 100644
|
||||||
|
--- a/pcsutil/cachepool/malloc.go
|
||||||
|
+++ b/pcsutil/cachepool/malloc.go
|
||||||
|
@@ -1,3 +1,6 @@
|
||||||
|
+//go:build !go1.23
|
||||||
|
+// +build !go1.23
|
||||||
|
+
|
||||||
|
package cachepool
|
||||||
|
|
||||||
|
import (
|
||||||
|
@@ -5,6 +8,8 @@ import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
+// 函数声明可以省略主体。 这样的声明为Go外部实现的功能(例如汇编例程)提供了签名。这是在汇编中实现函数的方式。
|
||||||
|
+
|
||||||
|
//go:linkname mallocgc runtime.mallocgc
|
||||||
|
func mallocgc(size uintptr, typ uintptr, needzero bool) unsafe.Pointer
|
||||||
|
|
||||||
|
@@ -30,4 +35,4 @@ func RawMallocByteSlice(size int) []byte {
|
||||||
|
Cap: size,
|
||||||
|
}))
|
||||||
|
return b
|
||||||
|
-}
|
||||||
|
+}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/pcsutil/cachepool/malloc_go_1.23.go b/pcsutil/cachepool/malloc_go_1.23.go
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..8c2b78d
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/pcsutil/cachepool/malloc_go_1.23.go
|
||||||
|
@@ -0,0 +1,31 @@
|
||||||
|
+//go:build go1.23
|
||||||
|
+// +build go1.23
|
||||||
|
+
|
||||||
|
+package cachepool
|
||||||
|
+
|
||||||
|
+import (
|
||||||
|
+ "unsafe"
|
||||||
|
+)
|
||||||
|
+
|
||||||
|
+// 说明:
|
||||||
|
+// 由于GO 1.23版本取消了 go:linkname 的支持,所以1.23以及以上版本需要使用本文件替代原始文件 malloc.go
|
||||||
|
+
|
||||||
|
+// RawByteSlice point to runtime.rawbyteslice
|
||||||
|
+func RawByteSlice(size int) (b []byte) {
|
||||||
|
+ bytesArray := make([]byte, size)
|
||||||
|
+ return bytesArray
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+// RawMalloc allocates a new slice. The slice is not zeroed.
|
||||||
|
+func RawMalloc(size int) unsafe.Pointer {
|
||||||
|
+ bytesArray := make([]byte, size)
|
||||||
|
+ // 使用unsafe.Pointer获取字节数组的指针
|
||||||
|
+ bytesPtr := unsafe.Pointer(&bytesArray[0])
|
||||||
|
+ return bytesPtr
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+// RawMallocByteSlice allocates a new byte slice. The slice is not zeroed.
|
||||||
|
+func RawMallocByteSlice(size int) []byte {
|
||||||
|
+ bytesArray := make([]byte, size)
|
||||||
|
+ return bytesArray
|
||||||
|
+}
|
||||||
|
\ No newline at end of file
|
Loading…
x
Reference in New Issue
Block a user