mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 04:22:25 -06:00
bump to modernc.org/sqlite v1.29.7 (#2850)
This commit is contained in:
parent
c67bbe5ba0
commit
b3f2d44143
120 changed files with 631479 additions and 58069 deletions
4
vendor/modernc.org/libc/.gitignore
generated
vendored
Normal file
4
vendor/modernc.org/libc/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
*.gz
|
||||
*.zip
|
||||
go.work
|
||||
go.sum
|
||||
1
vendor/modernc.org/libc/AUTHORS
generated
vendored
1
vendor/modernc.org/libc/AUTHORS
generated
vendored
|
|
@ -14,4 +14,5 @@ Jan Mercl <0xjnml@gmail.com>
|
|||
Jason DeBettencourt <jasond17@gmail.com>
|
||||
Koichi Shiraishi <zchee.io@gmail.com>
|
||||
Marius Orcsik <marius@federated.id>
|
||||
Scot C Bontrager <scot@indievisible.org>
|
||||
Steffen Butzer <steffen(dot)butzer@outlook.com>
|
||||
|
|
|
|||
1
vendor/modernc.org/libc/CONTRIBUTORS
generated
vendored
1
vendor/modernc.org/libc/CONTRIBUTORS
generated
vendored
|
|
@ -13,5 +13,6 @@ Jan Mercl <0xjnml@gmail.com>
|
|||
Jason DeBettencourt <jasond17@gmail.com>
|
||||
Koichi Shiraishi <zchee.io@gmail.com>
|
||||
Marius Orcsik <marius@federated.id>
|
||||
Scot C Bontrager <scot@indievisible.org>
|
||||
Steffen Butzer <steffen(dot)butzer@outlook.com>
|
||||
ZHU Zijia <piggynl@outlook.com>
|
||||
|
|
|
|||
193
vendor/modernc.org/libc/COPYRIGHT-MUSL
generated
vendored
Normal file
193
vendor/modernc.org/libc/COPYRIGHT-MUSL
generated
vendored
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
musl as a whole is licensed under the following standard MIT license:
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Copyright © 2005-2020 Rich Felker, et al.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Authors/contributors include:
|
||||
|
||||
A. Wilcox
|
||||
Ada Worcester
|
||||
Alex Dowad
|
||||
Alex Suykov
|
||||
Alexander Monakov
|
||||
Andre McCurdy
|
||||
Andrew Kelley
|
||||
Anthony G. Basile
|
||||
Aric Belsito
|
||||
Arvid Picciani
|
||||
Bartosz Brachaczek
|
||||
Benjamin Peterson
|
||||
Bobby Bingham
|
||||
Boris Brezillon
|
||||
Brent Cook
|
||||
Chris Spiegel
|
||||
Clément Vasseur
|
||||
Daniel Micay
|
||||
Daniel Sabogal
|
||||
Daurnimator
|
||||
David Carlier
|
||||
David Edelsohn
|
||||
Denys Vlasenko
|
||||
Dmitry Ivanov
|
||||
Dmitry V. Levin
|
||||
Drew DeVault
|
||||
Emil Renner Berthing
|
||||
Fangrui Song
|
||||
Felix Fietkau
|
||||
Felix Janda
|
||||
Gianluca Anzolin
|
||||
Hauke Mehrtens
|
||||
He X
|
||||
Hiltjo Posthuma
|
||||
Isaac Dunham
|
||||
Jaydeep Patil
|
||||
Jens Gustedt
|
||||
Jeremy Huntwork
|
||||
Jo-Philipp Wich
|
||||
Joakim Sindholt
|
||||
John Spencer
|
||||
Julien Ramseier
|
||||
Justin Cormack
|
||||
Kaarle Ritvanen
|
||||
Khem Raj
|
||||
Kylie McClain
|
||||
Leah Neukirchen
|
||||
Luca Barbato
|
||||
Luka Perkov
|
||||
M Farkas-Dyck (Strake)
|
||||
Mahesh Bodapati
|
||||
Markus Wichmann
|
||||
Masanori Ogino
|
||||
Michael Clark
|
||||
Michael Forney
|
||||
Mikhail Kremnyov
|
||||
Natanael Copa
|
||||
Nicholas J. Kain
|
||||
orc
|
||||
Pascal Cuoq
|
||||
Patrick Oppenlander
|
||||
Petr Hosek
|
||||
Petr Skocik
|
||||
Pierre Carrier
|
||||
Reini Urban
|
||||
Rich Felker
|
||||
Richard Pennington
|
||||
Ryan Fairfax
|
||||
Samuel Holland
|
||||
Segev Finer
|
||||
Shiz
|
||||
sin
|
||||
Solar Designer
|
||||
Stefan Kristiansson
|
||||
Stefan O'Rear
|
||||
Szabolcs Nagy
|
||||
Timo Teräs
|
||||
Trutz Behn
|
||||
Valentin Ochs
|
||||
Will Dietz
|
||||
William Haddon
|
||||
William Pitcock
|
||||
|
||||
Portions of this software are derived from third-party works licensed
|
||||
under terms compatible with the above MIT license:
|
||||
|
||||
The TRE regular expression implementation (src/regex/reg* and
|
||||
src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed
|
||||
under a 2-clause BSD license (license text in the source files). The
|
||||
included version has been heavily modified by Rich Felker in 2012, in
|
||||
the interests of size, simplicity, and namespace cleanliness.
|
||||
|
||||
Much of the math library code (src/math/* and src/complex/*) is
|
||||
Copyright © 1993,2004 Sun Microsystems or
|
||||
Copyright © 2003-2011 David Schultz or
|
||||
Copyright © 2003-2009 Steven G. Kargl or
|
||||
Copyright © 2003-2009 Bruce D. Evans or
|
||||
Copyright © 2008 Stephen L. Moshier or
|
||||
Copyright © 2017-2018 Arm Limited
|
||||
and labelled as such in comments in the individual source files. All
|
||||
have been licensed under extremely permissive terms.
|
||||
|
||||
The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008
|
||||
The Android Open Source Project and is licensed under a two-clause BSD
|
||||
license. It was taken from Bionic libc, used on Android.
|
||||
|
||||
The AArch64 memcpy and memset code (src/string/aarch64/*) are
|
||||
Copyright © 1999-2019, Arm Limited.
|
||||
|
||||
The implementation of DES for crypt (src/crypt/crypt_des.c) is
|
||||
Copyright © 1994 David Burren. It is licensed under a BSD license.
|
||||
|
||||
The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was
|
||||
originally written by Solar Designer and placed into the public
|
||||
domain. The code also comes with a fallback permissive license for use
|
||||
in jurisdictions that may not recognize the public domain.
|
||||
|
||||
The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
|
||||
Valentin Ochs and is licensed under an MIT-style license.
|
||||
|
||||
The x86_64 port was written by Nicholas J. Kain and is licensed under
|
||||
the standard MIT terms.
|
||||
|
||||
The mips and microblaze ports were originally written by Richard
|
||||
Pennington for use in the ellcc project. The original code was adapted
|
||||
by Rich Felker for build system and code conventions during upstream
|
||||
integration. It is licensed under the standard MIT terms.
|
||||
|
||||
The mips64 port was contributed by Imagination Technologies and is
|
||||
licensed under the standard MIT terms.
|
||||
|
||||
The powerpc port was also originally written by Richard Pennington,
|
||||
and later supplemented and integrated by John Spencer. It is licensed
|
||||
under the standard MIT terms.
|
||||
|
||||
All other files which have no copyright comments are original works
|
||||
produced specifically for use as part of this library, written either
|
||||
by Rich Felker, the main author of the library, or by one or more
|
||||
contibutors listed above. Details on authorship of individual files
|
||||
can be found in the git version control history of the project. The
|
||||
omission of copyright and license comments in each file is in the
|
||||
interest of source tree size.
|
||||
|
||||
In addition, permission is hereby granted for all public header files
|
||||
(include/* and arch/*/bits/*) and crt files intended to be linked into
|
||||
applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit
|
||||
the copyright notice and permission notice otherwise required by the
|
||||
license, and to use these files without any requirement of
|
||||
attribution. These files include substantial contributions from:
|
||||
|
||||
Bobby Bingham
|
||||
John Spencer
|
||||
Nicholas J. Kain
|
||||
Rich Felker
|
||||
Richard Pennington
|
||||
Stefan Kristiansson
|
||||
Szabolcs Nagy
|
||||
|
||||
all of whom have explicitly granted such permission.
|
||||
|
||||
This file previously contained text expressing a belief that most of
|
||||
the files covered by the above exception were sufficiently trivial not
|
||||
to be subject to copyright, resulting in confusion over whether it
|
||||
negated the permissions granted in the license. In the spirit of
|
||||
permissive licensing, and of not having licensing issues being an
|
||||
obstacle to adoption, that text has been removed.
|
||||
3
vendor/modernc.org/libc/HACKING
generated
vendored
3
vendor/modernc.org/libc/HACKING
generated
vendored
|
|
@ -1,3 +0,0 @@
|
|||
Install:
|
||||
|
||||
$ go get modernc.org/libc
|
||||
265
vendor/modernc.org/libc/Makefile
generated
vendored
265
vendor/modernc.org/libc/Makefile
generated
vendored
|
|
@ -1,197 +1,116 @@
|
|||
# Copyright 2019 The Libc Authors. All rights reserved.
|
||||
# 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.
|
||||
|
||||
.PHONY: all bench build_all_targets clean cover cpu editor internalError later mem nuke todo edit work devbench \
|
||||
darwin_amd64 \
|
||||
darwin_arm64 \
|
||||
linux_386 \
|
||||
linux_amd64 \
|
||||
linux_arm \
|
||||
linux_arm64 \
|
||||
strace \
|
||||
.PHONY: all build_all_targets check clean download edit editor generate dev membrk-test test work xtest short-test xlibc libc-test surface
|
||||
|
||||
SHELL=/bin/bash -o pipefail
|
||||
|
||||
grep=--include=*.go --include=*.l --include=*.y --include=*.yy --include=*.qbe --include=*.ssa
|
||||
ngrep='internalError\|TODOOK'
|
||||
log=log-$(shell go env GOOS)-$(shell go env GOARCH)
|
||||
DIR = /tmp/libc
|
||||
TAR = musl-7ada6dde6f9dc6a2836c3d92c2f762d35fd229e0.tar.gz
|
||||
URL = https://git.musl-libc.org/cgit/musl/snapshot/$(TAR)
|
||||
|
||||
all:
|
||||
date
|
||||
go version 2>&1 | tee $(log)
|
||||
go generate
|
||||
gofmt -l -s -w *.go
|
||||
go install -v ./...
|
||||
go test
|
||||
go test 2>&1 -timeout 1h | tee -a $(log)
|
||||
# go vet -unsafeptr=false 2>&1 | grep -v $(ngrep) || true
|
||||
# golint 2>&1 | grep -v $(ngrep) || true
|
||||
# make todo
|
||||
# misspell *.go
|
||||
# staticcheck || true
|
||||
grep -n 'FAIL\|PASS' $(log)
|
||||
go version
|
||||
date 2>&1 | tee -a $(log)
|
||||
all: editor
|
||||
golint 2>&1
|
||||
staticcheck 2>&1
|
||||
|
||||
build_all_targets:
|
||||
./build_all_targets.sh
|
||||
echo done
|
||||
|
||||
darwin_amd64:
|
||||
@echo "Should be executed only on darwin/amd64."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
darwin_arm64:
|
||||
@echo "Should be executed only on darwin/arm64."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
# only on freebsd/amd64
|
||||
freebsd_amd64:
|
||||
@echo "Should be executed only on freebsd/amd64."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
# only on freebsd/386
|
||||
freebsd_386:
|
||||
@echo "Should be executed only on freebsd/386."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
# only on freebsd/arm
|
||||
freebsd_arm:
|
||||
@echo "Should be executed only on freebsd/arm."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
freebsd_arm64:
|
||||
go run addport.go freebsd_amd64 freebsd_arm64
|
||||
go build -v ./...
|
||||
|
||||
# only on netbsd/amd64
|
||||
netbsd_amd64:
|
||||
@echo "Should be executed only on netbsd/amd64."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
# only on netbsd/arm
|
||||
netbsd_arm:
|
||||
@echo "Should be executed only on netbsd/arm."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
linux_amd64:
|
||||
@echo "Should be executed only on linux/amd64."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
linux_386:
|
||||
CCGO_CPP=i686-linux-gnu-cpp TARGET_GOOS=linux TARGET_GOARCH=386 go generate
|
||||
GOOS=linux GOARCH=386 go build -v ./...
|
||||
|
||||
linux_arm:
|
||||
CCGO_CPP=arm-linux-gnueabi-cpp TARGET_GOOS=linux TARGET_GOARCH=arm go generate
|
||||
GOOS=linux GOARCH=arm go build -v ./...
|
||||
|
||||
linux_arm64:
|
||||
CCGO_CPP=aarch64-linux-gnu-cpp TARGET_GOOS=linux TARGET_GOARCH=arm64 go generate
|
||||
GOOS=linux GOARCH=arm64 go build -v ./...
|
||||
|
||||
linux_s390x:
|
||||
CCGO_CPP=s390x-linux-gnu-cpp TARGET_GOOS=linux TARGET_GOARCH=s390x go generate
|
||||
GOOS=linux GOARCH=s390x go build -v ./...
|
||||
|
||||
linux_ppc64le:
|
||||
CCGO_CPP=powerpc64le-linux-gnu-cpp TARGET_GOOS=linux TARGET_GOARCH=ppc64le go generate
|
||||
GOOS=linux GOARCH=ppc64le go build -v ./...
|
||||
|
||||
# only on openbsd/amd64
|
||||
openbsd_amd64:
|
||||
@echo "Should be executed only on openbsd/amd64."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
#
|
||||
# only on openbsd/386
|
||||
openbsd_386:
|
||||
@echo "Should be executed only on openbsd/386."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
# only on openbsd/arm64
|
||||
openbsd_arm64:
|
||||
@echo "Should be executed only on openbsd/arm64."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
windows_amd64:
|
||||
@echo "Should be executed only on windows/amd64."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
windows_arm64:
|
||||
@echo "Should be executed only on windows/arm64."
|
||||
go generate 2>&1 | tee log-generate
|
||||
go build -v ./...
|
||||
|
||||
windows_386:
|
||||
@echo "Should be executed only on linux/amd64."
|
||||
CCGO_CPP=i686-w64-mingw32-cpp TARGET_GOOS=windows TARGET_GOARCH=386 go generate
|
||||
GOOS=windows GOARCH=386 go build -v ./...
|
||||
|
||||
all_targets: linux_amd64 linux_386 linux_arm linux_arm64 linux_s390x # windows_amd64 windows_386
|
||||
echo done
|
||||
|
||||
devbench:
|
||||
date 2>&1 | tee log-devbench
|
||||
go test -timeout 24h -dev -run @ -bench . 2>&1 | tee -a log-devbench
|
||||
grep -n 'FAIL\|SKIP' log-devbench || true
|
||||
|
||||
bench:
|
||||
date 2>&1 | tee log-bench
|
||||
go test -timeout 24h -v -run '^[^E]' -bench . 2>&1 | tee -a log-bench
|
||||
grep -n 'FAIL\|SKIP' log-bench || true
|
||||
|
||||
clean:
|
||||
rm -f log-* cpu.test mem.test *.out
|
||||
git clean -fd
|
||||
find testdata/nsz.repo.hu/ -name \*.go -delete
|
||||
make -C testdata/nsz.repo.hu/libc-test/ cleanall
|
||||
go clean
|
||||
rm -f *~ *.test *.out
|
||||
|
||||
cover:
|
||||
t=$(shell mktemp) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t
|
||||
check:
|
||||
staticcheck 2>&1 | grep -v U1000
|
||||
|
||||
cpu: clean
|
||||
go test -run @ -bench . -cpuprofile cpu.out
|
||||
go tool pprof -lines *.test cpu.out
|
||||
download:
|
||||
@if [ ! -f $(TAR) ]; then wget $(URL) ; fi
|
||||
|
||||
edit:
|
||||
@touch log
|
||||
@if [ -f "Session.vim" ]; then novim -S & else novim -p Makefile libc.go & fi
|
||||
@if [ -f "Session.vim" ]; then novim -S & else novim -p Makefile all_musl_test.go generator.go libc.go libc_musl.go & fi
|
||||
|
||||
editor:
|
||||
# go generate 2>&1 | tee log
|
||||
gofmt -l -s -w *.go
|
||||
go test -short 2>&1 | tee -a log
|
||||
go install -v ./...
|
||||
go build -o /dev/null generate.go
|
||||
go build -o /dev/null strace.go
|
||||
gofmt -l -s -w *.go 2>&1 | tee log-editor
|
||||
go test -c -o /dev/null 2>&1 | tee -a log-editor
|
||||
go install -v 2>&1 | tee -a log-editor
|
||||
go build -o /dev/null generator*.go
|
||||
|
||||
later:
|
||||
@grep -n $(grep) LATER * || true
|
||||
@grep -n $(grep) MAYBE * || true
|
||||
generate: download
|
||||
mkdir -p $(DIR) || true
|
||||
rm -rf $(DIR)/*
|
||||
GO_GENERATE_DIR=$(DIR) go run generator*.go 2>&1 | tee log-generate
|
||||
go build -v
|
||||
# go install github.com/mdempsky/unconvert@latest
|
||||
go build -v 2>&1 | tee -a log-generate
|
||||
go test -v -short -count=1 ./... | tee -a log-generate
|
||||
git status | tee -a log-generate
|
||||
grep 'TRC\|TODO\|ERRORF\|FAIL' log-generate || true
|
||||
|
||||
mem: clean
|
||||
go test -v -run ParserCS -memprofile mem.out -timeout 24h
|
||||
go tool pprof -lines -web -alloc_space *.test mem.out
|
||||
dev: download
|
||||
mkdir -p $(DIR) || true
|
||||
rm -rf $(DIR)/*
|
||||
echo -n > /tmp/ccgo.log
|
||||
GO_GENERATE_DIR=$(DIR) GO_GENERATE_DEV=1 go run -tags=ccgo.dmesg,ccgo.assert generator*.go 2>&1 | tee log-generate
|
||||
go build -v | tee -a log-generate
|
||||
go test -v -short -count=1 ./... | tee -a log-generate
|
||||
git status | tee -a log-generate
|
||||
grep 'TRC\|TODO\|ERRORF\|FAIL' log-generate || true
|
||||
grep 'TRC\|TODO\|ERRORF\|FAIL' /tmp/ccgo.log || true
|
||||
|
||||
nuke: clean
|
||||
go clean -i
|
||||
membrk-test:
|
||||
echo -n > /tmp/ccgo.log
|
||||
touch log-test
|
||||
cp log-test log-test0
|
||||
go test -v -timeout 24h -count=1 -tags=libc.membrk 2>&1 | tee log-test
|
||||
grep -a 'TRC\|TODO\|ERRORF\|FAIL' log-test || true 2>&1 | tee -a log-test
|
||||
|
||||
todo:
|
||||
@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true
|
||||
@grep -nr $(grep) 'TODO\|panic' * | grep -v $(ngrep) || true
|
||||
@grep -nr $(grep) BUG * | grep -v $(ngrep) || true
|
||||
@grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true
|
||||
@grep -nir $(grep) 'work.*progress' || true
|
||||
test:
|
||||
echo -n > /tmp/ccgo.log
|
||||
touch log-test
|
||||
cp log-test log-test0
|
||||
go test -v -timeout 24h -count=1 2>&1 | tee log-test
|
||||
|
||||
short-test:
|
||||
echo -n > /tmp/ccgo.log
|
||||
touch log-test
|
||||
cp log-test log-test0
|
||||
go test -v -timeout 24h -count=1 -short 2>&1 | tee log-test
|
||||
grep -a 'TRC\|TODO\|ERRORF\|FAIL' log-test || true 2>&1 | tee -a log-test
|
||||
|
||||
xlibc:
|
||||
echo -n > /tmp/ccgo.log
|
||||
touch log-test
|
||||
cp log-test log-test0
|
||||
go test -v -timeout 24h -count=1 -tags=ccgo.dmesg,ccgo.assert 2>&1 -run TestLibc | tee log-test
|
||||
grep -a 'TRC\|TODO\|ERRORF\|FAIL' log-test || true 2>&1 | tee -a log-test
|
||||
|
||||
xpthread:
|
||||
echo -n > /tmp/ccgo.log
|
||||
touch log-test
|
||||
cp log-test log-test0
|
||||
go test -v -timeout 24h -count=1 2>&1 -run TestLibc -re pthread | tee log-test
|
||||
grep -a 'TRC\|TODO\|ERRORF\|FAIL' log-test || true 2>&1 | tee -a log-test
|
||||
|
||||
libc-test:
|
||||
echo -n > /tmp/ccgo.log
|
||||
touch log-test
|
||||
cp log-test log-test0
|
||||
go test -v -timeout 24h -count=1 2>&1 -run TestLibc | tee log-test
|
||||
# grep -a 'TRC\|TODO\|ERRORF\|FAIL' log-test || true 2>&1 | tee -a log-test
|
||||
grep -o 'undefined: \<.*\>' log-test | sort -u
|
||||
|
||||
xtest:
|
||||
echo -n > /tmp/ccgo.log
|
||||
touch log-test
|
||||
cp log-test log-test0
|
||||
go test -v -timeout 24h -count=1 -tags=ccgo.dmesg,ccgo.assert 2>&1 | tee log-test
|
||||
grep -a 'TRC\|TODO\|ERRORF\|FAIL' log-test || true 2>&1 | tee -a log-test
|
||||
|
||||
work:
|
||||
rm -f go.work*
|
||||
|
|
@ -201,6 +120,6 @@ work:
|
|||
go work use ../ccgo/v3
|
||||
go work use ../cc/v4
|
||||
|
||||
strace:
|
||||
go run strace.go
|
||||
go build -v ./...
|
||||
surface:
|
||||
surface > surface.new
|
||||
surface surface.old surface.new > log-todo-surface || true
|
||||
|
|
|
|||
109
vendor/modernc.org/libc/aliases.go
generated
vendored
Normal file
109
vendor/modernc.org/libc/aliases.go
generated
vendored
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
// 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 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
func X__vm_wait(tls *TLS) {}
|
||||
|
||||
// static volatile int *const dummy_lockptr = 0;
|
||||
//
|
||||
// weak_alias(dummy_lockptr, __atexit_lockptr);
|
||||
// weak_alias(dummy_lockptr, __bump_lockptr);
|
||||
// weak_alias(dummy_lockptr, __sem_open_lockptr);
|
||||
var X__atexit_lockptr int32
|
||||
var X__bump_lockptr int32
|
||||
var X__sem_open_lockptr int32
|
||||
|
||||
// static int dummy(int fd)
|
||||
//
|
||||
// {
|
||||
// return fd;
|
||||
// }
|
||||
//
|
||||
// weak_alias(dummy, __aio_close);
|
||||
func X__aio_close(tls *TLS, fd int32) int32 {
|
||||
return fd
|
||||
}
|
||||
|
||||
func Xtzset(tls *TLS) {
|
||||
___tzset(tls)
|
||||
}
|
||||
|
||||
type DIR = TDIR
|
||||
|
||||
const DT_DETACHED = _DT_DETACHED
|
||||
|
||||
const DT_EXITING = _DT_EXITING
|
||||
|
||||
const DT_JOINABLE = _DT_JOINABLE
|
||||
|
||||
type FILE = TFILE
|
||||
|
||||
type HEADER = THEADER
|
||||
|
||||
func Xfcntl64(tls *TLS, fd int32, cmd int32, va uintptr) (r int32) {
|
||||
return Xfcntl(tls, fd, cmd, va)
|
||||
}
|
||||
|
||||
func Xfopen64(tls *TLS, filename uintptr, mode uintptr) (r uintptr) {
|
||||
return Xfopen(tls, filename, mode)
|
||||
}
|
||||
|
||||
func Xfstat64(tls *TLS, fd int32, st uintptr) (r int32) {
|
||||
return Xfstat(tls, fd, st)
|
||||
}
|
||||
|
||||
func Xftruncate64(tls *TLS, fd int32, length Toff_t) (r int32) {
|
||||
return Xftruncate(tls, fd, length)
|
||||
}
|
||||
|
||||
func Xgetrlimit64(tls *TLS, resource int32, rlim uintptr) (r int32) {
|
||||
return Xgetrlimit(tls, resource, rlim)
|
||||
}
|
||||
|
||||
func Xlseek64(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) {
|
||||
return Xlseek(tls, fd, offset, whence)
|
||||
}
|
||||
|
||||
func Xlstat64(tls *TLS, path uintptr, buf uintptr) (r int32) {
|
||||
return Xlstat(tls, path, buf)
|
||||
}
|
||||
|
||||
func Xmkstemp64(tls *TLS, template uintptr) (r int32) {
|
||||
return Xmkstemp(tls, template)
|
||||
}
|
||||
|
||||
func Xmkstemps64(tls *TLS, template uintptr, len1 int32) (r int32) {
|
||||
return Xmkstemps(tls, template, len1)
|
||||
}
|
||||
|
||||
func Xmmap64(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) {
|
||||
return Xmmap(tls, start, len1, prot, flags, fd, off)
|
||||
}
|
||||
|
||||
func Xopen64(tls *TLS, filename uintptr, flags int32, va uintptr) (r int32) {
|
||||
return Xopen(tls, filename, flags, va)
|
||||
}
|
||||
|
||||
func Xreaddir64(tls *TLS, dir uintptr) (r uintptr) {
|
||||
return Xreaddir(tls, dir)
|
||||
}
|
||||
|
||||
func Xsetrlimit64(tls *TLS, resource int32, rlim uintptr) (r int32) {
|
||||
return Xsetrlimit(tls, resource, rlim)
|
||||
}
|
||||
|
||||
func Xstat64(tls *TLS, path uintptr, buf uintptr) (r int32) {
|
||||
return Xstat(tls, path, buf)
|
||||
}
|
||||
|
||||
func Xpthread_setcancelstate(tls *TLS, new int32, old uintptr) int32 {
|
||||
return _pthread_setcancelstate(tls, new, old)
|
||||
}
|
||||
|
||||
func Xpthread_sigmask(tls *TLS, now int32, set, old uintptr) int32 {
|
||||
return _pthread_sigmask(tls, now, set, old)
|
||||
}
|
||||
114
vendor/modernc.org/libc/atomic.go
generated
vendored
Normal file
114
vendor/modernc.org/libc/atomic.go
generated
vendored
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
// 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 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc/v2"
|
||||
|
||||
import (
|
||||
"math"
|
||||
"math/bits"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func a_store_8(addr uintptr, val int8) int8 {
|
||||
*(*int8)(unsafe.Pointer(addr)) = val
|
||||
return val
|
||||
}
|
||||
|
||||
func a_load_8(addr uintptr) (val int8) {
|
||||
return *(*int8)(unsafe.Pointer(addr))
|
||||
}
|
||||
|
||||
func a_load_16(addr uintptr) (val int16) {
|
||||
if addr&1 != 0 {
|
||||
panic("unaligned atomic access")
|
||||
}
|
||||
|
||||
return *(*int16)(unsafe.Pointer(addr))
|
||||
}
|
||||
|
||||
func a_store_16(addr uintptr, val uint16) {
|
||||
if addr&1 != 0 {
|
||||
panic("unaligned atomic access")
|
||||
}
|
||||
|
||||
*(*uint16)(unsafe.Pointer(addr)) = val
|
||||
}
|
||||
|
||||
// static inline int a_ctz_l(unsigned long x)
|
||||
func _a_ctz_l(tls *TLS, x ulong) int32 {
|
||||
if unsafe.Sizeof(x) == 8 {
|
||||
return int32(bits.TrailingZeros64(x))
|
||||
}
|
||||
|
||||
return int32(bits.TrailingZeros32(uint32(x)))
|
||||
}
|
||||
|
||||
// static inline int a_ctz_64(uint64_t x)
|
||||
func _a_ctz_64(tls *TLS, x uint64) int32 {
|
||||
return int32(bits.TrailingZeros64(x))
|
||||
}
|
||||
|
||||
func AtomicAddFloat32(addr *float32, delta float32) (new float32) {
|
||||
v := AtomicLoadFloat32(addr) + delta
|
||||
AtomicStoreFloat32(addr, v)
|
||||
return v
|
||||
}
|
||||
|
||||
func AtomicLoadFloat32(addr *float32) (val float32) {
|
||||
return math.Float32frombits(atomic.LoadUint32((*uint32)(unsafe.Pointer(addr))))
|
||||
}
|
||||
|
||||
func AtomicStoreFloat32(addr *float32, val float32) {
|
||||
atomic.StoreUint32((*uint32)(unsafe.Pointer(addr)), math.Float32bits(val))
|
||||
}
|
||||
|
||||
func AtomicAddFloat64(addr *float64, delta float64) (new float64) {
|
||||
v := AtomicLoadFloat64(addr) + delta
|
||||
AtomicStoreFloat64(addr, v)
|
||||
return v
|
||||
}
|
||||
|
||||
func AtomicLoadFloat64(addr *float64) (val float64) {
|
||||
return math.Float64frombits(atomic.LoadUint64((*uint64)(unsafe.Pointer(addr))))
|
||||
}
|
||||
|
||||
func AtomicStoreFloat64(addr *float64, val float64) {
|
||||
atomic.StoreUint64((*uint64)(unsafe.Pointer(addr)), math.Float64bits(val))
|
||||
}
|
||||
|
||||
func AtomicAddInt32(addr *int32, delta int32) (new int32) { return atomic.AddInt32(addr, delta) }
|
||||
|
||||
func AtomicAddInt64(addr *int64, delta int64) (new int64) { return atomic.AddInt64(addr, delta) }
|
||||
|
||||
func AtomicAddUint32(addr *uint32, delta uint32) (new uint32) { return atomic.AddUint32(addr, delta) }
|
||||
|
||||
func AtomicAddUint64(addr *uint64, delta uint64) (new uint64) { return atomic.AddUint64(addr, delta) }
|
||||
|
||||
func AtomicAddUintptr(addr *uintptr, delta uintptr) (new uintptr) {
|
||||
return atomic.AddUintptr(addr, delta)
|
||||
|
||||
}
|
||||
|
||||
func AtomicLoadInt32(addr *int32) (val int32) { return atomic.LoadInt32(addr) }
|
||||
|
||||
func AtomicLoadInt64(addr *int64) (val int64) { return atomic.LoadInt64(addr) }
|
||||
|
||||
func AtomicLoadUint32(addr *uint32) (val uint32) { return atomic.LoadUint32(addr) }
|
||||
|
||||
func AtomicLoadUint64(addr *uint64) (val uint64) { return atomic.LoadUint64(addr) }
|
||||
|
||||
func AtomicLoadUintptr(addr *uintptr) (val uintptr) { return atomic.LoadUintptr(addr) }
|
||||
|
||||
func AtomicStoreInt32(addr *int32, val int32) { atomic.StoreInt32(addr, val) }
|
||||
|
||||
func AtomicStoreUint32(addr *uint32, val uint32) { atomic.StoreUint32(addr, val) }
|
||||
|
||||
func AtomicStoreUint64(addr *uint64, val uint64) { atomic.StoreUint64(addr, val) }
|
||||
|
||||
func AtomicStoreUintptr(addr *uintptr, val uintptr) { atomic.StoreUintptr(addr, val) }
|
||||
|
||||
func AtomicStoreInt64(addr *int64, val int64) { atomic.StoreInt64(addr, val) }
|
||||
9
vendor/modernc.org/libc/builder.json
generated
vendored
Normal file
9
vendor/modernc.org/libc/builder.json
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"autogen": "linux/(amd64|loong64)",
|
||||
"autoupdate": "",
|
||||
"autotag": "darwin/(amd64|arm64)|freebsd/(amd64|arm64)|linux/(386|amd64|arm|arm64|loong64|ppc64le|riscv64|s390x)|openbsd/(386|amd64|arm64)|windows/(amd64|arm64)",
|
||||
"download": [
|
||||
{"re": "linux/(amd64|loong64)", "files": ["https://git.musl-libc.org/cgit/musl/snapshot/musl-7ada6dde6f9dc6a2836c3d92c2f762d35fd229e0.tar.gz"]}
|
||||
],
|
||||
"test": "darwin/(amd64|arm64)|freebsd/(amd64|arm64)|linux/(386|amd64|arm|arm64|loong64|ppc64le|riscv64|s390x)|openbsd/(386|amd64|arm64)|windows/(amd64|arm64)"
|
||||
}
|
||||
439
vendor/modernc.org/libc/builtin.go
generated
vendored
Normal file
439
vendor/modernc.org/libc/builtin.go
generated
vendored
Normal file
|
|
@ -0,0 +1,439 @@
|
|||
// 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 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
mbits "math/bits"
|
||||
"os"
|
||||
"unsafe"
|
||||
|
||||
"modernc.org/mathutil"
|
||||
)
|
||||
|
||||
func X__builtin_inff(tls *TLS) float32 {
|
||||
return float32(math.Inf(1))
|
||||
}
|
||||
|
||||
func X__builtin_nanf(tls *TLS, s uintptr) float32 {
|
||||
return float32(math.NaN())
|
||||
}
|
||||
|
||||
func X__builtin_printf(tls *TLS, fmt uintptr, va uintptr) (r int32) {
|
||||
return Xprintf(tls, fmt, va)
|
||||
}
|
||||
|
||||
func X__builtin_round(tls *TLS, x float64) (r float64) {
|
||||
return Xround(tls, x)
|
||||
}
|
||||
|
||||
func X__builtin_expect(t *TLS, exp, c long) long {
|
||||
return exp
|
||||
}
|
||||
|
||||
func X__builtin_bzero(t *TLS, s uintptr, n Tsize_t) {
|
||||
Xbzero(t, s, n)
|
||||
}
|
||||
|
||||
func X__builtin_abort(t *TLS) {
|
||||
Xabort(t)
|
||||
}
|
||||
|
||||
func X__builtin_abs(t *TLS, j int32) int32 {
|
||||
return Xabs(t, j)
|
||||
}
|
||||
|
||||
func X__builtin_ctz(t *TLS, n uint32) int32 {
|
||||
return int32(mbits.TrailingZeros32(n))
|
||||
}
|
||||
|
||||
func X__builtin_clz(t *TLS, n uint32) int32 {
|
||||
return int32(mbits.LeadingZeros32(n))
|
||||
}
|
||||
|
||||
func X__builtin_clzl(t *TLS, n ulong) int32 {
|
||||
return int32(mbits.LeadingZeros64(n))
|
||||
}
|
||||
|
||||
func X__builtin_clzll(t *TLS, n uint64) int32 {
|
||||
return int32(mbits.LeadingZeros64(n))
|
||||
}
|
||||
func X__builtin_constant_p_impl() { panic(todo("internal error: should never be called")) }
|
||||
|
||||
func X__builtin_copysign(t *TLS, x, y float64) float64 {
|
||||
return Xcopysign(t, x, y)
|
||||
}
|
||||
|
||||
func X__builtin_copysignf(t *TLS, x, y float32) float32 {
|
||||
return Xcopysignf(t, x, y)
|
||||
}
|
||||
|
||||
func X__builtin_copysignl(t *TLS, x, y float64) float64 {
|
||||
return Xcopysign(t, x, y)
|
||||
}
|
||||
|
||||
func X__builtin_exit(t *TLS, status int32) {
|
||||
Xexit(t, status)
|
||||
}
|
||||
|
||||
func X__builtin_fabs(t *TLS, x float64) float64 {
|
||||
return Xfabs(t, x)
|
||||
}
|
||||
|
||||
func X__builtin_fabsf(t *TLS, x float32) float32 {
|
||||
return Xfabsf(t, x)
|
||||
}
|
||||
|
||||
func X__builtin_fabsl(t *TLS, x float64) float64 {
|
||||
return Xfabsl(t, x)
|
||||
}
|
||||
|
||||
func X__builtin_free(t *TLS, ptr uintptr) {
|
||||
Xfree(t, ptr)
|
||||
}
|
||||
|
||||
func X__builtin_getentropy(t *TLS, buf uintptr, n Tsize_t) int32 {
|
||||
return Xgetentropy(t, buf, n)
|
||||
}
|
||||
|
||||
func X__builtin_huge_val(t *TLS) float64 {
|
||||
return math.Inf(1)
|
||||
}
|
||||
|
||||
func X__builtin_huge_valf(t *TLS) float32 {
|
||||
return float32(math.Inf(1))
|
||||
}
|
||||
|
||||
func X__builtin_inf(t *TLS) float64 {
|
||||
return math.Inf(1)
|
||||
}
|
||||
|
||||
func X__builtin_infl(t *TLS) float64 {
|
||||
return math.Inf(1)
|
||||
}
|
||||
|
||||
func X__builtin_malloc(t *TLS, size Tsize_t) uintptr {
|
||||
return Xmalloc(t, size)
|
||||
}
|
||||
|
||||
func X__builtin_memcmp(t *TLS, s1, s2 uintptr, n Tsize_t) int32 {
|
||||
return Xmemcmp(t, s1, s2, n)
|
||||
}
|
||||
|
||||
func X__builtin_nan(t *TLS, s uintptr) float64 {
|
||||
return math.NaN()
|
||||
}
|
||||
|
||||
func X__builtin_nanl(t *TLS, s uintptr) float64 {
|
||||
return math.NaN()
|
||||
}
|
||||
|
||||
func X__builtin_prefetch(t *TLS, addr, args uintptr) {
|
||||
}
|
||||
|
||||
func X__builtin_strchr(t *TLS, s uintptr, c int32) uintptr {
|
||||
return Xstrchr(t, s, c)
|
||||
}
|
||||
|
||||
func X__builtin_strcmp(t *TLS, s1, s2 uintptr) int32 {
|
||||
return Xstrcmp(t, s1, s2)
|
||||
}
|
||||
|
||||
func X__builtin_strcpy(t *TLS, dest, src uintptr) uintptr {
|
||||
return Xstrcpy(t, dest, src)
|
||||
}
|
||||
|
||||
func X__builtin_strlen(t *TLS, s uintptr) Tsize_t {
|
||||
return Xstrlen(t, s)
|
||||
}
|
||||
|
||||
func X__builtin_trap(t *TLS) {
|
||||
Xabort(t)
|
||||
}
|
||||
|
||||
func X__builtin_popcount(t *TLS, x uint32) int32 {
|
||||
return int32(mbits.OnesCount32(x))
|
||||
}
|
||||
|
||||
// int __builtin_popcountl (unsigned long x)
|
||||
func X__builtin_popcountl(t *TLS, x ulong) int32 {
|
||||
return int32(mbits.OnesCount64(x))
|
||||
}
|
||||
|
||||
// char * __builtin___strcpy_chk (char *dest, const char *src, size_t os);
|
||||
func X__builtin___strcpy_chk(t *TLS, dest, src uintptr, os Tsize_t) uintptr {
|
||||
return Xstrcpy(t, dest, src)
|
||||
}
|
||||
|
||||
func X__builtin_mmap(t *TLS, addr uintptr, length Tsize_t, prot, flags, fd int32, offset Toff_t) uintptr {
|
||||
return Xmmap(t, addr, length, prot, flags, fd, offset)
|
||||
}
|
||||
|
||||
// uint16_t __builtin_bswap16 (uint32_t x)
|
||||
func X__builtin_bswap16(t *TLS, x uint16) uint16 {
|
||||
return x<<8 |
|
||||
x>>8
|
||||
}
|
||||
|
||||
// uint32_t __builtin_bswap32 (uint32_t x)
|
||||
func X__builtin_bswap32(t *TLS, x uint32) uint32 {
|
||||
return x<<24 |
|
||||
x&0xff00<<8 |
|
||||
x&0xff0000>>8 |
|
||||
x>>24
|
||||
}
|
||||
|
||||
// uint64_t __builtin_bswap64 (uint64_t x)
|
||||
func X__builtin_bswap64(t *TLS, x uint64) uint64 {
|
||||
return x<<56 |
|
||||
x&0xff00<<40 |
|
||||
x&0xff0000<<24 |
|
||||
x&0xff000000<<8 |
|
||||
x&0xff00000000>>8 |
|
||||
x&0xff0000000000>>24 |
|
||||
x&0xff000000000000>>40 |
|
||||
x>>56
|
||||
}
|
||||
|
||||
// bool __builtin_add_overflow (type1 a, type2 b, type3 *res)
|
||||
func X__builtin_add_overflowInt64(t *TLS, a, b int64, res uintptr) int32 {
|
||||
r, ovf := mathutil.AddOverflowInt64(a, b)
|
||||
*(*int64)(unsafe.Pointer(res)) = r
|
||||
return Bool32(ovf)
|
||||
}
|
||||
|
||||
// bool __builtin_add_overflow (type1 a, type2 b, type3 *res)
|
||||
func X__builtin_add_overflowUint32(t *TLS, a, b uint32, res uintptr) int32 {
|
||||
r := a + b
|
||||
*(*uint32)(unsafe.Pointer(res)) = r
|
||||
return Bool32(r < a)
|
||||
}
|
||||
|
||||
// bool __builtin_add_overflow (type1 a, type2 b, type3 *res)
|
||||
func X__builtin_add_overflowUint64(t *TLS, a, b uint64, res uintptr) int32 {
|
||||
r := a + b
|
||||
*(*uint64)(unsafe.Pointer(res)) = r
|
||||
return Bool32(r < a)
|
||||
}
|
||||
|
||||
// bool __builtin_sub_overflow (type1 a, type2 b, type3 *res)
|
||||
func X__builtin_sub_overflowInt64(t *TLS, a, b int64, res uintptr) int32 {
|
||||
r, ovf := mathutil.SubOverflowInt64(a, b)
|
||||
*(*int64)(unsafe.Pointer(res)) = r
|
||||
return Bool32(ovf)
|
||||
}
|
||||
|
||||
// bool __builtin_mul_overflow (type1 a, type2 b, type3 *res)
|
||||
func X__builtin_mul_overflowInt64(t *TLS, a, b int64, res uintptr) int32 {
|
||||
r, ovf := mathutil.MulOverflowInt64(a, b)
|
||||
*(*int64)(unsafe.Pointer(res)) = r
|
||||
return Bool32(ovf)
|
||||
}
|
||||
|
||||
// bool __builtin_mul_overflow (type1 a, type2 b, type3 *res)
|
||||
func X__builtin_mul_overflowUint64(t *TLS, a, b uint64, res uintptr) int32 {
|
||||
hi, lo := mbits.Mul64(a, b)
|
||||
*(*uint64)(unsafe.Pointer(res)) = lo
|
||||
return Bool32(hi != 0)
|
||||
}
|
||||
|
||||
// bool __builtin_mul_overflow (type1 a, type2 b, type3 *res)
|
||||
func X__builtin_mul_overflowUint128(t *TLS, a, b Uint128, res uintptr) int32 {
|
||||
r, ovf := a.mulOvf(b)
|
||||
*(*Uint128)(unsafe.Pointer(res)) = r
|
||||
return Bool32(ovf)
|
||||
}
|
||||
|
||||
func X__builtin_unreachable(t *TLS) {
|
||||
fmt.Fprintf(os.Stderr, "unrechable\n")
|
||||
os.Stderr.Sync()
|
||||
Xexit(t, 1)
|
||||
}
|
||||
|
||||
func X__builtin_snprintf(t *TLS, str uintptr, size Tsize_t, format, args uintptr) int32 {
|
||||
return Xsnprintf(t, str, size, format, args)
|
||||
}
|
||||
|
||||
func X__builtin_sprintf(t *TLS, str, format, args uintptr) (r int32) {
|
||||
return Xsprintf(t, str, format, args)
|
||||
}
|
||||
|
||||
func X__builtin_memcpy(t *TLS, dest, src uintptr, n Tsize_t) (r uintptr) {
|
||||
return Xmemcpy(t, dest, src, n)
|
||||
}
|
||||
|
||||
// void * __builtin___memcpy_chk (void *dest, const void *src, size_t n, size_t os);
|
||||
func X__builtin___memcpy_chk(t *TLS, dest, src uintptr, n, os Tsize_t) (r uintptr) {
|
||||
if os != ^Tsize_t(0) && n < os {
|
||||
Xabort(t)
|
||||
}
|
||||
|
||||
return Xmemcpy(t, dest, src, n)
|
||||
}
|
||||
|
||||
func X__builtin_memset(t *TLS, s uintptr, c int32, n Tsize_t) uintptr {
|
||||
return Xmemset(t, s, c, n)
|
||||
}
|
||||
|
||||
// void * __builtin___memset_chk (void *s, int c, size_t n, size_t os);
|
||||
func X__builtin___memset_chk(t *TLS, s uintptr, c int32, n, os Tsize_t) uintptr {
|
||||
if os < n {
|
||||
Xabort(t)
|
||||
}
|
||||
|
||||
return Xmemset(t, s, c, n)
|
||||
}
|
||||
|
||||
// size_t __builtin_object_size (const void * ptr, int type)
|
||||
func X__builtin_object_size(t *TLS, p uintptr, typ int32) Tsize_t {
|
||||
return ^Tsize_t(0) //TODO frontend magic
|
||||
}
|
||||
|
||||
// int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
|
||||
func X__builtin___sprintf_chk(t *TLS, s uintptr, flag int32, os Tsize_t, format, args uintptr) (r int32) {
|
||||
return Xsprintf(t, s, format, args)
|
||||
}
|
||||
|
||||
func X__builtin_vsnprintf(t *TLS, str uintptr, size Tsize_t, format, va uintptr) int32 {
|
||||
return Xvsnprintf(t, str, size, format, va)
|
||||
}
|
||||
|
||||
// int __builtin___snprintf_chk(char * str, size_t maxlen, int flag, size_t os, const char * format, ...);
|
||||
func X__builtin___snprintf_chk(t *TLS, str uintptr, maxlen Tsize_t, flag int32, os Tsize_t, format, args uintptr) (r int32) {
|
||||
if os != ^Tsize_t(0) && maxlen > os {
|
||||
Xabort(t)
|
||||
}
|
||||
|
||||
return Xsnprintf(t, str, maxlen, format, args)
|
||||
}
|
||||
|
||||
// int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os, const char *fmt, va_list ap);
|
||||
func X__builtin___vsnprintf_chk(t *TLS, str uintptr, maxlen Tsize_t, flag int32, os Tsize_t, format, args uintptr) (r int32) {
|
||||
if os != ^Tsize_t(0) && maxlen > os {
|
||||
Xabort(t)
|
||||
}
|
||||
|
||||
return Xsnprintf(t, str, maxlen, format, args)
|
||||
}
|
||||
|
||||
func Xisnan(t *TLS, x float64) int32 {
|
||||
return X__builtin_isnan(t, x)
|
||||
}
|
||||
|
||||
func X__isnan(t *TLS, x float64) int32 {
|
||||
return X__builtin_isnan(t, x)
|
||||
}
|
||||
|
||||
func X__builtin_isnan(t *TLS, x float64) int32 {
|
||||
return Bool32(math.IsNaN(x))
|
||||
}
|
||||
|
||||
func Xisnanf(t *TLS, arg float32) int32 {
|
||||
return X__builtin_isnanf(t, arg)
|
||||
}
|
||||
|
||||
func X__isnanf(t *TLS, arg float32) int32 {
|
||||
return X__builtin_isnanf(t, arg)
|
||||
}
|
||||
|
||||
func X__builtin_isnanf(t *TLS, x float32) int32 {
|
||||
return Bool32(math.IsNaN(float64(x)))
|
||||
}
|
||||
|
||||
func Xisnanl(t *TLS, arg float64) int32 {
|
||||
return X__builtin_isnanl(t, arg)
|
||||
}
|
||||
|
||||
func X__isnanl(t *TLS, arg float64) int32 {
|
||||
return X__builtin_isnanl(t, arg)
|
||||
}
|
||||
|
||||
func X__builtin_isnanl(t *TLS, x float64) int32 {
|
||||
return Bool32(math.IsNaN(x))
|
||||
}
|
||||
|
||||
func X__builtin_llabs(tls *TLS, a int64) int64 {
|
||||
return Xllabs(tls, a)
|
||||
}
|
||||
|
||||
func X__builtin_log2(t *TLS, x float64) float64 {
|
||||
return Xlog2(t, x)
|
||||
}
|
||||
|
||||
func X__builtin___strncpy_chk(t *TLS, dest, src uintptr, n, os Tsize_t) (r uintptr) {
|
||||
if n != ^Tsize_t(0) && os < n {
|
||||
Xabort(t)
|
||||
}
|
||||
|
||||
return Xstrncpy(t, dest, src, n)
|
||||
}
|
||||
|
||||
func X__builtin___strcat_chk(t *TLS, dest, src uintptr, os Tsize_t) (r uintptr) {
|
||||
return Xstrcat(t, dest, src)
|
||||
}
|
||||
|
||||
func X__builtin___memmove_chk(t *TLS, dest, src uintptr, n, os Tsize_t) uintptr {
|
||||
if os != ^Tsize_t(0) && os < n {
|
||||
Xabort(t)
|
||||
}
|
||||
|
||||
return Xmemmove(t, dest, src, n)
|
||||
}
|
||||
|
||||
func X__builtin_isunordered(t *TLS, a, b float64) int32 {
|
||||
return Bool32(math.IsNaN(a) || math.IsNaN(b))
|
||||
}
|
||||
|
||||
func X__builtin_ffs(tls *TLS, i int32) (r int32) {
|
||||
return Xffs(tls, i)
|
||||
}
|
||||
|
||||
func X__builtin_rintf(tls *TLS, x float32) (r float32) {
|
||||
return Xrintf(tls, x)
|
||||
}
|
||||
|
||||
func X__builtin_lrintf(tls *TLS, x float32) (r long) {
|
||||
return Xlrintf(tls, x)
|
||||
}
|
||||
|
||||
func X__builtin_lrint(tls *TLS, x float64) (r long) {
|
||||
return Xlrint(tls, x)
|
||||
}
|
||||
|
||||
// double __builtin_fma(double x, double y, double z);
|
||||
func X__builtin_fma(tls *TLS, x, y, z float64) (r float64) {
|
||||
return math.FMA(x, y, z)
|
||||
}
|
||||
|
||||
func X__builtin_alloca(tls *TLS, size Tsize_t) uintptr {
|
||||
return Xalloca(tls, size)
|
||||
}
|
||||
|
||||
func X__builtin_isprint(tls *TLS, c int32) (r int32) {
|
||||
return Xisprint(tls, c)
|
||||
}
|
||||
|
||||
func X__builtin_isblank(tls *TLS, c int32) (r int32) {
|
||||
return Xisblank(tls, c)
|
||||
}
|
||||
|
||||
func X__builtin_trunc(tls *TLS, x float64) (r float64) {
|
||||
return Xtrunc(tls, x)
|
||||
}
|
||||
|
||||
func X__builtin_hypot(tls *TLS, x float64, y float64) (r float64) {
|
||||
return Xhypot(tls, x, y)
|
||||
}
|
||||
|
||||
func X__builtin_fmax(tls *TLS, x float64, y float64) (r float64) {
|
||||
return Xfmax(tls, x, y)
|
||||
}
|
||||
|
||||
func X__builtin_fmin(tls *TLS, x float64, y float64) (r float64) {
|
||||
return Xfmin(tls, x, y)
|
||||
}
|
||||
2
vendor/modernc.org/libc/ccgo.go
generated
vendored
2
vendor/modernc.org/libc/ccgo.go
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
// Code generated by 'go generate' - DO NOT EDIT.
|
||||
|
||||
//go:build !(linux && (amd64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
|
|
|||
154744
vendor/modernc.org/libc/ccgo_linux_amd64.go
generated
vendored
Normal file
154744
vendor/modernc.org/libc/ccgo_linux_amd64.go
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
154052
vendor/modernc.org/libc/ccgo_linux_loong64.go
generated
vendored
Normal file
154052
vendor/modernc.org/libc/ccgo_linux_loong64.go
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
19
vendor/modernc.org/libc/etc.go
generated
vendored
19
vendor/modernc.org/libc/etc.go
generated
vendored
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && (amd64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
|
@ -170,6 +172,10 @@ func removeObject(t uintptr) {
|
|||
}
|
||||
|
||||
func (t *TLS) setErrno(err interface{}) {
|
||||
if t == nil {
|
||||
panic("nil TLS")
|
||||
}
|
||||
|
||||
if memgrind {
|
||||
if atomic.SwapInt32(&t.reentryGuard, 1) != 0 {
|
||||
panic(todo("concurrent use of TLS instance %p", t))
|
||||
|
|
@ -566,6 +572,19 @@ func VaUintptr(app *uintptr) uintptr {
|
|||
return v
|
||||
}
|
||||
|
||||
func getVaList(va uintptr) []string {
|
||||
r := []string{}
|
||||
|
||||
for p := va; ; p += 8 {
|
||||
st := *(*uintptr)(unsafe.Pointer(p))
|
||||
if st == 0 {
|
||||
return r
|
||||
}
|
||||
r = append(r, GoString(st))
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func roundup(n, to uintptr) uintptr {
|
||||
if r := n % to; r != 0 {
|
||||
return n + to - r
|
||||
|
|
|
|||
69
vendor/modernc.org/libc/etc_musl.go
generated
vendored
Normal file
69
vendor/modernc.org/libc/etc_musl.go
generated
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
// Copyright 2023 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 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// origin returns caller's short position, skipping skip frames.
|
||||
func origin(skip int) string {
|
||||
pc, fn, fl, _ := runtime.Caller(skip)
|
||||
f := runtime.FuncForPC(pc)
|
||||
var fns string
|
||||
if f != nil {
|
||||
fns = f.Name()
|
||||
if x := strings.LastIndex(fns, "."); x > 0 {
|
||||
fns = fns[x+1:]
|
||||
}
|
||||
if strings.HasPrefix(fns, "func") {
|
||||
num := true
|
||||
for _, c := range fns[len("func"):] {
|
||||
if c < '0' || c > '9' {
|
||||
num = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if num {
|
||||
return origin(skip + 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s:%d:%s", filepath.Base(fn), fl, fns)
|
||||
}
|
||||
|
||||
// todo prints and return caller's position and an optional message tagged with TODO. Output goes to stderr.
|
||||
func todo(s string, args ...interface{}) string {
|
||||
switch {
|
||||
case s == "":
|
||||
s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
|
||||
default:
|
||||
s = fmt.Sprintf(s, args...)
|
||||
}
|
||||
r := fmt.Sprintf("%s\n\tTODO %s", origin(2), s)
|
||||
// fmt.Fprintf(os.Stderr, "%s\n", r)
|
||||
// os.Stdout.Sync()
|
||||
return r
|
||||
}
|
||||
|
||||
// trc prints and return caller's position and an optional message tagged with TRC. Output goes to stderr.
|
||||
func trc(s string, args ...interface{}) string {
|
||||
switch {
|
||||
case s == "":
|
||||
s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
|
||||
default:
|
||||
s = fmt.Sprintf(s, args...)
|
||||
}
|
||||
r := fmt.Sprintf("%s: TRC %s", origin(2), s)
|
||||
fmt.Fprintf(os.Stderr, "%s\n", r)
|
||||
os.Stderr.Sync()
|
||||
return r
|
||||
}
|
||||
12
vendor/modernc.org/libc/int128.go
generated
vendored
12
vendor/modernc.org/libc/int128.go
generated
vendored
|
|
@ -49,7 +49,7 @@ func Int128FromFloat32(n float32) Int128 { return Int128(mathutil.NewInt128FromF
|
|||
func Int128FromFloat64(n float64) Int128 { return Int128(mathutil.NewInt128FromFloat64(n)) }
|
||||
func Int128FromInt16(n int16) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) }
|
||||
func Int128FromInt32(n int32) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) }
|
||||
func Int128FromInt64(n int64) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) }
|
||||
func Int128FromInt64(n int64) Int128 { return Int128(mathutil.NewInt128FromInt64(n)) }
|
||||
func Int128FromInt8(n int8) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) }
|
||||
func Int128FromUint16(n uint16) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) }
|
||||
func Int128FromUint32(n uint32) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) }
|
||||
|
|
@ -65,7 +65,7 @@ func (n Int128) And(v Int128) Int128 { return Int128{n.Lo & v.Lo, n.Hi & v.Hi}
|
|||
func (n Int128) Cmp(y Int128) int { return mathutil.Int128(n).Cmp(mathutil.Int128(y)) }
|
||||
func (n Int128) Int16() int16 { return int16(n.Lo) }
|
||||
func (n Int128) Int32() int32 { return int32(n.Lo) }
|
||||
func (n Int128) Int64() int64 { return int64(n.Lo) }
|
||||
func (n Int128) Int64() int64 { return n.Lo }
|
||||
func (n Int128) Int8() int8 { return int8(n.Lo) }
|
||||
func (n Int128) Or(v Int128) Int128 { return Int128{n.Lo | v.Lo, n.Hi | v.Hi} }
|
||||
func (n Int128) Uint128() (r Uint128) { return Uint128{uint64(n.Lo), uint64(n.Hi)} }
|
||||
|
|
@ -316,16 +316,16 @@ func (n Uint128) add64(m uint64) Uint128 {
|
|||
|
||||
func (n Uint128) Float32() float32 {
|
||||
if n.Hi == 0 {
|
||||
return float32(uint64(n.Lo))
|
||||
return float32(n.Lo)
|
||||
}
|
||||
|
||||
return float32(n.Hi)*(1<<64) + float32(uint64(n.Lo))
|
||||
return float32(n.Hi)*(1<<64) + float32(n.Lo)
|
||||
}
|
||||
|
||||
func (n Uint128) Float64() float64 {
|
||||
if n.Hi == 0 {
|
||||
return float64(uint64(n.Lo))
|
||||
return float64(n.Lo)
|
||||
}
|
||||
|
||||
return float64(n.Hi)*(1<<64) + float64(uint64(n.Lo))
|
||||
return float64(n.Hi)*(1<<64) + float64(n.Lo)
|
||||
}
|
||||
|
|
|
|||
2
vendor/modernc.org/libc/ioutil_linux.go
generated
vendored
2
vendor/modernc.org/libc/ioutil_linux.go
generated
vendored
|
|
@ -6,6 +6,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && (amd64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
|
|
|||
3
vendor/modernc.org/libc/libc.go
generated
vendored
3
vendor/modernc.org/libc/libc.go
generated
vendored
|
|
@ -2,8 +2,9 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && (amd64 || loong64))
|
||||
|
||||
//go.generate echo package libc > ccgo.go
|
||||
//go:generate go run generate.go
|
||||
//go:generate go fmt ./...
|
||||
|
||||
// Package libc provides run time support for ccgo generated programs and
|
||||
|
|
|
|||
3
vendor/modernc.org/libc/libc64.go
generated
vendored
3
vendor/modernc.org/libc/libc64.go
generated
vendored
|
|
@ -2,8 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build amd64 || arm64 || ppc64le || riscv64 || s390x || loong64 || mips64le
|
||||
// +build amd64 arm64 ppc64le riscv64 s390x loong64 mips64le
|
||||
//go:build ((amd64 || loong64) && !linux) || arm64 || ppc64le || riscv64 || s390x || mips64le
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
|
|
|||
2
vendor/modernc.org/libc/libc_amd64.go
generated
vendored
2
vendor/modernc.org/libc/libc_amd64.go
generated
vendored
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && amd64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
|
|
|||
2
vendor/modernc.org/libc/libc_linux.go
generated
vendored
2
vendor/modernc.org/libc/libc_linux.go
generated
vendored
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && (amd64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
|
|
|||
2
vendor/modernc.org/libc/libc_linux_amd64.go
generated
vendored
2
vendor/modernc.org/libc/libc_linux_amd64.go
generated
vendored
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && amd64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
|
|
|||
779
vendor/modernc.org/libc/libc_linux_loong64.go
generated
vendored
779
vendor/modernc.org/libc/libc_linux_loong64.go
generated
vendored
|
|
@ -1,779 +0,0 @@
|
|||
// Copyright 2020 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 (
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
gotime "time"
|
||||
"unicode"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"modernc.org/libc/errno"
|
||||
"modernc.org/libc/fcntl"
|
||||
"modernc.org/libc/signal"
|
||||
"modernc.org/libc/stdio"
|
||||
"modernc.org/libc/sys/types"
|
||||
"modernc.org/libc/time"
|
||||
"modernc.org/libc/wctype"
|
||||
)
|
||||
|
||||
var (
|
||||
startTime = gotime.Now() // For clock(3)
|
||||
)
|
||||
|
||||
// int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
|
||||
func Xsigaction(t *TLS, signum int32, act, oldact uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v signum=%v oldact=%v, (%v:)", t, signum, oldact, origin(2))
|
||||
}
|
||||
// musl/arch/x86_64/ksigaction.h
|
||||
//
|
||||
// struct k_sigaction {
|
||||
// void (*handler)(int);
|
||||
// unsigned long flags;
|
||||
// void (*restorer)(void);
|
||||
// unsigned mask[2];
|
||||
// };
|
||||
type k_sigaction struct {
|
||||
handler uintptr
|
||||
flags ulong
|
||||
restorer uintptr
|
||||
mask [2]uint32
|
||||
}
|
||||
|
||||
var kact, koldact uintptr
|
||||
if act != 0 {
|
||||
sz := int(unsafe.Sizeof(k_sigaction{}))
|
||||
kact = t.Alloc(sz)
|
||||
defer t.Free(sz)
|
||||
*(*k_sigaction)(unsafe.Pointer(kact)) = k_sigaction{
|
||||
handler: (*signal.Sigaction)(unsafe.Pointer(act)).F__sigaction_handler.Fsa_handler,
|
||||
flags: ulong((*signal.Sigaction)(unsafe.Pointer(act)).Fsa_flags),
|
||||
restorer: (*signal.Sigaction)(unsafe.Pointer(act)).Fsa_restorer,
|
||||
}
|
||||
Xmemcpy(t, kact+unsafe.Offsetof(k_sigaction{}.mask), act+unsafe.Offsetof(signal.Sigaction{}.Fsa_mask), types.Size_t(unsafe.Sizeof(k_sigaction{}.mask)))
|
||||
}
|
||||
if oldact != 0 {
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
if _, _, err := unix.Syscall6(unix.SYS_RT_SIGACTION, uintptr(signum), kact, koldact, unsafe.Sizeof(k_sigaction{}.mask), 0, 0); err != 0 {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if oldact != 0 {
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// int fcntl(int fd, int cmd, ... /* arg */ );
|
||||
func Xfcntl64(t *TLS, fd, cmd int32, args uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v cmd=%v args=%v, (%v:)", t, cmd, args, origin(2))
|
||||
}
|
||||
var arg uintptr
|
||||
if args != 0 {
|
||||
arg = *(*uintptr)(unsafe.Pointer(args))
|
||||
}
|
||||
if cmd == fcntl.F_SETFL {
|
||||
arg |= unix.O_LARGEFILE
|
||||
}
|
||||
n, _, err := unix.Syscall(unix.SYS_FCNTL, uintptr(fd), uintptr(cmd), arg)
|
||||
if err != 0 {
|
||||
// if dmesgs {
|
||||
// dmesg("%v: fd %v cmd %v", origin(1), fcntlCmdStr(fd), cmd)
|
||||
// }
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %d %s %#x: %d", origin(1), fd, fcntlCmdStr(cmd), arg, n)
|
||||
// }
|
||||
return int32(n)
|
||||
}
|
||||
|
||||
// int lstat(const char *pathname, struct stat *statbuf);
|
||||
func Xlstat64(t *TLS, pathname, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2))
|
||||
}
|
||||
if err := syscall.Lstat(GoString(pathname), (*syscall.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %q: %v", origin(1), GoString(pathname), err)
|
||||
// }
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %q: ok", origin(1), GoString(pathname))
|
||||
// }
|
||||
return 0
|
||||
}
|
||||
|
||||
// int stat(const char *pathname, struct stat *statbuf);
|
||||
func Xstat64(t *TLS, pathname, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2))
|
||||
}
|
||||
if err := syscall.Stat(GoString(pathname), (*syscall.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %q: %v", origin(1), GoString(pathname), err)
|
||||
// }
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %q: ok", origin(1), GoString(pathname))
|
||||
// }
|
||||
return 0
|
||||
}
|
||||
|
||||
// int fstat(int fd, struct stat *statbuf);
|
||||
func Xfstat64(t *TLS, fd int32, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v fd=%v statbuf=%v, (%v:)", t, fd, statbuf, origin(2))
|
||||
}
|
||||
if err := syscall.Fstat(int(fd), (*syscall.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
// if dmesgs {
|
||||
// dmesg("%v: fd %d: %v", origin(1), fd, err)
|
||||
// }
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %d size %#x: ok\n%+v", origin(1), fd, (*stat.Stat)(unsafe.Pointer(statbuf)).Fst_size, (*stat.Stat)(unsafe.Pointer(statbuf)))
|
||||
// }
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xmmap(t *TLS, addr uintptr, length types.Size_t, prot, flags, fd int32, offset types.Off_t) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v addr=%v length=%v fd=%v offset=%v, (%v:)", t, addr, length, fd, offset, origin(2))
|
||||
}
|
||||
return Xmmap64(t, addr, length, prot, flags, fd, offset)
|
||||
}
|
||||
|
||||
// void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
|
||||
func Xmmap64(t *TLS, addr uintptr, length types.Size_t, prot, flags, fd int32, offset types.Off_t) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v addr=%v length=%v fd=%v offset=%v, (%v:)", t, addr, length, fd, offset, origin(2))
|
||||
}
|
||||
data, _, err := unix.Syscall6(unix.SYS_MMAP, addr, uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
|
||||
if err != 0 {
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %v", origin(1), err)
|
||||
// }
|
||||
t.setErrno(err)
|
||||
return ^uintptr(0) // (void*)-1
|
||||
}
|
||||
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %#x", origin(1), data)
|
||||
// }
|
||||
return data
|
||||
}
|
||||
|
||||
// void *mremap(void *old_address, size_t old_size, size_t new_size, int flags, ... /* void *new_address */);
|
||||
func Xmremap(t *TLS, old_address uintptr, old_size, new_size types.Size_t, flags int32, args uintptr) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v old_address=%v new_size=%v flags=%v args=%v, (%v:)", t, old_address, new_size, flags, args, origin(2))
|
||||
}
|
||||
var arg uintptr
|
||||
if args != 0 {
|
||||
arg = *(*uintptr)(unsafe.Pointer(args))
|
||||
}
|
||||
data, _, err := unix.Syscall6(unix.SYS_MREMAP, old_address, uintptr(old_size), uintptr(new_size), uintptr(flags), arg, 0)
|
||||
if err != 0 {
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %v", origin(1), err)
|
||||
// }
|
||||
t.setErrno(err)
|
||||
return ^uintptr(0) // (void*)-1
|
||||
}
|
||||
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %#x", origin(1), data)
|
||||
// }
|
||||
return data
|
||||
}
|
||||
|
||||
// int ftruncate(int fd, off_t length);
|
||||
func Xftruncate64(t *TLS, fd int32, length types.Off_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v fd=%v length=%v, (%v:)", t, fd, length, origin(2))
|
||||
}
|
||||
if _, _, err := unix.Syscall(unix.SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0); err != 0 {
|
||||
// if dmesgs {
|
||||
// dmesg("%v: fd %d: %v", origin(1), fd, err)
|
||||
// }
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %d %#x: ok", origin(1), fd, length)
|
||||
// }
|
||||
return 0
|
||||
}
|
||||
|
||||
// off64_t lseek64(int fd, off64_t offset, int whence);
|
||||
func Xlseek64(t *TLS, fd int32, offset types.Off_t, whence int32) types.Off_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v fd=%v offset=%v whence=%v, (%v:)", t, fd, offset, whence, origin(2))
|
||||
}
|
||||
n, _, err := unix.Syscall(unix.SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
|
||||
if err != 0 {
|
||||
// if dmesgs {
|
||||
// dmesg("%v: fd %v, off %#x, whence %v: %v", origin(1), fd, offset, whenceStr(whence), err)
|
||||
// }
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
// if dmesgs {
|
||||
// dmesg("%v: fd %v, off %#x, whence %v: %#x", origin(1), fd, offset, whenceStr(whence), n)
|
||||
// }
|
||||
return types.Off_t(n)
|
||||
}
|
||||
|
||||
// int utime(const char *filename, const struct utimbuf *times);
|
||||
func Xutime(t *TLS, filename, times uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v times=%v, (%v:)", t, times, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_UTIME, filename, times, 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// unsigned int alarm(unsigned int seconds);
|
||||
func Xalarm(t *TLS, seconds uint32) uint32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v seconds=%v, (%v:)", t, seconds, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n, _, err := unix.Syscall(unix.SYS_ALARM, uintptr(seconds), 0, 0)
|
||||
// if err != 0 {
|
||||
// panic(todo(""))
|
||||
// }
|
||||
|
||||
// return uint32(n)
|
||||
}
|
||||
|
||||
// time_t time(time_t *tloc);
|
||||
func Xtime(t *TLS, tloc uintptr) types.Time_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v tloc=%v, (%v:)", t, tloc, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n, _, err := unix.Syscall(unix.SYS_TIME, tloc, 0, 0)
|
||||
// if err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return types.Time_t(-1)
|
||||
// }
|
||||
|
||||
// if tloc != 0 {
|
||||
// *(*types.Time_t)(unsafe.Pointer(tloc)) = types.Time_t(n)
|
||||
// }
|
||||
// return types.Time_t(n)
|
||||
}
|
||||
|
||||
// int getrlimit(int resource, struct rlimit *rlim);
|
||||
func Xgetrlimit64(t *TLS, resource int32, rlim uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v resource=%v rlim=%v, (%v:)", t, resource, rlim, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_GETRLIMIT, uintptr(resource), uintptr(rlim), 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int mkdir(const char *path, mode_t mode);
|
||||
func Xmkdir(t *TLS, path uintptr, mode types.Mode_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v path=%v mode=%v, (%v:)", t, path, mode, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_MKDIR, path, uintptr(mode), 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// // if dmesgs {
|
||||
// // dmesg("%v: %q: ok", origin(1), GoString(path))
|
||||
// // }
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int symlink(const char *target, const char *linkpath);
|
||||
func Xsymlink(t *TLS, target, linkpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v linkpath=%v, (%v:)", t, linkpath, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_SYMLINK, target, linkpath, 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// // if dmesgs {
|
||||
// // dmesg("%v: %q %q: ok", origin(1), GoString(target), GoString(linkpath))
|
||||
// // }
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int chmod(const char *pathname, mode_t mode)
|
||||
func Xchmod(t *TLS, pathname uintptr, mode types.Mode_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_CHMOD, pathname, uintptr(mode), 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// // if dmesgs {
|
||||
// // dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode)
|
||||
// // }
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int utimes(const char *filename, const struct timeval times[2]);
|
||||
func Xutimes(t *TLS, filename, times uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v times=%v, (%v:)", t, times, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_UTIMES, filename, times, 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// // if dmesgs {
|
||||
// // dmesg("%v: %q: ok", origin(1), GoString(filename))
|
||||
// // }
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int unlink(const char *pathname);
|
||||
func Xunlink(t *TLS, pathname uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v, (%v:)", t, pathname, origin(2))
|
||||
}
|
||||
if err := syscall.Unlink(GoString(pathname)); err != nil {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %q: ok", origin(1), GoString(pathname))
|
||||
// }
|
||||
return 0
|
||||
}
|
||||
|
||||
// int access(const char *pathname, int mode);
|
||||
func Xaccess(t *TLS, pathname uintptr, mode int32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2))
|
||||
}
|
||||
if err := syscall.Access(GoString(pathname), uint32(mode)); err != nil {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode)
|
||||
// }
|
||||
return 0
|
||||
}
|
||||
|
||||
// int rmdir(const char *pathname);
|
||||
func Xrmdir(t *TLS, pathname uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v, (%v:)", t, pathname, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_RMDIR, pathname, 0, 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// // if dmesgs {
|
||||
// // dmesg("%v: %q: ok", origin(1), GoString(pathname))
|
||||
// // }
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int rename(const char *oldpath, const char *newpath);
|
||||
func Xrename(t *TLS, oldpath, newpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_RENAME, oldpath, newpath, 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int mknod(const char *pathname, mode_t mode, dev_t dev);
|
||||
func Xmknod(t *TLS, pathname uintptr, mode types.Mode_t, dev types.Dev_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v dev=%v, (%v:)", t, pathname, mode, dev, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_MKNOD, pathname, uintptr(mode), uintptr(dev)); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int chown(const char *pathname, uid_t owner, gid_t group);
|
||||
func Xchown(t *TLS, pathname uintptr, owner types.Uid_t, group types.Gid_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v owner=%v group=%v, (%v:)", t, pathname, owner, group, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// // if _, _, err := unix.Syscall(unix.SYS_CHOWN, pathname, uintptr(owner), uintptr(group)); err != 0 {
|
||||
// // t.setErrno(err)
|
||||
// // return -1
|
||||
// // }
|
||||
|
||||
// // return 0
|
||||
}
|
||||
|
||||
// int link(const char *oldpath, const char *newpath);
|
||||
func Xlink(t *TLS, oldpath, newpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_LINK, oldpath, newpath, 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int pipe(int pipefd[2]);
|
||||
func Xpipe(t *TLS, pipefd uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pipefd=%v, (%v:)", t, pipefd, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_PIPE, pipefd, 0, 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int dup2(int oldfd, int newfd);
|
||||
func Xdup2(t *TLS, oldfd, newfd int32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newfd=%v, (%v:)", t, newfd, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n, _, err := unix.Syscall(unix.SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
|
||||
// if err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return int32(n)
|
||||
}
|
||||
|
||||
// ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);
|
||||
func Xreadlink(t *TLS, path, buf uintptr, bufsize types.Size_t) types.Ssize_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v buf=%v bufsize=%v, (%v:)", t, buf, bufsize, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n, _, err := unix.Syscall(unix.SYS_READLINK, path, buf, uintptr(bufsize))
|
||||
// if err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return types.Ssize_t(n)
|
||||
}
|
||||
|
||||
// FILE *fopen64(const char *pathname, const char *mode);
|
||||
func Xfopen64(t *TLS, pathname, mode uintptr) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v mode=%v, (%v:)", t, mode, origin(2))
|
||||
}
|
||||
m := strings.ReplaceAll(GoString(mode), "b", "")
|
||||
var flags int
|
||||
switch m {
|
||||
case "r":
|
||||
flags = os.O_RDONLY
|
||||
case "r+":
|
||||
flags = os.O_RDWR
|
||||
case "w":
|
||||
flags = os.O_WRONLY | os.O_CREATE | os.O_TRUNC
|
||||
case "w+":
|
||||
flags = os.O_RDWR | os.O_CREATE | os.O_TRUNC
|
||||
case "a":
|
||||
flags = os.O_WRONLY | os.O_CREATE | os.O_APPEND
|
||||
case "a+":
|
||||
flags = os.O_RDWR | os.O_CREATE | os.O_APPEND
|
||||
default:
|
||||
panic(m)
|
||||
}
|
||||
fd, err := unix.Open(GoString(pathname), flags|unix.O_LARGEFILE, 0666)
|
||||
if err != nil {
|
||||
t.setErrno(err)
|
||||
return 0
|
||||
}
|
||||
|
||||
if p := newFile(t, int32(fd)); p != 0 {
|
||||
return p
|
||||
}
|
||||
|
||||
Xclose(t, int32(fd))
|
||||
t.setErrno(errno.ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
// int iswspace(wint_t wc);
|
||||
func Xiswspace(t *TLS, wc wctype.Wint_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v wc=%v, (%v:)", t, wc, origin(2))
|
||||
}
|
||||
return Bool32(unicode.IsSpace(rune(wc)))
|
||||
}
|
||||
|
||||
// int iswalnum(wint_t wc);
|
||||
func Xiswalnum(t *TLS, wc wctype.Wint_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v wc=%v, (%v:)", t, wc, origin(2))
|
||||
}
|
||||
return Bool32(unicode.IsLetter(rune(wc)) || unicode.IsNumber(rune(wc)))
|
||||
}
|
||||
|
||||
// int setrlimit(int resource, const struct rlimit *rlim);
|
||||
func Xsetrlimit64(t *TLS, resource int32, rlim uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v resource=%v rlim=%v, (%v:)", t, resource, rlim, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_SETRLIMIT, uintptr(resource), uintptr(rlim), 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
func AtomicLoadPInt8(addr uintptr) (val int8) {
|
||||
return int8(a_load_8(addr))
|
||||
}
|
||||
|
||||
func AtomicLoadPInt16(addr uintptr) (val int16) {
|
||||
return int16(a_load_16(addr))
|
||||
}
|
||||
|
||||
func AtomicLoadPUint8(addr uintptr) byte {
|
||||
return byte(a_load_8(addr))
|
||||
}
|
||||
|
||||
func AtomicLoadPUint16(addr uintptr) uint16 {
|
||||
return uint16(a_load_16(addr))
|
||||
}
|
||||
|
||||
func AtomicLoadNUint8(ptr uintptr, memorder int32) uint8 {
|
||||
return byte(a_load_8(ptr))
|
||||
}
|
||||
|
||||
var _table1 = [384]int32{
|
||||
129: int32(1),
|
||||
130: int32(2),
|
||||
131: int32(3),
|
||||
132: int32(4),
|
||||
133: int32(5),
|
||||
134: int32(6),
|
||||
135: int32(7),
|
||||
136: int32(8),
|
||||
137: int32(9),
|
||||
138: int32(10),
|
||||
139: int32(11),
|
||||
140: int32(12),
|
||||
141: int32(13),
|
||||
142: int32(14),
|
||||
143: int32(15),
|
||||
144: int32(16),
|
||||
145: int32(17),
|
||||
146: int32(18),
|
||||
147: int32(19),
|
||||
148: int32(20),
|
||||
149: int32(21),
|
||||
150: int32(22),
|
||||
151: int32(23),
|
||||
152: int32(24),
|
||||
153: int32(25),
|
||||
154: int32(26),
|
||||
155: int32(27),
|
||||
156: int32(28),
|
||||
157: int32(29),
|
||||
158: int32(30),
|
||||
159: int32(31),
|
||||
160: int32(32),
|
||||
161: int32(33),
|
||||
162: int32(34),
|
||||
163: int32(35),
|
||||
164: int32(36),
|
||||
165: int32(37),
|
||||
166: int32(38),
|
||||
167: int32(39),
|
||||
168: int32(40),
|
||||
169: int32(41),
|
||||
170: int32(42),
|
||||
171: int32(43),
|
||||
172: int32(44),
|
||||
173: int32(45),
|
||||
174: int32(46),
|
||||
175: int32(47),
|
||||
176: int32(48),
|
||||
177: int32(49),
|
||||
178: int32(50),
|
||||
179: int32(51),
|
||||
180: int32(52),
|
||||
181: int32(53),
|
||||
182: int32(54),
|
||||
183: int32(55),
|
||||
184: int32(56),
|
||||
185: int32(57),
|
||||
186: int32(58),
|
||||
187: int32(59),
|
||||
188: int32(60),
|
||||
189: int32(61),
|
||||
190: int32(62),
|
||||
191: int32(63),
|
||||
192: int32(64),
|
||||
193: int32('a'),
|
||||
194: int32('b'),
|
||||
195: int32('c'),
|
||||
196: int32('d'),
|
||||
197: int32('e'),
|
||||
198: int32('f'),
|
||||
199: int32('g'),
|
||||
200: int32('h'),
|
||||
201: int32('i'),
|
||||
202: int32('j'),
|
||||
203: int32('k'),
|
||||
204: int32('l'),
|
||||
205: int32('m'),
|
||||
206: int32('n'),
|
||||
207: int32('o'),
|
||||
208: int32('p'),
|
||||
209: int32('q'),
|
||||
210: int32('r'),
|
||||
211: int32('s'),
|
||||
212: int32('t'),
|
||||
213: int32('u'),
|
||||
214: int32('v'),
|
||||
215: int32('w'),
|
||||
216: int32('x'),
|
||||
217: int32('y'),
|
||||
218: int32('z'),
|
||||
219: int32(91),
|
||||
220: int32(92),
|
||||
221: int32(93),
|
||||
222: int32(94),
|
||||
223: int32(95),
|
||||
224: int32(96),
|
||||
225: int32('a'),
|
||||
226: int32('b'),
|
||||
227: int32('c'),
|
||||
228: int32('d'),
|
||||
229: int32('e'),
|
||||
230: int32('f'),
|
||||
231: int32('g'),
|
||||
232: int32('h'),
|
||||
233: int32('i'),
|
||||
234: int32('j'),
|
||||
235: int32('k'),
|
||||
236: int32('l'),
|
||||
237: int32('m'),
|
||||
238: int32('n'),
|
||||
239: int32('o'),
|
||||
240: int32('p'),
|
||||
241: int32('q'),
|
||||
242: int32('r'),
|
||||
243: int32('s'),
|
||||
244: int32('t'),
|
||||
245: int32('u'),
|
||||
246: int32('v'),
|
||||
247: int32('w'),
|
||||
248: int32('x'),
|
||||
249: int32('y'),
|
||||
250: int32('z'),
|
||||
251: int32(123),
|
||||
252: int32(124),
|
||||
253: int32(125),
|
||||
254: int32(126),
|
||||
255: int32(127),
|
||||
}
|
||||
|
||||
var _ptable1 = uintptr(unsafe.Pointer(&_table1)) + uintptr(128)*4
|
||||
|
||||
func X__ctype_tolower_loc(tls *TLS) (r uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v, (%v:)", tls, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
return uintptr(unsafe.Pointer(&_ptable1))
|
||||
}
|
||||
|
||||
type Tin6_addr = struct {
|
||||
F__in6_union struct {
|
||||
F__s6_addr16 [0][8]uint16
|
||||
F__s6_addr32 [0][4]uint32
|
||||
F__s6_addr [16]uint8
|
||||
}
|
||||
}
|
||||
|
||||
var Xin6addr_any = Tin6_addr{}
|
||||
|
||||
func Xrewinddir(tls *TLS, f uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v f=%v, (%v:)", tls, f, origin(2))
|
||||
}
|
||||
Xfseek(tls, f, 0, stdio.SEEK_SET)
|
||||
}
|
||||
|
||||
// clock_t clock(void);
|
||||
func Xclock(t *TLS) time.Clock_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v, (%v:)", t, origin(2))
|
||||
}
|
||||
return time.Clock_t(gotime.Since(startTime) * gotime.Duration(time.CLOCKS_PER_SEC) / gotime.Second)
|
||||
}
|
||||
2
vendor/modernc.org/libc/libc_loong64.go
generated
vendored
2
vendor/modernc.org/libc/libc_loong64.go
generated
vendored
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && loong64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
|
|
|||
1033
vendor/modernc.org/libc/libc_musl.go
generated
vendored
Normal file
1033
vendor/modernc.org/libc/libc_musl.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
31
vendor/modernc.org/libc/libc_musl_linux_amd64.go
generated
vendored
Normal file
31
vendor/modernc.org/libc/libc_musl_linux_amd64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2023 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
|
||||
|
||||
package libc // import "modernc.org/libc
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
type long = int64
|
||||
|
||||
type ulong = uint64
|
||||
|
||||
// RawMem represents the biggest byte array the runtime can handle
|
||||
type RawMem [1<<50 - 1]byte
|
||||
|
||||
// int renameat2(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags);
|
||||
func Xrenameat2(t *TLS, olddirfd int32, oldpath uintptr, newdirfd int32, newpath uintptr, flags int32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v olddirfd=%v oldpath=%v newdirfd=%v newpath=%v flags=%v, (%v:)", t, olddirfd, oldpath, newdirfd, newpath, flags, origin(2))
|
||||
}
|
||||
if _, _, err := unix.Syscall6(unix.SYS_RENAMEAT2, uintptr(olddirfd), oldpath, uintptr(newdirfd), newpath, uintptr(flags), 0); err != 0 {
|
||||
t.setErrno(int32(err))
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
29
vendor/modernc.org/libc/libc_musl_linux_loong64.go
generated
vendored
Normal file
29
vendor/modernc.org/libc/libc_musl_linux_loong64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2023 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 (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
type long = int64
|
||||
|
||||
type ulong = uint64
|
||||
|
||||
// RawMem represents the biggest byte array the runtime can handle
|
||||
type RawMem [1<<50 - 1]byte
|
||||
|
||||
// int renameat2(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags);
|
||||
func Xrenameat2(t *TLS, olddirfd int32, oldpath uintptr, newdirfd int32, newpath uintptr, flags int32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v olddirfd=%v oldpath=%v newdirfd=%v newpath=%v flags=%v, (%v:)", t, olddirfd, oldpath, newdirfd, newpath, flags, origin(2))
|
||||
}
|
||||
if _, _, err := unix.Syscall6(unix.SYS_RENAMEAT2, uintptr(olddirfd), oldpath, uintptr(newdirfd), newpath, uintptr(flags), 0); err != 0 {
|
||||
t.setErrno(int32(err))
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
1000
vendor/modernc.org/libc/libc_openbsd.go
generated
vendored
1000
vendor/modernc.org/libc/libc_openbsd.go
generated
vendored
File diff suppressed because it is too large
Load diff
699
vendor/modernc.org/libc/libc_openbsd_386.go
generated
vendored
699
vendor/modernc.org/libc/libc_openbsd_386.go
generated
vendored
|
|
@ -4,706 +4,7 @@
|
|||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"modernc.org/libc/fcntl"
|
||||
"modernc.org/libc/fts"
|
||||
"modernc.org/libc/sys/types"
|
||||
"modernc.org/libc/time"
|
||||
"modernc.org/libc/utime"
|
||||
)
|
||||
|
||||
type (
|
||||
long = int32
|
||||
ulong = uint32
|
||||
)
|
||||
|
||||
// int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
|
||||
func Xsigaction(t *TLS, signum int32, act, oldact uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v signum=%v oldact=%v, (%v:)", t, signum, oldact, origin(2))
|
||||
}
|
||||
if _, _, err := unix.Syscall(unix.SYS_SIGACTION, uintptr(signum), act, oldact); err != 0 {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// FILE *fopen64(const char *pathname, const char *mode);
|
||||
func Xfopen64(t *TLS, pathname, mode uintptr) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v mode=%v, (%v:)", t, mode, origin(2))
|
||||
}
|
||||
m := strings.ReplaceAll(GoString(mode), "b", "")
|
||||
var flags int
|
||||
switch m {
|
||||
case "r":
|
||||
flags = fcntl.O_RDONLY
|
||||
case "r+":
|
||||
flags = fcntl.O_RDWR
|
||||
case "w":
|
||||
flags = fcntl.O_WRONLY | fcntl.O_CREAT | fcntl.O_TRUNC
|
||||
case "w+":
|
||||
flags = fcntl.O_RDWR | fcntl.O_CREAT | fcntl.O_TRUNC
|
||||
case "a":
|
||||
flags = fcntl.O_WRONLY | fcntl.O_CREAT | fcntl.O_APPEND
|
||||
case "a+":
|
||||
flags = fcntl.O_RDWR | fcntl.O_CREAT | fcntl.O_APPEND
|
||||
default:
|
||||
panic(m)
|
||||
}
|
||||
fd, err := unix.Open(GoString(pathname), int(flags), 0666)
|
||||
if err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %q: %v FAIL", origin(1), GoString(pathname), GoString(mode), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return 0
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %q: fd %v", origin(1), GoString(pathname), GoString(mode), fd)
|
||||
}
|
||||
if p := newFile(t, int32(fd)); p != 0 {
|
||||
return p
|
||||
}
|
||||
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
// int lstat(const char *pathname, struct stat *statbuf);
|
||||
func Xlstat64(t *TLS, pathname, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2))
|
||||
}
|
||||
if err := unix.Lstat(GoString(pathname), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v FAIL", origin(1), GoString(pathname), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: ok", origin(1), GoString(pathname))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int stat(const char *pathname, struct stat *statbuf);
|
||||
func Xstat64(t *TLS, pathname, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2))
|
||||
}
|
||||
if err := unix.Stat(GoString(pathname), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v FAIL", origin(1), GoString(pathname), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: ok", origin(1), GoString(pathname))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int mkdir(const char *path, mode_t mode);
|
||||
func Xmkdir(t *TLS, path uintptr, mode types.Mode_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v path=%v mode=%v, (%v:)", t, path, mode, origin(2))
|
||||
}
|
||||
if err := unix.Mkdir(GoString(path), uint32(mode)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v FAIL", origin(1), GoString(path), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: ok", origin(1), GoString(path))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int access(const char *pathname, int mode);
|
||||
func Xaccess(t *TLS, pathname uintptr, mode int32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2))
|
||||
}
|
||||
if err := unix.Access(GoString(pathname), uint32(mode)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: %v FAIL", origin(1), GoString(pathname), mode, err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int unlink(const char *pathname);
|
||||
func Xunlink(t *TLS, pathname uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v, (%v:)", t, pathname, origin(2))
|
||||
}
|
||||
if err := unix.Unlink(GoString(pathname)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v", origin(1), GoString(pathname), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);
|
||||
func Xreadlink(t *TLS, path, buf uintptr, bufsize types.Size_t) types.Ssize_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v buf=%v bufsize=%v, (%v:)", t, buf, bufsize, origin(2))
|
||||
}
|
||||
var n int
|
||||
var err error
|
||||
switch {
|
||||
case buf == 0 || bufsize == 0:
|
||||
n, err = unix.Readlink(GoString(path), nil)
|
||||
default:
|
||||
n, err = unix.Readlink(GoString(path), (*RawMem)(unsafe.Pointer(buf))[:bufsize:bufsize])
|
||||
}
|
||||
if err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok")
|
||||
}
|
||||
return types.Ssize_t(n)
|
||||
}
|
||||
|
||||
// int symlink(const char *target, const char *linkpath);
|
||||
func Xsymlink(t *TLS, target, linkpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v linkpath=%v, (%v:)", t, linkpath, origin(2))
|
||||
}
|
||||
if err := unix.Symlink(GoString(target), GoString(linkpath)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int chmod(const char *pathname, mode_t mode)
|
||||
func Xchmod(t *TLS, pathname uintptr, mode types.Mode_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2))
|
||||
}
|
||||
if err := unix.Chmod(GoString(pathname), uint32(mode)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: %v FAIL", origin(1), GoString(pathname), mode, err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// time_t time(time_t *tloc);
|
||||
func Xtime(t *TLS, tloc uintptr) time.Time_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v tloc=%v, (%v:)", t, tloc, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n := time.Now().UTC().Unix()
|
||||
// if tloc != 0 {
|
||||
// *(*types.Time_t)(unsafe.Pointer(tloc)) = types.Time_t(n)
|
||||
// }
|
||||
// return types.Time_t(n)
|
||||
}
|
||||
|
||||
// int utimes(const char *filename, const struct timeval times[2]);
|
||||
func Xutimes(t *TLS, filename, times uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v times=%v, (%v:)", t, times, origin(2))
|
||||
}
|
||||
var a []unix.Timeval
|
||||
if times != 0 {
|
||||
a = make([]unix.Timeval, 2)
|
||||
a[0] = *(*unix.Timeval)(unsafe.Pointer(times))
|
||||
a[1] = *(*unix.Timeval)(unsafe.Pointer(times + unsafe.Sizeof(unix.Timeval{})))
|
||||
}
|
||||
if err := unix.Utimes(GoString(filename), a); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int fstat(int fd, struct stat *statbuf);
|
||||
func Xfstat64(t *TLS, fd int32, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v fd=%v statbuf=%v, (%v:)", t, fd, statbuf, origin(2))
|
||||
}
|
||||
if err := unix.Fstat(int(fd), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: fd %d: %v FAIL", origin(1), fd, err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: fd %d: ok", origin(1), fd)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// off64_t lseek64(int fd, off64_t offset, int whence);
|
||||
func Xlseek64(t *TLS, fd int32, offset types.Off_t, whence int32) types.Off_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v fd=%v offset=%v whence=%v, (%v:)", t, fd, offset, whence, origin(2))
|
||||
}
|
||||
n, err := unix.Seek(int(fd), int64(offset), int(whence))
|
||||
if err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return types.Off_t(n)
|
||||
}
|
||||
|
||||
func Xfcntl64(t *TLS, fd, cmd int32, args uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v cmd=%v args=%v, (%v:)", t, cmd, args, origin(2))
|
||||
}
|
||||
var arg uintptr
|
||||
if args != 0 {
|
||||
arg = *(*uintptr)(unsafe.Pointer(args))
|
||||
}
|
||||
n, _, err := unix.Syscall(unix.SYS_FCNTL, uintptr(fd), uintptr(cmd), arg)
|
||||
if err != 0 {
|
||||
if dmesgs {
|
||||
dmesg("%v: fd %v cmd %v", origin(1), fcntlCmdStr(fd), cmd)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %d %s %#x: %d", origin(1), fd, fcntlCmdStr(cmd), arg, n)
|
||||
}
|
||||
return int32(n)
|
||||
}
|
||||
|
||||
// int rename(const char *oldpath, const char *newpath);
|
||||
func Xrename(t *TLS, oldpath, newpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2))
|
||||
}
|
||||
if err := unix.Rename(GoString(oldpath), GoString(newpath)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int mknod(const char *pathname, mode_t mode, dev_t dev);
|
||||
func Xmknod(t *TLS, pathname uintptr, mode types.Mode_t, dev types.Dev_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v dev=%v, (%v:)", t, pathname, mode, dev, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_MKNOD, pathname, uintptr(mode), uintptr(dev)); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int utime(const char *filename, const struct utimbuf *times);
|
||||
func Xutime(t *TLS, filename, times uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v times=%v, (%v:)", t, times, origin(2))
|
||||
}
|
||||
var a []unix.Timeval
|
||||
if times != 0 {
|
||||
a = make([]unix.Timeval, 2)
|
||||
a[0].Sec = int64((*utime.Utimbuf)(unsafe.Pointer(times)).Factime)
|
||||
a[1].Sec = int64((*utime.Utimbuf)(unsafe.Pointer(times)).Fmodtime)
|
||||
}
|
||||
if err := unix.Utimes(GoString(filename), a); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int chown(const char *pathname, uid_t owner, gid_t group);
|
||||
func Xchown(t *TLS, pathname uintptr, owner types.Uid_t, group types.Gid_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v owner=%v group=%v, (%v:)", t, pathname, owner, group, origin(2))
|
||||
}
|
||||
if _, _, err := unix.Syscall(unix.SYS_CHOWN, pathname, uintptr(owner), uintptr(group)); err != 0 {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// int link(const char *oldpath, const char *newpath);
|
||||
func Xlink(t *TLS, oldpath, newpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_LINK, oldpath, newpath, 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int dup2(int oldfd, int newfd);
|
||||
func Xdup2(t *TLS, oldfd, newfd int32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newfd=%v, (%v:)", t, newfd, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n, _, err := unix.Syscall(unix.SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
|
||||
// if err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return int32(n)
|
||||
}
|
||||
|
||||
// unsigned int alarm(unsigned int seconds);
|
||||
func Xalarm(t *TLS, seconds uint32) uint32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v seconds=%v, (%v:)", t, seconds, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n, _, err := unix.Syscall(unix.SYS_ALARM, uintptr(seconds), 0, 0)
|
||||
// if err != 0 {
|
||||
// panic(todo(""))
|
||||
// }
|
||||
|
||||
// return uint32(n)
|
||||
}
|
||||
|
||||
func Xgetnameinfo(tls *TLS, sa1 uintptr, sl socklen_t, node uintptr, nodelen size_t, serv uintptr, servlen size_t, flags int32) int32 { /* getnameinfo.c:125:5: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v sa1=%v sl=%v node=%v nodelen=%v serv=%v servlen=%v flags=%v, (%v:)", tls, sa1, sl, node, nodelen, serv, servlen, flags, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
//TODO bp := tls.Alloc(347)
|
||||
//TODO defer tls.Free(347)
|
||||
|
||||
//TODO // var ptr [78]int8 at bp, 78
|
||||
|
||||
//TODO // var buf [256]int8 at bp+78, 256
|
||||
|
||||
//TODO // var num [13]int8 at bp+334, 13
|
||||
|
||||
//TODO var af int32 = int32((*sockaddr)(unsafe.Pointer(sa1)).sa_family)
|
||||
//TODO var a uintptr
|
||||
//TODO var scopeid uint32
|
||||
|
||||
//TODO switch af {
|
||||
//TODO case 2:
|
||||
//TODO a = (sa1 + 4 /* &.sin_addr */)
|
||||
//TODO if (uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in{}))) {
|
||||
//TODO return -6
|
||||
//TODO }
|
||||
//TODO mkptr4(tls, bp /* &ptr[0] */, a)
|
||||
//TODO scopeid = uint32(0)
|
||||
//TODO break
|
||||
//TODO case 10:
|
||||
//TODO a = (sa1 + 8 /* &.sin6_addr */)
|
||||
//TODO if (uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in6{}))) {
|
||||
//TODO return -6
|
||||
//TODO }
|
||||
//TODO if Xmemcmp(tls, a, ts+88 /* "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff" */, uint64(12)) != 0 {
|
||||
//TODO mkptr6(tls, bp /* &ptr[0] */, a)
|
||||
//TODO } else {
|
||||
//TODO mkptr4(tls, bp /* &ptr[0] */, (a + uintptr(12)))
|
||||
//TODO }
|
||||
//TODO scopeid = (*sockaddr_in6)(unsafe.Pointer(sa1)).sin6_scope_id
|
||||
//TODO break
|
||||
//TODO default:
|
||||
//TODO return -6
|
||||
//TODO }
|
||||
|
||||
//TODO if (node != 0) && (nodelen != 0) {
|
||||
//TODO *(*int8)(unsafe.Pointer(bp + 78 /* &buf[0] */)) = int8(0)
|
||||
//TODO if !((flags & 0x01) != 0) {
|
||||
//TODO reverse_hosts(tls, bp+78 /* &buf[0] */, a, scopeid, af)
|
||||
//TODO }
|
||||
//TODO if !(int32(*(*int8)(unsafe.Pointer(bp + 78 /* buf */))) != 0) && !((flags & 0x01) != 0) {
|
||||
//TODO Xabort(tls) //TODO-
|
||||
//TODO // unsigned char query[18+PTR_MAX], reply[512];
|
||||
//TODO // int qlen = __res_mkquery(0, ptr, 1, RR_PTR,
|
||||
//TODO // 0, 0, 0, query, sizeof query);
|
||||
//TODO // query[3] = 0; /* don't need AD flag */
|
||||
//TODO // int rlen = __res_send(query, qlen, reply, sizeof reply);
|
||||
//TODO // buf[0] = 0;
|
||||
//TODO // if (rlen > 0)
|
||||
//TODO // __dns_parse(reply, rlen, dns_parse_callback, buf);
|
||||
//TODO }
|
||||
//TODO if !(int32(*(*int8)(unsafe.Pointer(bp + 78 /* buf */))) != 0) {
|
||||
//TODO if (flags & 0x08) != 0 {
|
||||
//TODO return -2
|
||||
//TODO }
|
||||
//TODO Xinet_ntop(tls, af, a, bp+78 /* &buf[0] */, uint32(unsafe.Sizeof([256]int8{})))
|
||||
//TODO if scopeid != 0 {
|
||||
//TODO Xabort(tls) //TODO-
|
||||
//TODO // char *p = 0, tmp[IF_NAMESIZE+1];
|
||||
//TODO // if (!(flags & NI_NUMERICSCOPE) &&
|
||||
//TODO // (IN6_IS_ADDR_LINKLOCAL(a) ||
|
||||
//TODO // IN6_IS_ADDR_MC_LINKLOCAL(a)))
|
||||
//TODO // p = if_indextoname(scopeid, tmp+1);
|
||||
//TODO // if (!p)
|
||||
//TODO // p = itoa(num, scopeid);
|
||||
//TODO // *--p = '%';
|
||||
//TODO // strcat(buf, p);
|
||||
//TODO }
|
||||
//TODO }
|
||||
//TODO if Xstrlen(tls, bp+78 /* &buf[0] */) >= size_t(nodelen) {
|
||||
//TODO return -12
|
||||
//TODO }
|
||||
//TODO Xstrcpy(tls, node, bp+78 /* &buf[0] */)
|
||||
//TODO }
|
||||
|
||||
//TODO if (serv != 0) && (servlen != 0) {
|
||||
//TODO var p uintptr = bp + 78 /* buf */
|
||||
//TODO var port int32 = int32(Xntohs(tls, (*sockaddr_in)(unsafe.Pointer(sa1)).sin_port))
|
||||
//TODO *(*int8)(unsafe.Pointer(bp + 78 /* &buf[0] */)) = int8(0)
|
||||
//TODO if !((flags & 0x02) != 0) {
|
||||
//TODO reverse_services(tls, bp+78 /* &buf[0] */, port, (flags & 0x10))
|
||||
//TODO }
|
||||
//TODO if !(int32(*(*int8)(unsafe.Pointer(p))) != 0) {
|
||||
//TODO p = itoa(tls, bp+334 /* &num[0] */, uint32(port))
|
||||
//TODO }
|
||||
//TODO if Xstrlen(tls, p) >= size_t(servlen) {
|
||||
//TODO return -12
|
||||
//TODO }
|
||||
//TODO Xstrcpy(tls, serv, p)
|
||||
//TODO }
|
||||
|
||||
//TODO return 0
|
||||
}
|
||||
|
||||
func Xgethostbyaddr_r(tls *TLS, a uintptr, l socklen_t, af int32, h uintptr, buf uintptr, buflen size_t, res uintptr, err uintptr) int32 { /* gethostbyaddr_r.c:10:5: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v a=%v l=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, a, l, af, h, buf, buflen, res, err, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
//TODO bp := tls.Alloc(28)
|
||||
//TODO defer tls.Free(28)
|
||||
|
||||
//TODO //TODO union {
|
||||
//TODO //TODO struct sockaddr_in sin;
|
||||
//TODO //TODO struct sockaddr_in6 sin6;
|
||||
//TODO //TODO } sa = { .sin.sin_family = af };
|
||||
//TODO *(*struct {
|
||||
//TODO sin sockaddr_in
|
||||
//TODO _ [12]byte
|
||||
//TODO })(unsafe.Pointer(bp /* sa1 */)) = struct {
|
||||
//TODO sin sockaddr_in
|
||||
//TODO _ [12]byte
|
||||
//TODO }{} //TODO-
|
||||
//TODO (*sockaddr_in)(unsafe.Pointer(bp /* &sa1 */)).sin_family = sa_family_t(af) //TODO-
|
||||
//TODO var sl socklen_t
|
||||
//TODO if af == 10 {
|
||||
//TODO sl = uint32(unsafe.Sizeof(sockaddr_in6{}))
|
||||
//TODO } else {
|
||||
//TODO sl = uint32(unsafe.Sizeof(sockaddr_in{}))
|
||||
//TODO }
|
||||
//TODO var i int32
|
||||
|
||||
//TODO *(*uintptr)(unsafe.Pointer(res)) = uintptr(0)
|
||||
|
||||
//TODO // Load address argument into sockaddr structure
|
||||
//TODO if (af == 10) && (l == socklen_t(16)) {
|
||||
//TODO Xmemcpy(tls, (bp /* &sa1 */ /* &.sin6 */ + 8 /* &.sin6_addr */), a, uint64(16))
|
||||
//TODO } else if (af == 2) && (l == socklen_t(4)) {
|
||||
//TODO Xmemcpy(tls, (bp /* &sa1 */ /* &.sin */ + 4 /* &.sin_addr */), a, uint64(4))
|
||||
//TODO } else {
|
||||
//TODO *(*int32)(unsafe.Pointer(err)) = 3
|
||||
//TODO return 22
|
||||
//TODO }
|
||||
|
||||
//TODO // Align buffer and check for space for pointers and ip address
|
||||
//TODO i = (int32(uintptr_t(buf) & (uint64(unsafe.Sizeof(uintptr(0))) - uint64(1))))
|
||||
//TODO if !(i != 0) {
|
||||
//TODO i = int32(unsafe.Sizeof(uintptr(0)))
|
||||
//TODO }
|
||||
//TODO if buflen <= (((uint64(5) * uint64(unsafe.Sizeof(uintptr(0)))) - uint64(i)) + uint64(l)) {
|
||||
//TODO return 34
|
||||
//TODO }
|
||||
//TODO buf += (uintptr(uint64(unsafe.Sizeof(uintptr(0))) - uint64(i)))
|
||||
//TODO buflen = buflen - (((uint64(5) * uint64(unsafe.Sizeof(uintptr(0)))) - uint64(i)) + uint64(l))
|
||||
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_addr_list = buf
|
||||
//TODO buf += (uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0)))))
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_aliases = buf
|
||||
//TODO buf += (uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0)))))
|
||||
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list)) = buf
|
||||
//TODO Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list)), a, uint64(l))
|
||||
//TODO buf += uintptr(l)
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list + 1*8)) = uintptr(0)
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases)) = buf
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases + 1*8)) = uintptr(0)
|
||||
|
||||
//TODO switch Xgetnameinfo(tls, bp /* &sa1 */, sl, buf, uint32(buflen), uintptr(0), uint32(0), 0) {
|
||||
//TODO case -3:
|
||||
//TODO *(*int32)(unsafe.Pointer(err)) = 2
|
||||
//TODO return 11
|
||||
//TODO case -12:
|
||||
//TODO return 34
|
||||
//TODO default:
|
||||
//TODO fallthrough
|
||||
//TODO case -10:
|
||||
//TODO fallthrough
|
||||
//TODO case -11:
|
||||
//TODO fallthrough
|
||||
//TODO case -4:
|
||||
//TODO *(*int32)(unsafe.Pointer(err)) = 3
|
||||
//TODO return *(*int32)(unsafe.Pointer(X___errno_location(tls)))
|
||||
//TODO case 0:
|
||||
//TODO break
|
||||
//TODO }
|
||||
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_addrtype = af
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_length = int32(l)
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_name = *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases))
|
||||
//TODO *(*uintptr)(unsafe.Pointer(res)) = h
|
||||
//TODO return 0
|
||||
}
|
||||
|
||||
// int getrlimit(int resource, struct rlimit *rlim);
|
||||
func Xgetrlimit64(t *TLS, resource int32, rlim uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v resource=%v rlim=%v, (%v:)", t, resource, rlim, origin(2))
|
||||
}
|
||||
if _, _, err := unix.Syscall(unix.SYS_GETRLIMIT, uintptr(resource), uintptr(rlim), 0); err != 0 {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func newFtsent(t *TLS, info int, path string, stat *unix.Stat_t, err syscall.Errno) (r *fts.FTSENT) {
|
||||
var statp uintptr
|
||||
if stat != nil {
|
||||
statp = Xmalloc(t, types.Size_t(unsafe.Sizeof(unix.Stat_t{})))
|
||||
if statp == 0 {
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
*(*unix.Stat_t)(unsafe.Pointer(statp)) = *stat
|
||||
}
|
||||
csp, errx := CString(path)
|
||||
if errx != nil {
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
return &fts.FTSENT{
|
||||
Ffts_info: uint16(info),
|
||||
Ffts_path: csp,
|
||||
Ffts_pathlen: uint32(len(path)),
|
||||
Ffts_statp: statp,
|
||||
Ffts_errno: int32(err),
|
||||
}
|
||||
}
|
||||
|
||||
// DIR *opendir(const char *name);
|
||||
func Xopendir(t *TLS, name uintptr) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v name=%v, (%v:)", t, name, origin(2))
|
||||
}
|
||||
p := Xmalloc(t, uint32(unsafe.Sizeof(darwinDir{})))
|
||||
if p == 0 {
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
fd := int(Xopen(t, name, fcntl.O_RDONLY|fcntl.O_DIRECTORY|fcntl.O_CLOEXEC, 0))
|
||||
if fd < 0 {
|
||||
if dmesgs {
|
||||
dmesg("%v: FAIL %v", origin(1), (*darwinDir)(unsafe.Pointer(p)).fd)
|
||||
}
|
||||
Xfree(t, p)
|
||||
return 0
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
(*darwinDir)(unsafe.Pointer(p)).fd = fd
|
||||
(*darwinDir)(unsafe.Pointer(p)).h = 0
|
||||
(*darwinDir)(unsafe.Pointer(p)).l = 0
|
||||
(*darwinDir)(unsafe.Pointer(p)).eof = false
|
||||
return p
|
||||
}
|
||||
|
|
|
|||
722
vendor/modernc.org/libc/libc_openbsd_amd64.go
generated
vendored
722
vendor/modernc.org/libc/libc_openbsd_amd64.go
generated
vendored
|
|
@ -4,729 +4,7 @@
|
|||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"syscall"
|
||||
gotime "time"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"modernc.org/libc/fcntl"
|
||||
"modernc.org/libc/fts"
|
||||
"modernc.org/libc/stdio"
|
||||
"modernc.org/libc/sys/types"
|
||||
"modernc.org/libc/time"
|
||||
"modernc.org/libc/utime"
|
||||
)
|
||||
|
||||
type (
|
||||
long = int64
|
||||
ulong = uint64
|
||||
)
|
||||
|
||||
var (
|
||||
startTime = gotime.Now() // For clock(3)
|
||||
)
|
||||
|
||||
// int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
|
||||
func Xsigaction(t *TLS, signum int32, act, oldact uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v signum=%v oldact=%v, (%v:)", t, signum, oldact, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_SIGACTION, uintptr(signum), act, oldact); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// FILE *fopen64(const char *pathname, const char *mode);
|
||||
func Xfopen64(t *TLS, pathname, mode uintptr) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v mode=%v, (%v:)", t, mode, origin(2))
|
||||
}
|
||||
m := strings.ReplaceAll(GoString(mode), "b", "")
|
||||
var flags int
|
||||
switch m {
|
||||
case "r":
|
||||
flags = fcntl.O_RDONLY
|
||||
case "r+":
|
||||
flags = fcntl.O_RDWR
|
||||
case "w":
|
||||
flags = fcntl.O_WRONLY | fcntl.O_CREAT | fcntl.O_TRUNC
|
||||
case "w+":
|
||||
flags = fcntl.O_RDWR | fcntl.O_CREAT | fcntl.O_TRUNC
|
||||
case "a":
|
||||
flags = fcntl.O_WRONLY | fcntl.O_CREAT | fcntl.O_APPEND
|
||||
case "a+":
|
||||
flags = fcntl.O_RDWR | fcntl.O_CREAT | fcntl.O_APPEND
|
||||
default:
|
||||
panic(m)
|
||||
}
|
||||
fd, err := unix.Open(GoString(pathname), int(flags), 0666)
|
||||
if err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %q: %v FAIL", origin(1), GoString(pathname), GoString(mode), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return 0
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %q: fd %v", origin(1), GoString(pathname), GoString(mode), fd)
|
||||
}
|
||||
if p := newFile(t, int32(fd)); p != 0 {
|
||||
return p
|
||||
}
|
||||
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
// int lstat(const char *pathname, struct stat *statbuf);
|
||||
func Xlstat64(t *TLS, pathname, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2))
|
||||
}
|
||||
if err := unix.Lstat(GoString(pathname), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v FAIL", origin(1), GoString(pathname), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: ok", origin(1), GoString(pathname))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int stat(const char *pathname, struct stat *statbuf);
|
||||
func Xstat64(t *TLS, pathname, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2))
|
||||
}
|
||||
if err := unix.Stat(GoString(pathname), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v FAIL", origin(1), GoString(pathname), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: ok", origin(1), GoString(pathname))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int mkdir(const char *path, mode_t mode);
|
||||
func Xmkdir(t *TLS, path uintptr, mode types.Mode_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v path=%v mode=%v, (%v:)", t, path, mode, origin(2))
|
||||
}
|
||||
if err := unix.Mkdir(GoString(path), uint32(mode)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v FAIL", origin(1), GoString(path), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: ok", origin(1), GoString(path))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int access(const char *pathname, int mode);
|
||||
func Xaccess(t *TLS, pathname uintptr, mode int32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2))
|
||||
}
|
||||
if err := unix.Access(GoString(pathname), uint32(mode)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: %v FAIL", origin(1), GoString(pathname), mode, err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int unlink(const char *pathname);
|
||||
func Xunlink(t *TLS, pathname uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v, (%v:)", t, pathname, origin(2))
|
||||
}
|
||||
if err := unix.Unlink(GoString(pathname)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v", origin(1), GoString(pathname), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);
|
||||
func Xreadlink(t *TLS, path, buf uintptr, bufsize types.Size_t) types.Ssize_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v buf=%v bufsize=%v, (%v:)", t, buf, bufsize, origin(2))
|
||||
}
|
||||
var n int
|
||||
var err error
|
||||
switch {
|
||||
case buf == 0 || bufsize == 0:
|
||||
n, err = unix.Readlink(GoString(path), nil)
|
||||
default:
|
||||
n, err = unix.Readlink(GoString(path), (*RawMem)(unsafe.Pointer(buf))[:bufsize:bufsize])
|
||||
}
|
||||
if err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok")
|
||||
}
|
||||
return types.Ssize_t(n)
|
||||
}
|
||||
|
||||
// int symlink(const char *target, const char *linkpath);
|
||||
func Xsymlink(t *TLS, target, linkpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v linkpath=%v, (%v:)", t, linkpath, origin(2))
|
||||
}
|
||||
if err := unix.Symlink(GoString(target), GoString(linkpath)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int chmod(const char *pathname, mode_t mode)
|
||||
func Xchmod(t *TLS, pathname uintptr, mode types.Mode_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2))
|
||||
}
|
||||
if err := unix.Chmod(GoString(pathname), uint32(mode)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: %v FAIL", origin(1), GoString(pathname), mode, err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// time_t time(time_t *tloc);
|
||||
func Xtime(t *TLS, tloc uintptr) time.Time_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v tloc=%v, (%v:)", t, tloc, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n := time.Now().UTC().Unix()
|
||||
// if tloc != 0 {
|
||||
// *(*types.Time_t)(unsafe.Pointer(tloc)) = types.Time_t(n)
|
||||
// }
|
||||
// return types.Time_t(n)
|
||||
}
|
||||
|
||||
// int utimes(const char *filename, const struct timeval times[2]);
|
||||
func Xutimes(t *TLS, filename, times uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v times=%v, (%v:)", t, times, origin(2))
|
||||
}
|
||||
var a []unix.Timeval
|
||||
if times != 0 {
|
||||
a = make([]unix.Timeval, 2)
|
||||
a[0] = *(*unix.Timeval)(unsafe.Pointer(times))
|
||||
a[1] = *(*unix.Timeval)(unsafe.Pointer(times + unsafe.Sizeof(unix.Timeval{})))
|
||||
}
|
||||
if err := unix.Utimes(GoString(filename), a); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int fstat(int fd, struct stat *statbuf);
|
||||
func Xfstat64(t *TLS, fd int32, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v fd=%v statbuf=%v, (%v:)", t, fd, statbuf, origin(2))
|
||||
}
|
||||
if err := unix.Fstat(int(fd), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: fd %d: %v FAIL", origin(1), fd, err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: fd %d: ok", origin(1), fd)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// off64_t lseek64(int fd, off64_t offset, int whence);
|
||||
func Xlseek64(t *TLS, fd int32, offset types.Off_t, whence int32) types.Off_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v fd=%v offset=%v whence=%v, (%v:)", t, fd, offset, whence, origin(2))
|
||||
}
|
||||
n, err := unix.Seek(int(fd), int64(offset), int(whence))
|
||||
if err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: fd %d, offset %#0x, whence %d, ok", origin(1), fd, offset, whence)
|
||||
}
|
||||
return types.Off_t(n)
|
||||
}
|
||||
|
||||
func Xfcntl64(t *TLS, fd, cmd int32, args uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v cmd=%v args=%v, (%v:)", t, cmd, args, origin(2))
|
||||
}
|
||||
var arg uintptr
|
||||
if args != 0 {
|
||||
arg = *(*uintptr)(unsafe.Pointer(args))
|
||||
}
|
||||
n, _, err := unix.Syscall(unix.SYS_FCNTL, uintptr(fd), uintptr(cmd), arg)
|
||||
if err != 0 {
|
||||
if dmesgs {
|
||||
dmesg("%v: fd %v cmd %v", origin(1), fcntlCmdStr(fd), cmd)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %d %s %#x: %d", origin(1), fd, fcntlCmdStr(cmd), arg, n)
|
||||
}
|
||||
return int32(n)
|
||||
}
|
||||
|
||||
// int rename(const char *oldpath, const char *newpath);
|
||||
func Xrename(t *TLS, oldpath, newpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2))
|
||||
}
|
||||
if err := unix.Rename(GoString(oldpath), GoString(newpath)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int mknod(const char *pathname, mode_t mode, dev_t dev);
|
||||
func Xmknod(t *TLS, pathname uintptr, mode types.Mode_t, dev types.Dev_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v dev=%v, (%v:)", t, pathname, mode, dev, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_MKNOD, pathname, uintptr(mode), uintptr(dev)); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int utime(const char *filename, const struct utimbuf *times);
|
||||
func Xutime(t *TLS, filename, times uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v times=%v, (%v:)", t, times, origin(2))
|
||||
}
|
||||
var a []unix.Timeval
|
||||
if times != 0 {
|
||||
a = make([]unix.Timeval, 2)
|
||||
a[0].Sec = (*utime.Utimbuf)(unsafe.Pointer(times)).Factime
|
||||
a[1].Sec = (*utime.Utimbuf)(unsafe.Pointer(times)).Fmodtime
|
||||
}
|
||||
if err := unix.Utimes(GoString(filename), a); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int chown(const char *pathname, uid_t owner, gid_t group);
|
||||
func Xchown(t *TLS, pathname uintptr, owner types.Uid_t, group types.Gid_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v owner=%v group=%v, (%v:)", t, pathname, owner, group, origin(2))
|
||||
}
|
||||
if _, _, err := unix.Syscall(unix.SYS_CHOWN, pathname, uintptr(owner), uintptr(group)); err != 0 {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// int link(const char *oldpath, const char *newpath);
|
||||
func Xlink(t *TLS, oldpath, newpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_LINK, oldpath, newpath, 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int dup2(int oldfd, int newfd);
|
||||
func Xdup2(t *TLS, oldfd, newfd int32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newfd=%v, (%v:)", t, newfd, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n, _, err := unix.Syscall(unix.SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
|
||||
// if err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return int32(n)
|
||||
}
|
||||
|
||||
// unsigned int alarm(unsigned int seconds);
|
||||
func Xalarm(t *TLS, seconds uint32) uint32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v seconds=%v, (%v:)", t, seconds, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n, _, err := unix.Syscall(unix.SYS_ALARM, uintptr(seconds), 0, 0)
|
||||
// if err != 0 {
|
||||
// panic(todo(""))
|
||||
// }
|
||||
|
||||
// return uint32(n)
|
||||
}
|
||||
|
||||
// int getnameinfo(const struct sockaddr * restrict sa, socklen_t salen, char * restrict host, socklen_t hostlen, char * restrict serv, socklen_t servlen, int flags);
|
||||
func Xgetnameinfo(tls *TLS, sa1 uintptr, sl socklen_t, node uintptr, nodelen size_t, serv uintptr, servlen size_t, flags int32) int32 { /* getnameinfo.c:125:5: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v sa1=%v sl=%v node=%v nodelen=%v serv=%v servlen=%v flags=%v, (%v:)", tls, sa1, sl, node, nodelen, serv, servlen, flags, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
//TODO bp := tls.Alloc(347)
|
||||
//TODO defer tls.Free(347)
|
||||
|
||||
//TODO // var ptr [78]int8 at bp, 78
|
||||
|
||||
//TODO // var buf [256]int8 at bp+78, 256
|
||||
|
||||
//TODO // var num [13]int8 at bp+334, 13
|
||||
|
||||
//TODO var af int32 = int32((*sockaddr)(unsafe.Pointer(sa1)).sa_family)
|
||||
//TODO var a uintptr
|
||||
//TODO var scopeid uint32
|
||||
|
||||
//TODO switch af {
|
||||
//TODO case 2:
|
||||
//TODO a = (sa1 + 4 /* &.sin_addr */)
|
||||
//TODO if (uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in{}))) {
|
||||
//TODO return -6
|
||||
//TODO }
|
||||
//TODO mkptr4(tls, bp /* &ptr[0] */, a)
|
||||
//TODO scopeid = uint32(0)
|
||||
//TODO break
|
||||
//TODO case 10:
|
||||
//TODO a = (sa1 + 8 /* &.sin6_addr */)
|
||||
//TODO if (uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in6{}))) {
|
||||
//TODO return -6
|
||||
//TODO }
|
||||
//TODO if Xmemcmp(tls, a, ts+88 /* "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff" */, uint64(12)) != 0 {
|
||||
//TODO mkptr6(tls, bp /* &ptr[0] */, a)
|
||||
//TODO } else {
|
||||
//TODO mkptr4(tls, bp /* &ptr[0] */, (a + uintptr(12)))
|
||||
//TODO }
|
||||
//TODO scopeid = (*sockaddr_in6)(unsafe.Pointer(sa1)).sin6_scope_id
|
||||
//TODO break
|
||||
//TODO default:
|
||||
//TODO return -6
|
||||
//TODO }
|
||||
|
||||
//TODO if (node != 0) && (nodelen != 0) {
|
||||
//TODO *(*int8)(unsafe.Pointer(bp + 78 /* &buf[0] */)) = int8(0)
|
||||
//TODO if !((flags & 0x01) != 0) {
|
||||
//TODO reverse_hosts(tls, bp+78 /* &buf[0] */, a, scopeid, af)
|
||||
//TODO }
|
||||
//TODO if !(int32(*(*int8)(unsafe.Pointer(bp + 78 /* buf */))) != 0) && !((flags & 0x01) != 0) {
|
||||
//TODO Xabort(tls) //TODO-
|
||||
//TODO // unsigned char query[18+PTR_MAX], reply[512];
|
||||
//TODO // int qlen = __res_mkquery(0, ptr, 1, RR_PTR,
|
||||
//TODO // 0, 0, 0, query, sizeof query);
|
||||
//TODO // query[3] = 0; /* don't need AD flag */
|
||||
//TODO // int rlen = __res_send(query, qlen, reply, sizeof reply);
|
||||
//TODO // buf[0] = 0;
|
||||
//TODO // if (rlen > 0)
|
||||
//TODO // __dns_parse(reply, rlen, dns_parse_callback, buf);
|
||||
//TODO }
|
||||
//TODO if !(int32(*(*int8)(unsafe.Pointer(bp + 78 /* buf */))) != 0) {
|
||||
//TODO if (flags & 0x08) != 0 {
|
||||
//TODO return -2
|
||||
//TODO }
|
||||
//TODO Xinet_ntop(tls, af, a, bp+78 /* &buf[0] */, uint32(unsafe.Sizeof([256]int8{})))
|
||||
//TODO if scopeid != 0 {
|
||||
//TODO Xabort(tls) //TODO-
|
||||
//TODO // char *p = 0, tmp[IF_NAMESIZE+1];
|
||||
//TODO // if (!(flags & NI_NUMERICSCOPE) &&
|
||||
//TODO // (IN6_IS_ADDR_LINKLOCAL(a) ||
|
||||
//TODO // IN6_IS_ADDR_MC_LINKLOCAL(a)))
|
||||
//TODO // p = if_indextoname(scopeid, tmp+1);
|
||||
//TODO // if (!p)
|
||||
//TODO // p = itoa(num, scopeid);
|
||||
//TODO // *--p = '%';
|
||||
//TODO // strcat(buf, p);
|
||||
//TODO }
|
||||
//TODO }
|
||||
//TODO if Xstrlen(tls, bp+78 /* &buf[0] */) >= size_t(nodelen) {
|
||||
//TODO return -12
|
||||
//TODO }
|
||||
//TODO Xstrcpy(tls, node, bp+78 /* &buf[0] */)
|
||||
//TODO }
|
||||
|
||||
//TODO if (serv != 0) && (servlen != 0) {
|
||||
//TODO var p uintptr = bp + 78 /* buf */
|
||||
//TODO var port int32 = int32(Xntohs(tls, (*sockaddr_in)(unsafe.Pointer(sa1)).sin_port))
|
||||
//TODO *(*int8)(unsafe.Pointer(bp + 78 /* &buf[0] */)) = int8(0)
|
||||
//TODO if !((flags & 0x02) != 0) {
|
||||
//TODO reverse_services(tls, bp+78 /* &buf[0] */, port, (flags & 0x10))
|
||||
//TODO }
|
||||
//TODO if !(int32(*(*int8)(unsafe.Pointer(p))) != 0) {
|
||||
//TODO p = itoa(tls, bp+334 /* &num[0] */, uint32(port))
|
||||
//TODO }
|
||||
//TODO if Xstrlen(tls, p) >= size_t(servlen) {
|
||||
//TODO return -12
|
||||
//TODO }
|
||||
//TODO Xstrcpy(tls, serv, p)
|
||||
//TODO }
|
||||
|
||||
//TODO return 0
|
||||
}
|
||||
|
||||
func Xgethostbyaddr_r(tls *TLS, a uintptr, l socklen_t, af int32, h uintptr, buf uintptr, buflen size_t, res uintptr, err uintptr) int32 { /* gethostbyaddr_r.c:10:5: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v a=%v l=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, a, l, af, h, buf, buflen, res, err, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
//TODO bp := tls.Alloc(28)
|
||||
//TODO defer tls.Free(28)
|
||||
|
||||
//TODO //TODO union {
|
||||
//TODO //TODO struct sockaddr_in sin;
|
||||
//TODO //TODO struct sockaddr_in6 sin6;
|
||||
//TODO //TODO } sa = { .sin.sin_family = af };
|
||||
//TODO *(*struct {
|
||||
//TODO sin sockaddr_in
|
||||
//TODO _ [12]byte
|
||||
//TODO })(unsafe.Pointer(bp /* sa1 */)) = struct {
|
||||
//TODO sin sockaddr_in
|
||||
//TODO _ [12]byte
|
||||
//TODO }{} //TODO-
|
||||
//TODO (*sockaddr_in)(unsafe.Pointer(bp /* &sa1 */)).sin_family = sa_family_t(af) //TODO-
|
||||
//TODO var sl socklen_t
|
||||
//TODO if af == 10 {
|
||||
//TODO sl = uint32(unsafe.Sizeof(sockaddr_in6{}))
|
||||
//TODO } else {
|
||||
//TODO sl = uint32(unsafe.Sizeof(sockaddr_in{}))
|
||||
//TODO }
|
||||
//TODO var i int32
|
||||
|
||||
//TODO *(*uintptr)(unsafe.Pointer(res)) = uintptr(0)
|
||||
|
||||
//TODO // Load address argument into sockaddr structure
|
||||
//TODO if (af == 10) && (l == socklen_t(16)) {
|
||||
//TODO Xmemcpy(tls, (bp /* &sa1 */ /* &.sin6 */ + 8 /* &.sin6_addr */), a, uint64(16))
|
||||
//TODO } else if (af == 2) && (l == socklen_t(4)) {
|
||||
//TODO Xmemcpy(tls, (bp /* &sa1 */ /* &.sin */ + 4 /* &.sin_addr */), a, uint64(4))
|
||||
//TODO } else {
|
||||
//TODO *(*int32)(unsafe.Pointer(err)) = 3
|
||||
//TODO return 22
|
||||
//TODO }
|
||||
|
||||
//TODO // Align buffer and check for space for pointers and ip address
|
||||
//TODO i = (int32(uintptr_t(buf) & (uint64(unsafe.Sizeof(uintptr(0))) - uint64(1))))
|
||||
//TODO if !(i != 0) {
|
||||
//TODO i = int32(unsafe.Sizeof(uintptr(0)))
|
||||
//TODO }
|
||||
//TODO if buflen <= (((uint64(5) * uint64(unsafe.Sizeof(uintptr(0)))) - uint64(i)) + uint64(l)) {
|
||||
//TODO return 34
|
||||
//TODO }
|
||||
//TODO buf += (uintptr(uint64(unsafe.Sizeof(uintptr(0))) - uint64(i)))
|
||||
//TODO buflen = buflen - (((uint64(5) * uint64(unsafe.Sizeof(uintptr(0)))) - uint64(i)) + uint64(l))
|
||||
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_addr_list = buf
|
||||
//TODO buf += (uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0)))))
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_aliases = buf
|
||||
//TODO buf += (uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0)))))
|
||||
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list)) = buf
|
||||
//TODO Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list)), a, uint64(l))
|
||||
//TODO buf += uintptr(l)
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list + 1*8)) = uintptr(0)
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases)) = buf
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases + 1*8)) = uintptr(0)
|
||||
|
||||
//TODO switch Xgetnameinfo(tls, bp /* &sa1 */, sl, buf, uint32(buflen), uintptr(0), uint32(0), 0) {
|
||||
//TODO case -3:
|
||||
//TODO *(*int32)(unsafe.Pointer(err)) = 2
|
||||
//TODO return 11
|
||||
//TODO case -12:
|
||||
//TODO return 34
|
||||
//TODO default:
|
||||
//TODO fallthrough
|
||||
//TODO case -10:
|
||||
//TODO fallthrough
|
||||
//TODO case -11:
|
||||
//TODO fallthrough
|
||||
//TODO case -4:
|
||||
//TODO *(*int32)(unsafe.Pointer(err)) = 3
|
||||
//TODO return *(*int32)(unsafe.Pointer(X___errno_location(tls)))
|
||||
//TODO case 0:
|
||||
//TODO break
|
||||
//TODO }
|
||||
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_addrtype = af
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_length = int32(l)
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_name = *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases))
|
||||
//TODO *(*uintptr)(unsafe.Pointer(res)) = h
|
||||
//TODO return 0
|
||||
}
|
||||
|
||||
// int getrlimit(int resource, struct rlimit *rlim);
|
||||
func Xgetrlimit64(t *TLS, resource int32, rlim uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v resource=%v rlim=%v, (%v:)", t, resource, rlim, origin(2))
|
||||
}
|
||||
if _, _, err := unix.Syscall(unix.SYS_GETRLIMIT, uintptr(resource), uintptr(rlim), 0); err != 0 {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func newFtsent(t *TLS, info int, path string, stat *unix.Stat_t, err syscall.Errno) (r *fts.FTSENT) {
|
||||
var statp uintptr
|
||||
if stat != nil {
|
||||
statp = Xmalloc(t, types.Size_t(unsafe.Sizeof(unix.Stat_t{})))
|
||||
if statp == 0 {
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
*(*unix.Stat_t)(unsafe.Pointer(statp)) = *stat
|
||||
}
|
||||
csp, errx := CString(path)
|
||||
if errx != nil {
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
return &fts.FTSENT{
|
||||
Ffts_info: uint16(info),
|
||||
Ffts_path: csp,
|
||||
Ffts_pathlen: uint64(len(path)),
|
||||
Ffts_statp: statp,
|
||||
Ffts_errno: int32(err),
|
||||
}
|
||||
}
|
||||
|
||||
// DIR *opendir(const char *name);
|
||||
func Xopendir(t *TLS, name uintptr) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v name=%v, (%v:)", t, name, origin(2))
|
||||
}
|
||||
p := Xmalloc(t, uint64(unsafe.Sizeof(darwinDir{})))
|
||||
if p == 0 {
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
fd := int(Xopen(t, name, fcntl.O_RDONLY|fcntl.O_DIRECTORY|fcntl.O_CLOEXEC, 0))
|
||||
if fd < 0 {
|
||||
if dmesgs {
|
||||
dmesg("%v: FAIL %v", origin(1), (*darwinDir)(unsafe.Pointer(p)).fd)
|
||||
}
|
||||
Xfree(t, p)
|
||||
return 0
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
(*darwinDir)(unsafe.Pointer(p)).fd = fd
|
||||
(*darwinDir)(unsafe.Pointer(p)).h = 0
|
||||
(*darwinDir)(unsafe.Pointer(p)).l = 0
|
||||
(*darwinDir)(unsafe.Pointer(p)).eof = false
|
||||
return p
|
||||
}
|
||||
|
||||
func Xrewinddir(tls *TLS, f uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v f=%v, (%v:)", tls, f, origin(2))
|
||||
}
|
||||
Xfseek(tls, f, 0, stdio.SEEK_SET)
|
||||
}
|
||||
|
||||
// clock_t clock(void);
|
||||
func Xclock(t *TLS) time.Clock_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v, (%v:)", t, origin(2))
|
||||
}
|
||||
return time.Clock_t(gotime.Since(startTime) * gotime.Duration(time.CLOCKS_PER_SEC) / gotime.Second)
|
||||
}
|
||||
|
|
|
|||
714
vendor/modernc.org/libc/libc_openbsd_arm64.go
generated
vendored
714
vendor/modernc.org/libc/libc_openbsd_arm64.go
generated
vendored
|
|
@ -4,721 +4,7 @@
|
|||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"syscall"
|
||||
gotime "time"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"modernc.org/libc/fcntl"
|
||||
"modernc.org/libc/fts"
|
||||
"modernc.org/libc/sys/types"
|
||||
"modernc.org/libc/time"
|
||||
"modernc.org/libc/utime"
|
||||
)
|
||||
|
||||
type (
|
||||
long = int64
|
||||
ulong = uint64
|
||||
)
|
||||
|
||||
var (
|
||||
startTime = gotime.Now() // For clock(3)
|
||||
)
|
||||
|
||||
// int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
|
||||
func Xsigaction(t *TLS, signum int32, act, oldact uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v signum=%v oldact=%v, (%v:)", t, signum, oldact, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_SIGACTION, uintptr(signum), act, oldact); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// FILE *fopen64(const char *pathname, const char *mode);
|
||||
func Xfopen64(t *TLS, pathname, mode uintptr) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v mode=%v, (%v:)", t, mode, origin(2))
|
||||
}
|
||||
m := strings.ReplaceAll(GoString(mode), "b", "")
|
||||
var flags int
|
||||
switch m {
|
||||
case "r":
|
||||
flags = fcntl.O_RDONLY
|
||||
case "r+":
|
||||
flags = fcntl.O_RDWR
|
||||
case "w":
|
||||
flags = fcntl.O_WRONLY | fcntl.O_CREAT | fcntl.O_TRUNC
|
||||
case "w+":
|
||||
flags = fcntl.O_RDWR | fcntl.O_CREAT | fcntl.O_TRUNC
|
||||
case "a":
|
||||
flags = fcntl.O_WRONLY | fcntl.O_CREAT | fcntl.O_APPEND
|
||||
case "a+":
|
||||
flags = fcntl.O_RDWR | fcntl.O_CREAT | fcntl.O_APPEND
|
||||
default:
|
||||
panic(m)
|
||||
}
|
||||
fd, err := unix.Open(GoString(pathname), int(flags), 0666)
|
||||
if err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %q: %v FAIL", origin(1), GoString(pathname), GoString(mode), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return 0
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %q: fd %v", origin(1), GoString(pathname), GoString(mode), fd)
|
||||
}
|
||||
if p := newFile(t, int32(fd)); p != 0 {
|
||||
return p
|
||||
}
|
||||
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
// int lstat(const char *pathname, struct stat *statbuf);
|
||||
func Xlstat64(t *TLS, pathname, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2))
|
||||
}
|
||||
if err := unix.Lstat(GoString(pathname), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v FAIL", origin(1), GoString(pathname), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: ok", origin(1), GoString(pathname))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int stat(const char *pathname, struct stat *statbuf);
|
||||
func Xstat64(t *TLS, pathname, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2))
|
||||
}
|
||||
if err := unix.Stat(GoString(pathname), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v FAIL", origin(1), GoString(pathname), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: ok", origin(1), GoString(pathname))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int mkdir(const char *path, mode_t mode);
|
||||
func Xmkdir(t *TLS, path uintptr, mode types.Mode_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v path=%v mode=%v, (%v:)", t, path, mode, origin(2))
|
||||
}
|
||||
if err := unix.Mkdir(GoString(path), uint32(mode)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v FAIL", origin(1), GoString(path), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: ok", origin(1), GoString(path))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int access(const char *pathname, int mode);
|
||||
func Xaccess(t *TLS, pathname uintptr, mode int32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2))
|
||||
}
|
||||
if err := unix.Access(GoString(pathname), uint32(mode)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: %v FAIL", origin(1), GoString(pathname), mode, err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int unlink(const char *pathname);
|
||||
func Xunlink(t *TLS, pathname uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v, (%v:)", t, pathname, origin(2))
|
||||
}
|
||||
if err := unix.Unlink(GoString(pathname)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v", origin(1), GoString(pathname), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);
|
||||
func Xreadlink(t *TLS, path, buf uintptr, bufsize types.Size_t) types.Ssize_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v buf=%v bufsize=%v, (%v:)", t, buf, bufsize, origin(2))
|
||||
}
|
||||
var n int
|
||||
var err error
|
||||
switch {
|
||||
case buf == 0 || bufsize == 0:
|
||||
n, err = unix.Readlink(GoString(path), nil)
|
||||
default:
|
||||
n, err = unix.Readlink(GoString(path), (*RawMem)(unsafe.Pointer(buf))[:bufsize:bufsize])
|
||||
}
|
||||
if err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok")
|
||||
}
|
||||
return types.Ssize_t(n)
|
||||
}
|
||||
|
||||
// int symlink(const char *target, const char *linkpath);
|
||||
func Xsymlink(t *TLS, target, linkpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v linkpath=%v, (%v:)", t, linkpath, origin(2))
|
||||
}
|
||||
if err := unix.Symlink(GoString(target), GoString(linkpath)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int chmod(const char *pathname, mode_t mode)
|
||||
func Xchmod(t *TLS, pathname uintptr, mode types.Mode_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2))
|
||||
}
|
||||
if err := unix.Chmod(GoString(pathname), uint32(mode)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: %v FAIL", origin(1), GoString(pathname), mode, err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// time_t time(time_t *tloc);
|
||||
func Xtime(t *TLS, tloc uintptr) time.Time_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v tloc=%v, (%v:)", t, tloc, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n := time.Now().UTC().Unix()
|
||||
// if tloc != 0 {
|
||||
// *(*types.Time_t)(unsafe.Pointer(tloc)) = types.Time_t(n)
|
||||
// }
|
||||
// return types.Time_t(n)
|
||||
}
|
||||
|
||||
// int utimes(const char *filename, const struct timeval times[2]);
|
||||
func Xutimes(t *TLS, filename, times uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v times=%v, (%v:)", t, times, origin(2))
|
||||
}
|
||||
var a []unix.Timeval
|
||||
if times != 0 {
|
||||
a = make([]unix.Timeval, 2)
|
||||
a[0] = *(*unix.Timeval)(unsafe.Pointer(times))
|
||||
a[1] = *(*unix.Timeval)(unsafe.Pointer(times + unsafe.Sizeof(unix.Timeval{})))
|
||||
}
|
||||
if err := unix.Utimes(GoString(filename), a); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int fstat(int fd, struct stat *statbuf);
|
||||
func Xfstat64(t *TLS, fd int32, statbuf uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v fd=%v statbuf=%v, (%v:)", t, fd, statbuf, origin(2))
|
||||
}
|
||||
if err := unix.Fstat(int(fd), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: fd %d: %v FAIL", origin(1), fd, err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: fd %d: ok", origin(1), fd)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// off64_t lseek64(int fd, off64_t offset, int whence);
|
||||
func Xlseek64(t *TLS, fd int32, offset types.Off_t, whence int32) types.Off_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v fd=%v offset=%v whence=%v, (%v:)", t, fd, offset, whence, origin(2))
|
||||
}
|
||||
n, err := unix.Seek(int(fd), int64(offset), int(whence))
|
||||
if err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return types.Off_t(n)
|
||||
}
|
||||
|
||||
func Xfcntl64(t *TLS, fd, cmd int32, args uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v cmd=%v args=%v, (%v:)", t, cmd, args, origin(2))
|
||||
}
|
||||
var arg uintptr
|
||||
if args != 0 {
|
||||
arg = *(*uintptr)(unsafe.Pointer(args))
|
||||
}
|
||||
n, _, err := unix.Syscall(unix.SYS_FCNTL, uintptr(fd), uintptr(cmd), arg)
|
||||
if err != 0 {
|
||||
if dmesgs {
|
||||
dmesg("%v: fd %v cmd %v", origin(1), fcntlCmdStr(fd), cmd)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %d %s %#x: %d", origin(1), fd, fcntlCmdStr(cmd), arg, n)
|
||||
}
|
||||
return int32(n)
|
||||
}
|
||||
|
||||
// int rename(const char *oldpath, const char *newpath);
|
||||
func Xrename(t *TLS, oldpath, newpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2))
|
||||
}
|
||||
if err := unix.Rename(GoString(oldpath), GoString(newpath)); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int mknod(const char *pathname, mode_t mode, dev_t dev);
|
||||
func Xmknod(t *TLS, pathname uintptr, mode types.Mode_t, dev types.Dev_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v mode=%v dev=%v, (%v:)", t, pathname, mode, dev, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_MKNOD, pathname, uintptr(mode), uintptr(dev)); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int utime(const char *filename, const struct utimbuf *times);
|
||||
func Xutime(t *TLS, filename, times uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v times=%v, (%v:)", t, times, origin(2))
|
||||
}
|
||||
var a []unix.Timeval
|
||||
if times != 0 {
|
||||
a = make([]unix.Timeval, 2)
|
||||
a[0].Sec = (*utime.Utimbuf)(unsafe.Pointer(times)).Factime
|
||||
a[1].Sec = (*utime.Utimbuf)(unsafe.Pointer(times)).Fmodtime
|
||||
}
|
||||
if err := unix.Utimes(GoString(filename), a); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %v FAIL", origin(1), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// int chown(const char *pathname, uid_t owner, gid_t group);
|
||||
func Xchown(t *TLS, pathname uintptr, owner types.Uid_t, group types.Gid_t) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v owner=%v group=%v, (%v:)", t, pathname, owner, group, origin(2))
|
||||
}
|
||||
if _, _, err := unix.Syscall(unix.SYS_CHOWN, pathname, uintptr(owner), uintptr(group)); err != 0 {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// int link(const char *oldpath, const char *newpath);
|
||||
func Xlink(t *TLS, oldpath, newpath uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// if _, _, err := unix.Syscall(unix.SYS_LINK, oldpath, newpath, 0); err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return 0
|
||||
}
|
||||
|
||||
// int dup2(int oldfd, int newfd);
|
||||
func Xdup2(t *TLS, oldfd, newfd int32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v newfd=%v, (%v:)", t, newfd, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n, _, err := unix.Syscall(unix.SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
|
||||
// if err != 0 {
|
||||
// t.setErrno(err)
|
||||
// return -1
|
||||
// }
|
||||
|
||||
// return int32(n)
|
||||
}
|
||||
|
||||
// unsigned int alarm(unsigned int seconds);
|
||||
func Xalarm(t *TLS, seconds uint32) uint32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v seconds=%v, (%v:)", t, seconds, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
// n, _, err := unix.Syscall(unix.SYS_ALARM, uintptr(seconds), 0, 0)
|
||||
// if err != 0 {
|
||||
// panic(todo(""))
|
||||
// }
|
||||
|
||||
// return uint32(n)
|
||||
}
|
||||
|
||||
// int getnameinfo(const struct sockaddr * restrict sa, socklen_t salen, char * restrict host, socklen_t hostlen, char * restrict serv, socklen_t servlen, int flags);
|
||||
func Xgetnameinfo(tls *TLS, sa1 uintptr, sl socklen_t, node uintptr, nodelen size_t, serv uintptr, servlen size_t, flags int32) int32 { /* getnameinfo.c:125:5: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v sa1=%v sl=%v node=%v nodelen=%v serv=%v servlen=%v flags=%v, (%v:)", tls, sa1, sl, node, nodelen, serv, servlen, flags, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
//TODO bp := tls.Alloc(347)
|
||||
//TODO defer tls.Free(347)
|
||||
|
||||
//TODO // var ptr [78]int8 at bp, 78
|
||||
|
||||
//TODO // var buf [256]int8 at bp+78, 256
|
||||
|
||||
//TODO // var num [13]int8 at bp+334, 13
|
||||
|
||||
//TODO var af int32 = int32((*sockaddr)(unsafe.Pointer(sa1)).sa_family)
|
||||
//TODO var a uintptr
|
||||
//TODO var scopeid uint32
|
||||
|
||||
//TODO switch af {
|
||||
//TODO case 2:
|
||||
//TODO a = (sa1 + 4 /* &.sin_addr */)
|
||||
//TODO if (uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in{}))) {
|
||||
//TODO return -6
|
||||
//TODO }
|
||||
//TODO mkptr4(tls, bp /* &ptr[0] */, a)
|
||||
//TODO scopeid = uint32(0)
|
||||
//TODO break
|
||||
//TODO case 10:
|
||||
//TODO a = (sa1 + 8 /* &.sin6_addr */)
|
||||
//TODO if (uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in6{}))) {
|
||||
//TODO return -6
|
||||
//TODO }
|
||||
//TODO if Xmemcmp(tls, a, ts+88 /* "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff" */, uint64(12)) != 0 {
|
||||
//TODO mkptr6(tls, bp /* &ptr[0] */, a)
|
||||
//TODO } else {
|
||||
//TODO mkptr4(tls, bp /* &ptr[0] */, (a + uintptr(12)))
|
||||
//TODO }
|
||||
//TODO scopeid = (*sockaddr_in6)(unsafe.Pointer(sa1)).sin6_scope_id
|
||||
//TODO break
|
||||
//TODO default:
|
||||
//TODO return -6
|
||||
//TODO }
|
||||
|
||||
//TODO if (node != 0) && (nodelen != 0) {
|
||||
//TODO *(*int8)(unsafe.Pointer(bp + 78 /* &buf[0] */)) = int8(0)
|
||||
//TODO if !((flags & 0x01) != 0) {
|
||||
//TODO reverse_hosts(tls, bp+78 /* &buf[0] */, a, scopeid, af)
|
||||
//TODO }
|
||||
//TODO if !(int32(*(*int8)(unsafe.Pointer(bp + 78 /* buf */))) != 0) && !((flags & 0x01) != 0) {
|
||||
//TODO Xabort(tls) //TODO-
|
||||
//TODO // unsigned char query[18+PTR_MAX], reply[512];
|
||||
//TODO // int qlen = __res_mkquery(0, ptr, 1, RR_PTR,
|
||||
//TODO // 0, 0, 0, query, sizeof query);
|
||||
//TODO // query[3] = 0; /* don't need AD flag */
|
||||
//TODO // int rlen = __res_send(query, qlen, reply, sizeof reply);
|
||||
//TODO // buf[0] = 0;
|
||||
//TODO // if (rlen > 0)
|
||||
//TODO // __dns_parse(reply, rlen, dns_parse_callback, buf);
|
||||
//TODO }
|
||||
//TODO if !(int32(*(*int8)(unsafe.Pointer(bp + 78 /* buf */))) != 0) {
|
||||
//TODO if (flags & 0x08) != 0 {
|
||||
//TODO return -2
|
||||
//TODO }
|
||||
//TODO Xinet_ntop(tls, af, a, bp+78 /* &buf[0] */, uint32(unsafe.Sizeof([256]int8{})))
|
||||
//TODO if scopeid != 0 {
|
||||
//TODO Xabort(tls) //TODO-
|
||||
//TODO // char *p = 0, tmp[IF_NAMESIZE+1];
|
||||
//TODO // if (!(flags & NI_NUMERICSCOPE) &&
|
||||
//TODO // (IN6_IS_ADDR_LINKLOCAL(a) ||
|
||||
//TODO // IN6_IS_ADDR_MC_LINKLOCAL(a)))
|
||||
//TODO // p = if_indextoname(scopeid, tmp+1);
|
||||
//TODO // if (!p)
|
||||
//TODO // p = itoa(num, scopeid);
|
||||
//TODO // *--p = '%';
|
||||
//TODO // strcat(buf, p);
|
||||
//TODO }
|
||||
//TODO }
|
||||
//TODO if Xstrlen(tls, bp+78 /* &buf[0] */) >= size_t(nodelen) {
|
||||
//TODO return -12
|
||||
//TODO }
|
||||
//TODO Xstrcpy(tls, node, bp+78 /* &buf[0] */)
|
||||
//TODO }
|
||||
|
||||
//TODO if (serv != 0) && (servlen != 0) {
|
||||
//TODO var p uintptr = bp + 78 /* buf */
|
||||
//TODO var port int32 = int32(Xntohs(tls, (*sockaddr_in)(unsafe.Pointer(sa1)).sin_port))
|
||||
//TODO *(*int8)(unsafe.Pointer(bp + 78 /* &buf[0] */)) = int8(0)
|
||||
//TODO if !((flags & 0x02) != 0) {
|
||||
//TODO reverse_services(tls, bp+78 /* &buf[0] */, port, (flags & 0x10))
|
||||
//TODO }
|
||||
//TODO if !(int32(*(*int8)(unsafe.Pointer(p))) != 0) {
|
||||
//TODO p = itoa(tls, bp+334 /* &num[0] */, uint32(port))
|
||||
//TODO }
|
||||
//TODO if Xstrlen(tls, p) >= size_t(servlen) {
|
||||
//TODO return -12
|
||||
//TODO }
|
||||
//TODO Xstrcpy(tls, serv, p)
|
||||
//TODO }
|
||||
|
||||
//TODO return 0
|
||||
}
|
||||
|
||||
func Xgethostbyaddr_r(tls *TLS, a uintptr, l socklen_t, af int32, h uintptr, buf uintptr, buflen size_t, res uintptr, err uintptr) int32 { /* gethostbyaddr_r.c:10:5: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v a=%v l=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, a, l, af, h, buf, buflen, res, err, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
//TODO bp := tls.Alloc(28)
|
||||
//TODO defer tls.Free(28)
|
||||
|
||||
//TODO //TODO union {
|
||||
//TODO //TODO struct sockaddr_in sin;
|
||||
//TODO //TODO struct sockaddr_in6 sin6;
|
||||
//TODO //TODO } sa = { .sin.sin_family = af };
|
||||
//TODO *(*struct {
|
||||
//TODO sin sockaddr_in
|
||||
//TODO _ [12]byte
|
||||
//TODO })(unsafe.Pointer(bp /* sa1 */)) = struct {
|
||||
//TODO sin sockaddr_in
|
||||
//TODO _ [12]byte
|
||||
//TODO }{} //TODO-
|
||||
//TODO (*sockaddr_in)(unsafe.Pointer(bp /* &sa1 */)).sin_family = sa_family_t(af) //TODO-
|
||||
//TODO var sl socklen_t
|
||||
//TODO if af == 10 {
|
||||
//TODO sl = uint32(unsafe.Sizeof(sockaddr_in6{}))
|
||||
//TODO } else {
|
||||
//TODO sl = uint32(unsafe.Sizeof(sockaddr_in{}))
|
||||
//TODO }
|
||||
//TODO var i int32
|
||||
|
||||
//TODO *(*uintptr)(unsafe.Pointer(res)) = uintptr(0)
|
||||
|
||||
//TODO // Load address argument into sockaddr structure
|
||||
//TODO if (af == 10) && (l == socklen_t(16)) {
|
||||
//TODO Xmemcpy(tls, (bp /* &sa1 */ /* &.sin6 */ + 8 /* &.sin6_addr */), a, uint64(16))
|
||||
//TODO } else if (af == 2) && (l == socklen_t(4)) {
|
||||
//TODO Xmemcpy(tls, (bp /* &sa1 */ /* &.sin */ + 4 /* &.sin_addr */), a, uint64(4))
|
||||
//TODO } else {
|
||||
//TODO *(*int32)(unsafe.Pointer(err)) = 3
|
||||
//TODO return 22
|
||||
//TODO }
|
||||
|
||||
//TODO // Align buffer and check for space for pointers and ip address
|
||||
//TODO i = (int32(uintptr_t(buf) & (uint64(unsafe.Sizeof(uintptr(0))) - uint64(1))))
|
||||
//TODO if !(i != 0) {
|
||||
//TODO i = int32(unsafe.Sizeof(uintptr(0)))
|
||||
//TODO }
|
||||
//TODO if buflen <= (((uint64(5) * uint64(unsafe.Sizeof(uintptr(0)))) - uint64(i)) + uint64(l)) {
|
||||
//TODO return 34
|
||||
//TODO }
|
||||
//TODO buf += (uintptr(uint64(unsafe.Sizeof(uintptr(0))) - uint64(i)))
|
||||
//TODO buflen = buflen - (((uint64(5) * uint64(unsafe.Sizeof(uintptr(0)))) - uint64(i)) + uint64(l))
|
||||
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_addr_list = buf
|
||||
//TODO buf += (uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0)))))
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_aliases = buf
|
||||
//TODO buf += (uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0)))))
|
||||
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list)) = buf
|
||||
//TODO Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list)), a, uint64(l))
|
||||
//TODO buf += uintptr(l)
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list + 1*8)) = uintptr(0)
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases)) = buf
|
||||
//TODO *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases + 1*8)) = uintptr(0)
|
||||
|
||||
//TODO switch Xgetnameinfo(tls, bp /* &sa1 */, sl, buf, uint32(buflen), uintptr(0), uint32(0), 0) {
|
||||
//TODO case -3:
|
||||
//TODO *(*int32)(unsafe.Pointer(err)) = 2
|
||||
//TODO return 11
|
||||
//TODO case -12:
|
||||
//TODO return 34
|
||||
//TODO default:
|
||||
//TODO fallthrough
|
||||
//TODO case -10:
|
||||
//TODO fallthrough
|
||||
//TODO case -11:
|
||||
//TODO fallthrough
|
||||
//TODO case -4:
|
||||
//TODO *(*int32)(unsafe.Pointer(err)) = 3
|
||||
//TODO return *(*int32)(unsafe.Pointer(X___errno_location(tls)))
|
||||
//TODO case 0:
|
||||
//TODO break
|
||||
//TODO }
|
||||
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_addrtype = af
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_length = int32(l)
|
||||
//TODO (*hostent)(unsafe.Pointer(h)).h_name = *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases))
|
||||
//TODO *(*uintptr)(unsafe.Pointer(res)) = h
|
||||
//TODO return 0
|
||||
}
|
||||
|
||||
// int getrlimit(int resource, struct rlimit *rlim);
|
||||
func Xgetrlimit64(t *TLS, resource int32, rlim uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v resource=%v rlim=%v, (%v:)", t, resource, rlim, origin(2))
|
||||
}
|
||||
if _, _, err := unix.Syscall(unix.SYS_GETRLIMIT, uintptr(resource), uintptr(rlim), 0); err != 0 {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func newFtsent(t *TLS, info int, path string, stat *unix.Stat_t, err syscall.Errno) (r *fts.FTSENT) {
|
||||
var statp uintptr
|
||||
if stat != nil {
|
||||
statp = Xmalloc(t, types.Size_t(unsafe.Sizeof(unix.Stat_t{})))
|
||||
if statp == 0 {
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
*(*unix.Stat_t)(unsafe.Pointer(statp)) = *stat
|
||||
}
|
||||
csp, errx := CString(path)
|
||||
if errx != nil {
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
return &fts.FTSENT{
|
||||
Ffts_info: uint16(info),
|
||||
Ffts_path: csp,
|
||||
Ffts_pathlen: uint64(len(path)),
|
||||
Ffts_statp: statp,
|
||||
Ffts_errno: int32(err),
|
||||
}
|
||||
}
|
||||
|
||||
// DIR *opendir(const char *name);
|
||||
func Xopendir(t *TLS, name uintptr) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v name=%v, (%v:)", t, name, origin(2))
|
||||
}
|
||||
p := Xmalloc(t, uint64(unsafe.Sizeof(darwinDir{})))
|
||||
if p == 0 {
|
||||
panic("OOM")
|
||||
}
|
||||
|
||||
fd := int(Xopen(t, name, fcntl.O_RDONLY|fcntl.O_DIRECTORY|fcntl.O_CLOEXEC, 0))
|
||||
if fd < 0 {
|
||||
if dmesgs {
|
||||
dmesg("%v: FAIL %v", origin(1), (*darwinDir)(unsafe.Pointer(p)).fd)
|
||||
}
|
||||
Xfree(t, p)
|
||||
return 0
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: ok", origin(1))
|
||||
}
|
||||
(*darwinDir)(unsafe.Pointer(p)).fd = fd
|
||||
(*darwinDir)(unsafe.Pointer(p)).h = 0
|
||||
(*darwinDir)(unsafe.Pointer(p)).l = 0
|
||||
(*darwinDir)(unsafe.Pointer(p)).eof = false
|
||||
return p
|
||||
}
|
||||
|
||||
// clock_t clock(void);
|
||||
func Xclock(t *TLS) time.Clock_t {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v, (%v:)", t, origin(2))
|
||||
}
|
||||
return time.Clock_t(gotime.Since(startTime) * gotime.Duration(time.CLOCKS_PER_SEC) / gotime.Second)
|
||||
}
|
||||
|
|
|
|||
34
vendor/modernc.org/libc/libc_unix.go
generated
vendored
34
vendor/modernc.org/libc/libc_unix.go
generated
vendored
|
|
@ -2,15 +2,15 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build unix
|
||||
//go:build unix && !(linux && (amd64 || loong64))
|
||||
// +build unix
|
||||
// +build !linux !amd64,!loong64
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
// "encoding/hex"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/rand"
|
||||
"os"
|
||||
|
|
@ -117,10 +117,6 @@ func Xgethostname(t *TLS, name uintptr, slen types.Size_t) int32 {
|
|||
if __ccgo_strace {
|
||||
trc("t=%v name=%v slen=%v, (%v:)", t, name, slen, origin(2))
|
||||
}
|
||||
if slen < 0 {
|
||||
t.setErrno(errno.EINVAL)
|
||||
return -1
|
||||
}
|
||||
|
||||
if slen == 0 {
|
||||
return 0
|
||||
|
|
@ -298,7 +294,7 @@ func Xtmpfile(t *TLS) uintptr {
|
|||
if __ccgo_strace {
|
||||
trc("t=%v, (%v:)", t, origin(2))
|
||||
}
|
||||
f, err := ioutil.TempFile("", "tmpfile-")
|
||||
f, err := os.CreateTemp("", "tmpfile-")
|
||||
if err != nil {
|
||||
t.setErrno(err)
|
||||
return 0
|
||||
|
|
@ -317,7 +313,7 @@ func Xtmpfile(t *TLS) uintptr {
|
|||
// FILE *fdopen(int fd, const char *mode);
|
||||
func Xfdopen(t *TLS, fd int32, mode uintptr) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v fd=%v mode=%v, (%v:)", t, fd, mode, origin(2))
|
||||
trc("t=%v fd=%v mode=%v, (%v:)", t, fd, GoString(mode), origin(2))
|
||||
}
|
||||
m := strings.ReplaceAll(GoString(mode), "b", "")
|
||||
switch m {
|
||||
|
|
@ -333,12 +329,12 @@ func Xfdopen(t *TLS, fd int32, mode uintptr) uintptr {
|
|||
return 0
|
||||
}
|
||||
|
||||
if p := newFile(t, fd); p != 0 {
|
||||
return p
|
||||
p := newFile(t, fd)
|
||||
if p == 0 {
|
||||
t.setErrno(errno.EINVAL)
|
||||
return 0
|
||||
}
|
||||
|
||||
t.setErrno(errno.EINVAL)
|
||||
return 0
|
||||
return p
|
||||
}
|
||||
|
||||
// struct passwd *getpwnam(const char *name);
|
||||
|
|
@ -587,11 +583,7 @@ func initPasswd2(t *TLS, buf uintptr, buflen types.Size_t, p *pwd.Passwd, name,
|
|||
}
|
||||
|
||||
p.Fpw_shell, buf, buflen = bufString(buf, buflen, shell)
|
||||
if buf == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
return buf != 0
|
||||
}
|
||||
|
||||
func bufString(buf uintptr, buflen types.Size_t, s string) (uintptr, uintptr, types.Size_t) {
|
||||
|
|
@ -971,14 +963,16 @@ func Xuuid_unparse(t *TLS, uu, out uintptr) {
|
|||
*(*byte)(unsafe.Pointer(out + uintptr(len(s)))) = 0
|
||||
}
|
||||
|
||||
var staticRandomData = &rand.Rand{}
|
||||
// no longer used?
|
||||
// var staticRandomData = &rand.Rand{}
|
||||
|
||||
// char *initstate(unsigned seed, char *state, size_t size);
|
||||
func Xinitstate(t *TLS, seed uint32, statebuf uintptr, statelen types.Size_t) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v seed=%v statebuf=%v statelen=%v, (%v:)", t, seed, statebuf, statelen, origin(2))
|
||||
}
|
||||
staticRandomData = rand.New(rand.NewSource(int64(seed)))
|
||||
// staticRandomData = rand.New(rand.NewSource(int64(seed)))
|
||||
_ = rand.New(rand.NewSource(int64(seed)))
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
|||
2
vendor/modernc.org/libc/libc_unix1.go
generated
vendored
2
vendor/modernc.org/libc/libc_unix1.go
generated
vendored
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build unix && !illumos
|
||||
//go:build unix && !illumos && !(linux && (amd64 || loong64)) && !openbsd
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
|
|
|||
6
vendor/modernc.org/libc/mem.go
generated
vendored
6
vendor/modernc.org/libc/mem.go
generated
vendored
|
|
@ -2,8 +2,10 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !libc.membrk && !libc.memgrind
|
||||
// +build !libc.membrk,!libc.memgrind
|
||||
//go:build !libc.membrk && !libc.memgrind && !(linux && (amd64 || loong64))
|
||||
// +build !libc.membrk
|
||||
// +build !libc.memgrind
|
||||
// +build !linux !amd64,!loong64
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
|
|
|||
6
vendor/modernc.org/libc/mem_brk.go
generated
vendored
6
vendor/modernc.org/libc/mem_brk.go
generated
vendored
|
|
@ -2,8 +2,10 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build libc.membrk && !libc.memgrind
|
||||
// +build libc.membrk,!libc.memgrind
|
||||
//go:build libc.membrk && !libc.memgrind && !(linux && (amd64 || loong64))
|
||||
// +build libc.membrk
|
||||
// +build !libc.memgrind
|
||||
// +build !linux !amd64,!loong64
|
||||
|
||||
// This is a debug-only version of the memory handling functions. When a
|
||||
// program is built with -tags=libc.membrk a simple but safe version of malloc
|
||||
|
|
|
|||
305
vendor/modernc.org/libc/mem_brk_musl.go
generated
vendored
Normal file
305
vendor/modernc.org/libc/mem_brk_musl.go
generated
vendored
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
// Copyright 2023 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 libc.membrk && !libc.memgrind && linux && (amd64 || loong64)
|
||||
|
||||
// This is a debug-only version of the memory handling functions. When a
|
||||
// program is built with -tags=libc.membrk a simple but safe version of malloc
|
||||
// and friends is used that works like sbrk(2). Additionally free becomes a
|
||||
// nop.
|
||||
|
||||
// The fixed heap is initially filled with random bytes from a full cycle PRNG,
|
||||
// program startup time is substantially prolonged.
|
||||
|
||||
package libc // import "modernc.org/libc/v2"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/bits"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"modernc.org/mathutil"
|
||||
)
|
||||
|
||||
const (
|
||||
isMemBrk = true
|
||||
|
||||
heapSize = 1 << 30
|
||||
)
|
||||
|
||||
var (
|
||||
brkIndex uintptr
|
||||
heap [heapSize]byte
|
||||
heapP uintptr
|
||||
heap0 uintptr
|
||||
heapRecords []heapRecord
|
||||
heapUsable = map[uintptr]Tsize_t{}
|
||||
heapFree = map[uintptr]struct{}{}
|
||||
rng *mathutil.FC32
|
||||
)
|
||||
|
||||
type heapRecord struct {
|
||||
p uintptr
|
||||
pc uintptr
|
||||
}
|
||||
|
||||
func (r *heapRecord) String() string {
|
||||
return fmt.Sprintf("[p=%#0x usable=%v pc=%s]", r.p, Xmalloc_usable_size(nil, r.p), pc2origin(r.pc))
|
||||
}
|
||||
|
||||
func init() {
|
||||
if roundup(heapGuard, heapAlign) != heapGuard {
|
||||
panic("internal error")
|
||||
}
|
||||
|
||||
heap0 = uintptr(unsafe.Pointer(&heap[0]))
|
||||
heapP = roundup(heap0, heapAlign)
|
||||
var err error
|
||||
if rng, err = mathutil.NewFC32(math.MinInt32, math.MaxInt32, true); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
rng.Seed(time.Now().UnixNano())
|
||||
for i := range heap {
|
||||
heap[i] = byte(rng.Next())
|
||||
}
|
||||
}
|
||||
|
||||
func pc2origin(pc uintptr) string {
|
||||
f := runtime.FuncForPC(pc)
|
||||
var fn, fns string
|
||||
var fl int
|
||||
if f != nil {
|
||||
fn, fl = f.FileLine(pc)
|
||||
fns = f.Name()
|
||||
if x := strings.LastIndex(fns, "."); x > 0 {
|
||||
fns = fns[x+1:]
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s:%d:%s", fn, fl, fns)
|
||||
}
|
||||
|
||||
func malloc0(tls *TLS, pc uintptr, n0 Tsize_t, zero bool) (r uintptr) {
|
||||
usable := roundup(uintptr(n0), heapAlign)
|
||||
rq := usable + 2*heapGuard
|
||||
if brkIndex+rq > uintptr(len(heap)) {
|
||||
tls.setErrno(ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
r, brkIndex = heapP+brkIndex, brkIndex+rq
|
||||
heapRecords = append(heapRecords, heapRecord{p: r, pc: pc})
|
||||
r += heapGuard
|
||||
heapUsable[r] = Tsize_t(usable)
|
||||
if zero {
|
||||
n := uintptr(n0)
|
||||
for i := uintptr(0); i < n; i++ {
|
||||
*(*byte)(unsafe.Pointer(r + i)) = 0
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func Xmalloc(tls *TLS, n Tsize_t) (r uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v n=%v, (%v:)", tls, n, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
|
||||
if n > math.MaxInt {
|
||||
tls.setErrno(ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
if n == 0 {
|
||||
// malloc(0) should return unique pointers
|
||||
// (often expected and gnulib replaces malloc if malloc(0) returns 0)
|
||||
n = 1
|
||||
}
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
pc, _, _, _ := runtime.Caller(1)
|
||||
return malloc0(tls, pc, n, false)
|
||||
}
|
||||
|
||||
func Xcalloc(tls *TLS, m Tsize_t, n Tsize_t) (r uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v m=%v n=%v, (%v:)", tls, m, n, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
|
||||
hi, rq := bits.Mul(uint(m), uint(n))
|
||||
if hi != 0 || rq > math.MaxInt {
|
||||
tls.setErrno(ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
if rq == 0 {
|
||||
rq = 1
|
||||
}
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
pc, _, _, _ := runtime.Caller(1)
|
||||
return malloc0(tls, pc, Tsize_t(rq), true)
|
||||
}
|
||||
|
||||
func Xrealloc(tls *TLS, p uintptr, n Tsize_t) (r uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v p=%v n=%v, (%v:)", tls, p, n, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
|
||||
if n == 0 {
|
||||
Xfree(tls, p)
|
||||
return 0
|
||||
}
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
pc, _, _, _ := runtime.Caller(1)
|
||||
if p == 0 {
|
||||
return malloc0(tls, pc, n, false)
|
||||
}
|
||||
|
||||
usable := heapUsable[p]
|
||||
if usable == 0 {
|
||||
panic(todo("realloc of unallocated memory: %#0x", p))
|
||||
}
|
||||
|
||||
if usable >= n { // in place
|
||||
return p
|
||||
}
|
||||
|
||||
// malloc
|
||||
r = malloc0(tls, pc, n, false)
|
||||
copy(unsafe.Slice((*byte)(unsafe.Pointer(r)), usable), unsafe.Slice((*byte)(unsafe.Pointer(p)), usable))
|
||||
Xfree(tls, p)
|
||||
return r
|
||||
}
|
||||
|
||||
func Xfree(tls *TLS, p uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v p=%v, (%v:)", tls, p, origin(2))
|
||||
}
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
if p == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if _, ok := heapUsable[p]; !ok {
|
||||
panic(todo("free of unallocated memory: %#0x", p))
|
||||
}
|
||||
|
||||
if _, ok := heapFree[p]; ok {
|
||||
panic(todo("double free: %#0x", p))
|
||||
}
|
||||
|
||||
heapFree[p] = struct{}{}
|
||||
}
|
||||
|
||||
func Xmalloc_usable_size(tls *TLS, p uintptr) (r Tsize_t) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v p=%v, (%v:)", tls, p, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
if p == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
return heapUsable[p]
|
||||
}
|
||||
|
||||
func MemAudit() (r []*MemAuditError) {
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
a := heapRecords
|
||||
auditP := heap0
|
||||
rng.Seek(0)
|
||||
for _, v := range a {
|
||||
heapP := v.p
|
||||
mallocP := heapP + heapGuard
|
||||
usable := heapUsable[mallocP]
|
||||
for ; auditP < mallocP; auditP++ {
|
||||
if g, e := *(*byte)(unsafe.Pointer(auditP)), byte(rng.Next()); g != e {
|
||||
r = append(r, &MemAuditError{Caller: pc2origin(v.pc), Message: fmt.Sprintf("guard area before %#0x, %v is corrupted at %#0x, got %#02x, expected %#02x", mallocP, usable, auditP, g, e)})
|
||||
}
|
||||
}
|
||||
for i := 0; Tsize_t(i) < usable; i++ {
|
||||
rng.Next()
|
||||
}
|
||||
auditP = mallocP + uintptr(usable)
|
||||
z := roundup(auditP, heapAlign)
|
||||
z += heapGuard
|
||||
for ; auditP < z; auditP++ {
|
||||
if g, e := *(*byte)(unsafe.Pointer(auditP)), byte(rng.Next()); g != e {
|
||||
r = append(r, &MemAuditError{Caller: pc2origin(v.pc), Message: fmt.Sprintf("guard area after %#0x, %v is corrupted at %#0x, got %#02x, expected %#02x", mallocP, usable, auditP, g, e)})
|
||||
}
|
||||
}
|
||||
}
|
||||
z := heap0 + uintptr(len(heap))
|
||||
for ; auditP < z; auditP++ {
|
||||
if g, e := *(*byte)(unsafe.Pointer(auditP)), byte(rng.Next()); g != e {
|
||||
r = append(r, &MemAuditError{Caller: "-", Message: fmt.Sprintf("guard area after used heap is corrupted at %#0x, got %#02x, expected %#02x", auditP, g, e)})
|
||||
return r // Report only the first fail
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func UsableSize(p uintptr) Tsize_t {
|
||||
if p == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
return heapUsable[p]
|
||||
}
|
||||
|
||||
// MemAuditStart locks the memory allocator, initializes and enables memory
|
||||
// auditing. Finaly it unlocks the memory allocator.
|
||||
//
|
||||
// Some memory handling errors, like double free or freeing of unallocated
|
||||
// memory, will panic when memory auditing is enabled.
|
||||
//
|
||||
// This memory auditing functionality has to be enabled using the libc.memgrind
|
||||
// build tag.
|
||||
//
|
||||
// It is intended only for debug/test builds. It slows down memory allocation
|
||||
// routines and it has additional memory costs.
|
||||
func MemAuditStart() {}
|
||||
|
||||
// MemAuditReport locks the memory allocator, reports memory leaks, if any.
|
||||
// Finally it disables memory auditing and unlocks the memory allocator.
|
||||
//
|
||||
// This memory auditing functionality has to be enabled using the libc.memgrind
|
||||
// build tag.
|
||||
//
|
||||
// It is intended only for debug/test builds. It slows down memory allocation
|
||||
// routines and it has additional memory costs.
|
||||
func MemAuditReport() error { return nil }
|
||||
151
vendor/modernc.org/libc/mem_musl.go
generated
vendored
Normal file
151
vendor/modernc.org/libc/mem_musl.go
generated
vendored
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
// Copyright 2023 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 !libc.membrk && !libc.memgrind && linux && (amd64 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc/v2"
|
||||
|
||||
import (
|
||||
"math"
|
||||
"math/bits"
|
||||
|
||||
"modernc.org/memory"
|
||||
)
|
||||
|
||||
const (
|
||||
isMemBrk = false
|
||||
)
|
||||
|
||||
func Xmalloc(tls *TLS, n Tsize_t) (r uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v n=%v, (%v:)", tls, n, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
if n > math.MaxInt {
|
||||
tls.setErrno(ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
if n == 0 {
|
||||
// malloc(0) should return unique pointers
|
||||
// (often expected and gnulib replaces malloc if malloc(0) returns 0)
|
||||
n = 1
|
||||
}
|
||||
var err error
|
||||
if r, err = allocator.UintptrMalloc(int(n)); err != nil {
|
||||
r = 0
|
||||
tls.setErrno(ENOMEM)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func Xcalloc(tls *TLS, m Tsize_t, n Tsize_t) (r uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v m=%v n=%v, (%v:)", tls, m, n, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
hi, rq := bits.Mul(uint(m), uint(n))
|
||||
if hi != 0 || rq > math.MaxInt {
|
||||
tls.setErrno(ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
if rq == 0 {
|
||||
rq = 1
|
||||
}
|
||||
|
||||
var err error
|
||||
if r, err = allocator.UintptrCalloc(int(rq)); err != nil {
|
||||
r = 0
|
||||
tls.setErrno(ENOMEM)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func Xrealloc(tls *TLS, p uintptr, n Tsize_t) (r uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v p=%v n=%v, (%v:)", tls, p, n, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
var err error
|
||||
if r, err = allocator.UintptrRealloc(p, int(n)); err != nil {
|
||||
r = 0
|
||||
tls.setErrno(ENOMEM)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func Xfree(tls *TLS, p uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v p=%v, (%v:)", tls, p, origin(2))
|
||||
}
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
allocator.UintptrFree(p)
|
||||
}
|
||||
|
||||
func Xmalloc_usable_size(tls *TLS, p uintptr) (r Tsize_t) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v p=%v, (%v:)", tls, p, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
if p == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
return Tsize_t(memory.UintptrUsableSize(p))
|
||||
}
|
||||
|
||||
func MemAudit() (r []*MemAuditError) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func UsableSize(p uintptr) Tsize_t {
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
return Tsize_t(memory.UintptrUsableSize(p))
|
||||
}
|
||||
|
||||
// MemAuditStart locks the memory allocator, initializes and enables memory
|
||||
// auditing. Finaly it unlocks the memory allocator.
|
||||
//
|
||||
// Some memory handling errors, like double free or freeing of unallocated
|
||||
// memory, will panic when memory auditing is enabled.
|
||||
//
|
||||
// This memory auditing functionality has to be enabled using the libc.memgrind
|
||||
// build tag.
|
||||
//
|
||||
// It is intended only for debug/test builds. It slows down memory allocation
|
||||
// routines and it has additional memory costs.
|
||||
func MemAuditStart() {}
|
||||
|
||||
// MemAuditReport locks the memory allocator, reports memory leaks, if any.
|
||||
// Finally it disables memory auditing and unlocks the memory allocator.
|
||||
//
|
||||
// This memory auditing functionality has to be enabled using the libc.memgrind
|
||||
// build tag.
|
||||
//
|
||||
// It is intended only for debug/test builds. It slows down memory allocation
|
||||
// routines and it has additional memory costs.
|
||||
func MemAuditReport() error { return nil }
|
||||
6
vendor/modernc.org/libc/memgrind.go
generated
vendored
6
vendor/modernc.org/libc/memgrind.go
generated
vendored
|
|
@ -2,8 +2,10 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !libc.membrk && libc.memgrind
|
||||
// +build !libc.membrk,libc.memgrind
|
||||
//go:build !libc.membrk && libc.memgrind && !(linux && (amd64 || loong64))
|
||||
// +build !libc.membrk
|
||||
// +build libc.memgrind
|
||||
// +build !linux !amd64,!loong64
|
||||
|
||||
// This is a debug-only version of the memory handling functions. When a
|
||||
// program is built with -tags=libc.memgrind the functions MemAuditStart and
|
||||
|
|
|
|||
339
vendor/modernc.org/libc/memgrind_musl.go
generated
vendored
Normal file
339
vendor/modernc.org/libc/memgrind_musl.go
generated
vendored
Normal file
|
|
@ -0,0 +1,339 @@
|
|||
// Copyright 2021 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 !libc.membrk && libc.memgrind && linux && (amd64 || loong64)
|
||||
|
||||
// This is a debug-only version of the memory handling functions. When a
|
||||
// program is built with -tags=libc.memgrind the functions MemAuditStart and
|
||||
// MemAuditReport can be used to check for memory leaks.
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"modernc.org/memory"
|
||||
)
|
||||
|
||||
const (
|
||||
isMemBrk = false
|
||||
memgrind = true
|
||||
)
|
||||
|
||||
type memReportItem struct {
|
||||
p, pc uintptr
|
||||
s string
|
||||
}
|
||||
|
||||
func (it *memReportItem) String() string {
|
||||
more := it.s
|
||||
if more != "" {
|
||||
a := strings.Split(more, "\n")
|
||||
more = "\n\t\t" + strings.Join(a, "\n\t\t")
|
||||
}
|
||||
return fmt.Sprintf("\t%s: %#x%s", pc2origin(it.pc), it.p, more)
|
||||
}
|
||||
|
||||
type memReport []memReportItem
|
||||
|
||||
func (r memReport) Error() string {
|
||||
a := []string{"memory leaks"}
|
||||
for _, v := range r {
|
||||
a = append(a, v.String())
|
||||
}
|
||||
return strings.Join(a, "\n")
|
||||
}
|
||||
|
||||
var (
|
||||
allocs map[uintptr]uintptr // addr: caller
|
||||
allocsMore map[uintptr]string
|
||||
frees map[uintptr]uintptr // addr: caller
|
||||
memAudit memReport
|
||||
memAuditEnabled bool
|
||||
)
|
||||
|
||||
func pc2origin(pc uintptr) string {
|
||||
f := runtime.FuncForPC(pc)
|
||||
var fn, fns string
|
||||
var fl int
|
||||
if f != nil {
|
||||
fn, fl = f.FileLine(pc)
|
||||
fns = f.Name()
|
||||
if x := strings.LastIndex(fns, "."); x > 0 {
|
||||
fns = fns[x+1:]
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s:%d:%s", fn, fl, fns)
|
||||
}
|
||||
|
||||
// void *malloc(size_t size);
|
||||
func Xmalloc(t *TLS, size Tsize_t) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v size=%v, (%v:)", t, size, origin(2))
|
||||
}
|
||||
if size == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
p, err := allocator.UintptrCalloc(int(size))
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %v -> %#x, %v", origin(1), size, p, err)
|
||||
// }
|
||||
if err != nil {
|
||||
t.setErrno(ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
if memAuditEnabled {
|
||||
pc, _, _, ok := runtime.Caller(1)
|
||||
if !ok {
|
||||
panic("cannot obtain caller's PC")
|
||||
}
|
||||
|
||||
delete(frees, p)
|
||||
if pc0, ok := allocs[p]; ok {
|
||||
dmesg("%v: malloc returns same address twice, previous call at %v:", pc2origin(pc), pc2origin(pc0))
|
||||
panic(fmt.Errorf("%v: malloc returns same address twice, previous call at %v:", pc2origin(pc), pc2origin(pc0)))
|
||||
}
|
||||
|
||||
allocs[p] = pc
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
// void *calloc(size_t nmemb, size_t size);
|
||||
func Xcalloc(t *TLS, n, size Tsize_t) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v size=%v, (%v:)", t, size, origin(2))
|
||||
}
|
||||
rq := int(n * size)
|
||||
if rq == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
p, err := allocator.UintptrCalloc(int(n * size))
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %v -> %#x, %v", origin(1), n*size, p, err)
|
||||
// }
|
||||
if err != nil {
|
||||
t.setErrno(ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
if memAuditEnabled {
|
||||
pc, _, _, ok := runtime.Caller(1)
|
||||
if !ok {
|
||||
panic("cannot obtain caller's PC")
|
||||
}
|
||||
|
||||
delete(frees, p)
|
||||
if pc0, ok := allocs[p]; ok {
|
||||
dmesg("%v: calloc returns same address twice, previous call at %v:", pc2origin(pc), pc2origin(pc0))
|
||||
panic(fmt.Errorf("%v: calloc returns same address twice, previous call at %v:", pc2origin(pc), pc2origin(pc0)))
|
||||
}
|
||||
|
||||
allocs[p] = pc
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
// void *realloc(void *ptr, size_t size);
|
||||
func Xrealloc(t *TLS, ptr uintptr, size Tsize_t) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v ptr=%v size=%v, (%v:)", t, ptr, size, origin(2))
|
||||
}
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
var pc uintptr
|
||||
if memAuditEnabled {
|
||||
var ok bool
|
||||
if pc, _, _, ok = runtime.Caller(1); !ok {
|
||||
panic("cannot obtain caller's PC")
|
||||
}
|
||||
|
||||
if ptr != 0 {
|
||||
if pc0, ok := frees[ptr]; ok {
|
||||
dmesg("%v: realloc: double free of %#x, previous call at %v:", pc2origin(pc), ptr, pc2origin(pc0))
|
||||
panic(fmt.Errorf("%v: realloc: double free of %#x, previous call at %v:", pc2origin(pc), ptr, pc2origin(pc0)))
|
||||
}
|
||||
|
||||
if _, ok := allocs[ptr]; !ok {
|
||||
dmesg("%v: %v: realloc, free of unallocated memory: %#x", origin(1), pc2origin(pc), ptr)
|
||||
panic(fmt.Errorf("%v: realloc, free of unallocated memory: %#x", pc2origin(pc), ptr))
|
||||
}
|
||||
|
||||
delete(allocs, ptr)
|
||||
delete(allocsMore, ptr)
|
||||
frees[ptr] = pc
|
||||
}
|
||||
}
|
||||
|
||||
p, err := allocator.UintptrRealloc(ptr, int(size))
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %#x, %v -> %#x, %v", origin(1), ptr, size, p, err)
|
||||
// }
|
||||
if err != nil {
|
||||
t.setErrno(ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
if memAuditEnabled && p != 0 {
|
||||
delete(frees, p)
|
||||
if pc0, ok := allocs[p]; ok {
|
||||
dmesg("%v: realloc returns same address twice, previous call at %v:", pc2origin(pc), pc2origin(pc0))
|
||||
panic(fmt.Errorf("%v: realloc returns same address twice, previous call at %v:", pc2origin(pc), pc2origin(pc0)))
|
||||
}
|
||||
|
||||
allocs[p] = pc
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
// void free(void *ptr);
|
||||
func Xfree(t *TLS, p uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v p=%v, (%v:)", t, p, origin(2))
|
||||
}
|
||||
if p == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// if dmesgs {
|
||||
// dmesg("%v: %#x", origin(1), p)
|
||||
// }
|
||||
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
sz := memory.UintptrUsableSize(p)
|
||||
if memAuditEnabled {
|
||||
pc, _, _, ok := runtime.Caller(1)
|
||||
if !ok {
|
||||
panic("cannot obtain caller's PC")
|
||||
}
|
||||
|
||||
if pc0, ok := frees[p]; ok {
|
||||
dmesg("%v: double free of %#x, previous call at %v:", pc2origin(pc), p, pc2origin(pc0))
|
||||
panic(fmt.Errorf("%v: double free of %#x, previous call at %v:", pc2origin(pc), p, pc2origin(pc0)))
|
||||
}
|
||||
|
||||
if _, ok := allocs[p]; !ok {
|
||||
dmesg("%v: free of unallocated memory: %#x", pc2origin(pc), p)
|
||||
panic(fmt.Errorf("%v: free of unallocated memory: %#x", pc2origin(pc), p))
|
||||
}
|
||||
|
||||
delete(allocs, p)
|
||||
delete(allocsMore, p)
|
||||
frees[p] = pc
|
||||
}
|
||||
|
||||
for i := uintptr(0); i < uintptr(sz); i++ {
|
||||
*(*byte)(unsafe.Pointer(p + i)) = 0
|
||||
}
|
||||
allocator.UintptrFree(p)
|
||||
}
|
||||
|
||||
func UsableSize(p uintptr) Tsize_t {
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
if memAuditEnabled {
|
||||
pc, _, _, ok := runtime.Caller(1)
|
||||
if !ok {
|
||||
panic("cannot obtain caller's PC")
|
||||
}
|
||||
|
||||
if _, ok := allocs[p]; !ok {
|
||||
dmesg("%v: usable size of unallocated memory: %#x", pc2origin(pc), p)
|
||||
panic(fmt.Errorf("%v: usable size of unallocated memory: %#x", pc2origin(pc), p))
|
||||
}
|
||||
}
|
||||
|
||||
return Tsize_t(memory.UintptrUsableSize(p))
|
||||
}
|
||||
|
||||
func Xmalloc_usable_size(tls *TLS, p uintptr) (r Tsize_t) {
|
||||
return UsableSize(p)
|
||||
}
|
||||
|
||||
// MemAuditStart locks the memory allocator, initializes and enables memory
|
||||
// auditing. Finally it unlocks the memory allocator.
|
||||
//
|
||||
// Some memory handling errors, like double free or freeing of unallocated
|
||||
// memory, will panic when memory auditing is enabled.
|
||||
//
|
||||
// This memory auditing functionality has to be enabled using the libc.memgrind
|
||||
// build tag.
|
||||
//
|
||||
// It is intended only for debug/test builds. It slows down memory allocation
|
||||
// routines and it has additional memory costs.
|
||||
func MemAuditStart() {
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
allocs = map[uintptr]uintptr{} // addr: caller
|
||||
allocsMore = map[uintptr]string{}
|
||||
frees = map[uintptr]uintptr{} // addr: caller
|
||||
memAuditEnabled = true
|
||||
}
|
||||
|
||||
// MemAuditReport locks the memory allocator, reports memory leaks, if any.
|
||||
// Finally it disables memory auditing and unlocks the memory allocator.
|
||||
//
|
||||
// This memory auditing functionality has to be enabled using the libc.memgrind
|
||||
// build tag.
|
||||
//
|
||||
// It is intended only for debug/test builds. It slows down memory allocation
|
||||
// routines and it has additional memory costs.
|
||||
func MemAuditReport() (r error) {
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer func() {
|
||||
allocs = nil
|
||||
allocsMore = nil
|
||||
frees = nil
|
||||
memAuditEnabled = false
|
||||
memAudit = nil
|
||||
allocatorMu.Unlock()
|
||||
}()
|
||||
|
||||
if len(allocs) != 0 {
|
||||
for p, pc := range allocs {
|
||||
memAudit = append(memAudit, memReportItem{p, pc, allocsMore[p]})
|
||||
}
|
||||
sort.Slice(memAudit, func(i, j int) bool {
|
||||
return memAudit[i].String() < memAudit[j].String()
|
||||
})
|
||||
return memAudit
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func MemAuditAnnotate(pc uintptr, s string) {
|
||||
allocatorMu.Lock()
|
||||
allocsMore[pc] = s
|
||||
allocatorMu.Unlock()
|
||||
}
|
||||
|
||||
func MemAudit() (r []*MemAuditError) {
|
||||
return nil
|
||||
}
|
||||
2
vendor/modernc.org/libc/musl_linux_amd64.go
generated
vendored
2
vendor/modernc.org/libc/musl_linux_amd64.go
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
// Code generated by 'ccgo -export-externs X -hide __syscall0,__syscall1,__syscall2,__syscall3,__syscall4,__syscall5,__syscall6 -nostdinc -nostdlib -o ../musl_linux_amd64.go -pkgname libc -static-locals-prefix _s -Iarch/x86_64 -Iarch/generic -Iobj/src/internal -Isrc/include -Isrc/internal -Iobj/include -Iinclude copyright.c src/ctype/__ctype_b_loc.c src/ctype/isalnum.c src/ctype/isalpha.c src/ctype/isdigit.c src/ctype/islower.c src/ctype/isprint.c src/ctype/isupper.c src/ctype/isxdigit.c src/dirent/closedir.c src/dirent/opendir.c src/dirent/readdir.c src/internal/floatscan.c src/internal/intscan.c src/internal/shgetc.c src/locale/localeconv.c src/math/__fpclassify.c src/math/__fpclassifyf.c src/math/__fpclassifyl.c src/math/copysignl.c src/math/fabsl.c src/math/fmodl.c src/math/nanf.c src/math/rint.c src/math/scalbn.c src/math/scalbnl.c src/multibyte/internal.c src/multibyte/mbrtowc.c src/multibyte/mbsinit.c src/network/freeaddrinfo.c src/network/getaddrinfo.c src/network/gethostbyaddr.c src/network/gethostbyaddr_r.c src/network/gethostbyname.c src/network/gethostbyname2.c src/network/gethostbyname2_r.c src/network/gethostbyname_r.c src/network/getnameinfo.c src/network/h_errno.c src/network/inet_aton.c src/network/inet_ntop.c src/network/inet_pton.c src/network/lookup_ipliteral.c src/network/lookup_name.c src/network/lookup_serv.c src/prng/rand_r.c src/stdio/__lockfile.c src/stdio/__toread.c src/stdio/__uflow.c src/stdio/sscanf.c src/stdio/vfscanf.c src/stdio/vsscanf.c src/stdlib/bsearch.c src/stdlib/strtod.c src/stdlib/strtol.c src/string/strdup.c src/string/strlcat.c src/string/strlcpy.c src/string/strncasecmp.c src/string/strncat.c src/string/strnlen.c src/string/strspn.c src/string/strtok.c src/thread/pthread_attr_get.c src/thread/pthread_attr_setdetachstate.c src/thread/pthread_mutex_lock.c src/thread/pthread_mutexattr_destroy.c src/thread/pthread_mutexattr_init.c src/thread/pthread_mutexattr_settype.c', DO NOT EDIT.
|
||||
|
||||
//go:build !(linux && amd64)
|
||||
|
||||
package libc
|
||||
|
||||
import (
|
||||
|
|
|
|||
7201
vendor/modernc.org/libc/musl_linux_loong64.go
generated
vendored
7201
vendor/modernc.org/libc/musl_linux_loong64.go
generated
vendored
File diff suppressed because it is too large
Load diff
2
vendor/modernc.org/libc/printf.go
generated
vendored
2
vendor/modernc.org/libc/printf.go
generated
vendored
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && (amd64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
|
|
|||
27
vendor/modernc.org/libc/pthread.go
generated
vendored
27
vendor/modernc.org/libc/pthread.go
generated
vendored
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && (amd64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
|
@ -37,6 +39,7 @@ type TLS struct {
|
|||
errnop uintptr
|
||||
allocaStack [][]uintptr
|
||||
allocas []uintptr
|
||||
jumpBuffers []uintptr
|
||||
pthreadData
|
||||
stack stackHeader
|
||||
|
||||
|
|
@ -82,6 +85,29 @@ func (t *TLS) FreeAlloca() func() {
|
|||
}
|
||||
}
|
||||
|
||||
func (tls *TLS) PushJumpBuffer(jb uintptr) {
|
||||
tls.jumpBuffers = append(tls.jumpBuffers, jb)
|
||||
}
|
||||
|
||||
type LongjmpRetval int32
|
||||
|
||||
func (tls *TLS) PopJumpBuffer(jb uintptr) {
|
||||
n := len(tls.jumpBuffers)
|
||||
if n == 0 || tls.jumpBuffers[n-1] != jb {
|
||||
panic(todo("unsupported setjmp/longjmp usage"))
|
||||
}
|
||||
|
||||
tls.jumpBuffers = tls.jumpBuffers[:n-1]
|
||||
}
|
||||
|
||||
func (tls *TLS) Longjmp(jb uintptr, val int32) {
|
||||
tls.PopJumpBuffer(jb)
|
||||
if val == 0 {
|
||||
val = 1
|
||||
}
|
||||
panic(LongjmpRetval(val))
|
||||
}
|
||||
|
||||
func Xalloca(tls *TLS, size size_t) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v size=%v, (%v:)", tls, size, origin(2))
|
||||
|
|
@ -420,6 +446,7 @@ func (m *mutex) lock(id int32) int32 {
|
|||
|
||||
m.Unlock()
|
||||
m.wait.Lock()
|
||||
// intentional empty section - wake up other waiters
|
||||
m.wait.Unlock()
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
6
vendor/modernc.org/libc/pthread_all.go
generated
vendored
6
vendor/modernc.org/libc/pthread_all.go
generated
vendored
|
|
@ -2,8 +2,10 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !freebsd && !openbsd
|
||||
// +build !freebsd,!openbsd
|
||||
//go:build !freebsd && !openbsd && !(linux && (amd64 || loong64))
|
||||
// +build !freebsd
|
||||
// +build !openbsd
|
||||
// +build !linux !amd64,!loong64
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
|
|
|||
508
vendor/modernc.org/libc/pthread_musl.go
generated
vendored
Normal file
508
vendor/modernc.org/libc/pthread_musl.go
generated
vendored
Normal file
|
|
@ -0,0 +1,508 @@
|
|||
// 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 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"slices"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type pthreadAttr struct {
|
||||
detachState int32
|
||||
}
|
||||
|
||||
type pthreadCleanupItem struct {
|
||||
routine, arg uintptr
|
||||
}
|
||||
|
||||
// C version is 40 bytes.
|
||||
type pthreadMutex struct {
|
||||
sync.Mutex // 0 8
|
||||
count int32 // 8 4
|
||||
mType uint32 // 12 4
|
||||
outer sync.Mutex // 16 8
|
||||
owner int32 // 20 4
|
||||
// 24
|
||||
}
|
||||
|
||||
type pthreadConds struct {
|
||||
sync.Mutex
|
||||
conds map[uintptr][]chan struct{}
|
||||
}
|
||||
|
||||
var (
|
||||
// Ensure there's enough space for unsafe type conversions.
|
||||
_ [unsafe.Sizeof(sync.Mutex{}) - __CCGO_SIZEOF_GO_MUTEX]byte
|
||||
_ [unsafe.Sizeof(Tpthread_mutex_t{}) - unsafe.Sizeof(pthreadMutex{})]byte
|
||||
_ [unsafe.Sizeof(Tpthread_attr_t{}) - unsafe.Sizeof(pthreadAttr{})]byte
|
||||
|
||||
pthreadKeysMutex sync.Mutex
|
||||
pthreadKeyDestructors []uintptr
|
||||
pthreadKeysFree []Tpthread_key_t
|
||||
|
||||
conds = pthreadConds{conds: map[uintptr][]chan struct{}{}}
|
||||
)
|
||||
|
||||
func _pthread_setcancelstate(tls *TLS, new int32, old uintptr) int32 {
|
||||
//TODO actually respect cancel state
|
||||
if uint32(new) > 2 {
|
||||
return EINVAL
|
||||
}
|
||||
|
||||
p := tls.pthread + unsafe.Offsetof(t__pthread{}.Fcanceldisable)
|
||||
if old != 0 {
|
||||
r := *(*int32)(unsafe.Pointer(p))
|
||||
*(*int32)(unsafe.Pointer(old)) = int32(byte(r))
|
||||
}
|
||||
*(*int32)(unsafe.Pointer(p)) = new
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_getspecific(tls *TLS, k Tpthread_key_t) uintptr {
|
||||
return tls.pthreadKeyValues[k]
|
||||
}
|
||||
|
||||
func Xpthread_setspecific(tls *TLS, k Tpthread_key_t, x uintptr) int32 {
|
||||
if tls.pthreadKeyValues == nil {
|
||||
tls.pthreadKeyValues = map[Tpthread_key_t]uintptr{}
|
||||
}
|
||||
tls.pthreadKeyValues[k] = x
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_key_create(tls *TLS, k uintptr, dtor uintptr) int32 {
|
||||
pthreadKeysMutex.Lock()
|
||||
|
||||
defer pthreadKeysMutex.Unlock()
|
||||
|
||||
var key Tpthread_key_t
|
||||
switch l := Tpthread_key_t(len(pthreadKeysFree)); {
|
||||
case l == 0:
|
||||
key = Tpthread_key_t(len(pthreadKeyDestructors))
|
||||
pthreadKeyDestructors = append(pthreadKeyDestructors, dtor)
|
||||
default:
|
||||
key = pthreadKeysFree[l-1]
|
||||
pthreadKeysFree = pthreadKeysFree[:l-1]
|
||||
pthreadKeyDestructors[key] = dtor
|
||||
}
|
||||
*(*Tpthread_key_t)(unsafe.Pointer(k)) = key
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_key_delete(tls *TLS, k Tpthread_key_t) int32 {
|
||||
pthreadKeysMutex.Lock()
|
||||
|
||||
defer pthreadKeysMutex.Unlock()
|
||||
|
||||
pthreadKeysFree = append(pthreadKeysFree, k)
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_create(tls *TLS, res, attrp, entry, arg uintptr) int32 {
|
||||
var attr pthreadAttr
|
||||
if attrp != 0 {
|
||||
attr = *(*pthreadAttr)(unsafe.Pointer(attrp))
|
||||
}
|
||||
|
||||
detachState := int32(_DT_JOINABLE)
|
||||
if attr.detachState != 0 {
|
||||
detachState = _DT_DETACHED
|
||||
}
|
||||
tls2 := NewTLS()
|
||||
tls2.ownsPthread = false
|
||||
*(*Tpthread_t)(unsafe.Pointer(res)) = tls2.pthread
|
||||
(*t__pthread)(unsafe.Pointer(tls2.pthread)).Fdetach_state = detachState
|
||||
if detachState == _DT_JOINABLE {
|
||||
(*sync.Mutex)(unsafe.Pointer(tls2.pthread + unsafe.Offsetof(t__pthread{}.F__ccgo_join_mutex))).Lock()
|
||||
}
|
||||
|
||||
go func() {
|
||||
Xpthread_exit(tls2, (*(*func(*TLS, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{entry})))(tls2, arg))
|
||||
}()
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_exit(tls *TLS, result uintptr) {
|
||||
state := atomic.LoadInt32((*int32)(unsafe.Pointer(tls.pthread + unsafe.Offsetof(t__pthread{}.Fdetach_state))))
|
||||
(*t__pthread)(unsafe.Pointer(tls.pthread)).Fresult = result
|
||||
switch state {
|
||||
case _DT_JOINABLE, _DT_DETACHED:
|
||||
// ok
|
||||
default:
|
||||
panic(todo("", state))
|
||||
}
|
||||
|
||||
for len(tls.pthreadCleanupItems) != 0 {
|
||||
Xpthread_cleanup_pop(tls, 1)
|
||||
}
|
||||
for {
|
||||
done := true
|
||||
for k, v := range tls.pthreadKeyValues {
|
||||
if v != 0 {
|
||||
delete(tls.pthreadKeyValues, k)
|
||||
pthreadKeysMutex.Lock()
|
||||
d := pthreadKeyDestructors[k]
|
||||
pthreadKeysMutex.Unlock()
|
||||
if d != 0 {
|
||||
done = false
|
||||
(*(*func(*TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{d})))(tls, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
if done {
|
||||
break
|
||||
}
|
||||
}
|
||||
if state == _DT_JOINABLE {
|
||||
(*sync.Mutex)(unsafe.Pointer(tls.pthread + unsafe.Offsetof(t__pthread{}.F__ccgo_join_mutex))).Unlock()
|
||||
}
|
||||
atomic.StoreInt32((*int32)(unsafe.Pointer(tls.pthread+unsafe.Offsetof(t__pthread{}.Fdetach_state))), _DT_EXITED)
|
||||
tls.Close()
|
||||
runtime.Goexit()
|
||||
}
|
||||
|
||||
func Xpthread_join(tls *TLS, t Tpthread_t, res uintptr) (r int32) {
|
||||
if (*t__pthread)(unsafe.Pointer(t)).Fdetach_state > _DT_JOINABLE {
|
||||
return EINVAL
|
||||
}
|
||||
|
||||
(*sync.Mutex)(unsafe.Pointer(t + unsafe.Offsetof(t__pthread{}.F__ccgo_join_mutex))).Lock()
|
||||
if res != 0 {
|
||||
*(*uintptr)(unsafe.Pointer(res)) = (*t__pthread)(unsafe.Pointer(tls.pthread)).Fresult
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_cleanup_push(tls *TLS, f, x uintptr) {
|
||||
X_pthread_cleanup_push(tls, 0, f, x)
|
||||
}
|
||||
|
||||
func __pthread_cleanup_push(tls *TLS, _, f, x uintptr) {
|
||||
tls.pthreadCleanupItems = append(tls.pthreadCleanupItems, pthreadCleanupItem{f, x})
|
||||
}
|
||||
|
||||
func X_pthread_cleanup_push(tls *TLS, _, f, x uintptr) {
|
||||
tls.pthreadCleanupItems = append(tls.pthreadCleanupItems, pthreadCleanupItem{f, x})
|
||||
}
|
||||
|
||||
func Xpthread_cleanup_pop(tls *TLS, run int32) {
|
||||
X_pthread_cleanup_pop(tls, 0, run)
|
||||
}
|
||||
|
||||
func __pthread_cleanup_pop(tls *TLS, _ uintptr, run int32) {
|
||||
X_pthread_cleanup_pop(tls, 0, run)
|
||||
}
|
||||
|
||||
func X_pthread_cleanup_pop(tls *TLS, _ uintptr, run int32) {
|
||||
l := len(tls.pthreadCleanupItems)
|
||||
item := tls.pthreadCleanupItems[l-1]
|
||||
tls.pthreadCleanupItems = tls.pthreadCleanupItems[:l-1]
|
||||
if run != 0 {
|
||||
(*(*func(*TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{item.routine})))(tls, item.arg)
|
||||
}
|
||||
}
|
||||
|
||||
func Xpthread_attr_init(tls *TLS, a uintptr) int32 {
|
||||
*(*Tpthread_attr_t)(unsafe.Pointer(a)) = Tpthread_attr_t{}
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_attr_setscope(tls *TLS, a uintptr, scope int32) int32 {
|
||||
switch scope {
|
||||
case PTHREAD_SCOPE_SYSTEM:
|
||||
return 0
|
||||
case PTHREAD_SCOPE_PROCESS:
|
||||
return ENOTSUP
|
||||
default:
|
||||
return EINVAL
|
||||
}
|
||||
}
|
||||
|
||||
func Xpthread_attr_setstacksize(tls *TLS, a uintptr, stacksite Tsize_t) int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_attr_setdetachstate(tls *TLS, a uintptr, state int32) (r int32) {
|
||||
if uint32(state) > 1 {
|
||||
return EINVAL
|
||||
}
|
||||
|
||||
(*pthreadAttr)(unsafe.Pointer(a)).detachState = state
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_attr_getdetachstate(tls *TLS, a uintptr, state uintptr) int32 {
|
||||
*(*int32)(unsafe.Pointer(state)) = (*pthreadAttr)(unsafe.Pointer(a)).detachState
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_attr_destroy(tls *TLS, a uintptr) int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_self(tls *TLS) uintptr {
|
||||
return tls.pthread
|
||||
}
|
||||
|
||||
func Xpthread_mutex_init(tls *TLS, m, a uintptr) int32 {
|
||||
*(*Tpthread_mutex_t)(unsafe.Pointer(m)) = Tpthread_mutex_t{}
|
||||
if a != 0 {
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).mType = (*Tpthread_mutexattr_t)(unsafe.Pointer(a)).F__attr
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_mutex_destroy(tls *TLS, mutex uintptr) int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_mutex_lock(tls *TLS, m uintptr) int32 {
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Lock()
|
||||
owner := (*pthreadMutex)(unsafe.Pointer(m)).owner
|
||||
typ := (*pthreadMutex)(unsafe.Pointer(m)).mType
|
||||
switch typ {
|
||||
case PTHREAD_MUTEX_NORMAL:
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).owner = tls.ID
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Unlock()
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).Lock()
|
||||
case PTHREAD_MUTEX_RECURSIVE:
|
||||
switch owner {
|
||||
case 0:
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).count = 1
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).owner = tls.ID
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Unlock()
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).Lock()
|
||||
return 0
|
||||
case tls.ID:
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).count++
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Unlock()
|
||||
return 0
|
||||
default:
|
||||
wait:
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Unlock()
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).Lock()
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Lock()
|
||||
if (*pthreadMutex)(unsafe.Pointer(m)).owner != 0 {
|
||||
goto wait
|
||||
}
|
||||
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).count = 1
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).owner = tls.ID
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Unlock()
|
||||
return 0
|
||||
}
|
||||
default:
|
||||
panic(todo("typ=%v", typ))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_mutex_trylock(tls *TLS, m uintptr) int32 {
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Lock()
|
||||
owner := (*pthreadMutex)(unsafe.Pointer(m)).owner
|
||||
typ := (*pthreadMutex)(unsafe.Pointer(m)).mType
|
||||
switch typ {
|
||||
case PTHREAD_MUTEX_NORMAL:
|
||||
if owner != 0 {
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Unlock()
|
||||
return EBUSY
|
||||
}
|
||||
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).owner = tls.ID
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Unlock()
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).Lock()
|
||||
return 0
|
||||
default:
|
||||
panic(todo("typ=%v", typ))
|
||||
}
|
||||
}
|
||||
|
||||
func Xpthread_mutex_unlock(tls *TLS, m uintptr) int32 {
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Lock()
|
||||
count := (*pthreadMutex)(unsafe.Pointer(m)).count
|
||||
owner := (*pthreadMutex)(unsafe.Pointer(m)).owner
|
||||
typ := (*pthreadMutex)(unsafe.Pointer(m)).mType
|
||||
switch typ {
|
||||
case PTHREAD_MUTEX_NORMAL:
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Unlock()
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).Unlock()
|
||||
return 0
|
||||
case PTHREAD_MUTEX_RECURSIVE:
|
||||
switch owner {
|
||||
case tls.ID:
|
||||
switch count {
|
||||
case 1:
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).owner = 0
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Unlock()
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).Unlock()
|
||||
return 0
|
||||
default:
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).count--
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).outer.Unlock()
|
||||
return 0
|
||||
}
|
||||
default:
|
||||
panic(todo("", owner, tls.ID))
|
||||
}
|
||||
default:
|
||||
panic(todo("", typ))
|
||||
}
|
||||
}
|
||||
|
||||
func Xpthread_cond_init(tls *TLS, c, a uintptr) int32 {
|
||||
*(*Tpthread_cond_t)(unsafe.Pointer(c)) = Tpthread_cond_t{}
|
||||
if a != 0 {
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
conds.Lock()
|
||||
delete(conds.conds, c)
|
||||
conds.Unlock()
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_cond_timedwait(tls *TLS, c, m, ts uintptr) (r int32) {
|
||||
var to <-chan time.Time
|
||||
if ts != 0 {
|
||||
deadlineSecs := (*Ttimespec)(unsafe.Pointer(ts)).Ftv_sec
|
||||
deadlineNsecs := (*Ttimespec)(unsafe.Pointer(ts)).Ftv_nsec
|
||||
deadline := time.Unix(deadlineSecs, deadlineNsecs)
|
||||
d := deadline.Sub(time.Now())
|
||||
if d <= 0 {
|
||||
return ETIMEDOUT
|
||||
}
|
||||
|
||||
to = time.After(d)
|
||||
}
|
||||
|
||||
conds.Lock()
|
||||
waiters := conds.conds[c]
|
||||
ch := make(chan struct{}, 1)
|
||||
waiters = append(waiters, ch)
|
||||
conds.conds[c] = waiters
|
||||
conds.Unlock()
|
||||
|
||||
defer func() {
|
||||
conds.Lock()
|
||||
|
||||
defer conds.Unlock()
|
||||
|
||||
waiters = conds.conds[c]
|
||||
for i, v := range waiters {
|
||||
if v == ch {
|
||||
conds.conds[c] = slices.Delete(waiters, i, i+1)
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
switch typ := (*pthreadMutex)(unsafe.Pointer(m)).mType; typ {
|
||||
case PTHREAD_MUTEX_NORMAL:
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).owner = 0
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).Unlock()
|
||||
select {
|
||||
case <-ch:
|
||||
// ok
|
||||
case <-to:
|
||||
r = ETIMEDOUT
|
||||
}
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).owner = tls.ID
|
||||
(*pthreadMutex)(unsafe.Pointer(m)).Lock()
|
||||
return r
|
||||
default:
|
||||
panic(todo("", typ))
|
||||
}
|
||||
}
|
||||
|
||||
func Xpthread_cond_wait(tls *TLS, c, m uintptr) int32 {
|
||||
return Xpthread_cond_timedwait(tls, c, m, 0)
|
||||
}
|
||||
|
||||
func Xpthread_cond_signal(tls *TLS, c uintptr) int32 {
|
||||
return pthreadSignalN(tls, c, false)
|
||||
}
|
||||
|
||||
func pthreadSignalN(tls *TLS, c uintptr, all bool) int32 {
|
||||
conds.Lock()
|
||||
waiters := conds.conds[c]
|
||||
handle := waiters
|
||||
if len(waiters) != 0 {
|
||||
switch {
|
||||
case all:
|
||||
delete(conds.conds, c)
|
||||
default:
|
||||
handle = handle[:1]
|
||||
conds.conds[c] = waiters[1:]
|
||||
}
|
||||
}
|
||||
conds.Unlock()
|
||||
for _, v := range handle {
|
||||
close(v)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_cond_broadcast(tls *TLS, c uintptr) int32 {
|
||||
return pthreadSignalN(tls, c, true)
|
||||
}
|
||||
|
||||
func Xpthread_cond_destroy(tls *TLS, c uintptr) int32 {
|
||||
return Xpthread_cond_broadcast(tls, c)
|
||||
}
|
||||
|
||||
func Xpthread_atfork(tls *TLS, prepare, parent, child uintptr) int32 {
|
||||
// fork(2) not supported.
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_mutexattr_init(tls *TLS, a uintptr) int32 {
|
||||
*(*Tpthread_mutexattr_t)(unsafe.Pointer(a)) = Tpthread_mutexattr_t{}
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_mutexattr_destroy(tls *TLS, a uintptr) int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_mutexattr_settype(tls *TLS, a uintptr, typ int32) int32 {
|
||||
if uint32(typ) > 2 {
|
||||
return EINVAL
|
||||
}
|
||||
|
||||
(*Tpthread_mutexattr_t)(unsafe.Pointer(a)).F__attr = uint32(typ) & 3
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_detach(tls *TLS, t uintptr) int32 {
|
||||
state := atomic.SwapInt32((*int32)(unsafe.Pointer(tls.pthread+unsafe.Offsetof(t__pthread{}.Fdetach_state))), _DT_DETACHED)
|
||||
switch state {
|
||||
case _DT_EXITED, _DT_DETACHED:
|
||||
return 0
|
||||
default:
|
||||
panic(todo("", tls.ID, state))
|
||||
}
|
||||
}
|
||||
|
||||
// int pthread_equal(pthread_t, pthread_t);
|
||||
func Xpthread_equal(tls *TLS, t, u uintptr) int32 {
|
||||
return Bool32(t == u)
|
||||
}
|
||||
|
||||
// int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old)
|
||||
func _pthread_sigmask(tls *TLS, now int32, set, old uintptr) int32 {
|
||||
// ignored
|
||||
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
|
||||
2200
vendor/modernc.org/libc/rtl.go
generated
vendored
Normal file
2200
vendor/modernc.org/libc/rtl.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
2
vendor/modernc.org/libc/scanf.go
generated
vendored
2
vendor/modernc.org/libc/scanf.go
generated
vendored
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && (amd64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
|
|
|||
9305
vendor/modernc.org/libc/surface.new
generated
vendored
Normal file
9305
vendor/modernc.org/libc/surface.new
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
9184
vendor/modernc.org/libc/surface.old
generated
vendored
Normal file
9184
vendor/modernc.org/libc/surface.old
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
2
vendor/modernc.org/libc/sync.go
generated
vendored
2
vendor/modernc.org/libc/sync.go
generated
vendored
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && (amd64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
|
|
|||
90
vendor/modernc.org/libc/syscall_musl.go
generated
vendored
Normal file
90
vendor/modernc.org/libc/syscall_musl.go
generated
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
// 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 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func ___syscall_cp(tls *TLS, n, a, b, c, d, e, f long) long {
|
||||
r1, _, err := (syscall.Syscall6(uintptr(n), uintptr(a), uintptr(b), uintptr(c), uintptr(d), uintptr(e), uintptr(f)))
|
||||
if err != 0 {
|
||||
return long(-err)
|
||||
}
|
||||
|
||||
return long(r1)
|
||||
}
|
||||
|
||||
func X__syscall0(tls *TLS, n long) long {
|
||||
switch n {
|
||||
case __NR_sched_yield:
|
||||
runtime.Gosched()
|
||||
return 0
|
||||
default:
|
||||
r1, _, err := syscall.Syscall(uintptr(n), 0, 0, 0)
|
||||
if err != 0 {
|
||||
return long(-err)
|
||||
}
|
||||
|
||||
return long(r1)
|
||||
}
|
||||
}
|
||||
|
||||
func X__syscall1(tls *TLS, n, a1 long) long {
|
||||
r1, _, err := syscall.Syscall(uintptr(n), uintptr(a1), 0, 0)
|
||||
if err != 0 {
|
||||
return long(-err)
|
||||
}
|
||||
|
||||
return long(r1)
|
||||
}
|
||||
|
||||
func X__syscall2(tls *TLS, n, a1, a2 long) long {
|
||||
r1, _, err := syscall.Syscall(uintptr(n), uintptr(a1), uintptr(a2), 0)
|
||||
if err != 0 {
|
||||
return long(-err)
|
||||
}
|
||||
|
||||
return long(r1)
|
||||
}
|
||||
|
||||
func X__syscall3(tls *TLS, n, a1, a2, a3 long) long {
|
||||
r1, _, err := syscall.Syscall(uintptr(n), uintptr(a1), uintptr(a2), uintptr(a3))
|
||||
if err != 0 {
|
||||
return long(-err)
|
||||
}
|
||||
|
||||
return long(r1)
|
||||
}
|
||||
|
||||
func X__syscall4(tls *TLS, n, a1, a2, a3, a4 long) long {
|
||||
r1, _, err := syscall.Syscall6(uintptr(n), uintptr(a1), uintptr(a2), uintptr(a3), uintptr(a4), 0, 0)
|
||||
if err != 0 {
|
||||
return long(-err)
|
||||
}
|
||||
|
||||
return long(r1)
|
||||
}
|
||||
|
||||
func X__syscall5(tls *TLS, n, a1, a2, a3, a4, a5 long) long {
|
||||
r1, _, err := syscall.Syscall6(uintptr(n), uintptr(a1), uintptr(a2), uintptr(a3), uintptr(a4), uintptr(a5), 0)
|
||||
if err != 0 {
|
||||
return long(-err)
|
||||
}
|
||||
|
||||
return long(r1)
|
||||
}
|
||||
|
||||
func X__syscall6(tls *TLS, n, a1, a2, a3, a4, a5, a6 long) long {
|
||||
r1, _, err := syscall.Syscall6(uintptr(n), uintptr(a1), uintptr(a2), uintptr(a3), uintptr(a4), uintptr(a5), uintptr(a6))
|
||||
if err != 0 {
|
||||
return long(-err)
|
||||
}
|
||||
|
||||
return long(r1)
|
||||
}
|
||||
5
vendor/modernc.org/libc/unconvert.sh
generated
vendored
Normal file
5
vendor/modernc.org/libc/unconvert.sh
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
set -evx
|
||||
until unconvert -fastmath ./...
|
||||
do
|
||||
unconvert -fastmath -apply ./...
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue