mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-06 05:17:38 +03:00
Remove unsafe linkname usages
This commit is contained in:
parent
842fd713ff
commit
afbe231237
2 changed files with 7 additions and 6 deletions
|
@ -4,6 +4,8 @@ package buf
|
|||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/sagernet/sing/common"
|
||||
)
|
||||
|
||||
type dbgVar struct {
|
||||
|
@ -17,8 +19,10 @@ var dbgvars any
|
|||
// go.info.runtime.dbgvars: relocation target go.info.[]github.com/sagernet/sing/common/buf.dbgVar not defined
|
||||
// var dbgvars []dbgVar
|
||||
|
||||
//nolint:gochecknoinits
|
||||
func init() {
|
||||
if !common.UnsafeBuffer {
|
||||
return
|
||||
}
|
||||
debugVars := *(*[]dbgVar)(unsafe.Pointer(&dbgvars))
|
||||
for _, v := range debugVars {
|
||||
if v.name == "invalidptr" {
|
||||
|
|
|
@ -32,11 +32,8 @@ func Extend(cause error, message ...any) error {
|
|||
return &extendedError{F.ToString(message...), cause}
|
||||
}
|
||||
|
||||
//go:linkname errCanceled net.errCanceled
|
||||
var errCanceled error
|
||||
|
||||
func IsClosedOrCanceled(err error) bool {
|
||||
return IsMulti(err, io.EOF, net.ErrClosed, io.ErrClosedPipe, os.ErrClosed, syscall.EPIPE, syscall.ECONNRESET, context.Canceled, context.DeadlineExceeded, errCanceled)
|
||||
return IsMulti(err, io.EOF, net.ErrClosed, io.ErrClosedPipe, os.ErrClosed, syscall.EPIPE, syscall.ECONNRESET, context.Canceled, context.DeadlineExceeded)
|
||||
}
|
||||
|
||||
func IsClosed(err error) bool {
|
||||
|
@ -44,5 +41,5 @@ func IsClosed(err error) bool {
|
|||
}
|
||||
|
||||
func IsCanceled(err error) bool {
|
||||
return IsMulti(err, context.Canceled, context.DeadlineExceeded, errCanceled)
|
||||
return IsMulti(err, context.Canceled, context.DeadlineExceeded)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue