chore: ⬆️ updated deps
This commit is contained in:
+1
@@ -17,6 +17,7 @@ Jason DeBettencourt <jasond17@gmail.com>
|
||||
Jasper Siepkes <jasper@siepkes.nl>
|
||||
Koichi Shiraishi <zchee.io@gmail.com>
|
||||
Marius Orcsik <marius@federated.id>
|
||||
Olivier Mengué <dolmen@cpan.org>
|
||||
Patricio Whittingslow <graded.sp@gmail.com>
|
||||
Scot C Bontrager <scot@indievisible.org>
|
||||
Steffen Butzer <steffen(dot)butzer@outlook.com>
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
# Contributing to this repository
|
||||
|
||||
Thank you for your interest in contributing! To help keep the project stable across its many targets, please follow these guidelines when submitting a pull request or merge request.
|
||||
|
||||
### Verification
|
||||
|
||||
Before submitting your changes, please ensure that they do not break the build for different architectures or build tags.
|
||||
|
||||
Run the following script in your local environment:
|
||||
|
||||
```bash
|
||||
$ ./build_all_targets.sh
|
||||
```
|
||||
|
||||
Please verify that all targets you can test pass before opening your request.
|
||||
|
||||
### Authors and Contributors
|
||||
|
||||
If you would like yourself and/or your company to be officially recognized in the project:
|
||||
|
||||
* Optionally, please include a change to the AUTHORS and/or CONTRIBUTORS files within your merge request.
|
||||
|
||||
### The Process
|
||||
|
||||
* Fork the repository (or host a public branch if you do not have a gitlab.com account).
|
||||
* Implement your changes, keeping them as focused as possible.
|
||||
* Submit your request with a clear description of the problem solved, the dependency improved, etc.
|
||||
|
||||
----
|
||||
|
||||
We appreciate your help in making the Go ecosystem more robust!
|
||||
+1
@@ -18,6 +18,7 @@ Jasper Siepkes <jasper@siepkes.nl>
|
||||
Koichi Shiraishi <zchee.io@gmail.com>
|
||||
Leonardo Taccari <leot@NetBSD.org>
|
||||
Marius Orcsik <marius@federated.id>
|
||||
Olivier Mengué <dolmen@cpan.org>
|
||||
Patricio Whittingslow <graded.sp@gmail.com>
|
||||
Roman Khafizianov <roman@any.org>
|
||||
Scot C Bontrager <scot@indievisible.org>
|
||||
|
||||
+4
-1
@@ -468,6 +468,9 @@ func Y__builtin_popcount(t *TLS, x uint32) (_2 int32)
|
||||
//go:noescape
|
||||
func Y__builtin_popcountl(t *TLS, x ulong) (_2 int32)
|
||||
|
||||
//go:noescape
|
||||
func Y__builtin_popcountll(t *TLS, x uint64) (_2 int32)
|
||||
|
||||
//go:noescape
|
||||
func Y__builtin_prefetch(t *TLS, addr, args uintptr)
|
||||
|
||||
@@ -5028,7 +5031,7 @@ func Ystrlcat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r Tsize_t)
|
||||
func Ystrlcpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r Tsize_t)
|
||||
|
||||
//go:noescape
|
||||
func Ystrlen(tls *TLS, s uintptr) (r Tsize_t)
|
||||
func Ystrlen(t *TLS, s uintptr) (r Tsize_t)
|
||||
|
||||
//go:noescape
|
||||
func Ystrncasecmp(tls *TLS, _l uintptr, _r uintptr, n Tsize_t) (r1 int32)
|
||||
|
||||
+15
-2
@@ -2427,6 +2427,19 @@ TEXT ·Y__builtin_popcountl(SB),$24-20
|
||||
MOVL AX, _2+16(FP)
|
||||
RET
|
||||
|
||||
// func Y__builtin_popcountll(t *TLS, x uint64) (_2 int32)
|
||||
TEXT ·Y__builtin_popcountll(SB),$24-20
|
||||
GO_ARGS
|
||||
NO_LOCAL_POINTERS
|
||||
MOVQ t+0(FP), AX
|
||||
MOVQ AX, 0(SP)
|
||||
MOVQ x+8(FP), AX
|
||||
MOVQ AX, 8(SP)
|
||||
CALL ·X__builtin_popcountll(SB)
|
||||
MOVL 16(SP), AX
|
||||
MOVL AX, _2+16(FP)
|
||||
RET
|
||||
|
||||
// func Y__builtin_prefetch(t *TLS, addr, args uintptr)
|
||||
TEXT ·Y__builtin_prefetch(SB),$24-24
|
||||
GO_ARGS
|
||||
@@ -25118,11 +25131,11 @@ TEXT ·Ystrlcpy(SB),$40-40
|
||||
MOVQ AX, r+32(FP)
|
||||
RET
|
||||
|
||||
// func Ystrlen(tls *TLS, s uintptr) (r Tsize_t)
|
||||
// func Ystrlen(t *TLS, s uintptr) (r Tsize_t)
|
||||
TEXT ·Ystrlen(SB),$24-24
|
||||
GO_ARGS
|
||||
NO_LOCAL_POINTERS
|
||||
MOVQ tls+0(FP), AX
|
||||
MOVQ t+0(FP), AX
|
||||
MOVQ AX, 0(SP)
|
||||
MOVQ s+8(FP), AX
|
||||
MOVQ AX, 8(SP)
|
||||
|
||||
+5
@@ -22,3 +22,8 @@ func X__builtin_clzl(t *TLS, n ulong) int32 {
|
||||
func X__builtin_popcountl(t *TLS, x ulong) int32 {
|
||||
return int32(mbits.OnesCount32(x))
|
||||
}
|
||||
|
||||
// int __builtin_popcountll (unsigned long long)
|
||||
func X__builtin_popcountll(t *TLS, x uint64) int32 {
|
||||
return int32(mbits.OnesCount64(x))
|
||||
}
|
||||
|
||||
+5
@@ -22,3 +22,8 @@ func X__builtin_clzl(t *TLS, n ulong) int32 {
|
||||
func X__builtin_popcountl(t *TLS, x ulong) int32 {
|
||||
return int32(mbits.OnesCount64(x))
|
||||
}
|
||||
|
||||
// int __builtin_popcountll (unsigned long long)
|
||||
func X__builtin_popcountll(t *TLS, x uint64) int32 {
|
||||
return int32(mbits.OnesCount64(x))
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// Copyright 2026 The Libc Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
mbits "math/bits"
|
||||
)
|
||||
|
||||
func X__builtin_ctzll(tls *TLS, x uint64) int32 {
|
||||
return int32(mbits.TrailingZeros64(x))
|
||||
}
|
||||
+8
@@ -531,6 +531,14 @@ func X__builtin_popcountl(t *TLS, x ulong) int32 {
|
||||
return int32(mbits.OnesCount64(uint64(x)))
|
||||
}
|
||||
|
||||
// int __builtin_popcountll (unsigned long long)
|
||||
func X__builtin_popcountll(t *TLS, x uint64) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return int32(mbits.OnesCount64(uint64(x)))
|
||||
}
|
||||
|
||||
// char * __builtin___strcpy_chk (char *dest, const char *src, size_t os);
|
||||
func X__builtin___strcpy_chk(t *TLS, dest, src uintptr, os types.Size_t) uintptr {
|
||||
if __ccgo_strace {
|
||||
|
||||
+21
-4
@@ -9,11 +9,13 @@ import (
|
||||
"math"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
|
||||
func X__sync_add_and_fetch[T constraints.Integer](t *TLS, p uintptr, v T) T {
|
||||
type integer interface {
|
||||
~int | ~int32 | ~int64 | ~uint | ~uint32 | ~uint64 | ~uintptr
|
||||
}
|
||||
|
||||
func X__sync_add_and_fetch[T integer](t *TLS, p uintptr, v T) T {
|
||||
switch unsafe.Sizeof(v) {
|
||||
case 4:
|
||||
return T(atomic.AddInt32((*int32)(unsafe.Pointer(p)), int32(v)))
|
||||
@@ -24,7 +26,7 @@ func X__sync_add_and_fetch[T constraints.Integer](t *TLS, p uintptr, v T) T {
|
||||
}
|
||||
}
|
||||
|
||||
func X__sync_sub_and_fetch[T constraints.Integer](t *TLS, p uintptr, v T) T {
|
||||
func X__sync_sub_and_fetch[T integer](t *TLS, p uintptr, v T) T {
|
||||
switch unsafe.Sizeof(v) {
|
||||
case 4:
|
||||
return T(atomic.AddInt32((*int32)(unsafe.Pointer(p)), -int32(v)))
|
||||
@@ -103,3 +105,18 @@ func Xstrlen(t *TLS, s uintptr) (r Tsize_t) {
|
||||
func _strlen(t *TLS, s uintptr) (r Tsize_t) {
|
||||
return strlen(s)
|
||||
}
|
||||
|
||||
func X__builtin_ilogb(tls *TLS, x float64) int32 {
|
||||
return int32(math.Ilogb(x))
|
||||
}
|
||||
|
||||
func X__builtin_ilogbl(tls *TLS, x float64) int32 {
|
||||
return int32(math.Ilogb(x))
|
||||
}
|
||||
|
||||
func X__builtin_ilogbf(tls *TLS, x float32) int32 {
|
||||
// Casting to float64 is safe and mathematically correct here.
|
||||
// Subnormal float32 values become normal float64 values,
|
||||
// which allows math.Ilogb to correctly return their negative exponent.
|
||||
return int32(math.Ilogb(float64(x)))
|
||||
}
|
||||
|
||||
+4
@@ -2791,3 +2791,7 @@ func Xdup(tls *TLS, fd int32) (r int32) {
|
||||
func X__builtin_ctz(t *TLS, n uint32) int32 {
|
||||
return int32(mbits.TrailingZeros32(n))
|
||||
}
|
||||
|
||||
func AtomicLoadNUint8(ptr uintptr, memorder int32) uint8 {
|
||||
return byte(a_load_8(ptr))
|
||||
}
|
||||
|
||||
+25
@@ -2480,3 +2480,28 @@ func Xdup(tls *TLS, fd int32) (r int32) {
|
||||
|
||||
return int32(nfd)
|
||||
}
|
||||
|
||||
func X__inline_isnand(t *TLS, x float64) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return Xisnan(t, x)
|
||||
}
|
||||
|
||||
func X__inline_isnanf(t *TLS, x float32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return Xisnanf(t, x)
|
||||
}
|
||||
|
||||
func X__inline_isnanl(t *TLS, x float64) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return Xisnan(t, x)
|
||||
}
|
||||
|
||||
func AtomicLoadNUint8(ptr uintptr, memorder int32) uint8 {
|
||||
return byte(a_load_8(ptr))
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// Copyright 2024 The Libc Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm || mips64le)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
// int statfs(const char *path, struct statfs *buf);
|
||||
// Wrapper for ___statfs from ccgo-transpiled musl.
|
||||
func Xstatfs(tls *TLS, path uintptr, buf uintptr) int32 {
|
||||
return ___statfs(tls, path, buf)
|
||||
}
|
||||
+4
@@ -2886,3 +2886,7 @@ func Xrecvmsg(t *TLS, sockfd int32, msg uintptr, flags int32) types.Ssize_t {
|
||||
|
||||
return types.Ssize_t(n)
|
||||
}
|
||||
|
||||
func AtomicLoadNUint8(ptr uintptr, memorder int32) uint8 {
|
||||
return byte(a_load_8(ptr))
|
||||
}
|
||||
|
||||
+53
-12
@@ -7,7 +7,6 @@ package libc // import "modernc.org/libc"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"golang.org/x/sys/windows"
|
||||
"math"
|
||||
mbits "math/bits"
|
||||
"os"
|
||||
@@ -24,6 +23,7 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/ncruces/go-strftime"
|
||||
"golang.org/x/sys/windows"
|
||||
"modernc.org/libc/errno"
|
||||
"modernc.org/libc/fcntl"
|
||||
"modernc.org/libc/limits"
|
||||
@@ -128,6 +128,7 @@ var (
|
||||
procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
|
||||
procGetModuleHandleA = modkernel32.NewProc("GetModuleHandleA")
|
||||
procGetModuleHandleW = modkernel32.NewProc("GetModuleHandleW")
|
||||
procGetNativeSystemInfo = modkernel32.NewProc("GetNativeSystemInfo")
|
||||
procGetPrivateProfileStringA = modkernel32.NewProc("GetPrivateProfileStringA")
|
||||
procGetProcAddress = modkernel32.NewProc("GetProcAddress")
|
||||
procGetProcessHeap = modkernel32.NewProc("GetProcessHeap")
|
||||
@@ -253,6 +254,7 @@ var (
|
||||
procWfindfirst64i32 = moducrt.NewProc("_wfindfirst64i32")
|
||||
procWfindnext32 = moducrt.NewProc("_wfindnext32")
|
||||
procWfindnext64i32 = moducrt.NewProc("_wfindnext64i32")
|
||||
procWfullpath = moducrt.NewProc("_wfullpath")
|
||||
procWmkdir = moducrt.NewProc("_wmkdir")
|
||||
procWstat32 = moducrt.NewProc("_wstat32")
|
||||
procWstat64i32 = moducrt.NewProc("_wstat64i32")
|
||||
@@ -3832,6 +3834,18 @@ func XRtlGetVersion(t *TLS, lpVersionInformation uintptr) uintptr {
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
// void GetNativeSystemInfo(
|
||||
//
|
||||
// LPSYSTEM_INFO lpSystemInfo
|
||||
//
|
||||
// );
|
||||
func XGetNativeSystemInfo(t *TLS, lpSystemInfo uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v lpSystemInfo=%v, (%v:)", t, lpSystemInfo, origin(2))
|
||||
}
|
||||
procGetNativeSystemInfo.Call(lpSystemInfo, 0, 0)
|
||||
}
|
||||
|
||||
// void GetSystemInfo(
|
||||
//
|
||||
// LPSYSTEM_INFO lpSystemInfo
|
||||
@@ -7702,17 +7716,6 @@ func X__mingw_strtod(t *TLS, s uintptr, p uintptr) float64 {
|
||||
return Xstrtod(t, s, p)
|
||||
}
|
||||
|
||||
func Xstrtod(t *TLS, s uintptr, p uintptr) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v s=%v p=%v, (%v:)", t, s, p, origin(2))
|
||||
}
|
||||
r0, _, err := procStrtod.Call(uintptr(s), uintptr(p))
|
||||
if err != windows.NOERROR {
|
||||
t.setErrno(err)
|
||||
}
|
||||
return math.Float64frombits(uint64(r0))
|
||||
}
|
||||
|
||||
// int vsnprintf(char *str, size_t size, const char *format, va_list ap);
|
||||
func X_vsnprintf(t *TLS, str uintptr, size types.Size_t, format, ap uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
@@ -7809,6 +7812,21 @@ func X_wfindnext64i32(tls *TLS, handle types.Intptr_t, fileinfo uintptr) (r int3
|
||||
return int32(r0)
|
||||
}
|
||||
|
||||
// wchar_t *_wfullpath(
|
||||
//
|
||||
// wchar_t *absPath,
|
||||
// const wchar_t *relPath,
|
||||
// size_t maxLength
|
||||
//
|
||||
// );
|
||||
func X_wfullpath(tls *TLS, absPath, relPath uintptr, maxLength Tsize_t) (r uintptr) {
|
||||
r0, _, err := procWfullpath.Call(absPath, relPath, uintptr(maxLength))
|
||||
if err != windows.NOERROR {
|
||||
tls.setErrno(int32(err.(windows.Errno)))
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// int _wchmod( const wchar_t *filename, int pmode );
|
||||
func X_wchmod(tls *TLS, filename uintptr, pmode int32) (r int32) {
|
||||
r0, _, err := procWchmod.Call(filename, uintptr(pmode))
|
||||
@@ -7862,3 +7880,26 @@ func X_wstat32(tls *TLS, path, buffer uintptr) (r int32) {
|
||||
}
|
||||
return int32(r0)
|
||||
}
|
||||
|
||||
func Xbsearch(tls *TLS, key uintptr, base uintptr, nel Tsize_t, width Tsize_t, cmp uintptr) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v key=%v base=%v nel=%v width=%v cmp=%v, (%v:)", tls, key, base, nel, width, cmp, origin(2))
|
||||
}
|
||||
var try uintptr
|
||||
var sign int32
|
||||
for nel > 0 {
|
||||
try = base + uintptr(width*(nel/2))
|
||||
sign = (*struct {
|
||||
f func(*TLS, uintptr, uintptr) int32
|
||||
})(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try)
|
||||
if sign < 0 {
|
||||
nel /= 2
|
||||
} else if sign > 0 {
|
||||
base = try + uintptr(width)
|
||||
nel -= nel/2 + 1
|
||||
} else {
|
||||
return try
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
+12
@@ -727,3 +727,15 @@ func Xstrspn(tls *TLS, s uintptr, c uintptr) size_t { /* strspn.c:6:8: */
|
||||
}
|
||||
return size_t((int32(s) - int32(a)) / 1)
|
||||
}
|
||||
|
||||
// Defined in libc_windows_386.s
|
||||
func callStrtod(fn uintptr, s uintptr, p uintptr) float64
|
||||
|
||||
func Xstrtod(t *TLS, s uintptr, p uintptr) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v s=%v p=%v, (%v:)", t, s, p, origin(2))
|
||||
}
|
||||
// We use the assembly bridge to call the function pointer directly.
|
||||
// This ensures we capture the float return value from ST(0).
|
||||
return callStrtod(procStrtod.Addr(), s, p)
|
||||
}
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#include "textflag.h"
|
||||
|
||||
// func callStrtod(fn uintptr, s uintptr, p uintptr) float64
|
||||
TEXT ·callStrtod(SB), NOSPLIT, $0
|
||||
// 1. Initialize FPU
|
||||
// This ensures the x87 stack is empty (Tag Word = FFFF).
|
||||
// Without this, garbage on the stack causes the result push to overflow -> NaN.
|
||||
FINIT
|
||||
|
||||
// 2. Load arguments from Go stack
|
||||
MOVL fn+0(FP), AX // Function pointer
|
||||
MOVL s+4(FP), CX // String pointer
|
||||
MOVL p+8(FP), DX // Endptr pointer
|
||||
|
||||
// 3. Setup C stack for __cdecl
|
||||
SUBL $8, SP
|
||||
MOVL DX, 4(SP) // Push endptr
|
||||
MOVL CX, 0(SP) // Push str
|
||||
|
||||
// 4. Call the C function
|
||||
CALL AX
|
||||
|
||||
// 5. Clean up stack
|
||||
ADDL $8, SP
|
||||
|
||||
// 6. Store FPU result (ST0) into Go return slot
|
||||
FMOVD F0, ret+12(FP)
|
||||
|
||||
RET
|
||||
+15
-2
@@ -6,11 +6,13 @@ package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/windows"
|
||||
"modernc.org/libc/errno"
|
||||
"modernc.org/libc/sys/types"
|
||||
"math"
|
||||
"os"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"modernc.org/libc/errno"
|
||||
"modernc.org/libc/sys/types"
|
||||
)
|
||||
|
||||
// int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
|
||||
@@ -627,3 +629,14 @@ func Xstrspn(tls *TLS, s uintptr, c uintptr) size_t { /* strspn.c:6:8: */
|
||||
}
|
||||
return size_t((int64(s) - int64(a)) / 1)
|
||||
}
|
||||
|
||||
func Xstrtod(t *TLS, s uintptr, p uintptr) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v s=%v p=%v, (%v:)", t, s, p, origin(2))
|
||||
}
|
||||
_, r2, err := procStrtod.Call(uintptr(s), uintptr(p))
|
||||
if err != windows.NOERROR {
|
||||
t.setErrno(err)
|
||||
}
|
||||
return math.Float64frombits(uint64(r2))
|
||||
}
|
||||
|
||||
+10
@@ -627,3 +627,13 @@ func Xstrspn(tls *TLS, s uintptr, c uintptr) size_t { /* strspn.c:6:8: */
|
||||
}
|
||||
return size_t((int64(s) - int64(a)) / 1)
|
||||
}
|
||||
|
||||
// Defined in libc_windows_arm64.s
|
||||
func callStrtod(fn uintptr, s uintptr, p uintptr) float64
|
||||
|
||||
func Xstrtod(t *TLS, s uintptr, p uintptr) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v s=%v p=%v, (%v:)", t, s, p, origin(2))
|
||||
}
|
||||
return callStrtod(procStrtod.Addr(), s, p)
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#include "textflag.h"
|
||||
|
||||
// func callStrtod(fn uintptr, s uintptr, p uintptr) float64
|
||||
TEXT ·callStrtod(SB), NOSPLIT, $0
|
||||
// 1. Load arguments from Go stack
|
||||
// Go passes args on stack for ABI0 (assembly functions).
|
||||
MOVD fn+0(FP), R2 // Function address (use R2 as temp)
|
||||
MOVD s+8(FP), R0 // Arg 1: str -> x0 (R0 in Go ASM)
|
||||
MOVD p+16(FP), R1 // Arg 2: endptr -> x1 (R1 in Go ASM)
|
||||
|
||||
// 2. Call the C function
|
||||
// BL (Branch with Link) to the address in R2
|
||||
CALL R2
|
||||
|
||||
// 3. Handle Return Value
|
||||
// C returns double in d0 (F0 in Go ASM).
|
||||
// Go expects return value at ret+24(FP).
|
||||
FMOVD F0, ret+24(FP)
|
||||
|
||||
RET
|
||||
-23
@@ -1121,29 +1121,6 @@ func Xwcstombs(tls *TLS, s uintptr, ws uintptr, n size_t) size_t { /* wcstombs.c
|
||||
return Xwcsrtombs(tls, s, bp, n, uintptr(0))
|
||||
}
|
||||
|
||||
func Xbsearch(tls *TLS, key uintptr, base uintptr, nel size_t, width size_t, cmp uintptr) uintptr { /* bsearch.c:3:6: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v key=%v base=%v nel=%v width=%v cmp=%v, (%v:)", tls, key, base, nel, width, cmp, origin(2))
|
||||
}
|
||||
var try uintptr
|
||||
var sign int32
|
||||
for nel > uint64(0) {
|
||||
try = base + uintptr(width*(nel/uint64(2)))
|
||||
sign = (*struct {
|
||||
f func(*TLS, uintptr, uintptr) int32
|
||||
})(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try)
|
||||
if sign < 0 {
|
||||
nel = nel / uint64(2)
|
||||
} else if sign > 0 {
|
||||
base = try + uintptr(width)
|
||||
nel = nel - (nel/uint64(2) + uint64(1))
|
||||
} else {
|
||||
return try
|
||||
}
|
||||
}
|
||||
return uintptr(0)
|
||||
}
|
||||
|
||||
// Support signed or unsigned plain-char
|
||||
|
||||
// Implementation choices...
|
||||
|
||||
-23
@@ -1199,29 +1199,6 @@ func Xwcstombs(tls *TLS, s uintptr, ws uintptr, n size_t) size_t { /* wcstombs.c
|
||||
return Xwcsrtombs(tls, s, bp, n, uintptr(0))
|
||||
}
|
||||
|
||||
func Xbsearch(tls *TLS, key uintptr, base uintptr, nel size_t, width size_t, cmp uintptr) uintptr { /* bsearch.c:3:6: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v key=%v base=%v nel=%v width=%v cmp=%v, (%v:)", tls, key, base, nel, width, cmp, origin(2))
|
||||
}
|
||||
var try uintptr
|
||||
var sign int32
|
||||
for nel > uint64(0) {
|
||||
try = base + uintptr(width*(nel/uint64(2)))
|
||||
sign = (*struct {
|
||||
f func(*TLS, uintptr, uintptr) int32
|
||||
})(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try)
|
||||
if sign < 0 {
|
||||
nel = nel / uint64(2)
|
||||
} else if sign > 0 {
|
||||
base = try + uintptr(width)
|
||||
nel = nel - (nel/uint64(2) + uint64(1))
|
||||
} else {
|
||||
return try
|
||||
}
|
||||
}
|
||||
return uintptr(0)
|
||||
}
|
||||
|
||||
// Support signed or unsigned plain-char
|
||||
|
||||
// Implementation choices...
|
||||
|
||||
+59
@@ -483,6 +483,65 @@ func _pthread_sigmask(tls *TLS, now int32, set, old uintptr) int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
type barrierState struct {
|
||||
mu sync.Mutex
|
||||
cond *sync.Cond
|
||||
count uint32
|
||||
tripCount uint32
|
||||
generation uint32
|
||||
}
|
||||
|
||||
var (
|
||||
barriers = map[uintptr]*barrierState{}
|
||||
barriersMu sync.Mutex
|
||||
)
|
||||
|
||||
// int pthread_barrier_init(pthread_barrier_t *restrict barrier, const pthread_barrierattr_t *restrict attr, unsigned count);
|
||||
func Xpthread_barrier_init(tls *TLS, barrier, attr uintptr, count uint32) int32 {
|
||||
if count == 0 {
|
||||
return EINVAL
|
||||
}
|
||||
barriersMu.Lock()
|
||||
defer barriersMu.Unlock()
|
||||
state := &barrierState{tripCount: count}
|
||||
state.cond = sync.NewCond(&state.mu)
|
||||
barriers[barrier] = state
|
||||
return 0
|
||||
}
|
||||
|
||||
// int pthread_barrier_destroy(pthread_barrier_t *barrier);
|
||||
func Xpthread_barrier_destroy(tls *TLS, barrier uintptr) int32 {
|
||||
barriersMu.Lock()
|
||||
defer barriersMu.Unlock()
|
||||
delete(barriers, barrier)
|
||||
return 0
|
||||
}
|
||||
|
||||
// int pthread_barrier_wait(pthread_barrier_t *barrier);
|
||||
func Xpthread_barrier_wait(tls *TLS, barrier uintptr) int32 {
|
||||
barriersMu.Lock()
|
||||
state := barriers[barrier]
|
||||
barriersMu.Unlock()
|
||||
if state == nil {
|
||||
return EINVAL
|
||||
}
|
||||
state.mu.Lock()
|
||||
gen := state.generation
|
||||
state.count++
|
||||
if state.count >= state.tripCount {
|
||||
state.count = 0
|
||||
state.generation++
|
||||
state.cond.Broadcast()
|
||||
state.mu.Unlock()
|
||||
return -1 // PTHREAD_BARRIER_SERIAL_THREAD
|
||||
}
|
||||
for gen == state.generation {
|
||||
state.cond.Wait()
|
||||
}
|
||||
state.mu.Unlock()
|
||||
return 0
|
||||
}
|
||||
|
||||
// 202402251838 all_test.go:589: files=36 buildFails=30 execFails=2 pass=4
|
||||
// 202402262246 all_test.go:589: files=36 buildFails=26 execFails=2 pass=8
|
||||
// 202403041858 all_musl_test.go:640: files=36 buildFails=22 execFails=4 pass=10
|
||||
|
||||
+5
@@ -7660,6 +7660,7 @@ X__builtin_nanl
|
||||
X__builtin_object_size
|
||||
X__builtin_popcount
|
||||
X__builtin_popcountl
|
||||
X__builtin_popcountll
|
||||
X__builtin_prefetch
|
||||
X__builtin_printf
|
||||
X__builtin_rintf
|
||||
@@ -8859,6 +8860,9 @@ Xpthread_self
|
||||
Xpthread_setcancelstate
|
||||
Xpthread_setspecific
|
||||
Xpthread_sigmask
|
||||
Xpthread_barrier_destroy
|
||||
Xpthread_barrier_init
|
||||
Xpthread_barrier_wait
|
||||
Xptrace
|
||||
Xptsname
|
||||
Xptsname_r
|
||||
@@ -9046,6 +9050,7 @@ Xsrandom
|
||||
Xsscanf
|
||||
Xstat
|
||||
Xstat64
|
||||
Xstatfs
|
||||
Xstatvfs
|
||||
Xstatx
|
||||
Xstderr
|
||||
|
||||
+5
@@ -7654,6 +7654,7 @@ X__builtin_nanl
|
||||
X__builtin_object_size
|
||||
X__builtin_popcount
|
||||
X__builtin_popcountl
|
||||
X__builtin_popcountll
|
||||
X__builtin_prefetch
|
||||
X__builtin_printf
|
||||
X__builtin_rintf
|
||||
@@ -8756,6 +8757,9 @@ Xpthread_self
|
||||
Xpthread_setcancelstate
|
||||
Xpthread_setspecific
|
||||
Xpthread_sigmask
|
||||
Xpthread_barrier_destroy
|
||||
Xpthread_barrier_init
|
||||
Xpthread_barrier_wait
|
||||
Xptrace
|
||||
Xptsname
|
||||
Xptsname_r
|
||||
@@ -8934,6 +8938,7 @@ Xsrandom
|
||||
Xsscanf
|
||||
Xstat
|
||||
Xstat64
|
||||
Xstatfs
|
||||
Xstatvfs
|
||||
Xstatx
|
||||
Xstderr
|
||||
|
||||
Reference in New Issue
Block a user