fix auth; update deps
This commit is contained in:
+1
@@ -15,5 +15,6 @@ Jan Mercl <0xjnml@gmail.com>
|
||||
Jason DeBettencourt <jasond17@gmail.com>
|
||||
Koichi Shiraishi <zchee.io@gmail.com>
|
||||
Marius Orcsik <marius@federated.id>
|
||||
Patricio Whittingslow <graded.sp@gmail.com>
|
||||
Scot C Bontrager <scot@indievisible.org>
|
||||
Steffen Butzer <steffen(dot)butzer@outlook.com>
|
||||
|
||||
+3
@@ -8,12 +8,15 @@
|
||||
|
||||
Dan Kortschak <dan@kortschak.io>
|
||||
Dan Peterson <danp@danp.net>
|
||||
Bjørn Wiegell <bj.wiegell@gmail.com>
|
||||
Fabrice Colliot <f.colliot@gmail.com>
|
||||
Jaap Aarts <jaap.aarts1@gmail.com>
|
||||
Jan Mercl <0xjnml@gmail.com>
|
||||
Jason DeBettencourt <jasond17@gmail.com>
|
||||
Koichi Shiraishi <zchee.io@gmail.com>
|
||||
Marius Orcsik <marius@federated.id>
|
||||
Patricio Whittingslow <graded.sp@gmail.com>
|
||||
Scot C Bontrager <scot@indievisible.org>
|
||||
Steffen Butzer <steffen(dot)butzer@outlook.com>
|
||||
W. Michael Petullo <mike@flyn.org>
|
||||
ZHU Zijia <piggynl@outlook.com>
|
||||
|
||||
+564
-1
@@ -9,6 +9,9 @@ SHELL=/bin/bash -o pipefail
|
||||
DIR = /tmp/libc
|
||||
TAR = musl-7ada6dde6f9dc6a2836c3d92c2f762d35fd229e0.tar.gz
|
||||
URL = https://git.musl-libc.org/cgit/musl/snapshot/$(TAR)
|
||||
UCRT_386 = libc_windows_386.go
|
||||
UCRT_AMD64 = libc_windows_amd64.go
|
||||
UCRT_ARM64 = libc_windows_arm64.go
|
||||
|
||||
all: editor
|
||||
golint 2>&1
|
||||
@@ -33,7 +36,7 @@ download:
|
||||
|
||||
edit:
|
||||
@touch log
|
||||
@if [ -f "Session.vim" ]; then novim -S & else novim -p Makefile all_musl_test.go generator.go libc.go libc_musl.go & fi
|
||||
@if [ -f "Session.vim" ]; then novim -S & else novim -p Makefile all_windows_test.go generator.go libc.go libc_windows*.go & fi
|
||||
|
||||
editor:
|
||||
gofmt -l -s -w *.go 2>&1 | tee log-editor
|
||||
@@ -41,6 +44,566 @@ editor:
|
||||
go install -v 2>&1 | tee -a log-editor
|
||||
go build -o /dev/null generator*.go
|
||||
|
||||
ucrt:
|
||||
make ucrt_amd64 ucrt_arm64 ucrt_386
|
||||
go build -v ./... 2>&1 | tee -a log-generate
|
||||
GOOS=darwin go build -v ./... 2>&1 | tee -a log-generate
|
||||
git status
|
||||
|
||||
ucrt_amd64:
|
||||
echo -n > log-generate
|
||||
( ccgo -v4 \
|
||||
--cpp=$(shell which x86_64-w64-mingw32-gcc) \
|
||||
--goos=windows \
|
||||
--goarch=amd64 \
|
||||
--package-name libc \
|
||||
--prefix-external=X \
|
||||
--prefix-field=F \
|
||||
--prefix-static-internal=_ \
|
||||
--prefix-static-none=_ \
|
||||
--prefix-tagged-struct=T \
|
||||
--prefix-tagged-union=T \
|
||||
--prefix-typename=T \
|
||||
--winapi-test panic \
|
||||
--winapi=ctype.h \
|
||||
--winapi=float.h \
|
||||
--winapi=io.h \
|
||||
--winapi=libucrt.c \
|
||||
--winapi=locale.h \
|
||||
--winapi=malloc.h \
|
||||
--winapi=math.h \
|
||||
--winapi=process.h \
|
||||
--winapi=types.h \
|
||||
--winapi=stat.h \
|
||||
--winapi=stdio.h \
|
||||
--winapi=stdlib.h \
|
||||
--winapi=string.h \
|
||||
--winapi=time.h \
|
||||
--winapi=timeb.h \
|
||||
--winapi=wchar.h \
|
||||
--winapi=winbase.h \
|
||||
-build-lines=" " \
|
||||
-eval-all-macros \
|
||||
-hide __acrt_iob_func \
|
||||
-hide __create_locale \
|
||||
-hide __free_locale \
|
||||
-hide __get_current_locale \
|
||||
-hide __iob_func \
|
||||
-hide __lock_fhandle \
|
||||
-hide __sep__ \
|
||||
-hide __updatetlocinfo \
|
||||
-hide __updatetmbcinfo \
|
||||
-hide _beginthread \
|
||||
-hide _beginthreadex \
|
||||
-hide _endthreadex \
|
||||
-hide _errno \
|
||||
-hide _filbuf \
|
||||
-hide _flsbuf \
|
||||
-hide _get_amblksiz \
|
||||
-hide _get_osplatform \
|
||||
-hide _get_osver \
|
||||
-hide _get_output_format \
|
||||
-hide _get_sbh_threshold \
|
||||
-hide _get_winmajor \
|
||||
-hide _get_winminor \
|
||||
-hide _get_winver \
|
||||
-hide _heapadd \
|
||||
-hide _heapset \
|
||||
-hide _heapused \
|
||||
-hide _matherr \
|
||||
-hide _onexit \
|
||||
-hide _set_amblksiz \
|
||||
-hide _set_malloc_crt_max_wait \
|
||||
-hide _set_output_format \
|
||||
-hide _set_sbh_threshold \
|
||||
-hide _strcmpi \
|
||||
-hide _strnset_l \
|
||||
-hide _strset_l \
|
||||
-hide _unlock_fhandle \
|
||||
-hide _wcsncpy_l \
|
||||
-hide _wctime \
|
||||
-hide _wctime_s \
|
||||
-hide _wgetdcwd_nolock \
|
||||
-hide _wgetenv \
|
||||
-hide _wputenv \
|
||||
-hide access \
|
||||
-hide at_quick_exit \
|
||||
-hide atexit \
|
||||
-hide chdir \
|
||||
-hide exit \
|
||||
-hide lldiv \
|
||||
-hide qsort \
|
||||
-hide chmod \
|
||||
-hide chsize \
|
||||
-hide close \
|
||||
-hide creat \
|
||||
-hide cwait \
|
||||
-hide dup \
|
||||
-hide dup2 \
|
||||
-hide eof \
|
||||
-hide execv \
|
||||
-hide execve \
|
||||
-hide execvp \
|
||||
-hide execvpe \
|
||||
-hide fcloseall \
|
||||
-hide fdopen \
|
||||
-hide fgetchar \
|
||||
-hide fgetpos64 \
|
||||
-hide filelength \
|
||||
-hide fileno \
|
||||
-hide flushall \
|
||||
-hide fopen64 \
|
||||
-hide fpreset \
|
||||
-hide fputchar \
|
||||
-hide fsetpos64 \
|
||||
-hide ftime \
|
||||
-hide fwide \
|
||||
-hide getcwd \
|
||||
-hide getpid \
|
||||
-hide getw \
|
||||
-hide isatty \
|
||||
-hide itoa \
|
||||
-hide lltoa \
|
||||
-hide lltow \
|
||||
-hide locking \
|
||||
-hide lseek \
|
||||
-hide lseek64 \
|
||||
-hide ltoa \
|
||||
-hide memccpy \
|
||||
-hide memicmp \
|
||||
-hide mempcpy \
|
||||
-hide mkdir \
|
||||
-hide mkstemp \
|
||||
-hide mktemp \
|
||||
-hide onexit \
|
||||
-hide putenv \
|
||||
-hide putw \
|
||||
-hide read \
|
||||
-hide rmdir \
|
||||
-hide rmtmp \
|
||||
-hide setmode \
|
||||
-hide spawnv \
|
||||
-hide spawnve \
|
||||
-hide spawnvp \
|
||||
-hide spawnvpe \
|
||||
-hide strcasecmp \
|
||||
-hide strcmpi \
|
||||
-hide strdup \
|
||||
-hide stricmp \
|
||||
-hide strlwr \
|
||||
-hide strlwr_l \
|
||||
-hide strncasecmp \
|
||||
-hide strnicmp \
|
||||
-hide strnset \
|
||||
-hide strrev \
|
||||
-hide strset \
|
||||
-hide strtok_r \
|
||||
-hide strupr \
|
||||
-hide swab \
|
||||
-hide tell \
|
||||
-hide tempnam \
|
||||
-hide tzset \
|
||||
-hide ulltoa \
|
||||
-hide ulltow \
|
||||
-hide ultoa \
|
||||
-hide umask \
|
||||
-hide unlink \
|
||||
-hide wcsdup \
|
||||
-hide wcsicmp \
|
||||
-hide wcsicoll \
|
||||
-hide wcslwr \
|
||||
-hide wcsnicmp \
|
||||
-hide wcsnset \
|
||||
-hide wcsrev \
|
||||
-hide wcsset \
|
||||
-hide wcsupr \
|
||||
-hide wmemchr \
|
||||
-hide wmemcmp \
|
||||
-hide wmemcpy \
|
||||
-hide wmemmove \
|
||||
-hide wmempcpy \
|
||||
-hide wmemset \
|
||||
-hide write \
|
||||
-hide wtoll \
|
||||
-ignore-link-errors \
|
||||
-import syscall \
|
||||
-keep-strings \
|
||||
-o $(UCRT_AMD64) \
|
||||
libucrt.c \
|
||||
|| true ) 2>&1 | tee -a log-generate
|
||||
sed -i '/"modernc.org\/libc"/d' $(UCRT_AMD64)
|
||||
sed -i 's/\<libc\>\.//g' $(UCRT_AMD64)
|
||||
GOOS=windows GOARCH=amd64 go build -v ./... 2>&1 | tee -a log-generate
|
||||
|
||||
ucrt_arm64:
|
||||
echo -n > log-generate
|
||||
( ccgo -v4 \
|
||||
--cpp=$(shell which x86_64-w64-mingw32-gcc) \
|
||||
--goos=windows \
|
||||
--goarch=amd64 \
|
||||
--package-name libc \
|
||||
--prefix-external=X \
|
||||
--prefix-field=F \
|
||||
--prefix-static-internal=_ \
|
||||
--prefix-static-none=_ \
|
||||
--prefix-tagged-struct=T \
|
||||
--prefix-tagged-union=T \
|
||||
--prefix-typename=T \
|
||||
--winapi-test panic \
|
||||
--winapi=ctype.h \
|
||||
--winapi=float.h \
|
||||
--winapi=io.h \
|
||||
--winapi=libucrt.c \
|
||||
--winapi=locale.h \
|
||||
--winapi=malloc.h \
|
||||
--winapi=math.h \
|
||||
--winapi=process.h \
|
||||
--winapi=types.h \
|
||||
--winapi=stat.h \
|
||||
--winapi=stdio.h \
|
||||
--winapi=stdlib.h \
|
||||
--winapi=string.h \
|
||||
--winapi=time.h \
|
||||
--winapi=timeb.h \
|
||||
--winapi=wchar.h \
|
||||
--winapi=winbase.h \
|
||||
-build-lines=" " \
|
||||
-eval-all-macros \
|
||||
-hide __acrt_iob_func \
|
||||
-hide _errno \
|
||||
-hide _wgetenv \
|
||||
-hide _wputenv \
|
||||
-hide exit \
|
||||
-hide lldiv \
|
||||
-hide qsort \
|
||||
-hide __sep__ \
|
||||
-hide __create_locale \
|
||||
-hide __free_locale \
|
||||
-hide __get_current_locale \
|
||||
-hide __iob_func \
|
||||
-hide __lock_fhandle \
|
||||
-hide __updatetlocinfo \
|
||||
-hide __updatetmbcinfo \
|
||||
-hide _beginthread \
|
||||
-hide _beginthreadex \
|
||||
-hide _endthreadex \
|
||||
-hide _filbuf \
|
||||
-hide _flsbuf \
|
||||
-hide _get_amblksiz \
|
||||
-hide _get_osplatform \
|
||||
-hide _get_osver \
|
||||
-hide _get_output_format \
|
||||
-hide _get_sbh_threshold \
|
||||
-hide _get_winmajor \
|
||||
-hide _get_winminor \
|
||||
-hide _get_winver \
|
||||
-hide _heapadd \
|
||||
-hide _heapset \
|
||||
-hide _heapused \
|
||||
-hide _matherr \
|
||||
-hide _onexit \
|
||||
-hide _set_amblksiz \
|
||||
-hide _set_malloc_crt_max_wait \
|
||||
-hide _set_output_format \
|
||||
-hide _set_sbh_threshold \
|
||||
-hide _strcmpi \
|
||||
-hide _strnset_l \
|
||||
-hide _strset_l \
|
||||
-hide _unlock_fhandle \
|
||||
-hide _wcsncpy_l \
|
||||
-hide _wctime \
|
||||
-hide _wctime_s \
|
||||
-hide _wgetdcwd_nolock \
|
||||
-hide access \
|
||||
-hide at_quick_exit \
|
||||
-hide atexit \
|
||||
-hide chdir \
|
||||
-hide chmod \
|
||||
-hide chsize \
|
||||
-hide close \
|
||||
-hide creat \
|
||||
-hide cwait \
|
||||
-hide dup \
|
||||
-hide dup2 \
|
||||
-hide eof \
|
||||
-hide execv \
|
||||
-hide execve \
|
||||
-hide execvp \
|
||||
-hide execvpe \
|
||||
-hide fcloseall \
|
||||
-hide fdopen \
|
||||
-hide fgetchar \
|
||||
-hide fgetpos64 \
|
||||
-hide filelength \
|
||||
-hide fileno \
|
||||
-hide flushall \
|
||||
-hide fopen64 \
|
||||
-hide fpreset \
|
||||
-hide fputchar \
|
||||
-hide fsetpos64 \
|
||||
-hide ftime \
|
||||
-hide fwide \
|
||||
-hide getcwd \
|
||||
-hide getpid \
|
||||
-hide getw \
|
||||
-hide isatty \
|
||||
-hide itoa \
|
||||
-hide lltoa \
|
||||
-hide lltow \
|
||||
-hide locking \
|
||||
-hide lseek \
|
||||
-hide lseek64 \
|
||||
-hide ltoa \
|
||||
-hide memccpy \
|
||||
-hide memicmp \
|
||||
-hide mempcpy \
|
||||
-hide mkdir \
|
||||
-hide mkstemp \
|
||||
-hide mktemp \
|
||||
-hide onexit \
|
||||
-hide putenv \
|
||||
-hide putw \
|
||||
-hide read \
|
||||
-hide rmdir \
|
||||
-hide rmtmp \
|
||||
-hide setmode \
|
||||
-hide spawnv \
|
||||
-hide spawnve \
|
||||
-hide spawnvp \
|
||||
-hide spawnvpe \
|
||||
-hide strcasecmp \
|
||||
-hide strcmpi \
|
||||
-hide strdup \
|
||||
-hide stricmp \
|
||||
-hide strlwr \
|
||||
-hide strlwr_l \
|
||||
-hide strncasecmp \
|
||||
-hide strnicmp \
|
||||
-hide strnset \
|
||||
-hide strrev \
|
||||
-hide strset \
|
||||
-hide strtok_r \
|
||||
-hide strupr \
|
||||
-hide swab \
|
||||
-hide tell \
|
||||
-hide tempnam \
|
||||
-hide tzset \
|
||||
-hide ulltoa \
|
||||
-hide ulltow \
|
||||
-hide ultoa \
|
||||
-hide umask \
|
||||
-hide unlink \
|
||||
-hide wcsdup \
|
||||
-hide wcsicmp \
|
||||
-hide wcsicoll \
|
||||
-hide wcslwr \
|
||||
-hide wcsnicmp \
|
||||
-hide wcsnset \
|
||||
-hide wcsrev \
|
||||
-hide wcsset \
|
||||
-hide wcsupr \
|
||||
-hide wmemchr \
|
||||
-hide wmemcmp \
|
||||
-hide wmemcpy \
|
||||
-hide wmemmove \
|
||||
-hide wmempcpy \
|
||||
-hide wmemset \
|
||||
-hide write \
|
||||
-hide wtoll \
|
||||
-ignore-link-errors \
|
||||
-import syscall \
|
||||
-keep-strings \
|
||||
-o $(UCRT_ARM64) \
|
||||
libucrt.c \
|
||||
|| true ) 2>&1 | tee -a log-generate
|
||||
sed -i '/"modernc.org\/libc"/d' $(UCRT_ARM64)
|
||||
sed -i 's/\<libc\>\.//g' $(UCRT_ARM64)
|
||||
GOOS=windows GOARCH=arm64 go build -v ./... 2>&1 | tee -a log-generate
|
||||
|
||||
ucrt_386:
|
||||
echo -n > log-generate
|
||||
( ccgo -v4 \
|
||||
--cpp=$(shell which i686-w64-mingw32-gcc) \
|
||||
--goos=windows \
|
||||
--goarch=386 \
|
||||
--package-name libc \
|
||||
--prefix-external=X \
|
||||
--prefix-field=F \
|
||||
--prefix-static-internal=_ \
|
||||
--prefix-static-none=_ \
|
||||
--prefix-tagged-struct=T \
|
||||
--prefix-tagged-union=T \
|
||||
--prefix-typename=T \
|
||||
--winapi-test panic \
|
||||
--winapi=ctype.h \
|
||||
--winapi=float.h \
|
||||
--winapi=io.h \
|
||||
--winapi=libucrt.c \
|
||||
--winapi=locale.h \
|
||||
--winapi=malloc.h \
|
||||
--winapi=math.h \
|
||||
--winapi=process.h \
|
||||
--winapi=types.h \
|
||||
--winapi=stat.h \
|
||||
--winapi=stdio.h \
|
||||
--winapi=stdlib.h \
|
||||
--winapi=string.h \
|
||||
--winapi=time.h \
|
||||
--winapi=timeb.h \
|
||||
--winapi=wchar.h \
|
||||
--winapi=winbase.h \
|
||||
-build-lines=" " \
|
||||
-eval-all-macros \
|
||||
-hide __acrt_iob_func \
|
||||
-hide _errno \
|
||||
-hide _wgetenv \
|
||||
-hide _wputenv \
|
||||
-hide exit \
|
||||
-hide lldiv \
|
||||
-hide qsort \
|
||||
-hide __sep__ \
|
||||
-hide __create_locale \
|
||||
-hide __free_locale \
|
||||
-hide __get_current_locale \
|
||||
-hide __lock_fhandle \
|
||||
-hide __updatetlocinfo \
|
||||
-hide __updatetmbcinfo \
|
||||
-hide _beginthread \
|
||||
-hide _beginthreadex \
|
||||
-hide _endthreadex \
|
||||
-hide _filbuf \
|
||||
-hide _flsbuf \
|
||||
-hide _get_amblksiz \
|
||||
-hide _get_osplatform \
|
||||
-hide _get_osver \
|
||||
-hide _get_output_format \
|
||||
-hide _get_sbh_threshold \
|
||||
-hide _get_winmajor \
|
||||
-hide _get_winminor \
|
||||
-hide _get_winver \
|
||||
-hide _heapadd \
|
||||
-hide _heapset \
|
||||
-hide _heapused \
|
||||
-hide _matherr \
|
||||
-hide _onexit \
|
||||
-hide _set_amblksiz \
|
||||
-hide _set_malloc_crt_max_wait \
|
||||
-hide _set_output_format \
|
||||
-hide _set_sbh_threshold \
|
||||
-hide _strcmpi \
|
||||
-hide _strnset_l \
|
||||
-hide _strset_l \
|
||||
-hide _unlock_fhandle \
|
||||
-hide _wcsncpy_l \
|
||||
-hide _wctime \
|
||||
-hide _wctime_s \
|
||||
-hide _wgetdcwd_nolock \
|
||||
-hide access \
|
||||
-hide at_quick_exit \
|
||||
-hide atexit \
|
||||
-hide chdir \
|
||||
-hide chmod \
|
||||
-hide chsize \
|
||||
-hide close \
|
||||
-hide creat \
|
||||
-hide cwait \
|
||||
-hide dup \
|
||||
-hide dup2 \
|
||||
-hide eof \
|
||||
-hide execv \
|
||||
-hide execve \
|
||||
-hide execvp \
|
||||
-hide execvpe \
|
||||
-hide fcloseall \
|
||||
-hide fdopen \
|
||||
-hide fgetchar \
|
||||
-hide fgetpos64 \
|
||||
-hide filelength \
|
||||
-hide fileno \
|
||||
-hide flushall \
|
||||
-hide fopen64 \
|
||||
-hide fpreset \
|
||||
-hide fputchar \
|
||||
-hide fsetpos64 \
|
||||
-hide ftime \
|
||||
-hide fwide \
|
||||
-hide getcwd \
|
||||
-hide getpid \
|
||||
-hide getw \
|
||||
-hide isatty \
|
||||
-hide itoa \
|
||||
-hide lltoa \
|
||||
-hide lltow \
|
||||
-hide locking \
|
||||
-hide lseek \
|
||||
-hide lseek64 \
|
||||
-hide ltoa \
|
||||
-hide memccpy \
|
||||
-hide memicmp \
|
||||
-hide mempcpy \
|
||||
-hide mkdir \
|
||||
-hide mkstemp \
|
||||
-hide mktemp \
|
||||
-hide onexit \
|
||||
-hide putenv \
|
||||
-hide putw \
|
||||
-hide read \
|
||||
-hide rmdir \
|
||||
-hide rmtmp \
|
||||
-hide setmode \
|
||||
-hide spawnv \
|
||||
-hide spawnve \
|
||||
-hide spawnvp \
|
||||
-hide spawnvpe \
|
||||
-hide strcasecmp \
|
||||
-hide strcmpi \
|
||||
-hide strdup \
|
||||
-hide stricmp \
|
||||
-hide strlwr \
|
||||
-hide strlwr_l \
|
||||
-hide strncasecmp \
|
||||
-hide strnicmp \
|
||||
-hide strnset \
|
||||
-hide strrev \
|
||||
-hide strset \
|
||||
-hide strtok_r \
|
||||
-hide strupr \
|
||||
-hide swab \
|
||||
-hide tell \
|
||||
-hide tempnam \
|
||||
-hide tzset \
|
||||
-hide ulltoa \
|
||||
-hide ulltow \
|
||||
-hide ultoa \
|
||||
-hide umask \
|
||||
-hide unlink \
|
||||
-hide wcsdup \
|
||||
-hide wcsicmp \
|
||||
-hide wcsicoll \
|
||||
-hide wcslwr \
|
||||
-hide wcsnicmp \
|
||||
-hide wcsnset \
|
||||
-hide wcsrev \
|
||||
-hide wcsset \
|
||||
-hide wcsupr \
|
||||
-hide wmemchr \
|
||||
-hide wmemcmp \
|
||||
-hide wmemcpy \
|
||||
-hide wmemmove \
|
||||
-hide wmempcpy \
|
||||
-hide wmemset \
|
||||
-hide write \
|
||||
-hide wtoll \
|
||||
-ignore-link-errors \
|
||||
-import syscall \
|
||||
-keep-strings \
|
||||
-o $(UCRT_386) \
|
||||
libucrt.c \
|
||||
|| true ) 2>&1 | tee -a log-generate
|
||||
sed -i '/"modernc.org\/libc"/d' $(UCRT_386)
|
||||
sed -i 's/\<libc\>\.//g' $(UCRT_386)
|
||||
GOOS=windows GOARCH=386 go build -v ./... 2>&1 | tee -a log-generate
|
||||
|
||||
generate: download
|
||||
mkdir -p $(DIR) || true
|
||||
rm -rf $(DIR)/*
|
||||
|
||||
+1
-1
@@ -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 linux && (amd64 || loong64)
|
||||
//go:build linux && (amd64 || arm64 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
// Copyright 202 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 (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
heapAlign = 16
|
||||
heapGuard = 16
|
||||
)
|
||||
|
||||
const FALSE = 0
|
||||
const TRUE = 1
|
||||
|
||||
var (
|
||||
pid = fmt.Sprintf("[%v %v] ", os.Getpid(), filepath.Base(os.Args[0]))
|
||||
)
|
||||
|
||||
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:]
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s:%d:%s", filepath.Base(fn), fl, fns)
|
||||
}
|
||||
|
||||
func trc(s string, args ...interface{}) string { //TODO-
|
||||
switch {
|
||||
case s == "":
|
||||
s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
|
||||
default:
|
||||
s = fmt.Sprintf(s, args...)
|
||||
}
|
||||
r := fmt.Sprintf("%s: TRC %s (%v:)", origin(2), s, origin(3))
|
||||
fmt.Fprintf(os.Stdout, "%s %s\n", pid, r)
|
||||
os.Stdout.Sync()
|
||||
return r
|
||||
}
|
||||
|
||||
func todo(s string, args ...interface{}) string { //TODO-
|
||||
switch {
|
||||
case s == "":
|
||||
s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
|
||||
default:
|
||||
s = fmt.Sprintf(s, args...)
|
||||
}
|
||||
r := fmt.Sprintf("%s %s: TODOTODO %s (%v:)", pid, origin(2), s, origin(3)) //TODOOK
|
||||
if dmesgs {
|
||||
dmesg("%s", r)
|
||||
}
|
||||
fmt.Fprintf(os.Stdout, "%s\n", r)
|
||||
fmt.Fprintf(os.Stdout, "%s\n", debug.Stack()) //TODO-
|
||||
os.Stdout.Sync()
|
||||
os.Exit(1)
|
||||
panic("unrechable")
|
||||
}
|
||||
|
||||
type sorter struct {
|
||||
len int
|
||||
base uintptr
|
||||
sz uintptr
|
||||
f func(*TLS, uintptr, uintptr) int32
|
||||
t *TLS
|
||||
}
|
||||
|
||||
func (s *sorter) Len() int { return s.len }
|
||||
|
||||
func (s *sorter) Less(i, j int) bool {
|
||||
return s.f(s.t, s.base+uintptr(i)*s.sz, s.base+uintptr(j)*s.sz) < 0
|
||||
}
|
||||
|
||||
func (s *sorter) Swap(i, j int) {
|
||||
p := s.base + uintptr(i)*s.sz
|
||||
q := s.base + uintptr(j)*s.sz
|
||||
for i := 0; i < int(s.sz); i++ {
|
||||
*(*byte)(unsafe.Pointer(p)), *(*byte)(unsafe.Pointer(q)) = *(*byte)(unsafe.Pointer(q)), *(*byte)(unsafe.Pointer(p))
|
||||
p++
|
||||
q++
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -2,13 +2,13 @@
|
||||
// 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:build linux && (amd64 || arm64 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc/v2"
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"math"
|
||||
"math/bits"
|
||||
mbits "math/bits"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -41,15 +41,15 @@ func a_store_16(addr uintptr, val uint16) {
|
||||
// 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(mbits.TrailingZeros64(x))
|
||||
}
|
||||
|
||||
return int32(bits.TrailingZeros32(uint32(x)))
|
||||
return int32(mbits.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))
|
||||
return int32(mbits.TrailingZeros64(x))
|
||||
}
|
||||
|
||||
func AtomicAddFloat32(addr *float32, delta float32) (new float32) {
|
||||
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"autogen": "linux/(amd64|loong64)",
|
||||
"autogen": "linux/(amd64|arm64|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)",
|
||||
"autotag": "darwin/(amd64|arm64)|freebsd/(amd64|arm64)|linux/(386|amd64|arm|arm64|loong64|ppc64le|riscv64|s390x)|openbsd/(386|amd64|arm64)|windows/(amd64|arm64|386)",
|
||||
"download": [
|
||||
{"re": "linux/(amd64|loong64)", "files": ["https://git.musl-libc.org/cgit/musl/snapshot/musl-7ada6dde6f9dc6a2836c3d92c2f762d35fd229e0.tar.gz"]}
|
||||
{"re": "linux/(amd64|arm64|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)"
|
||||
"test": "darwin/(amd64|arm64)|freebsd/(amd64|arm64)|linux/(386|amd64|arm|arm64|loong64|ppc64le|riscv64|s390x)|openbsd/(386|amd64|arm64)|windows/(amd64|arm64|386)"
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 linux && (amd64 || loong64)
|
||||
//go:build linux && (amd64 || arm64 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// Code generated by 'go generate' - DO NOT EDIT.
|
||||
|
||||
//go:build !(linux && (amd64 || loong64))
|
||||
//go:build !(linux && (amd64 || arm64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
+1212
-1213
File diff suppressed because one or more lines are too long
+154129
File diff suppressed because one or more lines are too long
-1
File diff suppressed because one or more lines are too long
+7
-3
@@ -10,7 +10,6 @@ package libc // import "modernc.org/libc"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -18,7 +17,6 @@ import (
|
||||
const dmesgs = true
|
||||
|
||||
var (
|
||||
pid = fmt.Sprintf("[%v %v] ", os.Getpid(), filepath.Base(os.Args[0]))
|
||||
logf *os.File
|
||||
)
|
||||
|
||||
@@ -28,7 +26,7 @@ func init() {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
dmesg("%v", time.Now())
|
||||
dmesg("==== dmesg init() %v", time.Now())
|
||||
}
|
||||
|
||||
func dmesg(s string, args ...interface{}) {
|
||||
@@ -43,3 +41,9 @@ func dmesg(s string, args ...interface{}) {
|
||||
fmt.Fprintln(logf, s)
|
||||
}
|
||||
}
|
||||
|
||||
func dmesgFinish() {
|
||||
dmesg("==== dmesgFinish() %v", time.Now())
|
||||
logf.Sync()
|
||||
logf.Close()
|
||||
}
|
||||
|
||||
+1
-161
@@ -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 !(linux && (amd64 || loong64))
|
||||
//go:build !((linux && (amd64 || arm64 || loong64)) || windows)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -62,50 +61,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
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:]
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s:%d:%s", filepath.Base(fn), fl, fns)
|
||||
}
|
||||
|
||||
func trc(s string, args ...interface{}) string { //TODO-
|
||||
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.Stdout, "%s\n", r)
|
||||
os.Stdout.Sync()
|
||||
return r
|
||||
}
|
||||
|
||||
func todo(s string, args ...interface{}) string { //TODO-
|
||||
switch {
|
||||
case s == "":
|
||||
s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
|
||||
default:
|
||||
s = fmt.Sprintf(s, args...)
|
||||
}
|
||||
r := fmt.Sprintf("%s: TODOTODO %s", origin(2), s) //TODOOK
|
||||
if dmesgs {
|
||||
dmesg("%s", r)
|
||||
}
|
||||
fmt.Fprintf(os.Stdout, "%s\n", r)
|
||||
fmt.Fprintf(os.Stdout, "%s\n", debug.Stack()) //TODO-
|
||||
os.Stdout.Sync()
|
||||
os.Exit(1)
|
||||
panic("unrechable")
|
||||
}
|
||||
|
||||
var coverPCs [1]uintptr //TODO not concurrent safe
|
||||
|
||||
func Cover() {
|
||||
@@ -481,97 +436,6 @@ func VaOther(app *uintptr, sz uint64) (r uintptr) {
|
||||
return r
|
||||
}
|
||||
|
||||
func VaInt32(app *uintptr) int32 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := int32(*(*int64)(unsafe.Pointer(ap)))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
func VaUint32(app *uintptr) uint32 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := uint32(*(*uint64)(unsafe.Pointer(ap)))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
func VaInt64(app *uintptr) int64 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := *(*int64)(unsafe.Pointer(ap))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
func VaUint64(app *uintptr) uint64 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := *(*uint64)(unsafe.Pointer(ap))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
func VaFloat32(app *uintptr) float32 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := *(*float64)(unsafe.Pointer(ap))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return float32(v)
|
||||
}
|
||||
|
||||
func VaFloat64(app *uintptr) float64 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := *(*float64)(unsafe.Pointer(ap))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
func VaUintptr(app *uintptr) uintptr {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := *(*uintptr)(unsafe.Pointer(ap))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
func getVaList(va uintptr) []string {
|
||||
r := []string{}
|
||||
|
||||
@@ -637,30 +501,6 @@ func Bool64(b bool) int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
type sorter struct {
|
||||
len int
|
||||
base uintptr
|
||||
sz uintptr
|
||||
f func(*TLS, uintptr, uintptr) int32
|
||||
t *TLS
|
||||
}
|
||||
|
||||
func (s *sorter) Len() int { return s.len }
|
||||
|
||||
func (s *sorter) Less(i, j int) bool {
|
||||
return s.f(s.t, s.base+uintptr(i)*s.sz, s.base+uintptr(j)*s.sz) < 0
|
||||
}
|
||||
|
||||
func (s *sorter) Swap(i, j int) {
|
||||
p := uintptr(s.base + uintptr(i)*s.sz)
|
||||
q := uintptr(s.base + uintptr(j)*s.sz)
|
||||
for i := 0; i < int(s.sz); i++ {
|
||||
*(*byte)(unsafe.Pointer(p)), *(*byte)(unsafe.Pointer(q)) = *(*byte)(unsafe.Pointer(q)), *(*byte)(unsafe.Pointer(p))
|
||||
p++
|
||||
q++
|
||||
}
|
||||
}
|
||||
|
||||
func CString(s string) (uintptr, error) {
|
||||
n := len(s)
|
||||
p := Xmalloc(nil, types.Size_t(n)+1)
|
||||
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// 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:build !(linux && (amd64 || arm64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
+11
-377
@@ -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 !(linux && (amd64 || loong64))
|
||||
//go:build !((linux && (amd64 || arm64 || loong64)) || windows)
|
||||
|
||||
//go.generate echo package libc > ccgo.go
|
||||
//go:generate go fmt ./...
|
||||
@@ -51,7 +51,7 @@ type (
|
||||
)
|
||||
|
||||
var (
|
||||
allocMu sync.Mutex
|
||||
allocatorMu sync.Mutex
|
||||
environInitialized bool
|
||||
isWindows bool
|
||||
ungetcMu sync.Mutex
|
||||
@@ -174,6 +174,7 @@ func exit(t *TLS, status int32, audit bool) {
|
||||
func X_exit(_ *TLS, status int32) {
|
||||
if dmesgs {
|
||||
dmesg("%v: EXIT %v", origin(1), status)
|
||||
dmesgFinish()
|
||||
}
|
||||
os.Exit(int(status))
|
||||
}
|
||||
@@ -510,13 +511,6 @@ func X__isnanl(t *TLS, arg float64) int32 {
|
||||
return Xisnanl(t, arg)
|
||||
}
|
||||
|
||||
func Xvfprintf(t *TLS, stream, format, ap uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v ap=%v, (%v:)", t, ap, origin(2))
|
||||
}
|
||||
return Xfprintf(t, stream, format, ap)
|
||||
}
|
||||
|
||||
// int __builtin_popcount (unsigned int x)
|
||||
func X__builtin_popcount(t *TLS, x uint32) int32 {
|
||||
if __ccgo_strace {
|
||||
@@ -735,19 +729,6 @@ func AtomicStoreNUint16(ptr uintptr, val uint16, memorder int32) {
|
||||
a_store_16(ptr, val)
|
||||
}
|
||||
|
||||
// int sprintf(char *str, const char *format, ...);
|
||||
func Xsprintf(t *TLS, str, format, args uintptr) (r int32) {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v args=%v, (%v:)", t, args, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
b := printf(format, args)
|
||||
r = int32(len(b))
|
||||
copy((*RawMem)(unsafe.Pointer(str))[:r:r], b)
|
||||
*(*byte)(unsafe.Pointer(str + uintptr(r))) = 0
|
||||
return int32(len(b))
|
||||
}
|
||||
|
||||
// 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 types.Size_t, format, args uintptr) (r int32) {
|
||||
if __ccgo_strace {
|
||||
@@ -795,14 +776,6 @@ func Xvprintf(t *TLS, s, ap uintptr) int32 {
|
||||
return Xprintf(t, s, ap)
|
||||
}
|
||||
|
||||
// int vsprintf(char *str, const char *format, va_list ap);
|
||||
func Xvsprintf(t *TLS, str, format, va uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v va=%v, (%v:)", t, va, origin(2))
|
||||
}
|
||||
return Xsprintf(t, str, format, va)
|
||||
}
|
||||
|
||||
// int vsnprintf(char *str, size_t size, const char *format, va_list ap);
|
||||
func Xvsnprintf(t *TLS, str uintptr, size types.Size_t, format, va uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
@@ -886,15 +859,6 @@ func Xstrcspn(t *TLS, s, reject uintptr) (r types.Size_t) {
|
||||
}
|
||||
}
|
||||
|
||||
// int printf(const char *format, ...);
|
||||
func Xprintf(t *TLS, format, args uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v args=%v, (%v:)", t, args, origin(2))
|
||||
}
|
||||
n, _ := write(printf(format, args))
|
||||
return int32(n)
|
||||
}
|
||||
|
||||
// int snprintf(char *str, size_t size, const char *format, ...);
|
||||
func Xsnprintf(t *TLS, str uintptr, size types.Size_t, format, args uintptr) (r int32) {
|
||||
if __ccgo_strace {
|
||||
@@ -995,206 +959,14 @@ func X__builtin_llabs(tls *TLS, a int64) int64 {
|
||||
return Xllabs(tls, a)
|
||||
}
|
||||
|
||||
func Xacos(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Acos(x)
|
||||
}
|
||||
|
||||
func Xacosh(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Acosh(x)
|
||||
}
|
||||
|
||||
func Xasin(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Asin(x)
|
||||
}
|
||||
|
||||
func Xasinh(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Asinh(x)
|
||||
}
|
||||
|
||||
func Xatan(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Atan(x)
|
||||
}
|
||||
|
||||
func Xatan2(t *TLS, x, y float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v y=%v, (%v:)", t, y, origin(2))
|
||||
}
|
||||
return math.Atan2(x, y)
|
||||
}
|
||||
|
||||
func Xatanh(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Atanh(x)
|
||||
}
|
||||
|
||||
func Xceil(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Ceil(x)
|
||||
}
|
||||
|
||||
func Xceilf(t *TLS, x float32) float32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return float32(math.Ceil(float64(x)))
|
||||
}
|
||||
|
||||
func Xcopysign(t *TLS, x, y float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v y=%v, (%v:)", t, y, origin(2))
|
||||
}
|
||||
return math.Copysign(x, y)
|
||||
}
|
||||
|
||||
func Xcopysignf(t *TLS, x, y float32) float32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v y=%v, (%v:)", t, y, origin(2))
|
||||
}
|
||||
return float32(math.Copysign(float64(x), float64(y)))
|
||||
}
|
||||
|
||||
func Xcos(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Cos(x)
|
||||
}
|
||||
|
||||
func Xcosf(t *TLS, x float32) float32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return float32(math.Cos(float64(x)))
|
||||
}
|
||||
|
||||
func Xcosh(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Cosh(x)
|
||||
}
|
||||
|
||||
func Xexp(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Exp(x)
|
||||
}
|
||||
|
||||
func Xfabs(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Abs(x)
|
||||
}
|
||||
|
||||
func Xfabsf(t *TLS, x float32) float32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return float32(math.Abs(float64(x)))
|
||||
}
|
||||
|
||||
func Xfloor(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Floor(x)
|
||||
}
|
||||
|
||||
func Xfmod(t *TLS, x, y float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v y=%v, (%v:)", t, y, origin(2))
|
||||
}
|
||||
return math.Mod(x, y)
|
||||
}
|
||||
|
||||
func Xhypot(t *TLS, x, y float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v y=%v, (%v:)", t, y, origin(2))
|
||||
}
|
||||
return math.Hypot(x, y)
|
||||
}
|
||||
|
||||
func Xisnan(t *TLS, x float64) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return X__builtin_isnan(t, x)
|
||||
}
|
||||
|
||||
func Xisnanf(t *TLS, x float32) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return Bool32(math.IsNaN(float64(x)))
|
||||
}
|
||||
|
||||
func Xisnanl(t *TLS, x float64) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return Bool32(math.IsNaN(x))
|
||||
} // ccgo has to handle long double as double as Go does not support long double.
|
||||
|
||||
func Xldexp(t *TLS, x float64, exp int32) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v exp=%v, (%v:)", t, x, exp, origin(2))
|
||||
}
|
||||
return math.Ldexp(x, int(exp))
|
||||
}
|
||||
|
||||
func Xlog(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Log(x)
|
||||
}
|
||||
|
||||
func Xlog10(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Log10(x)
|
||||
func X__builtin_hypot(t *TLS, x float64, y float64) (r float64) {
|
||||
return Xhypot(t, x, y)
|
||||
}
|
||||
|
||||
func X__builtin_log2(t *TLS, x float64) float64 {
|
||||
return Xlog2(t, x)
|
||||
}
|
||||
|
||||
func Xlog2(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Log2(x)
|
||||
}
|
||||
|
||||
func Xround(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Round(x)
|
||||
}
|
||||
|
||||
func X__builtin_round(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
@@ -1202,13 +974,6 @@ func X__builtin_round(t *TLS, x float64) float64 {
|
||||
return math.Round(x)
|
||||
}
|
||||
|
||||
func Xroundf(t *TLS, x float32) float32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return float32(math.Round(float64(x)))
|
||||
}
|
||||
|
||||
func X__builtin_roundf(t *TLS, x float32) float32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
@@ -1216,55 +981,6 @@ func X__builtin_roundf(t *TLS, x float32) float32 {
|
||||
return float32(math.Round(float64(x)))
|
||||
}
|
||||
|
||||
func Xsin(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Sin(x)
|
||||
}
|
||||
|
||||
func Xsinf(t *TLS, x float32) float32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return float32(math.Sin(float64(x)))
|
||||
}
|
||||
|
||||
func Xsinh(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Sinh(x)
|
||||
}
|
||||
|
||||
func Xsqrt(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Sqrt(x)
|
||||
}
|
||||
|
||||
func Xtan(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Tan(x)
|
||||
}
|
||||
|
||||
func Xtanh(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Tanh(x)
|
||||
}
|
||||
|
||||
func Xtrunc(t *TLS, x float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v, (%v:)", t, x, origin(2))
|
||||
}
|
||||
return math.Trunc(x)
|
||||
}
|
||||
|
||||
var nextRand = uint64(1)
|
||||
|
||||
// int rand(void);
|
||||
@@ -1276,35 +992,6 @@ func Xrand(t *TLS) int32 {
|
||||
return int32(uint32(nextRand / (math.MaxUint32 + 1) % math.MaxInt32))
|
||||
}
|
||||
|
||||
func Xpow(t *TLS, x, y float64) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v y=%v, (%v:)", t, y, origin(2))
|
||||
}
|
||||
r := math.Pow(x, y)
|
||||
if x > 0 && r == 1 && y >= -1.0000000000000000715e-18 && y < -1e-30 {
|
||||
r = 0.9999999999999999
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func Xfrexp(t *TLS, x float64, exp uintptr) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v exp=%v, (%v:)", t, x, exp, origin(2))
|
||||
}
|
||||
f, e := math.Frexp(x)
|
||||
*(*int32)(unsafe.Pointer(exp)) = int32(e)
|
||||
return f
|
||||
}
|
||||
|
||||
func Xmodf(t *TLS, x float64, iptr uintptr) float64 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v x=%v iptr=%v, (%v:)", t, x, iptr, origin(2))
|
||||
}
|
||||
i, f := math.Modf(x)
|
||||
*(*float64)(unsafe.Pointer(iptr)) = i
|
||||
return f
|
||||
}
|
||||
|
||||
// char *strncpy(char *dest, const char *src, size_t n)
|
||||
func Xstrncpy(t *TLS, dest, src uintptr, n types.Size_t) (r uintptr) {
|
||||
if __ccgo_strace {
|
||||
@@ -2403,76 +2090,23 @@ func Xffs(tls *TLS, i int32) (r int32) {
|
||||
return int32(mbits.TrailingZeros32(uint32(i))) + 1
|
||||
}
|
||||
|
||||
var _toint5 = Float32FromInt32(1) / Float32FromFloat32(1.1920928955078125e-07)
|
||||
|
||||
func X__builtin_rintf(tls *TLS, x float32) (r float32) {
|
||||
return Xrintf(tls, x)
|
||||
}
|
||||
|
||||
func Xrintf(tls *TLS, x float32) (r float32) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var e, s int32
|
||||
var y float32
|
||||
var v1 float32
|
||||
var _ /* u at bp+0 */ struct {
|
||||
Fi [0]uint32
|
||||
Ff float32
|
||||
}
|
||||
_, _, _, _ = e, s, y, v1
|
||||
*(*struct {
|
||||
Fi [0]uint32
|
||||
Ff float32
|
||||
})(unsafe.Pointer(bp)) = struct {
|
||||
Fi [0]uint32
|
||||
Ff float32
|
||||
}{}
|
||||
*(*float32)(unsafe.Pointer(bp)) = x
|
||||
e = int32(*(*uint32)(unsafe.Pointer(bp)) >> int32(23) & uint32(0xff))
|
||||
s = int32(*(*uint32)(unsafe.Pointer(bp)) >> int32(31))
|
||||
if e >= Int32FromInt32(0x7f)+Int32FromInt32(23) {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - _toint5 + _toint5
|
||||
} else {
|
||||
y = x + _toint5 - _toint5
|
||||
}
|
||||
if y == Float32FromInt32(0) {
|
||||
if s != 0 {
|
||||
v1 = -Float32FromFloat32(0)
|
||||
} else {
|
||||
v1 = Float32FromFloat32(0)
|
||||
}
|
||||
return v1
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func X__builtin_lrintf(tls *TLS, x float32) (r long) {
|
||||
return Xlrintf(tls, x)
|
||||
}
|
||||
|
||||
func Xlrintf(tls *TLS, x float32) (r long) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
return long(Xrintf(tls, x))
|
||||
}
|
||||
|
||||
func X__builtin_lrint(tls *TLS, x float64) (r long) {
|
||||
return Xlrint(tls, x)
|
||||
}
|
||||
|
||||
func Xlrint(tls *TLS, x float64) (r long) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
func Xprintf(t *TLS, format, va uintptr) int32 {
|
||||
n, err := os.Stdout.Write(printf(format, va))
|
||||
if err != nil {
|
||||
return -1
|
||||
}
|
||||
return long(Xrint(tls, x))
|
||||
|
||||
return int32(n)
|
||||
}
|
||||
|
||||
+1
-2
@@ -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 386 || arm
|
||||
// +build 386 arm
|
||||
//go:build !windows && (386 || arm)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
+1
-1
@@ -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 ((amd64 || loong64) && !linux) || arm64 || ppc64le || riscv64 || s390x || mips64le
|
||||
//go:build !windows && (((amd64 || arm64 || loong64) && !linux) || ppc64le || riscv64 || s390x || mips64le)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
+2
@@ -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 && arm64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
|
||||
+14
-2
@@ -55,6 +55,10 @@ type (
|
||||
ulong = types.User_ulong_t
|
||||
)
|
||||
|
||||
type pthreadAttr struct {
|
||||
detachState int32
|
||||
}
|
||||
|
||||
// // Keep these outside of the var block otherwise go generate will miss them.
|
||||
var X__stderrp = Xstdout
|
||||
var X__stdinp = Xstdin
|
||||
@@ -452,9 +456,11 @@ func Xsysconf(t *TLS, name int32) long {
|
||||
return long(unix.Getpagesize())
|
||||
case unistd.X_SC_NPROCESSORS_ONLN:
|
||||
return long(runtime.NumCPU())
|
||||
case unistd.X_SC_GETPW_R_SIZE_MAX:
|
||||
return 128
|
||||
}
|
||||
|
||||
panic(todo(""))
|
||||
panic(todo("", name))
|
||||
}
|
||||
|
||||
// int close(int fd);
|
||||
@@ -2158,7 +2164,7 @@ func X__ccgo_pthreadAttrGetDetachState(tls *TLS, a uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v a=%v, (%v:)", tls, a, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
return (*pthreadAttr)(unsafe.Pointer(a)).detachState
|
||||
}
|
||||
|
||||
func Xpthread_attr_getdetachstate(tls *TLS, a uintptr, state uintptr) int32 {
|
||||
@@ -2498,3 +2504,9 @@ func Xsetrlimit(t *TLS, resource int32, rlim uintptr) int32 {
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func X__fpclassifyd(tls *TLS, x float64) (r int32) {
|
||||
return X__fpclassify(tls, x)
|
||||
}
|
||||
|
||||
var Xin6addr_any = in6_addr{}
|
||||
|
||||
+1
-1
@@ -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 !(linux && (amd64 || loong64))
|
||||
//go:build !(linux && (amd64 || arm64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
-729
@@ -1,729 +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"
|
||||
gotime "time"
|
||||
"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/stat"
|
||||
"modernc.org/libc/sys/types"
|
||||
"modernc.org/libc/time"
|
||||
)
|
||||
|
||||
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/src/internal/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 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", 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.Fstatat(unix.AT_FDCWD, GoString(pathname), (*unix.Stat_t)(unsafe.Pointer(statbuf)), 0); 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 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.Unlinkat(unix.AT_FDCWD, GoString(pathname), 0); 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 := unix.Faccessat(unix.AT_FDCWD, GoString(pathname), uint32(mode), 0); err != nil {
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: %v", origin(1), GoString(pathname), err)
|
||||
}
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode)
|
||||
}
|
||||
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 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.Syscall(unix.SYS_FSTAT, uintptr(fd), statbuf, 0); err != 0 {
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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 rmdir(const char *pathname);
|
||||
func Xrmdir(t *TLS, pathname uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v pathname=%v, (%v:)", t, pathname, origin(2))
|
||||
}
|
||||
if err := unix.Rmdir(GoString(pathname)); err != nil {
|
||||
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))
|
||||
}
|
||||
if err := unix.Rename(GoString(oldpath), GoString(newpath)); err != nil {
|
||||
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(""))
|
||||
}
|
||||
|
||||
// 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.Chown(GoString(pathname), int(owner), int(group)); err != nil {
|
||||
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(""))
|
||||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
if _, _, err := unix.Syscall(unix.SYS_PIPE2, 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(""))
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
n, err := unix.Readlink(GoString(path), GoBytes(buf, int(bufsize)))
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
//TODO- flags |= fcntl.O_LARGEFILE
|
||||
fd, err := unix.Openat(unix.AT_FDCWD, GoString(pathname), flags, 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 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 {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: ok", origin(1), GoString(path))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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))
|
||||
}
|
||||
if err := unix.Chmod(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
|
||||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
n := gotime.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 tv []unix.Timeval
|
||||
if times != 0 {
|
||||
tv = make([]unix.Timeval, 2)
|
||||
*(*[2]unix.Timeval)(unsafe.Pointer(&tv[0])) = *(*[2]unix.Timeval)(unsafe.Pointer(times))
|
||||
}
|
||||
if err := unix.Utimes(GoString(filename), tv); err != nil {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
if times != 0 {
|
||||
*(*[2]unix.Timeval)(unsafe.Pointer(times)) = *(*[2]unix.Timeval)(unsafe.Pointer(&tv[0]))
|
||||
}
|
||||
if dmesgs {
|
||||
dmesg("%v: %q: ok", origin(1), GoString(filename))
|
||||
}
|
||||
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))
|
||||
}
|
||||
if times == 0 {
|
||||
return Xutimes(t, filename, 0)
|
||||
}
|
||||
|
||||
if err := unix.Utime(GoString(filename), (*unix.Utimbuf)(unsafe.Pointer(times))); err != nil {
|
||||
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(""))
|
||||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
if _, _, err := unix.Syscall(unix.SYS_SETRLIMIT, uintptr(resource), uintptr(rlim), 0); err != 0 {
|
||||
t.setErrno(err)
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
const __NFDBITS = 64
|
||||
|
||||
func X__fdelt_chk(tls *TLS, d int64) (r int64) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v d=%v, (%v:)", tls, d, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
|
||||
return d / __NFDBITS
|
||||
}
|
||||
+48
-13
@@ -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 linux && (amd64 || loong64)
|
||||
//go:build linux && (amd64 || arm64 || loong64)
|
||||
|
||||
//go:generate go run generator.go
|
||||
|
||||
@@ -128,11 +128,6 @@ import (
|
||||
"modernc.org/memory"
|
||||
)
|
||||
|
||||
const (
|
||||
heapAlign = 16
|
||||
heapGuard = 16
|
||||
)
|
||||
|
||||
var (
|
||||
_ error = (*MemAuditError)(nil)
|
||||
|
||||
@@ -278,15 +273,18 @@ type TLS struct {
|
||||
allocaStack []int
|
||||
allocas []uintptr
|
||||
jumpBuffers []uintptr
|
||||
pendingSignals chan os.Signal
|
||||
pthread uintptr // *t__pthread
|
||||
pthreadCleanupItems []pthreadCleanupItem
|
||||
pthreadKeyValues map[Tpthread_key_t]uintptr
|
||||
sigHandlers map[int32]uintptr
|
||||
sp int
|
||||
stack []tlsStackSlot
|
||||
|
||||
ID int32
|
||||
|
||||
ownsPthread bool
|
||||
checkSignals bool
|
||||
ownsPthread bool
|
||||
}
|
||||
|
||||
var __ccgo_environOnce sync.Once
|
||||
@@ -311,6 +309,7 @@ func NewTLS() (r *TLS) {
|
||||
ID: id,
|
||||
ownsPthread: true,
|
||||
pthread: pthread,
|
||||
sigHandlers: map[int32]uintptr{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,6 +403,29 @@ func (tls *TLS) Alloc(n0 int) (r uintptr) {
|
||||
func (tls *TLS) Free(n int) {
|
||||
//TODO shrink stacks if possible. Tcl is currently against.
|
||||
tls.sp--
|
||||
if !tls.checkSignals {
|
||||
return
|
||||
}
|
||||
|
||||
select {
|
||||
case sig := <-tls.pendingSignals:
|
||||
signum := int32(sig.(syscall.Signal))
|
||||
h, ok := tls.sigHandlers[signum]
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
|
||||
switch h {
|
||||
case SIG_DFL:
|
||||
// nop
|
||||
case SIG_IGN:
|
||||
// nop
|
||||
default:
|
||||
(*(*func(*TLS, int32))(unsafe.Pointer(&struct{ uintptr }{h})))(tls, signum)
|
||||
}
|
||||
default:
|
||||
// nop
|
||||
}
|
||||
}
|
||||
|
||||
func (tls *TLS) alloca(n Tsize_t) (r uintptr) {
|
||||
@@ -475,6 +497,10 @@ func Xexit(tls *TLS, code int32) {
|
||||
for _, v := range atExit {
|
||||
v()
|
||||
}
|
||||
atExitHandlersMu.Lock()
|
||||
for _, v := range atExitHandlers {
|
||||
(*(*func(*TLS))(unsafe.Pointer(&struct{ uintptr }{v})))(tls)
|
||||
}
|
||||
os.Exit(int(code))
|
||||
}
|
||||
|
||||
@@ -647,24 +673,33 @@ func Xfork(t *TLS) int32 {
|
||||
const SIG_DFL = 0
|
||||
const SIG_IGN = 1
|
||||
|
||||
var sigHandlers = map[int32]uintptr{}
|
||||
|
||||
func Xsignal(tls *TLS, signum int32, handler uintptr) (r uintptr) {
|
||||
r, sigHandlers[signum] = sigHandlers[signum], handler
|
||||
sigHandlers[signum] = handler
|
||||
r, tls.sigHandlers[signum] = tls.sigHandlers[signum], handler
|
||||
switch handler {
|
||||
case SIG_DFL:
|
||||
gosignal.Reset(syscall.Signal(signum))
|
||||
case SIG_IGN:
|
||||
gosignal.Ignore(syscall.Signal(signum))
|
||||
default:
|
||||
panic(todo(""))
|
||||
if tls.pendingSignals == nil {
|
||||
tls.pendingSignals = make(chan os.Signal, 3)
|
||||
tls.checkSignals = true
|
||||
}
|
||||
gosignal.Notify(tls.pendingSignals, syscall.Signal(signum))
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
var (
|
||||
atExitHandlersMu sync.Mutex
|
||||
atExitHandlers []uintptr
|
||||
)
|
||||
|
||||
func Xatexit(tls *TLS, func_ uintptr) (r int32) {
|
||||
return -1
|
||||
atExitHandlersMu.Lock()
|
||||
atExitHandlers = append(atExitHandlers, func_)
|
||||
atExitHandlersMu.Unlock()
|
||||
return 0
|
||||
}
|
||||
|
||||
var __sync_synchronize_dummy int32
|
||||
|
||||
+1
-3
@@ -2,9 +2,7 @@
|
||||
// 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
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
+29
@@ -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
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// 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
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
+1
-3
@@ -2,9 +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 && !(linux && (amd64 || loong64))
|
||||
// +build unix
|
||||
// +build !linux !amd64,!loong64
|
||||
//go:build unix && !(linux && (amd64 || arm64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
+1
-1
@@ -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 && !(linux && (amd64 || loong64)) && !openbsd
|
||||
//go:build unix && !illumos && !(linux && (amd64 || arm64 || loong64)) && !openbsd
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
+1423
-7242
File diff suppressed because it is too large
Load Diff
+12165
-697
File diff suppressed because it is too large
Load Diff
+12086
-594
File diff suppressed because it is too large
Load Diff
+12086
-594
File diff suppressed because it is too large
Load Diff
+25
@@ -0,0 +1,25 @@
|
||||
//go:build ignore
|
||||
|
||||
#define _UCRT
|
||||
#define __CRT__NO_INLINE
|
||||
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
#include <io.h>
|
||||
#include <process.h>
|
||||
#include <float.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <locale.h>
|
||||
#include <malloc.h>
|
||||
|
||||
int __cdecl _mkdir(const char *_Path);
|
||||
|
||||
int __cdecl _fstat64(int _FileDes,struct _stat64 *_Stat);
|
||||
int __cdecl _stat64(const char *_Name,struct _stat64 *_Stat);
|
||||
int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat);
|
||||
+337
@@ -0,0 +1,337 @@
|
||||
// Copyright 2024 The Libc Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !(linux && (amd64 || arm64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"math"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Xsin(t *TLS, x float64) float64 {
|
||||
return math.Sin(x)
|
||||
}
|
||||
|
||||
func Xsinf(t *TLS, x float32) float32 {
|
||||
return float32(math.Sin(float64(x)))
|
||||
}
|
||||
|
||||
func Xsinh(t *TLS, x float64) float64 {
|
||||
return math.Sinh(x)
|
||||
}
|
||||
|
||||
func Xsinhf(t *TLS, x float32) float32 {
|
||||
return float32(math.Sinh(float64(x)))
|
||||
}
|
||||
|
||||
func Xcos(t *TLS, x float64) float64 {
|
||||
return math.Cos(x)
|
||||
}
|
||||
|
||||
func Xcosf(t *TLS, x float32) float32 {
|
||||
return float32(math.Cos(float64(x)))
|
||||
}
|
||||
|
||||
func Xcosh(t *TLS, x float64) float64 {
|
||||
return math.Cosh(x)
|
||||
}
|
||||
|
||||
func Xcoshf(t *TLS, x float32) float32 {
|
||||
return float32(math.Cosh(float64(x)))
|
||||
}
|
||||
|
||||
func Xtan(t *TLS, x float64) float64 {
|
||||
return math.Tan(x)
|
||||
}
|
||||
|
||||
func Xtanf(t *TLS, x float32) float32 {
|
||||
return float32(math.Tan(float64(x)))
|
||||
}
|
||||
|
||||
func Xtanh(t *TLS, x float64) float64 {
|
||||
return math.Tanh(x)
|
||||
}
|
||||
|
||||
func Xtanhf(t *TLS, x float32) float32 {
|
||||
return float32(math.Tanh(float64(x)))
|
||||
}
|
||||
|
||||
func Xasin(t *TLS, x float64) float64 {
|
||||
return math.Asin(x)
|
||||
}
|
||||
|
||||
func Xasinf(t *TLS, x float32) float32 {
|
||||
return float32(math.Asin(float64(x)))
|
||||
}
|
||||
|
||||
func Xasinh(t *TLS, x float64) float64 {
|
||||
return math.Asinh(x)
|
||||
}
|
||||
|
||||
func Xasinhf(t *TLS, x float32) float32 {
|
||||
return float32(math.Asinh(float64(x)))
|
||||
}
|
||||
|
||||
func Xacos(t *TLS, x float64) float64 {
|
||||
return math.Acos(x)
|
||||
}
|
||||
|
||||
func Xacosf(t *TLS, x float32) float32 {
|
||||
return float32(math.Acos(float64(x)))
|
||||
}
|
||||
|
||||
func Xacosh(t *TLS, x float64) float64 {
|
||||
return math.Acosh(x)
|
||||
}
|
||||
|
||||
func Xacoshf(t *TLS, x float32) float32 {
|
||||
return float32(math.Acosh(float64(x)))
|
||||
}
|
||||
|
||||
func Xatan(t *TLS, x float64) float64 {
|
||||
return math.Atan(x)
|
||||
}
|
||||
|
||||
func Xatanf(t *TLS, x float32) float32 {
|
||||
return float32(math.Atan(float64(x)))
|
||||
}
|
||||
|
||||
func Xatan2(t *TLS, x, y float64) float64 {
|
||||
return math.Atan2(x, y)
|
||||
}
|
||||
|
||||
func Xatan2f(t *TLS, x, y float32) float32 {
|
||||
return float32(math.Atan2(float64(x), float64(y)))
|
||||
}
|
||||
|
||||
func Xatanh(t *TLS, x float64) float64 {
|
||||
return math.Atanh(x)
|
||||
}
|
||||
|
||||
func Xatanhf(t *TLS, x float32) float32 {
|
||||
return float32(math.Atanh(float64(x)))
|
||||
}
|
||||
|
||||
func Xexp(t *TLS, x float64) float64 {
|
||||
return math.Exp(x)
|
||||
}
|
||||
|
||||
func Xexpf(t *TLS, x float32) float32 {
|
||||
return float32(math.Exp(float64(x)))
|
||||
}
|
||||
|
||||
func Xfabs(t *TLS, x float64) float64 {
|
||||
return math.Abs(x)
|
||||
}
|
||||
|
||||
func Xfabsf(t *TLS, x float32) float32 {
|
||||
return float32(math.Abs(float64(x)))
|
||||
}
|
||||
|
||||
func Xlog(t *TLS, x float64) float64 {
|
||||
return math.Log(x)
|
||||
}
|
||||
|
||||
func Xlogf(t *TLS, x float32) float32 {
|
||||
return float32(math.Log(float64(x)))
|
||||
}
|
||||
|
||||
func Xlog10(t *TLS, x float64) float64 {
|
||||
return math.Log10(x)
|
||||
}
|
||||
|
||||
func Xlog10f(t *TLS, x float32) float32 {
|
||||
return float32(math.Log10(float64(x)))
|
||||
}
|
||||
|
||||
func Xlog2(t *TLS, x float64) float64 {
|
||||
return math.Log2(x)
|
||||
}
|
||||
|
||||
func Xlog2f(t *TLS, x float32) float32 {
|
||||
return float32(math.Log2(float64(x)))
|
||||
}
|
||||
|
||||
func Xpow(t *TLS, x, y float64) float64 {
|
||||
r := math.Pow(x, y)
|
||||
if x > 0 && r == 1 && y >= -1.0000000000000000715e-18 && y < -1e-30 {
|
||||
r = 0.9999999999999999
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func Xpowf(t *TLS, x, y float32) float32 {
|
||||
return float32(math.Pow(float64(x), float64(y)))
|
||||
}
|
||||
|
||||
func Xsqrt(t *TLS, x float64) float64 {
|
||||
return math.Sqrt(x)
|
||||
}
|
||||
|
||||
func Xsqrtf(t *TLS, x float32) float32 {
|
||||
return float32(math.Sqrt(float64(x)))
|
||||
}
|
||||
|
||||
func Xround(t *TLS, x float64) float64 {
|
||||
return math.Round(x)
|
||||
}
|
||||
|
||||
func Xroundf(t *TLS, x float32) float32 {
|
||||
return float32(math.Round(float64(x)))
|
||||
}
|
||||
|
||||
func Xceil(t *TLS, x float64) float64 {
|
||||
return math.Ceil(x)
|
||||
}
|
||||
|
||||
func Xceilf(t *TLS, x float32) float32 {
|
||||
return float32(math.Ceil(float64(x)))
|
||||
}
|
||||
|
||||
func Xfloor(t *TLS, x float64) float64 {
|
||||
return math.Floor(x)
|
||||
}
|
||||
|
||||
func Xfloorf(t *TLS, x float32) float32 {
|
||||
return float32(math.Floor(float64(x)))
|
||||
}
|
||||
|
||||
func Xcopysign(t *TLS, x, y float64) float64 {
|
||||
return math.Copysign(x, y)
|
||||
}
|
||||
|
||||
func Xcopysignf(t *TLS, x, y float32) float32 {
|
||||
return float32(math.Copysign(float64(x), float64(y)))
|
||||
}
|
||||
|
||||
func Xfmod(t *TLS, x, y float64) float64 {
|
||||
return math.Mod(x, y)
|
||||
}
|
||||
|
||||
func Xfmodf(t *TLS, x, y float32) float32 {
|
||||
return float32(math.Mod(float64(x), float64(y)))
|
||||
}
|
||||
|
||||
func Xhypot(t *TLS, x, y float64) float64 {
|
||||
return math.Hypot(x, y)
|
||||
}
|
||||
|
||||
func Xhypotf(t *TLS, x, y float32) float32 {
|
||||
return float32(math.Hypot(float64(x), float64(y)))
|
||||
}
|
||||
|
||||
func Xisnan(t *TLS, x float64) int32 {
|
||||
return Bool32(math.IsNaN(x))
|
||||
}
|
||||
|
||||
func Xisnanf(t *TLS, x float32) int32 {
|
||||
return Bool32(math.IsNaN(float64(x)))
|
||||
}
|
||||
|
||||
func Xisnanl(t *TLS, x float64) int32 {
|
||||
return Bool32(math.IsNaN(x))
|
||||
}
|
||||
|
||||
func Xldexp(t *TLS, x float64, exp int32) float64 {
|
||||
return math.Ldexp(x, int(exp))
|
||||
}
|
||||
|
||||
func Xtrunc(t *TLS, x float64) float64 {
|
||||
return math.Trunc(x)
|
||||
}
|
||||
|
||||
func Xtruncf(t *TLS, x float32) float32 {
|
||||
return float32(math.Trunc(float64(x)))
|
||||
}
|
||||
|
||||
func Xfrexp(t *TLS, x float64, exp uintptr) float64 {
|
||||
f, e := math.Frexp(x)
|
||||
*(*int32)(unsafe.Pointer(exp)) = int32(e)
|
||||
return f
|
||||
}
|
||||
|
||||
func Xfrexpf(t *TLS, x float32, exp uintptr) float32 {
|
||||
f, e := math.Frexp(float64(x))
|
||||
*(*int32)(unsafe.Pointer(exp)) = int32(e)
|
||||
return float32(f)
|
||||
}
|
||||
|
||||
func Xmodf(t *TLS, x float64, iptr uintptr) float64 {
|
||||
i, f := math.Modf(x)
|
||||
*(*float64)(unsafe.Pointer(iptr)) = i
|
||||
return f
|
||||
}
|
||||
|
||||
func Xmodff(t *TLS, x float32, iptr uintptr) float32 {
|
||||
i, f := math.Modf(float64(x))
|
||||
*(*float32)(unsafe.Pointer(iptr)) = float32(i)
|
||||
return float32(f)
|
||||
}
|
||||
|
||||
var _toint5 = Float32FromInt32(1) / Float32FromFloat32(1.1920928955078125e-07)
|
||||
|
||||
func Xrintf(tls *TLS, x float32) (r float32) {
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var e, s int32
|
||||
var y float32
|
||||
var v1 float32
|
||||
var _ /* u at bp+0 */ struct {
|
||||
Fi [0]uint32
|
||||
Ff float32
|
||||
}
|
||||
_, _, _, _ = e, s, y, v1
|
||||
*(*struct {
|
||||
Fi [0]uint32
|
||||
Ff float32
|
||||
})(unsafe.Pointer(bp)) = struct {
|
||||
Fi [0]uint32
|
||||
Ff float32
|
||||
}{}
|
||||
*(*float32)(unsafe.Pointer(bp)) = x
|
||||
e = int32(*(*uint32)(unsafe.Pointer(bp)) >> int32(23) & uint32(0xff))
|
||||
s = int32(*(*uint32)(unsafe.Pointer(bp)) >> int32(31))
|
||||
if e >= Int32FromInt32(0x7f)+Int32FromInt32(23) {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - _toint5 + _toint5
|
||||
} else {
|
||||
y = x + _toint5 - _toint5
|
||||
}
|
||||
if y == Float32FromInt32(0) {
|
||||
if s != 0 {
|
||||
v1 = -Float32FromFloat32(0)
|
||||
} else {
|
||||
v1 = Float32FromFloat32(0)
|
||||
}
|
||||
return v1
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xlrintf(tls *TLS, x float32) (r long) {
|
||||
return long(Xrintf(tls, x))
|
||||
}
|
||||
|
||||
func Xlrint(tls *TLS, x float64) (r long) {
|
||||
return long(Xrint(tls, x))
|
||||
}
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 {
|
||||
switch {
|
||||
case x == 0: // also +0 and -0
|
||||
return 0
|
||||
case math.IsInf(x, 0), math.IsNaN(x):
|
||||
return x
|
||||
case x >= math.MinInt64 && x <= math.MaxInt64 && float64(int64(x)) == x:
|
||||
return x
|
||||
case x >= 0:
|
||||
return math.Floor(x + 0.5)
|
||||
default:
|
||||
return math.Ceil(x - 0.5)
|
||||
}
|
||||
}
|
||||
+13
-16
@@ -2,10 +2,7 @@
|
||||
// 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))
|
||||
// +build !libc.membrk
|
||||
// +build !libc.memgrind
|
||||
// +build !linux !amd64,!loong64
|
||||
//go:build !libc.membrk && !libc.memgrind && !((linux && (amd64 || arm64 || loong64)) || windows)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
@@ -30,9 +27,9 @@ func Xmalloc(t *TLS, n types.Size_t) uintptr {
|
||||
return 0
|
||||
}
|
||||
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
p, err := allocator.UintptrMalloc(int(n))
|
||||
if err != nil {
|
||||
@@ -53,9 +50,9 @@ func Xcalloc(t *TLS, n, size types.Size_t) uintptr {
|
||||
return 0
|
||||
}
|
||||
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
p, err := allocator.UintptrCalloc(int(n * size))
|
||||
if err != nil {
|
||||
@@ -71,9 +68,9 @@ func Xrealloc(t *TLS, ptr uintptr, size types.Size_t) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v ptr=%v size=%v, (%v:)", t, ptr, size, origin(2))
|
||||
}
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
p, err := allocator.UintptrRealloc(ptr, int(size))
|
||||
if err != nil {
|
||||
@@ -93,9 +90,9 @@ func Xfree(t *TLS, p uintptr) {
|
||||
return
|
||||
}
|
||||
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
allocator.UintptrFree(p)
|
||||
}
|
||||
@@ -109,17 +106,17 @@ func Xmalloc_usable_size(tls *TLS, p uintptr) (r types.Size_t) {
|
||||
return 0
|
||||
}
|
||||
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
return types.Size_t(memory.UintptrUsableSize(p))
|
||||
}
|
||||
|
||||
func UsableSize(p uintptr) types.Size_t {
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
return types.Size_t(memory.UintptrUsableSize(p))
|
||||
}
|
||||
|
||||
+4
-8
@@ -2,10 +2,7 @@
|
||||
// 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))
|
||||
// +build libc.membrk
|
||||
// +build !libc.memgrind
|
||||
// +build !linux !amd64,!loong64
|
||||
//go:build libc.membrk && !libc.memgrind && !((linux && (amd64 || arm64 || loong64)) || windows)
|
||||
|
||||
// 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
|
||||
@@ -22,8 +19,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
heapAlign = 16
|
||||
memgrind = false
|
||||
memgrind = false
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -41,9 +37,9 @@ func Xmalloc(t *TLS, n types.Size_t) uintptr {
|
||||
return 0
|
||||
}
|
||||
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
n2 := uintptr(n) + uintptrSize // reserve space for recording block size
|
||||
p := roundup(heapP, 16)
|
||||
|
||||
+3
-2
@@ -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 libc.membrk && !libc.memgrind && linux && (amd64 || loong64)
|
||||
//go:build libc.membrk && !libc.memgrind && linux && (amd64 || arm64 || 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
|
||||
@@ -12,7 +12,7 @@
|
||||
// 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"
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
memgrind = false
|
||||
isMemBrk = true
|
||||
|
||||
heapSize = 1 << 30
|
||||
|
||||
+4
-4
@@ -2,13 +2,13 @@
|
||||
// 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)
|
||||
//go:build !libc.membrk && !libc.memgrind && linux && (amd64 || arm64 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc/v2"
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"math"
|
||||
"math/bits"
|
||||
mbits "math/bits"
|
||||
|
||||
"modernc.org/memory"
|
||||
)
|
||||
@@ -49,7 +49,7 @@ func Xcalloc(tls *TLS, m Tsize_t, n Tsize_t) (r uintptr) {
|
||||
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))
|
||||
hi, rq := mbits.Mul(uint(m), uint(n))
|
||||
if hi != 0 || rq > math.MaxInt {
|
||||
tls.setErrno(ENOMEM)
|
||||
return 0
|
||||
|
||||
+21
-24
@@ -2,10 +2,7 @@
|
||||
// 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))
|
||||
// +build !libc.membrk
|
||||
// +build libc.memgrind
|
||||
// +build !linux !amd64,!loong64
|
||||
//go:build !libc.membrk && libc.memgrind && !((linux && (amd64 || arm64 || loong64)) || windows)
|
||||
|
||||
// This is a debug-only version of the memory handling functions. When a
|
||||
// program is built with -tags=libc.memgrind the functions MemAuditStart and
|
||||
@@ -20,7 +17,7 @@ import (
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"modernc.org/libc/errno"
|
||||
cerrno "modernc.org/libc/errno"
|
||||
"modernc.org/libc/sys/types"
|
||||
"modernc.org/memory"
|
||||
)
|
||||
@@ -83,16 +80,16 @@ func Xmalloc(t *TLS, size types.Size_t) uintptr {
|
||||
return 0
|
||||
}
|
||||
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
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(errno.ENOMEM)
|
||||
t.setErrno(cerrno.ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -123,16 +120,16 @@ func Xcalloc(t *TLS, n, size types.Size_t) uintptr {
|
||||
return 0
|
||||
}
|
||||
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
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(errno.ENOMEM)
|
||||
t.setErrno(cerrno.ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -158,9 +155,9 @@ func Xrealloc(t *TLS, ptr uintptr, size types.Size_t) uintptr {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v ptr=%v size=%v, (%v:)", t, ptr, size, origin(2))
|
||||
}
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
var pc uintptr
|
||||
if memAuditEnabled {
|
||||
@@ -191,7 +188,7 @@ func Xrealloc(t *TLS, ptr uintptr, size types.Size_t) uintptr {
|
||||
// dmesg("%v: %#x, %v -> %#x, %v", origin(1), ptr, size, p, err)
|
||||
// }
|
||||
if err != nil {
|
||||
t.setErrno(errno.ENOMEM)
|
||||
t.setErrno(cerrno.ENOMEM)
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -220,9 +217,9 @@ func Xfree(t *TLS, p uintptr) {
|
||||
// dmesg("%v: %#x", origin(1), p)
|
||||
// }
|
||||
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
sz := memory.UintptrUsableSize(p)
|
||||
if memAuditEnabled {
|
||||
@@ -253,9 +250,9 @@ func Xfree(t *TLS, p uintptr) {
|
||||
}
|
||||
|
||||
func UsableSize(p uintptr) types.Size_t {
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
if memAuditEnabled {
|
||||
pc, _, _, ok := runtime.Caller(1)
|
||||
@@ -284,9 +281,9 @@ func UsableSize(p uintptr) types.Size_t {
|
||||
// It is intended only for debug/test builds. It slows down memory allocation
|
||||
// routines and it has additional memory costs.
|
||||
func MemAuditStart() {
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer allocMu.Unlock()
|
||||
defer allocatorMu.Unlock()
|
||||
|
||||
allocs = map[uintptr]uintptr{} // addr: caller
|
||||
allocsMore = map[uintptr]string{}
|
||||
@@ -303,7 +300,7 @@ func MemAuditStart() {
|
||||
// It is intended only for debug/test builds. It slows down memory allocation
|
||||
// routines and it has additional memory costs.
|
||||
func MemAuditReport() (r error) {
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
|
||||
defer func() {
|
||||
allocs = nil
|
||||
@@ -311,7 +308,7 @@ func MemAuditReport() (r error) {
|
||||
frees = nil
|
||||
memAuditEnabled = false
|
||||
memAudit = nil
|
||||
allocMu.Unlock()
|
||||
allocatorMu.Unlock()
|
||||
}()
|
||||
|
||||
if len(allocs) != 0 {
|
||||
@@ -328,7 +325,7 @@ func MemAuditReport() (r error) {
|
||||
}
|
||||
|
||||
func MemAuditAnnotate(pc uintptr, s string) {
|
||||
allocMu.Lock()
|
||||
allocatorMu.Lock()
|
||||
allocsMore[pc] = s
|
||||
allocMu.Unlock()
|
||||
allocatorMu.Unlock()
|
||||
}
|
||||
|
||||
+18
-7
@@ -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 !libc.membrk && libc.memgrind && linux && (amd64 || loong64)
|
||||
//go:build !libc.membrk && libc.memgrind && linux && (amd64 || arm64 || 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
|
||||
@@ -12,6 +12,7 @@ package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -57,6 +58,13 @@ var (
|
||||
memAuditEnabled bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
if os.Getenv("LIBC_MEMAUDIT_AUTOSTART") == "1" {
|
||||
fmt.Fprintln(os.Stderr, "memory auditing autostarted")
|
||||
MemAuditStart()
|
||||
}
|
||||
}
|
||||
|
||||
func pc2origin(pc uintptr) string {
|
||||
f := runtime.FuncForPC(pc)
|
||||
var fn, fns string
|
||||
@@ -72,9 +80,10 @@ func pc2origin(pc uintptr) string {
|
||||
}
|
||||
|
||||
// void *malloc(size_t size);
|
||||
func Xmalloc(t *TLS, size Tsize_t) uintptr {
|
||||
func Xmalloc(t *TLS, size Tsize_t) (r uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v size=%v, (%v:)", t, size, origin(2))
|
||||
trc("t=%v size=%v, (%v: %v:)", t, size, origin(2), origin(3))
|
||||
defer func() { trc("Xmalloc->%#0x(%[1]v)", r) }()
|
||||
}
|
||||
if size == 0 {
|
||||
return 0
|
||||
@@ -111,9 +120,10 @@ func Xmalloc(t *TLS, size Tsize_t) uintptr {
|
||||
}
|
||||
|
||||
// void *calloc(size_t nmemb, size_t size);
|
||||
func Xcalloc(t *TLS, n, size Tsize_t) uintptr {
|
||||
func Xcalloc(t *TLS, n, size Tsize_t) (r uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v size=%v, (%v:)", t, size, origin(2))
|
||||
trc("t=%v size=%v, (%v: %v:)", t, size, origin(2), origin(3))
|
||||
defer func() { trc("Xcalloc->%#0x(%[1]v)", r) }()
|
||||
}
|
||||
rq := int(n * size)
|
||||
if rq == 0 {
|
||||
@@ -151,9 +161,10 @@ func Xcalloc(t *TLS, n, size Tsize_t) uintptr {
|
||||
}
|
||||
|
||||
// void *realloc(void *ptr, size_t size);
|
||||
func Xrealloc(t *TLS, ptr uintptr, size Tsize_t) uintptr {
|
||||
func Xrealloc(t *TLS, ptr uintptr, size Tsize_t) (r uintptr) {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v ptr=%v size=%v, (%v:)", t, ptr, size, origin(2))
|
||||
trc("t=%v ptr=%v size=%v, (%v: %v)", t, ptr, size, origin(2), origin(3))
|
||||
defer func() { trc("Xrealloc->%#0x(%[1]v)", r) }()
|
||||
}
|
||||
allocatorMu.Lock()
|
||||
|
||||
|
||||
-34
@@ -2304,40 +2304,6 @@ func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */
|
||||
return X__builtin_nanf(tls, ts+13)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-34
@@ -2304,40 +2304,6 @@ func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */
|
||||
return X__builtin_nanf(tls, ts+13)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-34
@@ -4712,40 +4712,6 @@ func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */
|
||||
return Xfmod(tls, x, y)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-34
@@ -4718,40 +4718,6 @@ func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */
|
||||
return Xfmod(tls, x, y)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-34
@@ -4714,40 +4714,6 @@ func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */
|
||||
return Xfmod(tls, x, y)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-34
@@ -4718,40 +4718,6 @@ func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */
|
||||
return Xfmod(tls, x, y)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-34
@@ -2080,40 +2080,6 @@ func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */
|
||||
return X__builtin_nanf(tls, ts+13)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ f float64 })(unsafe.Pointer(bp)) = func() (r struct{ f float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-34
@@ -2065,40 +2065,6 @@ func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */
|
||||
return X__builtin_nanf(tls, ts+13)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ f float64 })(unsafe.Pointer(bp)) = func() (r struct{ f float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-7205
File diff suppressed because it is too large
Load Diff
-35
@@ -2068,41 +2068,6 @@ func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */
|
||||
}
|
||||
return X__builtin_nanf(tls, ts+13)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ f float64 })(unsafe.Pointer(bp)) = func() (r struct{ f float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-7289
File diff suppressed because it is too large
Load Diff
-34
@@ -2078,40 +2078,6 @@ func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */
|
||||
return X__builtin_nanf(tls, ts+13)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ f float64 })(unsafe.Pointer(bp)) = func() (r struct{ f float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-35
@@ -2070,41 +2070,6 @@ func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */
|
||||
}
|
||||
return X__builtin_nanf(tls, ts+13)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ f float64 })(unsafe.Pointer(bp)) = func() (r struct{ f float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-35
@@ -2074,41 +2074,6 @@ func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */
|
||||
}
|
||||
return X__builtin_nanf(tls, ts+13)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ f float64 })(unsafe.Pointer(bp)) = func() (r struct{ f float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-35
@@ -2070,41 +2070,6 @@ func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */
|
||||
}
|
||||
return X__builtin_nanf(tls, ts+13)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ f float64 })(unsafe.Pointer(bp)) = func() (r struct{ f float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-35
@@ -2189,41 +2189,6 @@ func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */
|
||||
}
|
||||
return Xfmod(tls, x, y)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-35
@@ -2185,41 +2185,6 @@ func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */
|
||||
}
|
||||
return Xfmod(tls, x, y)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-35
@@ -2076,41 +2076,6 @@ func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */
|
||||
}
|
||||
return Xfmod(tls, x, y)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-35
@@ -2078,41 +2078,6 @@ func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */
|
||||
}
|
||||
return Xfmod(tls, x, y)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-35
@@ -2078,41 +2078,6 @@ func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */
|
||||
}
|
||||
return Xfmod(tls, x, y)
|
||||
}
|
||||
|
||||
var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
|
||||
|
||||
func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
}
|
||||
bp := tls.Alloc(8)
|
||||
defer tls.Free(8)
|
||||
|
||||
*(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
|
||||
*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
|
||||
return r
|
||||
}()
|
||||
var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
|
||||
var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
|
||||
var y double_t
|
||||
|
||||
if e >= 0x3ff+52 {
|
||||
return x
|
||||
}
|
||||
if s != 0 {
|
||||
y = x - toint + toint
|
||||
} else {
|
||||
y = x + toint - toint
|
||||
}
|
||||
if y == float64(0) {
|
||||
if s != 0 {
|
||||
return -Float64FromFloat64(0.0)
|
||||
}
|
||||
return float64(0)
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
|
||||
|
||||
-1143
File diff suppressed because it is too large
Load Diff
-1189
File diff suppressed because it is too large
Load Diff
-1267
File diff suppressed because it is too large
Load Diff
+2
@@ -10,3 +10,5 @@ package libc // import "modernc.org/libc"
|
||||
const dmesgs = false
|
||||
|
||||
func dmesg(s string, args ...interface{}) {}
|
||||
|
||||
func dmesgFinish() {}
|
||||
|
||||
+111
-1
@@ -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 !(linux && (amd64 || loong64))
|
||||
//go:build !(linux && (amd64 || arm64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
@@ -15,6 +15,97 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func VaInt32(app *uintptr) int32 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := int32(*(*int64)(unsafe.Pointer(ap)))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
func VaUint32(app *uintptr) uint32 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := uint32(*(*uint64)(unsafe.Pointer(ap)))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
func VaInt64(app *uintptr) int64 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := *(*int64)(unsafe.Pointer(ap))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
func VaUint64(app *uintptr) uint64 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := *(*uint64)(unsafe.Pointer(ap))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
func VaFloat32(app *uintptr) float32 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := *(*float64)(unsafe.Pointer(ap))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return float32(v)
|
||||
}
|
||||
|
||||
func VaFloat64(app *uintptr) float64 {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := *(*float64)(unsafe.Pointer(ap))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
func VaUintptr(app *uintptr) uintptr {
|
||||
ap := *(*uintptr)(unsafe.Pointer(app))
|
||||
if ap == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
ap = roundup(ap, 8)
|
||||
v := *(*uintptr)(unsafe.Pointer(ap))
|
||||
ap += 8
|
||||
*(*uintptr)(unsafe.Pointer(app)) = ap
|
||||
return v
|
||||
}
|
||||
|
||||
const (
|
||||
modNone = iota
|
||||
modHH
|
||||
@@ -346,6 +437,8 @@ more:
|
||||
arg = uint64(uint8(VaInt32(args)))
|
||||
case mod32:
|
||||
arg = uint64(VaInt32(args))
|
||||
case modZ:
|
||||
arg = uint64(VaInt64(args))
|
||||
default:
|
||||
panic(todo("", mod))
|
||||
}
|
||||
@@ -680,3 +773,20 @@ func fixNanInf(s string) string {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
func Xvfprintf(t *TLS, stream, format, va uintptr) int32 {
|
||||
return Xfprintf(t, stream, format, va)
|
||||
}
|
||||
|
||||
func Xvsprintf(t *TLS, str, format, va uintptr) int32 {
|
||||
return Xsprintf(t, str, format, va)
|
||||
}
|
||||
|
||||
// int sprintf(char *str, const char *format, ...);
|
||||
func Xsprintf(t *TLS, str, format, args uintptr) (r int32) {
|
||||
b := printf(format, args)
|
||||
r = int32(len(b))
|
||||
copy(unsafe.Slice((*byte)(unsafe.Pointer(str)), r)[:r:r], b)
|
||||
*(*byte)(unsafe.Pointer(str + uintptr(r))) = 0
|
||||
return int32(len(b))
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 !(linux && (amd64 || loong64))
|
||||
//go:build !((linux && (amd64 || arm64 || loong64)) || windows)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
+12
-4
@@ -2,10 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !freebsd && !openbsd && !(linux && (amd64 || loong64))
|
||||
// +build !freebsd
|
||||
// +build !openbsd
|
||||
// +build !linux !amd64,!loong64
|
||||
//go:build !freebsd && !openbsd && !((linux && (amd64 || arm64 || loong64)) || windows)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
@@ -50,3 +47,14 @@ func Xpthread_mutex_init(t *TLS, pMutex, pAttr uintptr) int32 {
|
||||
mutexes[pMutex] = newMutex(typ)
|
||||
return 0
|
||||
}
|
||||
|
||||
func Xpthread_atfork(tls *TLS, prepare, parent, child uintptr) int32 {
|
||||
// fork(2) not supported.
|
||||
return 0
|
||||
}
|
||||
|
||||
// int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old)
|
||||
func Xpthread_sigmask(tls *TLS, now int32, set, old uintptr) int32 {
|
||||
// ignored
|
||||
return 0
|
||||
}
|
||||
|
||||
+2
-3
@@ -2,13 +2,12 @@
|
||||
// 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:build linux && (amd64 || arm64 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"slices"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -399,7 +398,7 @@ func Xpthread_cond_timedwait(tls *TLS, c, m, ts uintptr) (r int32) {
|
||||
waiters = conds.conds[c]
|
||||
for i, v := range waiters {
|
||||
if v == ch {
|
||||
conds.conds[c] = slices.Delete(waiters, i, i+1)
|
||||
conds.conds[c] = append(waiters[:i], waiters[i+1:]...)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,9 +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:build linux && (amd64 || arm64 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc/v2"
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
+177
-60
@@ -2,13 +2,14 @@
|
||||
// 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:build !(linux && (amd64 || arm64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
import (
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@@ -86,6 +87,7 @@ func scanfConversion(r io.ByteScanner, format uintptr, args *uintptr) (_ uintptr
|
||||
|
||||
mod := 0
|
||||
width := -1
|
||||
discard := false
|
||||
flags:
|
||||
for {
|
||||
switch c := *(*byte)(unsafe.Pointer(format)); c {
|
||||
@@ -95,7 +97,7 @@ flags:
|
||||
// corresponding pointer argument is re‐ quired, and this specification is not
|
||||
// included in the count of successful assignments returned by scanf().
|
||||
format++
|
||||
panic(todo(""))
|
||||
discard = true
|
||||
case '\'':
|
||||
// For decimal conversions, an optional quote character ('). This specifies
|
||||
// that the input number may include thousands' separators as defined by the
|
||||
@@ -143,7 +145,18 @@ flags:
|
||||
// input '%' character. No conversion is done (but initial white space
|
||||
// characters are discarded), and assign‐ ment does not occur.
|
||||
format++
|
||||
panic(todo(""))
|
||||
skipReaderWhiteSpace(r)
|
||||
c, err := r.ReadByte()
|
||||
if err != nil {
|
||||
return format, -1, false
|
||||
}
|
||||
|
||||
if c == '%' {
|
||||
return format, 1, true
|
||||
}
|
||||
|
||||
r.UnreadByte()
|
||||
return format, 0, false
|
||||
case 'd':
|
||||
// Matches an optionally signed decimal integer; the next pointer must be a
|
||||
// pointer to int.
|
||||
@@ -193,22 +206,26 @@ flags:
|
||||
break
|
||||
}
|
||||
|
||||
arg := VaUintptr(args)
|
||||
v := int64(n)
|
||||
if neg {
|
||||
v = -v
|
||||
}
|
||||
switch mod {
|
||||
case modNone:
|
||||
*(*int32)(unsafe.Pointer(arg)) = int32(v)
|
||||
case modH:
|
||||
*(*int16)(unsafe.Pointer(arg)) = int16(v)
|
||||
case modHH:
|
||||
*(*int8)(unsafe.Pointer(arg)) = int8(v)
|
||||
case modL:
|
||||
*(*long)(unsafe.Pointer(arg)) = long(n)
|
||||
default:
|
||||
panic(todo(""))
|
||||
if !discard {
|
||||
arg := VaUintptr(args)
|
||||
v := int64(n)
|
||||
if neg {
|
||||
v = -v
|
||||
}
|
||||
switch mod {
|
||||
case modNone:
|
||||
*(*int32)(unsafe.Pointer(arg)) = int32(v)
|
||||
case modH:
|
||||
*(*int16)(unsafe.Pointer(arg)) = int16(v)
|
||||
case modHH:
|
||||
*(*int8)(unsafe.Pointer(arg)) = int8(v)
|
||||
case modL:
|
||||
*(*long)(unsafe.Pointer(arg)) = long(v)
|
||||
case modLL:
|
||||
*(*int64)(unsafe.Pointer(arg)) = int64(v)
|
||||
default:
|
||||
panic(todo("", mod))
|
||||
}
|
||||
}
|
||||
nvalues = 1
|
||||
case 'D':
|
||||
@@ -246,7 +263,7 @@ flags:
|
||||
for ; width != 0; width-- {
|
||||
c, err := r.ReadByte()
|
||||
if err != nil {
|
||||
if match {
|
||||
if match || err == io.EOF {
|
||||
break hex
|
||||
}
|
||||
|
||||
@@ -286,18 +303,20 @@ flags:
|
||||
break
|
||||
}
|
||||
|
||||
arg := VaUintptr(args)
|
||||
switch mod {
|
||||
case modNone:
|
||||
*(*uint32)(unsafe.Pointer(arg)) = uint32(n)
|
||||
case modH:
|
||||
*(*uint16)(unsafe.Pointer(arg)) = uint16(n)
|
||||
case modHH:
|
||||
*(*byte)(unsafe.Pointer(arg)) = byte(n)
|
||||
case modL:
|
||||
*(*ulong)(unsafe.Pointer(arg)) = ulong(n)
|
||||
default:
|
||||
panic(todo(""))
|
||||
if !discard {
|
||||
arg := VaUintptr(args)
|
||||
switch mod {
|
||||
case modNone:
|
||||
*(*uint32)(unsafe.Pointer(arg)) = uint32(n)
|
||||
case modH:
|
||||
*(*uint16)(unsafe.Pointer(arg)) = uint16(n)
|
||||
case modHH:
|
||||
*(*byte)(unsafe.Pointer(arg)) = byte(n)
|
||||
case modL:
|
||||
*(*ulong)(unsafe.Pointer(arg)) = ulong(n)
|
||||
default:
|
||||
panic(todo(""))
|
||||
}
|
||||
}
|
||||
nvalues = 1
|
||||
case 'f', 'e', 'g', 'E', 'a':
|
||||
@@ -323,17 +342,19 @@ flags:
|
||||
panic(todo("", err))
|
||||
}
|
||||
|
||||
arg := VaUintptr(args)
|
||||
if neg {
|
||||
n = -n
|
||||
}
|
||||
switch mod {
|
||||
case modNone:
|
||||
*(*float32)(unsafe.Pointer(arg)) = float32(n)
|
||||
case modL:
|
||||
*(*float64)(unsafe.Pointer(arg)) = n
|
||||
default:
|
||||
panic(todo("", mod, neg, n))
|
||||
if !discard {
|
||||
arg := VaUintptr(args)
|
||||
if neg {
|
||||
n = -n
|
||||
}
|
||||
switch mod {
|
||||
case modNone:
|
||||
*(*float32)(unsafe.Pointer(arg)) = float32(n)
|
||||
case modL:
|
||||
*(*float64)(unsafe.Pointer(arg)) = n
|
||||
default:
|
||||
panic(todo("", mod, neg, n))
|
||||
}
|
||||
}
|
||||
return format, 1, true
|
||||
case 's':
|
||||
@@ -342,8 +363,44 @@ flags:
|
||||
// hold the input sequence and the terminating null byte ('\0'), which is added
|
||||
// automatically. The input string stops at white space or at the maximum
|
||||
// field width, whichever occurs first.
|
||||
format++
|
||||
panic(todo(""))
|
||||
var c byte
|
||||
var err error
|
||||
var arg uintptr
|
||||
if !discard {
|
||||
arg = VaUintptr(args)
|
||||
}
|
||||
scans:
|
||||
for ; width != 0; width-- {
|
||||
if c, err = r.ReadByte(); err != nil {
|
||||
if err != io.EOF {
|
||||
nvalues = -1
|
||||
}
|
||||
break scans
|
||||
}
|
||||
|
||||
switch c {
|
||||
case ' ', '\t', '\n', '\r', '\v', '\f':
|
||||
break scans
|
||||
}
|
||||
|
||||
nvalues = 1
|
||||
match = true
|
||||
if !discard {
|
||||
*(*byte)(unsafe.Pointer(arg)) = c
|
||||
arg++
|
||||
}
|
||||
}
|
||||
if match {
|
||||
switch {
|
||||
case width == 0:
|
||||
r.UnreadByte()
|
||||
fallthrough
|
||||
default:
|
||||
if !discard {
|
||||
*(*byte)(unsafe.Pointer(arg)) = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'c':
|
||||
// Matches a sequence of characters whose length is specified by the maximum
|
||||
// field width (default 1); the next pointer must be a pointer to char, and
|
||||
@@ -370,7 +427,69 @@ flags:
|
||||
// hyphen". The string ends with the appearance of a character not in the
|
||||
// (or, with a circumflex, in) set or when the field width runs out.
|
||||
format++
|
||||
panic(todo(""))
|
||||
var re0 []byte
|
||||
bracket:
|
||||
for i := 0; ; i++ {
|
||||
c := *(*byte)(unsafe.Pointer(format))
|
||||
format++
|
||||
if c == ']' && i != 0 {
|
||||
break bracket
|
||||
}
|
||||
|
||||
re0 = append(re0, c)
|
||||
}
|
||||
set := map[byte]struct{}{}
|
||||
re := string(re0)
|
||||
neg := strings.HasPrefix(re, "^")
|
||||
if neg {
|
||||
re = re[1:]
|
||||
}
|
||||
for len(re) != 0 {
|
||||
switch {
|
||||
case len(re) >= 3 && re[1] == '-':
|
||||
for c := re[0]; c <= re[2]; c++ {
|
||||
set[c] = struct{}{}
|
||||
}
|
||||
re = re[3:]
|
||||
default:
|
||||
set[c] = struct{}{}
|
||||
re = re[1:]
|
||||
}
|
||||
}
|
||||
var arg uintptr
|
||||
if !discard {
|
||||
arg = VaUintptr(args)
|
||||
}
|
||||
for ; width != 0; width-- {
|
||||
c, err := r.ReadByte()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
return format, nvalues, match
|
||||
}
|
||||
|
||||
return format, -1, match
|
||||
}
|
||||
|
||||
if _, ok := set[c]; ok == !neg {
|
||||
match = true
|
||||
nvalues = 1
|
||||
if !discard {
|
||||
*(*byte)(unsafe.Pointer(arg)) = c
|
||||
arg++
|
||||
}
|
||||
}
|
||||
}
|
||||
if match {
|
||||
switch {
|
||||
case width == 0:
|
||||
r.UnreadByte()
|
||||
fallthrough
|
||||
default:
|
||||
if !discard {
|
||||
*(*byte)(unsafe.Pointer(arg)) = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'p':
|
||||
// Matches a pointer value (as printed by %p in printf(3); the next pointer
|
||||
// must be a pointer to a pointer to void.
|
||||
@@ -378,21 +497,17 @@ flags:
|
||||
skipReaderWhiteSpace(r)
|
||||
c, err := r.ReadByte()
|
||||
if err != nil {
|
||||
panic(todo(""))
|
||||
panic(todo("", err))
|
||||
}
|
||||
|
||||
if c != '0' {
|
||||
r.UnreadByte()
|
||||
panic(todo(""))
|
||||
}
|
||||
if c == '0' {
|
||||
if c, err = r.ReadByte(); err != nil {
|
||||
panic(todo("", err))
|
||||
}
|
||||
|
||||
if c, err = r.ReadByte(); err != nil {
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
if c != 'x' && c != 'X' {
|
||||
r.UnreadByte()
|
||||
panic(todo(""))
|
||||
if c != 'x' && c != 'X' {
|
||||
r.UnreadByte()
|
||||
}
|
||||
}
|
||||
|
||||
var digit, n uint64
|
||||
@@ -429,8 +544,10 @@ flags:
|
||||
break
|
||||
}
|
||||
|
||||
arg := VaUintptr(args)
|
||||
*(*uintptr)(unsafe.Pointer(arg)) = uintptr(n)
|
||||
if !discard {
|
||||
arg := VaUintptr(args)
|
||||
*(*uintptr)(unsafe.Pointer(arg)) = uintptr(n)
|
||||
}
|
||||
nvalues = 1
|
||||
case 'n':
|
||||
// Nothing is expected; instead, the number of characters consumed thus far
|
||||
|
||||
+1
-1
@@ -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 !(linux && (amd64 || loong64))
|
||||
//go:build !(linux && (amd64 || arm64 || loong64))
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
+1
-1
@@ -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 linux && (amd64 || loong64)
|
||||
//go:build linux && (amd64 || arm64 || loong64)
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user