Loading
Commits on Source 3
-
The shared libc_freebsd.go was hand-written assuming amd64: it stores int64 into time.Tm.Ftm_gmtoff (which is int32 on freebsd/386 and freebsd/arm), mixes raw uint64 literals with size_t arithmetic (size_t is uint32 on 32-bit FreeBSD), reads 8 bytes at a time in the strchrnul SWAR loop, and advances env pointers by hardcoded 8. None of this compiles on freebsd/386 or freebsd/arm. Fixes: * setTmGmtoff: new per-arch helper in libc_freebsd_{386,amd64,arm,arm64}.go, stores at the platform-native width matching time.Tm.Ftm_gmtoff. * assignSizeT / postIncSizeT: size_t analogues of AssignUint64 / PostIncUint64, added to libc_freebsd.go (works on every FreeBSD arch since size_t is the right width by definition). * Replace uint64(N) literals in setenv/__putenv/__env_rm_add with size_t(N) so they participate in size_t arithmetic at the native width. * Rewrite the strchrnul SWAR word loop to step by unsafe.Sizeof(size_t(0)) and read *(*size_t), so the all-ones / high-bit masks are computed at native word width. * Replace hardcoded *8 pointer-array indexing in env code with *unsafe.Sizeof(uintptr(0)) and "e += 8" with "e += unsafe.Sizeof(uintptr(0))". Verified with "go build ./..." and "go vet ./..." for GOOS=freebsd GOARCH={386,amd64,arm,arm64}; vet output is identical to the v1.72.3 baseline (no new warnings). -
cznic authored