From 60ecf133770b8d00f663239ce4d001ecd15f06c1 Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 4 Aug 2023 11:50:46 +0200 Subject: [PATCH 1/8] windows: add TimeBeginPeriod and TimeEndPeriod syscalls Updates golang/go#44343 Fixes golang/go#61723 Change-Id: I920f2fad6b3a2a9ba67ff2fafea4319644a0bc8c Reviewed-on: https://go-review.googlesource.com/c/sys/+/515915 Reviewed-by: qiulaidongfeng <2645477756@qq.com> Run-TryBot: Quim Muntal Reviewed-by: Alex Brainman Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Michael Knyszek --- windows/syscall_windows.go | 4 ++++ windows/syscall_windows_test.go | 9 +++++++++ windows/zsyscall_windows.go | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go index 373d16388a..88e60c8763 100644 --- a/windows/syscall_windows.go +++ b/windows/syscall_windows.go @@ -437,6 +437,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmGetWindowAttribute //sys DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmSetWindowAttribute +// Windows Multimedia API +//sys TimeBeginPeriod (period uint32) (err error) [failretval != 0] = winmm.timeBeginPeriod +//sys TimeEndPeriod (period uint32) (err error) [failretval != 0] = winmm.timeEndPeriod + // syscall interface implementation for other packages // GetCurrentProcess returns the handle for the current process. diff --git a/windows/syscall_windows_test.go b/windows/syscall_windows_test.go index 25f47ea533..8b51547d19 100644 --- a/windows/syscall_windows_test.go +++ b/windows/syscall_windows_test.go @@ -1164,3 +1164,12 @@ items_loop: } } } + +func TestTimePeriod(t *testing.T) { + if err := windows.TimeBeginPeriod(1); err != nil { + t.Fatal(err) + } + if err := windows.TimeEndPeriod(1); err != nil { + t.Fatal(err) + } +} diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go index 566dd3e315..1c31758eac 100644 --- a/windows/zsyscall_windows.go +++ b/windows/zsyscall_windows.go @@ -55,6 +55,7 @@ var ( moduser32 = NewLazySystemDLL("user32.dll") moduserenv = NewLazySystemDLL("userenv.dll") modversion = NewLazySystemDLL("version.dll") + modwinmm = NewLazySystemDLL("winmm.dll") modwintrust = NewLazySystemDLL("wintrust.dll") modws2_32 = NewLazySystemDLL("ws2_32.dll") modwtsapi32 = NewLazySystemDLL("wtsapi32.dll") @@ -468,6 +469,8 @@ var ( procGetFileVersionInfoSizeW = modversion.NewProc("GetFileVersionInfoSizeW") procGetFileVersionInfoW = modversion.NewProc("GetFileVersionInfoW") procVerQueryValueW = modversion.NewProc("VerQueryValueW") + proctimeBeginPeriod = modwinmm.NewProc("timeBeginPeriod") + proctimeEndPeriod = modwinmm.NewProc("timeEndPeriod") procWinVerifyTrustEx = modwintrust.NewProc("WinVerifyTrustEx") procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW") procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW") @@ -4017,6 +4020,22 @@ func _VerQueryValue(block unsafe.Pointer, subBlock *uint16, pointerToBufferPoint return } +func TimeBeginPeriod(period uint32) (err error) { + r1, _, e1 := syscall.Syscall(proctimeBeginPeriod.Addr(), 1, uintptr(period), 0, 0) + if r1 != 0 { + err = errnoErr(e1) + } + return +} + +func TimeEndPeriod(period uint32) (err error) { + r1, _, e1 := syscall.Syscall(proctimeEndPeriod.Addr(), 1, uintptr(period), 0, 0) + if r1 != 0 { + err = errnoErr(e1) + } + return +} + func WinVerifyTrustEx(hwnd HWND, actionId *GUID, data *WinTrustData) (ret error) { r0, _, _ := syscall.Syscall(procWinVerifyTrustEx.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(actionId)), uintptr(unsafe.Pointer(data))) if r0 != 0 { From ee578879d89c195b56ae72143c652798925c5696 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 4 Aug 2023 14:56:29 -0700 Subject: [PATCH 2/8] unix: add SchedSetAttr and SchedGetAttr for Linux Add wrappers for sched_getattr(2) and sched_setattr(2), as well as various SCHED_ values usable for these. The kludge in linux/types.go is needed so we can include both linux/sched/types.h (for struct sched_attr) and sched.h (for a few defines from include/bits/cpu-set.h). Unfortunately, they both define struct sched_param, thus the need to mask one of the definitions. Change-Id: I3e13cf49ccef7ae81a75d33826d18de84a52106d Signed-off-by: Kir Kolyshkin Reviewed-on: https://go-review.googlesource.com/c/sys/+/516756 Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Michael Knyszek TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor --- unix/linux/types.go | 9 +++++++++ unix/mkerrors.sh | 1 + unix/syscall_linux.go | 23 +++++++++++++++++++++++ unix/zerrors_linux.go | 17 +++++++++++++++++ unix/zsyscall_linux.go | 20 ++++++++++++++++++++ unix/ztypes_linux.go | 15 +++++++++++++++ 6 files changed, 85 insertions(+) diff --git a/unix/linux/types.go b/unix/linux/types.go index bf2df60b2a..25b9279384 100644 --- a/unix/linux/types.go +++ b/unix/linux/types.go @@ -138,6 +138,11 @@ struct termios2 { #include #include #include +// This is to avoid a conflict of struct sched_param being defined by +// both the kernel and the glibc (sched.h) headers. +#define sched_param kernel_sched_param +#include +#undef kernel_sched_param #include #include #include @@ -5796,3 +5801,7 @@ const ( RISCV_HWPROBE_MISALIGNED_UNSUPPORTED = C.RISCV_HWPROBE_MISALIGNED_UNSUPPORTED RISCV_HWPROBE_MISALIGNED_MASK = C.RISCV_HWPROBE_MISALIGNED_MASK ) + +type SchedAttr C.struct_sched_attr + +const SizeofSchedAttr = C.sizeof_struct_sched_attr diff --git a/unix/mkerrors.sh b/unix/mkerrors.sh index 8f775fafa6..47fa6a7ebd 100755 --- a/unix/mkerrors.sh +++ b/unix/mkerrors.sh @@ -583,6 +583,7 @@ ccflags="$@" $2 ~ /^PERF_/ || $2 ~ /^SECCOMP_MODE_/ || $2 ~ /^SEEK_/ || + $2 ~ /^SCHED_/ || $2 ~ /^SPLICE_/ || $2 ~ /^SYNC_FILE_RANGE_/ || $2 !~ /IOC_MAGIC/ && diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index a730878e49..0ba030197f 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -2471,6 +2471,29 @@ func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask * return pselect6(nfd, r, w, e, mutableTimeout, kernelMask) } +//sys schedSetattr(pid int, attr *SchedAttr, flags uint) (err error) +//sys schedGetattr(pid int, attr *SchedAttr, size uint, flags uint) (err error) + +// SchedSetAttr is a wrapper for sched_setattr(2) syscall. +// https://man7.org/linux/man-pages/man2/sched_setattr.2.html +func SchedSetAttr(pid int, attr *SchedAttr, flags uint) error { + if attr == nil { + return EINVAL + } + attr.Size = SizeofSchedAttr + return schedSetattr(pid, attr, flags) +} + +// SchedGetAttr is a wrapper for sched_getattr(2) syscall. +// https://man7.org/linux/man-pages/man2/sched_getattr.2.html +func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { + attr := &SchedAttr{} + if err := schedGetattr(pid, attr, SizeofSchedAttr, flags); err != nil { + return nil, err + } + return attr, nil +} + /* * Unimplemented */ diff --git a/unix/zerrors_linux.go b/unix/zerrors_linux.go index 3784f402e5..0787a043be 100644 --- a/unix/zerrors_linux.go +++ b/unix/zerrors_linux.go @@ -2821,6 +2821,23 @@ const ( RWF_SUPPORTED = 0x1f RWF_SYNC = 0x4 RWF_WRITE_LIFE_NOT_SET = 0x0 + SCHED_BATCH = 0x3 + SCHED_DEADLINE = 0x6 + SCHED_FIFO = 0x1 + SCHED_FLAG_ALL = 0x7f + SCHED_FLAG_DL_OVERRUN = 0x4 + SCHED_FLAG_KEEP_ALL = 0x18 + SCHED_FLAG_KEEP_PARAMS = 0x10 + SCHED_FLAG_KEEP_POLICY = 0x8 + SCHED_FLAG_RECLAIM = 0x2 + SCHED_FLAG_RESET_ON_FORK = 0x1 + SCHED_FLAG_UTIL_CLAMP = 0x60 + SCHED_FLAG_UTIL_CLAMP_MAX = 0x40 + SCHED_FLAG_UTIL_CLAMP_MIN = 0x20 + SCHED_IDLE = 0x5 + SCHED_NORMAL = 0x0 + SCHED_RESET_ON_FORK = 0x40000000 + SCHED_RR = 0x2 SCM_CREDENTIALS = 0x2 SCM_RIGHTS = 0x1 SCM_TIMESTAMP = 0x1d diff --git a/unix/zsyscall_linux.go b/unix/zsyscall_linux.go index a07321bed9..14ab34a565 100644 --- a/unix/zsyscall_linux.go +++ b/unix/zsyscall_linux.go @@ -2197,3 +2197,23 @@ func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { RawSyscallNoError(SYS_GETRESGID, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func schedSetattr(pid int, attr *SchedAttr, flags uint) (err error) { + _, _, e1 := Syscall(SYS_SCHED_SETATTR, uintptr(pid), uintptr(unsafe.Pointer(attr)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func schedGetattr(pid int, attr *SchedAttr, size uint, flags uint) (err error) { + _, _, e1 := Syscall6(SYS_SCHED_GETATTR, uintptr(pid), uintptr(unsafe.Pointer(attr)), uintptr(size), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index 26ef52aafc..494493c78c 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -5868,3 +5868,18 @@ const ( VIRTIO_NET_HDR_GSO_UDP_L4 = 0x5 VIRTIO_NET_HDR_GSO_ECN = 0x80 ) + +type SchedAttr struct { + Size uint32 + Policy uint32 + Flags uint64 + Nice int32 + Priority uint32 + Runtime uint64 + Deadline uint64 + Period uint64 + Util_min uint32 + Util_max uint32 +} + +const SizeofSchedAttr = 0x38 From 552c4e81921bc15a070c372bf28ce91e7122c706 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Wed, 9 Aug 2023 21:43:21 +0800 Subject: [PATCH 3/8] unix: avoid setting O_NONBLOCK needlessly by checking flags beforehand Change-Id: I227118221df469a677f3ff140ca7b94acb7f9571 Reviewed-on: https://go-review.googlesource.com/c/sys/+/517576 TryBot-Result: Gopher Robot Reviewed-by: Michael Knyszek Run-TryBot: Andy Pan Reviewed-by: Ian Lance Taylor Reviewed-by: Tobias Klauser Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- unix/syscall_unix.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/unix/syscall_unix.go b/unix/syscall_unix.go index 8bb30e7ce3..f6eda27050 100644 --- a/unix/syscall_unix.go +++ b/unix/syscall_unix.go @@ -549,6 +549,9 @@ func SetNonblock(fd int, nonblocking bool) (err error) { if err != nil { return err } + if (flag&O_NONBLOCK != 0) == nonblocking { + return nil + } if nonblocking { flag |= O_NONBLOCK } else { From eabbd5c0365faf8ae497f33939135aae720e7f2b Mon Sep 17 00:00:00 2001 From: Anton Kuklin Date: Thu, 10 Aug 2023 12:32:18 +0000 Subject: [PATCH 4/8] cpu: add support for amx detection Added detection for x86 AMX, including AMX-Tile, AMX-INT8 and AMX-BF16 instruction sets. Change-Id: Ib3d663430b64d46b46b22bdd05d40f1992e37ee0 GitHub-Last-Rev: 7986ed6d4f18f81e83bb2e6a782db90443db9de0 GitHub-Pull-Request: golang/sys#170 Reviewed-on: https://go-review.googlesource.com/c/sys/+/516815 Reviewed-by: Tobias Klauser Auto-Submit: Tobias Klauser TryBot-Result: Gopher Robot Run-TryBot: Tobias Klauser Reviewed-by: Michael Knyszek Reviewed-by: Dmitri Shuralyov --- cpu/cpu.go | 3 +++ cpu/cpu_x86.go | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/cpu/cpu.go b/cpu/cpu.go index 83f112c4c8..3ebc32570e 100644 --- a/cpu/cpu.go +++ b/cpu/cpu.go @@ -54,6 +54,9 @@ var X86 struct { HasAVX512VBMI2 bool // Advanced vector extension 512 Vector Byte Manipulation Instructions 2 HasAVX512BITALG bool // Advanced vector extension 512 Bit Algorithms HasAVX512BF16 bool // Advanced vector extension 512 BFloat16 Instructions + HasAMXTile bool // Advanced Matrix Extension Tile instructions + HasAMXInt8 bool // Advanced Matrix Extension Int8 instructions + HasAMXBF16 bool // Advanced Matrix Extension BFloat16 instructions HasBMI1 bool // Bit manipulation instruction set 1 HasBMI2 bool // Bit manipulation instruction set 2 HasCX16 bool // Compare and exchange 16 Bytes diff --git a/cpu/cpu_x86.go b/cpu/cpu_x86.go index f5aacfc825..2dcde8285d 100644 --- a/cpu/cpu_x86.go +++ b/cpu/cpu_x86.go @@ -37,6 +37,9 @@ func initOptions() { {Name: "avx512vbmi2", Feature: &X86.HasAVX512VBMI2}, {Name: "avx512bitalg", Feature: &X86.HasAVX512BITALG}, {Name: "avx512bf16", Feature: &X86.HasAVX512BF16}, + {Name: "amxtile", Feature: &X86.HasAMXTile}, + {Name: "amxint8", Feature: &X86.HasAMXInt8}, + {Name: "amxbf16", Feature: &X86.HasAMXBF16}, {Name: "bmi1", Feature: &X86.HasBMI1}, {Name: "bmi2", Feature: &X86.HasBMI2}, {Name: "cx16", Feature: &X86.HasCX16}, @@ -138,6 +141,10 @@ func archInit() { eax71, _, _, _ := cpuid(7, 1) X86.HasAVX512BF16 = isSet(5, eax71) } + + X86.HasAMXTile = isSet(24, edx7) + X86.HasAMXInt8 = isSet(25, edx7) + X86.HasAMXBF16 = isSet(22, edx7) } func isSet(bitpos uint, value uint32) bool { From 70233675aed4ad06978307d93ad8f12b9b6ca38c Mon Sep 17 00:00:00 2001 From: cui fliter Date: Tue, 15 Aug 2023 11:19:29 +0800 Subject: [PATCH 5/8] cpu: remove repetitive word Change-Id: I6dbed409b549ab2cfc862094f19373816b7c0859 Reviewed-on: https://go-review.googlesource.com/c/sys/+/519076 Reviewed-by: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Auto-Submit: Ian Lance Taylor --- cpu/cpu.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/cpu.go b/cpu/cpu.go index 3ebc32570e..4756ad5f79 100644 --- a/cpu/cpu.go +++ b/cpu/cpu.go @@ -38,7 +38,7 @@ var X86 struct { HasAVX512F bool // Advanced vector extension 512 Foundation Instructions HasAVX512CD bool // Advanced vector extension 512 Conflict Detection Instructions HasAVX512ER bool // Advanced vector extension 512 Exponential and Reciprocal Instructions - HasAVX512PF bool // Advanced vector extension 512 Prefetch Instructions Instructions + HasAVX512PF bool // Advanced vector extension 512 Prefetch Instructions HasAVX512VL bool // Advanced vector extension 512 Vector Length Extensions HasAVX512BW bool // Advanced vector extension 512 Byte and Word Instructions HasAVX512DQ bool // Advanced vector extension 512 Doubleword and Quadword Instructions From ad02017442a1dbaf61144e91aed6d5e243d0719d Mon Sep 17 00:00:00 2001 From: Mauri de Souza Meneguzzo Date: Sun, 13 Aug 2023 15:00:54 +0000 Subject: [PATCH 6/8] windows: use SyscallN in mkwinsyscall The mkwinsyscall command has a hard limit of 15 on the number of syscall arguments. Windows has several system calls with more than 15 arguments, for example CreateFontPackage has 18 arguments. If the number of arguments is higher than 15 we use SyscallN. Fixes golang/go#57914 Change-Id: I4205e779a960ae10c0778de7876154e0d7ec00a1 GitHub-Last-Rev: 1f1e96fab7327f803f8213ca4264d359046971cd GitHub-Pull-Request: golang/sys#171 Reviewed-on: https://go-review.googlesource.com/c/sys/+/518995 Reviewed-by: Alex Brainman TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov Run-TryBot: Alex Brainman --- windows/mkwinsyscall/mkwinsyscall.go | 10 ++-- windows/mkwinsyscall/mkwinsyscall_test.go | 63 +++++++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/windows/mkwinsyscall/mkwinsyscall.go b/windows/mkwinsyscall/mkwinsyscall.go index 11f4873bce..3947092c5f 100644 --- a/windows/mkwinsyscall/mkwinsyscall.go +++ b/windows/mkwinsyscall/mkwinsyscall.go @@ -57,7 +57,6 @@ import ( "go/parser" "go/token" "io" - "io/ioutil" "log" "os" "path/filepath" @@ -568,6 +567,8 @@ func (f *Fn) SyscallParamCount() int { return 12 case n <= 15: return 15 + case n <= 42: // current SyscallN limit + return n default: panic("too many arguments to system call") } @@ -579,6 +580,9 @@ func (f *Fn) Syscall() string { if c == 3 { return syscalldot() + "Syscall" } + if c > 15 { + return syscalldot() + "SyscallN" + } return syscalldot() + "Syscall" + strconv.Itoa(c) } @@ -923,7 +927,7 @@ func main() { if *filename == "" { _, err = os.Stdout.Write(data) } else { - err = ioutil.WriteFile(*filename, data, 0644) + err = os.WriteFile(*filename, data, 0644) } if err != nil { log.Fatal(err) @@ -1011,7 +1015,7 @@ func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{ {{define "results"}}{{if .Rets.List}}{{.Rets.List}} {{end}}{{end}} -{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}} +{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(),{{if le .ParamCount 15}} {{.ParamCount}},{{end}} {{.SyscallParamList}}){{end}} {{define "tmpvarsreadback"}}{{range .Params}}{{if .TmpVarReadbackCode}} {{.TmpVarReadbackCode}}{{end}}{{end}}{{end}} diff --git a/windows/mkwinsyscall/mkwinsyscall_test.go b/windows/mkwinsyscall/mkwinsyscall_test.go index cabbf40312..b000e6b5cc 100644 --- a/windows/mkwinsyscall/mkwinsyscall_test.go +++ b/windows/mkwinsyscall/mkwinsyscall_test.go @@ -9,6 +9,7 @@ import ( "go/format" "os" "path/filepath" + "strings" "testing" ) @@ -48,3 +49,65 @@ func TestDLLFilenameEscaping(t *testing.T) { }) } } + +func TestSyscallXGeneration(t *testing.T) { + tests := []struct { + name string + wantsysfunc string + sig string + }{ + { + name: "syscall with 2 params", + wantsysfunc: "syscall.Syscall", + sig: "Example(a1 *uint16, a2 *uint16) = ", + }, + { + name: "syscall with 6 params", + wantsysfunc: "syscall.Syscall6", + sig: "Example(a1 *uint, a2 *uint, a3 *uint, a4 *uint, a5 *uint, a6 *uint) = ", + }, + { + name: "syscall with 15 params", + wantsysfunc: "syscall.Syscall15", + sig: strings.ReplaceAll(`Example(a1 *uint, a2 *uint, a3 *uint, a4 *uint, a5 *uint, a6 *uint, + a7 *uint, a8 *uint, a9 *uint, a10 *uint, a11 *uint, a12 *uint, + a13 *uint, a14 *uint, a15 *uint) = `, "\n", ""), + }, + { + name: "syscall with 18 params", + wantsysfunc: "syscall.SyscallN", + sig: strings.ReplaceAll(`Example(a1 *uint, a2 *uint, a3 *uint, a4 *uint, a5 *uint, a6 *uint, + a7 *uint, a8 *uint, a9 *uint, a10 *uint, a11 *uint, a12 *uint, + a13 *uint, a14 *uint, a15 *uint, a16 *uint, a17 *uint, a18 *uint) = `, "\n", ""), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + // Write the syscall into a temp file for testing. + prefix := "package windows\n//sys " + tt.sig + suffix := ".Example" + name := filepath.Join(t.TempDir(), "syscall.go") + if err := os.WriteFile(name, []byte(prefix+"example"+suffix), 0666); err != nil { + t.Fatal(err) + } + + // Ensure parsing, generating, and formatting run without errors. + // This is good enough to show that escaping is working. + src, err := ParseFiles([]string{name}) + if err != nil { + t.Fatal(err) + } + var buf bytes.Buffer + if err := src.Generate(&buf); err != nil { + t.Fatal(err) + } + if _, err := format.Source(buf.Bytes()); err != nil { + t.Fatal(err) + } + + if !strings.Contains(buf.String(), tt.wantsysfunc+"(") { + t.Fatalf("expected syscall func %q in buffer %s", tt.wantsysfunc, buf.String()) + } + }) + } +} From e8190d9965d9b0b728bffc1d61d8e0ab5da15cac Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 17 Aug 2023 00:03:41 +0200 Subject: [PATCH 7/8] windows: don't check non-existent return code in GetStartupInfo Same as CL 520275 did in package syscall. For golang/go#31316 Change-Id: Ie9d8fed7f40b9e562534d5e91488b4ba1ac44f34 Reviewed-on: https://go-review.googlesource.com/c/sys/+/520295 TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Auto-Submit: Tobias Klauser Reviewed-by: Dmitri Shuralyov Run-TryBot: Tobias Klauser --- windows/syscall_windows.go | 7 ++++++- windows/syscall_windows_test.go | 9 +++++++++ windows/zsyscall_windows.go | 7 ++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go index 88e60c8763..67bad0926a 100644 --- a/windows/syscall_windows.go +++ b/windows/syscall_windows.go @@ -216,7 +216,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) = shell32.SHGetKnownFolderPath //sys TerminateProcess(handle Handle, exitcode uint32) (err error) //sys GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) -//sys GetStartupInfo(startupInfo *StartupInfo) (err error) = GetStartupInfoW +//sys getStartupInfo(startupInfo *StartupInfo) = GetStartupInfoW //sys GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) //sys DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) //sys WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) [failretval==0xffffffff] @@ -1628,6 +1628,11 @@ func SetConsoleCursorPosition(console Handle, position Coord) error { return setConsoleCursorPosition(console, *((*uint32)(unsafe.Pointer(&position)))) } +func GetStartupInfo(startupInfo *StartupInfo) error { + getStartupInfo(startupInfo) + return nil +} + func (s NTStatus) Errno() syscall.Errno { return rtlNtStatusToDosErrorNoTeb(s) } diff --git a/windows/syscall_windows_test.go b/windows/syscall_windows_test.go index 8b51547d19..bf53ab5f92 100644 --- a/windows/syscall_windows_test.go +++ b/windows/syscall_windows_test.go @@ -1173,3 +1173,12 @@ func TestTimePeriod(t *testing.T) { t.Fatal(err) } } + +func TestGetStartupInfo(t *testing.T) { + var si windows.StartupInfo + err := windows.GetStartupInfo(&si) + if err != nil { + // see https://go.dev/issue/31316 + t.Fatalf("GetStartupInfo: got error %v, want nil", err) + } +} diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go index 1c31758eac..5c385580f6 100644 --- a/windows/zsyscall_windows.go +++ b/windows/zsyscall_windows.go @@ -2370,11 +2370,8 @@ func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uin return } -func GetStartupInfo(startupInfo *StartupInfo) (err error) { - r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } +func getStartupInfo(startupInfo *StartupInfo) { + syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0) return } From 51546915a63b068d8e385208b9ba6ada4bcb182e Mon Sep 17 00:00:00 2001 From: chenguoqi Date: Thu, 17 Aug 2023 17:43:16 +0800 Subject: [PATCH 8/8] unix/linux: update to gcc 13.2.0, qemu 8.0.3 for loong64 and and Go 1.21.0 for all Running `GOOS=linux GOARCH={amd64,arm64,loong64,mips64le,riscv64} ./mkall.sh` produces no changes, as expected. Update Loong64's cross toolchain to support for the ELF psABI v2.0 relocs [1]. Updates #58784. [1]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html Change-Id: I676893b934d8cfc30b9f3702fc92a5ab82f7f116 Reviewed-on: https://go-review.googlesource.com/c/sys/+/483455 Auto-Submit: Tobias Klauser Auto-Submit: Ian Lance Taylor Reviewed-by: Meidan Li Run-TryBot: Ian Lance Taylor Run-TryBot: Tobias Klauser Reviewed-by: Tobias Klauser TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills Reviewed-by: Ian Lance Taylor --- unix/linux/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unix/linux/Dockerfile b/unix/linux/Dockerfile index 18d3acd3aa..195f999821 100644 --- a/unix/linux/Dockerfile +++ b/unix/linux/Dockerfile @@ -21,9 +21,9 @@ RUN git clone --branch v6.4 --depth 1 https://kernel.googlesource.com/pub/scm/li RUN git clone --branch release/2.37/master --depth 1 https://sourceware.org/git/glibc.git # Get Go -ENV GOLANG_VERSION 1.21rc2 +ENV GOLANG_VERSION 1.21.0 ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 8fe90332727c606019e80a7368e23f5e65ad59520e45ee4010692f15572e45c6 +ENV GOLANG_DOWNLOAD_SHA256 d0398903a16ba2232b389fb31032ddf57cac34efda306a0eebac34f0965a0742 RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ @@ -52,8 +52,8 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Only for loong64, getting tools of qemu-user and gcc-cross-compiler -ENV LOONG64_BASE_URL https://github.com/loongson/build-tools/releases/download/2022.09.06 -ENV LOONG64_GCC loongarch64-clfs-6.3-cross-tools-gcc-glibc.tar.xz +ENV LOONG64_BASE_URL https://github.com/loongson/build-tools/releases/download/2023.08.08 +ENV LOONG64_GCC CLFS-loongarch64-8.1-x86_64-cross-tools-gcc-glibc.tar.xz ENV LOONG64_QEMU qemu-loongarch64 ENV LOONG64_GCC_DOWNLOAD_URL $LOONG64_BASE_URL/$LOONG64_GCC ENV LOONG64_QEMU_DOWNLOAD_URL $LOONG64_BASE_URL/$LOONG64_QEMU