Update to go1.23.4
This commit is contained in:
@@ -42,6 +42,7 @@ func Syscall15(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a
|
||||
// Deprecated: Use [SyscallN] instead.
|
||||
func Syscall18(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18 uintptr) (r1, r2 uintptr, err Errno)
|
||||
|
||||
//go:noescape
|
||||
func SyscallN(trap uintptr, args ...uintptr) (r1, r2 uintptr, err Errno)
|
||||
func loadlibrary(filename *uint16) (handle uintptr, err Errno)
|
||||
func loadsystemlibrary(filename *uint16, absoluteFilepath *uint16) (handle uintptr, err Errno)
|
||||
|
||||
@@ -213,6 +213,51 @@ func TestGetStartupInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSyscallAllocations(t *testing.T) {
|
||||
testenv.SkipIfOptimizationOff(t)
|
||||
|
||||
// Test that syscall.SyscallN arguments do not escape.
|
||||
// The function used (in this case GetVersion) doesn't matter
|
||||
// as long as it is always available and doesn't panic.
|
||||
h, err := syscall.LoadLibrary("kernel32.dll")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer syscall.FreeLibrary(h)
|
||||
proc, err := syscall.GetProcAddress(h, "GetVersion")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
testAllocs := func(t *testing.T, name string, fn func() error) {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
n := int(testing.AllocsPerRun(10, func() {
|
||||
if err := fn(); err != nil {
|
||||
t.Fatalf("%s: %v", name, err)
|
||||
}
|
||||
}))
|
||||
if n > 0 {
|
||||
t.Errorf("allocs = %d, want 0", n)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
testAllocs(t, "SyscallN", func() error {
|
||||
r0, _, e1 := syscall.SyscallN(proc, 0, 0, 0)
|
||||
if r0 == 0 {
|
||||
return syscall.Errno(e1)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
testAllocs(t, "Syscall", func() error {
|
||||
r0, _, e1 := syscall.Syscall(proc, 3, 0, 0, 0)
|
||||
if r0 == 0 {
|
||||
return syscall.Errno(e1)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func FuzzUTF16FromString(f *testing.F) {
|
||||
f.Add("hi") // ASCII
|
||||
f.Add("â") // latin1
|
||||
|
||||
Reference in New Issue
Block a user