From a4b455185b1e18cf550929d928dd38b6b1704384 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Mon, 8 Jan 2024 10:07:35 -0800 Subject: [PATCH] Bring back gc() function Renaming gc() to _gc() was a mistake since the better thing to do is put it behind the _COSMO_SOURCE macro. We need this change because I haven't wanted to use my amazing garbage collector ever since we renamed it. You now need to define _COSMO_SOURCE yourself when using amalgamation header and cosmocc users need to pass the -mcosmo flag to get the gc() function Some other issues relating to cancelation have been fixed along the way. We're also now putting cosmocc in a folder named `.cosmocc` so it can be more safely excluded by grep --exclude-dir=.cosmocc --exclude-dir=o etc. --- .gitignore | 3 +- Makefile | 5 +- build/definitions.mk | 2 - build/objdump | 16 +- dsp/scale/gyarados.c | 2 +- dsp/tty/sendtitle.c | 2 +- dsp/tty/ttyraw.c | 2 +- examples/greenbean.c | 4 +- examples/ls.c | 2 +- examples/stat.c | 8 +- examples/unbourne.c | 2 +- libc/calls/getrandom.c | 2 + libc/calls/tmpfd.c | 2 +- libc/dlopen/dlopen.c | 3 + libc/intrin/stracef.greg.c | 13 + libc/log/libfatal.internal.h | 40 +- libc/log/vflogf.c | 2 + libc/mem/gc.c | 49 +- libc/mem/gc.h | 32 +- libc/mem/gc.internal.h | 9 - libc/nexgen32e/gclongjmp.S | 4 +- libc/nexgen32e/longjmp.S | 2 +- libc/nexgen32e/setjmp.S | 5 +- libc/proc/execve-sysv.c | 2 + libc/proc/fexecve.c | 12 +- libc/runtime/runtime.h | 2 +- libc/runtime/stack.h | 2 +- libc/stdio/getentropy.c | 3 + libc/stdio/tmpfile.c | 2 +- libc/thread/posixthread.internal.h | 4 +- libc/thread/pthread_cancel.c | 2 +- libc/thread/pthread_exit.c | 4 +- libc/thread/tls.h | 2 +- libc/thread/tls2.internal.h | 6 +- libc/x/xbasename.c | 2 +- net/https/chaincertificate.c | 2 +- net/https/finishcertificate.c | 6 +- net/turfwar/turfwar.c | 10 +- test/dsp/core/alaw_test.c | 2 +- test/dsp/core/getintegercoefficients_test.c | 2 +- test/dsp/scale/magikarp_test.c | 2 +- test/dsp/scale/scale_test.c | 2 +- test/libc/calls/access_test.c | 2 +- test/libc/calls/cachestat_test.c | 2 +- test/libc/calls/copy_file_range_test.c | 6 +- test/libc/calls/fchdir_test.c | 2 +- test/libc/calls/ftruncate_test.c | 2 +- test/libc/calls/getcwd_test.c | 2 +- test/libc/calls/getrandom_test.c | 6 +- test/libc/calls/ioctl_test.c | 2 +- test/libc/calls/makedirs_test.c | 2 +- test/libc/calls/mkdir_test.c | 2 +- test/libc/calls/mkntcmdline_test.c | 2 +- test/libc/calls/mkntenvblock_test.c | 2 +- test/libc/calls/mkntpath_test.c | 2 +- test/libc/calls/open_test.c | 2 +- test/libc/calls/openatemp_test.c | 2 +- test/libc/calls/poll_test.c | 2 +- test/libc/calls/readlinkat_test.c | 2 +- test/libc/calls/stackoverflow1_test.c | 2 +- test/libc/calls/stackoverflow2_test.c | 2 +- test/libc/calls/stackoverflow3_test.c | 2 +- test/libc/calls/stackoverflow4_test.c | 2 +- test/libc/calls/stat_test.c | 2 +- test/libc/calls/writev_test.c | 4 +- test/libc/fmt/stripexts_test.c | 2 +- test/libc/fmt/zleb64_test.c | 2 +- test/libc/intrin/cosmo_once_test.c | 2 +- test/libc/intrin/countbits_test.c | 2 +- test/libc/intrin/memcmp_test.c | 2 +- test/libc/intrin/memmove_test.c | 2 +- test/libc/intrin/memset_test.c | 2 +- test/libc/intrin/pthread_mutex_lock2_test.c | 2 +- test/libc/intrin/pthread_mutex_lock_test.c | 2 +- test/libc/intrin/strcmp_test.c | 2 +- test/libc/log/backtrace_test.c | 28 +- test/libc/mem/djbsort_test.c | 14 +- test/libc/mem/malloc_test.c | 4 +- test/libc/mem/qsort_test.c | 2 +- test/libc/mem/realpath_test.c | 2 +- test/libc/nexgen32e/gclongjmp_test.c | 12 +- test/libc/nexgen32e/lz4decode_test.c | 2 +- test/libc/nexgen32e/memset_test.c | 2 +- test/libc/nexgen32e/strsak32_test.c | 2 +- test/libc/proc/posix_spawn_test.c | 4 +- test/libc/proc/system_test.c | 8 +- test/libc/release/BUILD.mk | 6 + test/libc/release/smoke.c | 4 +- test/libc/release/smokecxx.cc | 2 - test/libc/runtime/ftrace_test.c | 2 +- test/libc/runtime/mmap_test.c | 6 +- test/libc/runtime/mprotect_test.c | 2 +- test/libc/runtime/zipos_test.c | 2 +- test/libc/sock/sendfile_test.c | 2 +- test/libc/sock/sendrecvmsg_test.c | 2 +- test/libc/stdio/devrand_test.c | 2 +- test/libc/stdio/dirstream_test.c | 2 +- test/libc/stdio/dtoa_test.c | 2 +- test/libc/stdio/dumphexc_test.c | 2 +- test/libc/stdio/ecvt_test.c | 2 +- test/libc/stdio/fgetln_test.c | 2 +- test/libc/stdio/fgets_test.c | 2 +- test/libc/stdio/fmemopen_test.c | 2 +- test/libc/stdio/fmt_test.c | 545 +++++++++--------- test/libc/stdio/fprintf_test.c | 2 +- test/libc/stdio/fputs_test.c | 2 +- test/libc/stdio/ftell_test.c | 2 +- test/libc/stdio/fwrite_test.c | 2 +- test/libc/stdio/getentropy_test.c | 2 +- test/libc/stdio/iconv_test.c | 2 +- test/libc/stdio/memory_test.c | 2 +- test/libc/stdio/mt19937_test.c | 2 +- test/libc/stdio/palandprintf_test.c | 8 +- test/libc/stdio/popen_test.c | 2 +- test/libc/stdio/sprintf_s_test.c | 2 +- test/libc/stdio/tmpfile_test.c | 2 +- test/libc/stdio/zipdir_test.c | 2 +- test/libc/str/bzero_test.c | 2 +- test/libc/str/crc32c_test.c | 2 +- test/libc/str/crc32z_test.c | 2 +- test/libc/str/longsort_test.c | 2 +- test/libc/str/memcasecmp_test.c | 2 +- test/libc/str/regex_test.c | 2 +- test/libc/str/strcasestr_test.c | 2 +- test/libc/str/strlcpy_test.c | 2 +- test/libc/str/strstr_test.c | 2 +- test/libc/thread/makecontext_test.c | 2 +- test/libc/thread/pthread_atfork_test.c | 2 +- test/libc/thread/pthread_barrier_wait_test.c | 2 +- test/libc/thread/pthread_cancel_test.c | 2 +- test/libc/thread/pthread_create_test.c | 14 +- test/libc/thread/pthread_rwlock_rdlock_test.c | 2 +- test/libc/thread/sem_open_test.c | 2 +- test/libc/thread/sem_timedwait_test.c | 2 +- test/libc/tinymath/acos_test.c | 14 +- test/libc/tinymath/acosh_test.c | 2 +- test/libc/tinymath/asin_test.c | 14 +- test/libc/tinymath/asinh_test.c | 32 +- test/libc/tinymath/atan2_test.c | 305 +++++----- test/libc/tinymath/atan2l_test.c | 50 +- test/libc/tinymath/atan_test.c | 28 +- test/libc/tinymath/atanh_test.c | 38 +- test/libc/tinymath/cbrt_test.c | 28 +- test/libc/tinymath/ceil_test.c | 2 +- test/libc/tinymath/copysign_test.c | 2 +- test/libc/tinymath/cos_test.c | 30 +- test/libc/tinymath/cosh_test.c | 2 +- test/libc/tinymath/csqrt_test.c | 2 +- test/libc/tinymath/erf_test.c | 2 +- test/libc/tinymath/exp10_test.c | 2 +- test/libc/tinymath/exp2_test.c | 2 +- test/libc/tinymath/exp2l_test.c | 2 +- test/libc/tinymath/exp_test.c | 48 +- test/libc/tinymath/expm1_test.c | 72 +-- test/libc/tinymath/fabs_test.c | 2 +- test/libc/tinymath/floor_test.c | 2 +- test/libc/tinymath/fmod_test.c | 2 +- test/libc/tinymath/fsum_test.c | 4 +- test/libc/tinymath/gamma_test.c | 2 +- test/libc/tinymath/hypot_test.c | 2 +- test/libc/tinymath/ldexp_test.c | 126 ++-- test/libc/tinymath/log10_test.c | 2 +- test/libc/tinymath/log1p_test.c | 2 +- test/libc/tinymath/log2_test.c | 2 +- test/libc/tinymath/log_test.c | 2 +- test/libc/tinymath/measureentropy_test.c | 2 +- test/libc/tinymath/powl_test.c | 124 ++-- test/libc/tinymath/remainder_test.c | 14 +- test/libc/tinymath/round_test.c | 2 +- test/libc/tinymath/sin_test.c | 50 +- test/libc/tinymath/sincos_test.c | 12 +- test/libc/tinymath/sinh_test.c | 2 +- test/libc/tinymath/sqrt_test.c | 2 +- test/libc/tinymath/strtod_test.c | 6 +- test/libc/tinymath/tan_test.c | 24 +- test/libc/tinymath/tanh_test.c | 64 +- test/libc/tinymath/tgamma_test.c | 30 +- test/libc/tinymath/trunc_test.c | 2 +- test/libc/x/utf16to32_test.c | 2 +- test/libc/x/utf16to8_test.c | 2 +- test/libc/x/utf8to16_test.c | 2 +- test/libc/x/utf8to32_test.c | 2 +- test/libc/x/xasprintf_test.c | 4 +- test/libc/x/xjoinpaths_test.c | 2 +- test/libc/x/xslurp_test.c | 2 +- test/libc/x/xstrcat_test.c | 2 +- test/libc/xed/x86ild_lib.c | 2 +- test/libc/xed/x86ild_test.c | 2 +- test/net/http/decodebase64_test.c | 2 +- test/net/http/decodelatin1_test.c | 2 +- test/net/http/encodebase64_test.c | 2 +- test/net/http/encodehttpheadervalue_test.c | 2 +- test/net/http/escapehtml_test.c | 2 +- test/net/http/escapejsstringliteral_test.c | 2 +- test/net/http/escapeurlparam_test.c | 2 +- test/net/http/indentlines_test.c | 2 +- test/net/http/isacceptablepath_test.c | 2 +- test/net/http/parsehttpmessage_test.c | 2 +- test/net/http/parseurl_test.c | 2 +- test/net/http/underlong_test.c | 2 +- test/net/http/visualizecontrolcodes_test.c | 16 +- test/net/https/mbedtls_test.c | 16 +- test/tool/build/lib/interner_test.c | 2 +- test/tool/build/lib/javadown_test.c | 2 +- test/tool/net/redbean_test.c | 2 +- test/tool/net/sqlite_test.c | 2 +- test/tool/viz/lib/bilinearscale_test.c | 2 +- test/tool/viz/lib/convoindex_test.c | 2 +- test/tool/viz/lib/fun_test.c | 2 +- test/tool/viz/lib/halfblit_test.c | 2 +- third_party/bzip2/blocksort.c | 2 +- third_party/bzip2/bzip2.c | 2 +- third_party/bzip2/huffman.c | 2 +- third_party/chibicc/chibicc.c | 2 +- third_party/chibicc/dox1.c | 6 +- third_party/chibicc/pybind.c | 2 +- third_party/hiredis/hiredis.c | 2 +- third_party/lua/ldo.c | 4 +- third_party/lua/ltests.c | 2 +- third_party/lua/luaencodejsondata.c | 2 +- third_party/musl/crypt_blowfish.c | 2 +- .../Modules/_decimal/libmpdec/transpose.c | 2 +- third_party/python/Modules/_threadmodule.c | 2 +- third_party/python/Modules/getpath.c | 2 +- third_party/python/Modules/posixmodule.c | 2 +- third_party/python/Modules/selectmodule.c | 2 +- third_party/python/Modules/tlsmodule.c | 2 +- third_party/python/Objects/listobject.c | 2 +- third_party/python/Python/import.c | 8 +- third_party/python/Python/marshal.c | 2 +- third_party/python/Python/sysmodule.c | 2 +- third_party/python/pycomp.c | 6 +- third_party/python/pyobj.c | 2 +- third_party/python/runpythonmodule.c | 2 +- third_party/quickjs/call.c | 2 +- third_party/quickjs/qjsc.c | 2 +- third_party/sed/compile.c | 2 +- third_party/sed/process.c | 2 +- third_party/smallz4/smallz4cat.c | 2 +- third_party/tidy/config.c | 2 +- third_party/unzip/unzip.c | 2 +- tool/args/args.c | 2 +- tool/build/bigmul.c | 2 +- tool/build/compile.c | 2 +- tool/build/fixupobj.c | 2 +- tool/build/lib/elfwriter.c | 4 +- tool/build/lib/elfwriter_zip.c | 12 +- tool/build/lib/psk.c | 6 +- tool/build/lz4toasm.c | 2 +- tool/build/runit.c | 10 +- tool/build/runitd.c | 2 +- tool/build/zipobj.c | 2 +- tool/curl/curl.c | 2 +- tool/decode/elf.c | 2 +- tool/decode/lib/asmcodegen.c | 2 +- tool/decode/macho.c | 2 +- tool/decode/pe2.c | 16 +- tool/decode/zip.c | 95 ++- tool/net/fetch.inc | 24 +- tool/net/lfuncs.c | 2 +- tool/net/lsqlite3.c | 2 +- tool/net/redbean.c | 64 +- tool/viz/cpuid.c | 10 +- tool/viz/datauri.c | 2 +- tool/viz/derasterize.c | 2 +- tool/viz/fontspace.c | 4 +- tool/viz/generatetortureimage.c | 4 +- tool/viz/getglyph.c | 14 +- tool/viz/img.c | 6 +- tool/viz/lib/bilinearscale.c | 12 +- tool/viz/lib/dither.c | 2 +- tool/viz/lib/formatmatrix-byte.c | 4 +- tool/viz/lib/formatmatrix-double.c | 2 +- tool/viz/lib/formatmatrix-float.c | 2 +- tool/viz/lib/formatmatrix-short.c | 4 +- tool/viz/lib/formatstringtable-assembly.c | 2 +- tool/viz/lib/ycbcr2rgb3.c | 2 +- tool/viz/maxmind.c | 2 +- tool/viz/printansi.c | 2 +- tool/viz/printimage.c | 2 +- 280 files changed, 1362 insertions(+), 1407 deletions(-) delete mode 100644 libc/mem/gc.internal.h diff --git a/.gitignore b/.gitignore index f3394ce62..84e967f07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ # -*- conf -*- /o -/cosmocc -/.prompt.jtlp +/.cosmocc # TODO: Find some way to have Python write to o/ __pycache__ diff --git a/Makefile b/Makefile index ea74d8296..f9a8ac644 100644 --- a/Makefile +++ b/Makefile @@ -150,7 +150,7 @@ export MODE export SOURCE_DATE_EPOCH export TMPDIR -COSMOCC = cosmocc/3.2 +COSMOCC = .cosmocc/3.2 TOOLCHAIN = $(COSMOCC)/bin/$(ARCH)-linux-cosmo- DOWNLOAD := $(shell build/download-cosmocc.sh $(COSMOCC) 3.2 28b48682595f0f46b45ab381118cdffdabc8fcfa29aa54e301fe6ffe35269f5e) @@ -543,9 +543,6 @@ o/cosmopolitan.h: o/cosmopolitan.h.txt \ $(wildcard libc/integral/*) \ $(foreach x,$(COSMOPOLITAN_H_PKGS),$($(x)_HDRS)) \ $(foreach x,$(COSMOPOLITAN_H_PKGS),$($(x)_INCS)) - @$(ECHO) '#ifndef __STRICT_ANSI__' >$@ - @$(ECHO) '#define _COSMO_SOURCE' >>$@ - @$(ECHO) '#endif' >>$@ @$(COMPILE) -AROLLUP -T$@ build/bootstrap/rollup.com @$< >>$@ o/cosmopolitan.html: private .UNSANDBOXED = 1 diff --git a/build/definitions.mk b/build/definitions.mk index 8a023d2d9..bd58f9669 100644 --- a/build/definitions.mk +++ b/build/definitions.mk @@ -146,8 +146,6 @@ DEFAULT_CFLAGS = \ -std=gnu2x DEFAULT_CXXFLAGS = \ - -fno-rtti \ - -fno-exceptions \ -fuse-cxa-atexit \ -Wno-int-in-bool-context \ -Wno-narrowing \ diff --git a/build/objdump b/build/objdump index 5132e16d7..32a4e218a 100755 --- a/build/objdump +++ b/build/objdump @@ -6,14 +6,14 @@ if [ -n "$OBJDUMP" ]; then fi find_objdump() { - if [ -x cosmocc/3.2/bin/$1-linux-cosmo-objdump ]; then - OBJDUMP=cosmocc/3.2/bin/$1-linux-cosmo-objdump - elif [ -x cosmocc/3.2/bin/$1-linux-musl-objdump ]; then - OBJDUMP=cosmocc/3.2/bin/$1-linux-musl-objdump - elif [ -x "$COSMO/cosmocc/3.2/bin/$1-linux-cosmo-objdump" ]; then - OBJDUMP="$COSMO/cosmocc/3.2/bin/$1-linux-cosmo-objdump" - elif [ -x "$COSMO/cosmocc/3.2/bin/$1-linux-musl-objdump" ]; then - OBJDUMP="$COSMO/cosmocc/3.2/bin/$1-linux-musl-objdump" + if [ -x .cosmocc/3.2/bin/$1-linux-cosmo-objdump ]; then + OBJDUMP=.cosmocc/3.2/bin/$1-linux-cosmo-objdump + elif [ -x .cosmocc/3.2/bin/$1-linux-musl-objdump ]; then + OBJDUMP=.cosmocc/3.2/bin/$1-linux-musl-objdump + elif [ -x "$COSMO/.cosmocc/3.2/bin/$1-linux-cosmo-objdump" ]; then + OBJDUMP="$COSMO/.cosmocc/3.2/bin/$1-linux-cosmo-objdump" + elif [ -x "$COSMO/.cosmocc/3.2/bin/$1-linux-musl-objdump" ]; then + OBJDUMP="$COSMO/.cosmocc/3.2/bin/$1-linux-musl-objdump" else echo "error: toolchain not found (try running 'cosmocc --update' or 'make' in the cosmo monorepo)" >&2 exit 1 diff --git a/dsp/scale/gyarados.c b/dsp/scale/gyarados.c index 19089ce8a..464ce2959 100644 --- a/dsp/scale/gyarados.c +++ b/dsp/scale/gyarados.c @@ -27,7 +27,7 @@ #include "libc/log/log.h" #include "libc/macros.internal.h" #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" diff --git a/dsp/tty/sendtitle.c b/dsp/tty/sendtitle.c index ca2567c27..ec4860ebb 100644 --- a/dsp/tty/sendtitle.c +++ b/dsp/tty/sendtitle.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "dsp/tty/tty.h" #include "libc/mem/arraylist2.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/x/x.h" diff --git a/dsp/tty/ttyraw.c b/dsp/tty/ttyraw.c index ec2f794c0..60ebeea8d 100644 --- a/dsp/tty/ttyraw.c +++ b/dsp/tty/ttyraw.c @@ -25,7 +25,7 @@ #include "libc/calls/ucontext.h" #include "libc/log/log.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "libc/sysv/consts/fileno.h" diff --git a/examples/greenbean.c b/examples/greenbean.c index 4bf386459..166b6e532 100644 --- a/examples/greenbean.c +++ b/examples/greenbean.c @@ -285,7 +285,7 @@ int main(int argc, char *argv[]) { // print all the ips that 0.0.0.0 would bind // Cosmo's GetHostIps() API is much easier than ioctl(SIOCGIFCONF) uint32_t *hostips; - for (hostips = _gc(GetHostIps()), i = 0; hostips[i]; ++i) { + for (hostips = gc(GetHostIps()), i = 0; hostips[i]; ++i) { kprintf("listening on http://%hhu.%hhu.%hhu.%hhu:%hu\n", hostips[i] >> 24, hostips[i] >> 16, hostips[i] >> 8, hostips[i], PORT); } @@ -339,7 +339,7 @@ int main(int argc, char *argv[]) { unassert(!pthread_attr_setguardsize(&attr, pagesz)); unassert(!pthread_attr_setsigmask_np(&attr, &block)); unassert(!pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0)); - pthread_t *th = _gc(calloc(threads, sizeof(pthread_t))); + pthread_t *th = gc(calloc(threads, sizeof(pthread_t))); for (i = 0; i < threads; ++i) { int rc; ++a_workers; diff --git a/examples/ls.c b/examples/ls.c index c91f8c81f..7d8e509f1 100644 --- a/examples/ls.c +++ b/examples/ls.c @@ -50,7 +50,7 @@ void List(const char *path) { if (strcmp(path, ".") == 0) { vpath = ""; } else if (!endswith(path, "/")) { - vpath = _gc(xasprintf("%s/", path)); + vpath = gc(xasprintf("%s/", path)); } else { vpath = path; } diff --git a/examples/stat.c b/examples/stat.c index 987020ca0..f04025d98 100644 --- a/examples/stat.c +++ b/examples/stat.c @@ -80,10 +80,10 @@ void PrintFileMetadata(const char *pathname, struct stat *st) { DescribeFileType(st->st_mode), "owner id", st->st_uid, "group id", st->st_gid, "flags", st->st_flags, "gen", st->st_gen, "device id (if special)", st->st_rdev, "block size", st->st_blksize, - "access time", _gc(xiso8601(&st->st_atim)), "modified time", - _gc(xiso8601(&st->st_mtim)), "c[omplicated]time", - _gc(xiso8601(&st->st_ctim)), "birthtime", - _gc(xiso8601(&st->st_birthtim))); + "access time", gc(xiso8601(&st->st_atim)), "modified time", + gc(xiso8601(&st->st_mtim)), "c[omplicated]time", + gc(xiso8601(&st->st_ctim)), "birthtime", + gc(xiso8601(&st->st_birthtim))); } int main(int argc, char *argv[]) { diff --git a/examples/unbourne.c b/examples/unbourne.c index af21e1a9e..6ad057a43 100644 --- a/examples/unbourne.c +++ b/examples/unbourne.c @@ -128,7 +128,7 @@ #include "libc/macros.internal.h" #include "libc/mem/alg.h" #include "libc/mem/alloca.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/paths.h" #include "libc/runtime/runtime.h" diff --git a/libc/calls/getrandom.c b/libc/calls/getrandom.c index b5fac8f9d..65171f28c 100644 --- a/libc/calls/getrandom.c +++ b/libc/calls/getrandom.c @@ -88,12 +88,14 @@ static ssize_t GetDevUrandom(char *p, size_t n) { int fd; ssize_t rc; BLOCK_SIGNALS; + BLOCK_CANCELATION; fd = sys_openat(AT_FDCWD, "/dev/urandom", O_RDONLY | O_CLOEXEC, 0); if (fd != -1) { rc = sys_read(fd, p, n); } else { rc = -1; } + ALLOW_CANCELATION; ALLOW_SIGNALS; return rc; } diff --git a/libc/calls/tmpfd.c b/libc/calls/tmpfd.c index a65b9088f..b33b147df 100644 --- a/libc/calls/tmpfd.c +++ b/libc/calls/tmpfd.c @@ -53,7 +53,7 @@ int _mkstemp(char *, int); * On newer Linux only (c. 2013) it's possible to turn the anonymous * returned file back into a real file, by doing this: * - * linkat(AT_FDCWD, _gc(xasprintf("/proc/self/fd/%d", fd)), + * linkat(AT_FDCWD, gc(xasprintf("/proc/self/fd/%d", fd)), * AT_FDCWD, "real.txt", AT_SYMLINK_FOLLOW) * * On the New Technology, temporary files created by this function diff --git a/libc/dlopen/dlopen.c b/libc/dlopen/dlopen.c index bd00f696e..9dcda52f6 100644 --- a/libc/dlopen/dlopen.c +++ b/libc/dlopen/dlopen.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/atomic.h" +#include "libc/calls/blockcancel.internal.h" #include "libc/calls/calls.h" #include "libc/calls/struct/sigset.internal.h" #include "libc/calls/struct/stat.h" @@ -798,6 +799,7 @@ static void *dlopen_silicon(const char *path, int mode) { void *cosmo_dlopen(const char *path, int mode) { void *res; BLOCK_SIGNALS; + BLOCK_CANCELATION; if (IsWindows()) { res = dlopen_nt(path, mode); } else if (IsXnuSilicon()) { @@ -814,6 +816,7 @@ void *cosmo_dlopen(const char *path, int mode) { } else { res = 0; } + ALLOW_CANCELATION; ALLOW_SIGNALS; STRACE("dlopen(%#s, %d) → %p% m", path, mode, res); return res; diff --git a/libc/intrin/stracef.greg.c b/libc/intrin/stracef.greg.c index 7872cc5ab..abe36383c 100644 --- a/libc/intrin/stracef.greg.c +++ b/libc/intrin/stracef.greg.c @@ -16,6 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/dce.h" +#include "libc/intrin/describebacktrace.internal.h" #include "libc/intrin/kprintf.h" #include "libc/intrin/strace.internal.h" #include "libc/runtime/runtime.h" @@ -27,3 +29,14 @@ dontinstrument void __stracef(const char *fmt, ...) { kvprintf(fmt, v); va_end(v); } + +#if IsModeDbg() +void report_cancellation_point(void) { + kprintf("error: cancelable raw system call not annotated in wrapper\n" + "choice #1 use BLOCK_CANCELATION / ALLOW_CANCELATION\n" + "choice #2 use BEGIN_CANCELATION_POINT / END_CANCELATION_POINT\n" + "backtrace: %s\n", + DescribeBacktrace(__builtin_frame_address(0))); + __builtin_trap(); +} +#endif diff --git a/libc/log/libfatal.internal.h b/libc/log/libfatal.internal.h index d1036a58a..ec4847edb 100644 --- a/libc/log/libfatal.internal.h +++ b/libc/log/libfatal.internal.h @@ -3,19 +3,19 @@ #include "libc/macros.internal.h" COSMOPOLITAN_C_START_ -__funline unsigned long __strlen(const char *s) { +forceinline unsigned long __strlen(const char *s) { unsigned long n = 0; while (*s++) ++n; return n; } -__funline int __strcmp(const char *l, const char *r) { +forceinline int __strcmp(const char *l, const char *r) { size_t i = 0; while (l[i] == r[i] && r[i]) ++i; return (l[i] & 255) - (r[i] & 255); } -__funline char *__stpcpy(char *d, const char *s) { +forceinline char *__stpcpy(char *d, const char *s) { size_t i; for (i = 0;; ++i) { if (!(d[i] = s[i])) { @@ -24,7 +24,7 @@ __funline char *__stpcpy(char *d, const char *s) { } } -__funline void *__repstosb(void *di, char al, size_t cx) { +forceinline void *__repstosb(void *di, char al, size_t cx) { #if defined(__x86__) && defined(__GNUC__) && !defined(__STRICT_ANSI__) asm("rep stosb" : "=D"(di), "=c"(cx), "=m"(*(char(*)[cx])di) @@ -40,7 +40,7 @@ __funline void *__repstosb(void *di, char al, size_t cx) { #endif } -__funline void *__repmovsb(void *di, const void *si, size_t cx) { +forceinline void *__repmovsb(void *di, const void *si, size_t cx) { #if defined(__x86__) && defined(__GNUC__) && !defined(__STRICT_ANSI__) asm("rep movsb" : "=D"(di), "=S"(si), "=c"(cx), "=m"(*(char(*)[cx])di) @@ -57,7 +57,7 @@ __funline void *__repmovsb(void *di, const void *si, size_t cx) { #endif } -__funline void *__mempcpy(void *d, const void *s, size_t n) { +forceinline void *__mempcpy(void *d, const void *s, size_t n) { size_t i; for (i = 0; i < n; ++i) { ((char *)d)[i] = ((const char *)s)[i]; @@ -66,7 +66,7 @@ __funline void *__mempcpy(void *d, const void *s, size_t n) { return (char *)d + n; } -__funline char *__uintcpy(char p[hasatleast 21], uint64_t x) { +forceinline char *__uintcpy(char p[hasatleast 21], uint64_t x) { char t; size_t i, a, b; i = 0; @@ -85,22 +85,22 @@ __funline char *__uintcpy(char p[hasatleast 21], uint64_t x) { return p + i; } -__funline char *__intcpy(char p[hasatleast 21], int64_t x) { +forceinline char *__intcpy(char p[hasatleast 21], int64_t x) { if (x < 0) *p++ = '-', x = -(uint64_t)x; return __uintcpy(p, x); } -__funline char *__fixcpy(char p[hasatleast 17], uint64_t x, uint8_t k) { +forceinline char *__fixcpy(char p[hasatleast 17], uint64_t x, uint8_t k) { while (k > 0) *p++ = "0123456789abcdef"[(x >> (k -= 4)) & 15]; *p = '\0'; return p; } -__funline char *__hexcpy(char p[hasatleast 17], uint64_t x) { +forceinline char *__hexcpy(char p[hasatleast 17], uint64_t x) { return __fixcpy(p, x, ROUNDUP(x ? (__builtin_clzll(x) ^ 63) + 1 : 1, 4)); } -__funline const void *__memchr(const void *s, unsigned char c, size_t n) { +forceinline const void *__memchr(const void *s, unsigned char c, size_t n) { size_t i; for (i = 0; i < n; ++i) { if (((const unsigned char *)s)[i] == c) { @@ -110,7 +110,7 @@ __funline const void *__memchr(const void *s, unsigned char c, size_t n) { return 0; } -__funline char *__strstr(const char *haystack, const char *needle) { +forceinline char *__strstr(const char *haystack, const char *needle) { size_t i; for (;;) { for (i = 0;; ++i) { @@ -123,8 +123,8 @@ __funline char *__strstr(const char *haystack, const char *needle) { return 0; } -__funline char16_t *__strstr16(const char16_t *haystack, - const char16_t *needle) { +forceinline char16_t *__strstr16(const char16_t *haystack, + const char16_t *needle) { size_t i; for (;;) { for (i = 0;; ++i) { @@ -137,21 +137,21 @@ __funline char16_t *__strstr16(const char16_t *haystack, return 0; } -__funline const char *__strchr(const char *s, unsigned char c) { +forceinline const char *__strchr(const char *s, unsigned char c) { for (;; ++s) { if ((*s & 255) == c) return s; if (!*s) return 0; } } -__funline unsigned long __atoul(const char *p) { +forceinline unsigned long __atoul(const char *p) { int c; unsigned long x = 0; while ('0' <= (c = *p++) && c <= '9') x *= 10, x += c - '0'; return x; } -__funline long __atol(const char *p) { +forceinline long __atol(const char *p) { int s = *p; unsigned long x; if (s == '-' || s == '+') ++p; @@ -160,7 +160,7 @@ __funline long __atol(const char *p) { return x; } -__funline void *__memset(void *a, int c, unsigned long n) { +forceinline void *__memset(void *a, int c, unsigned long n) { char *d = a; unsigned long i; for (i = 0; i < n; ++i) { @@ -170,7 +170,7 @@ __funline void *__memset(void *a, int c, unsigned long n) { return d; } -__funline void *__memcpy(void *a, const void *b, unsigned long n) { +forceinline void *__memcpy(void *a, const void *b, unsigned long n) { char *d = a; unsigned long i; const char *s = b; @@ -181,7 +181,7 @@ __funline void *__memcpy(void *a, const void *b, unsigned long n) { return d; } -__funline void *__memmove(void *a, const void *b, unsigned long n) { +forceinline void *__memmove(void *a, const void *b, unsigned long n) { char *d = a; unsigned long i; const char *s = b; diff --git a/libc/log/vflogf.c b/libc/log/vflogf.c index 7c049f0bd..c75bae727 100644 --- a/libc/log/vflogf.c +++ b/libc/log/vflogf.c @@ -95,6 +95,7 @@ void(vflogf)(unsigned level, const char *file, int line, FILE *f, flockfile(f); strace_enabled(-1); BLOCK_SIGNALS; + BLOCK_CANCELATION; // We display TIMESTAMP.MICROS normally. However, when we log multiple // times in the same second, we display TIMESTAMP+DELTAMICROS instead. @@ -136,6 +137,7 @@ void(vflogf)(unsigned level, const char *file, int line, FILE *f, _Exit(22); } + ALLOW_CANCELATION; ALLOW_SIGNALS; strace_enabled(+1); funlockfile(f); diff --git a/libc/mem/gc.c b/libc/mem/gc.c index 96bb0b8c5..b977d0964 100644 --- a/libc/mem/gc.c +++ b/libc/mem/gc.c @@ -39,7 +39,7 @@ static void TeardownGc(void) { if (__tls_enabled) { t = __get_tls(); if ((g = t->tib_garbages)) { - // exit() currently doesn't use _gclongjmp() like pthread_exit() + // exit() currently doesn't use gclongjmp() like pthread_exit() // so we need to run the deferred functions manually. while (g->i) { --g->i; @@ -88,7 +88,7 @@ static void DeferFunction(struct StackFrame *frame, void *fn, void *arg) { frame->addr = (intptr_t)__gc; } -// the gnu extension macros for _gc / _defer point here +// the gnu extension macros for gc / defer point here void __defer(void *rbp, void *fn, void *arg) { struct StackFrame *f, *frame = rbp; f = __builtin_frame_address(0); @@ -96,48 +96,3 @@ void __defer(void *rbp, void *fn, void *arg) { unassert(PointerNotOwnedByParentStackFrame(f, frame, arg)); DeferFunction(frame, fn, arg); } - -/** - * Frees memory when function returns. - * - * This garbage collector overwrites the return address on the stack so - * that the RET instruction calls a trampoline which calls free(). It's - * loosely analogous to Go's defer keyword rather than a true cycle gc. - * - * const char *s = _gc(strdup("hello")); - * puts(s); - * - * This macro is equivalent to: - * - * _defer(free, ptr) - * - * @warning do not return a gc()'d pointer - * @warning do not realloc() with gc()'d pointer - * @warning be careful about static keyword due to impact of inlining - * @note you should use -fno-omit-frame-pointer - */ -void *(_gc)(void *thing) { - struct StackFrame *frame; - frame = __builtin_frame_address(0); - DeferFunction(frame->next, _weakfree, thing); - return thing; -} - -/** - * Calls fn(arg) when function returns. - * - * This garbage collector overwrites the return address on the stack so - * that the RET instruction calls a trampoline which calls free(). It's - * loosely analogous to Go's defer keyword rather than a true cycle gc. - * - * @warning do not return a gc()'d pointer - * @warning do not realloc() with gc()'d pointer - * @warning be careful about static keyword due to impact of inlining - * @note you should use -fno-omit-frame-pointer - */ -void *(_defer)(void *fn, void *arg) { - struct StackFrame *frame; - frame = __builtin_frame_address(0); - DeferFunction(frame->next, fn, arg); - return arg; -} diff --git a/libc/mem/gc.h b/libc/mem/gc.h index 91b99d434..ae2f2ca46 100644 --- a/libc/mem/gc.h +++ b/libc/mem/gc.h @@ -1,25 +1,23 @@ #ifndef COSMOPOLITAN_LIBC_MEM_GC_H_ #define COSMOPOLITAN_LIBC_MEM_GC_H_ +#ifdef _COSMO_SOURCE COSMOPOLITAN_C_START_ -void *_gc(void *); -void *_defer(void *, void *); -void __defer(void *, void *, void *); -void _gclongjmp(void *, int) dontthrow wontreturn; -void _gc_free(void *); - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -#define _gc(THING) _defer((void *)_gc_free, (void *)(THING)) -#define _defer(FN, ARG) \ - ({ \ - autotype(ARG) Arg = (ARG); \ - /* prevent weird opts like tail call */ \ - asm volatile("" : "+g"(Arg) : : "memory"); \ - __defer(__builtin_frame_address(0), FN, Arg); \ - asm volatile("" : "+g"(Arg) : : "memory"); \ - Arg; \ +void _gc_free(void *) libcesque; +void __defer(void *, void *, void *) libcesque; +void gclongjmp(void *, int) libcesque wontreturn; +#define gc(THING) defer((void *)_gc_free, (void *)(THING)) +#define _gc(THING) defer((void *)_gc_free, (void *)(THING)) +#define defer(FN, ARG) \ + ({ \ + autotype(ARG) Arg = (ARG); \ + /* prevent weird opts like tail call */ \ + __asm__ volatile("" : "+g"(Arg) : : "memory"); \ + __defer(__builtin_frame_address(0), FN, Arg); \ + __asm__ volatile("" : "+g"(Arg) : : "memory"); \ + Arg; \ }) -#endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) */ COSMOPOLITAN_C_END_ +#endif /* _COSMO_SOURCE */ #endif /* COSMOPOLITAN_LIBC_MEM_GC_H_ */ diff --git a/libc/mem/gc.internal.h b/libc/mem/gc.internal.h deleted file mode 100644 index 2c0e24d6a..000000000 --- a/libc/mem/gc.internal.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_MEM_GC_INTERNAL_H_ -#define COSMOPOLITAN_LIBC_MEM_GC_INTERNAL_H_ -#include "libc/mem/gc.h" - -#define gc(THING) _gc(THING) -#define defer(FN, ARG) _defer(FN, ARG) -#define gclongjmp(JB, ARG) _gclongjmp(JB, ARG) - -#endif /* COSMOPOLITAN_LIBC_MEM_GC_INTERNAL_H_ */ diff --git a/libc/nexgen32e/gclongjmp.S b/libc/nexgen32e/gclongjmp.S index 14252d655..18f092000 100644 --- a/libc/nexgen32e/gclongjmp.S +++ b/libc/nexgen32e/gclongjmp.S @@ -30,7 +30,7 @@ // @see examples/ctrlc.c // @noreturn .ftrace1 -_gclongjmp: +gclongjmp: .ftrace2 #ifdef __x86_64__ push %rbp @@ -65,4 +65,4 @@ _gclongjmp: #else #error "unsupported architecture" #endif /* __x86_64__ */ - .endfn _gclongjmp,globl + .endfn gclongjmp,globl diff --git a/libc/nexgen32e/longjmp.S b/libc/nexgen32e/longjmp.S index 643c599d6..307d699da 100644 --- a/libc/nexgen32e/longjmp.S +++ b/libc/nexgen32e/longjmp.S @@ -23,7 +23,7 @@ // @param rdi points to the jmp_buf // @param esi is returned by setjmp() invocation (coerced nonzero) // @noreturn -// @see _gclongjmp() +// @see gclongjmp() // @see siglongjmp() .ftrace1 longjmp: diff --git a/libc/nexgen32e/setjmp.S b/libc/nexgen32e/setjmp.S index 3277bc112..1a4498f5f 100644 --- a/libc/nexgen32e/setjmp.S +++ b/libc/nexgen32e/setjmp.S @@ -25,10 +25,11 @@ // @returnstwice // @assume system five nexgen32e abi conformant // @note code built w/ microsoft abi compiler can't call this -// @see longjmp(), _gclongjmp() +// @see longjmp(), gclongjmp() .ftrace1 setjmp: .ftrace2 +_setjmp: #ifdef __x86_64__ lea 8(%rsp),%rax mov %rax,(%rdi) @@ -60,5 +61,5 @@ setjmp: #else #error "unsupported architecture" #endif + .endfn _setjmp,globl .endfn setjmp,globl - .alias setjmp,_setjmp diff --git a/libc/proc/execve-sysv.c b/libc/proc/execve-sysv.c index 2beb928dc..04a40f861 100644 --- a/libc/proc/execve-sysv.c +++ b/libc/proc/execve-sysv.c @@ -58,6 +58,7 @@ static bool IsApeFile(const char *path) { } else { bool res = false; BLOCK_SIGNALS; + BLOCK_CANCELATION; int fd; char buf[8]; int flags = O_RDONLY | O_NOCTTY | O_NONBLOCK | O_CLOEXEC; @@ -65,6 +66,7 @@ static bool IsApeFile(const char *path) { res = sys_pread(fd, buf, 8, 0, 0) == 8 && IsApeLoadable(buf); sys_close(fd); } + ALLOW_CANCELATION; ALLOW_SIGNALS; return res; } diff --git a/libc/proc/fexecve.c b/libc/proc/fexecve.c index 7cc3e95b5..052027508 100644 --- a/libc/proc/fexecve.c +++ b/libc/proc/fexecve.c @@ -201,14 +201,14 @@ int fexecve(int fd, char *const argv[], char *const envp[]) { } if (!__isfdkind(fd, kFdZip)) { bool memfdReq; - BEGIN_CANCELATION_POINT; BLOCK_SIGNALS; + BLOCK_CANCELATION; strace_enabled(-1); memfdReq = ((rc = fcntl(fd, F_GETFD)) != -1) && (rc & FD_CLOEXEC) && IsAPEFd(fd); strace_enabled(+1); + ALLOW_CANCELATION; ALLOW_SIGNALS; - END_CANCELATION_POINT; if (rc == -1) { break; } else if (!memfdReq) { @@ -221,13 +221,13 @@ int fexecve(int fd, char *const argv[], char *const envp[]) { } int newfd; char *path = alloca(PATH_MAX); - BEGIN_CANCELATION_POINT; BLOCK_SIGNALS; + BLOCK_CANCELATION; strace_enabled(-1); newfd = fd_to_mem_fd(fd, path); strace_enabled(+1); + ALLOW_CANCELATION; ALLOW_SIGNALS; - END_CANCELATION_POINT; if (newfd == -1) { break; } @@ -242,13 +242,13 @@ int fexecve(int fd, char *const argv[], char *const envp[]) { if (!savedErr) { savedErr = errno; } - BEGIN_CANCELATION_POINT; BLOCK_SIGNALS; + BLOCK_CANCELATION; strace_enabled(-1); close(newfd); strace_enabled(+1); + ALLOW_CANCELATION; ALLOW_SIGNALS; - END_CANCELATION_POINT; } while (0); if (savedErr) { errno = savedErr; diff --git a/libc/runtime/runtime.h b/libc/runtime/runtime.h index 5e5958f5a..ff26dde66 100644 --- a/libc/runtime/runtime.h +++ b/libc/runtime/runtime.h @@ -136,7 +136,7 @@ long __get_minsigstksz(void) pureconst; void __get_main_stack(void **, size_t *, int *); long __get_safe_size(long, long); char *__get_tmpdir(void); -__funline int __trace_disabled(int x) { +forceinline int __trace_disabled(int x) { return 0; } #ifndef FTRACE diff --git a/libc/runtime/stack.h b/libc/runtime/stack.h index 6d89da176..dd5270634 100644 --- a/libc/runtime/stack.h +++ b/libc/runtime/stack.h @@ -96,7 +96,7 @@ extern char ape_stack_align[] __attribute__((__weak__)); * since it'll not only ensure stack overflows are detected, it * will also trigger the stack to grow down safely. */ -__funline void CheckLargeStackAllocation(void *p, ssize_t n) { +forceinline void CheckLargeStackAllocation(void *p, ssize_t n) { for (; n > 0; n -= 4096) { ((char *)p)[n - 1] = 0; } diff --git a/libc/stdio/getentropy.c b/libc/stdio/getentropy.c index d0de3c28f..a028053d4 100644 --- a/libc/stdio/getentropy.c +++ b/libc/stdio/getentropy.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/blockcancel.internal.h" #include "libc/calls/struct/sigset.internal.h" #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" @@ -45,7 +46,9 @@ int getentropy(void *p, size_t n) { rc = 0; } else { BLOCK_SIGNALS; + BLOCK_CANCELATION; if (__getrandom(p, n, 0) != n) notpossible; + ALLOW_CANCELATION; ALLOW_SIGNALS; rc = 0; } diff --git a/libc/stdio/tmpfile.c b/libc/stdio/tmpfile.c index 40450e0fb..e69a81d78 100644 --- a/libc/stdio/tmpfile.c +++ b/libc/stdio/tmpfile.c @@ -42,7 +42,7 @@ * On newer Linux only (c. 2013) it's possible to turn the anonymous * returned file back into a real file, by doing this: * - * linkat(AT_FDCWD, _gc(xasprintf("/proc/self/fd/%d", fileno(f))), + * linkat(AT_FDCWD, gc(xasprintf("/proc/self/fd/%d", fileno(f))), * AT_FDCWD, "real.txt", AT_SYMLINK_FOLLOW) * * On the New Technology, temporary files created by this function diff --git a/libc/thread/posixthread.internal.h b/libc/thread/posixthread.internal.h index 0b55225a3..866a288a9 100644 --- a/libc/thread/posixthread.internal.h +++ b/libc/thread/posixthread.internal.h @@ -116,11 +116,11 @@ void _pthread_unref(struct PosixThread *); void _pthread_unwind(struct PosixThread *); void _pthread_zombify(struct PosixThread *); -__funline pureconst struct PosixThread *_pthread_self(void) { +forceinline pureconst struct PosixThread *_pthread_self(void) { return (struct PosixThread *)__get_tls()->tib_pthread; } -__funline void _pthread_ref(struct PosixThread *pt) { +forceinline void _pthread_ref(struct PosixThread *pt) { atomic_fetch_add_explicit(&pt->pt_refs, 1, memory_order_relaxed); } diff --git a/libc/thread/pthread_cancel.c b/libc/thread/pthread_cancel.c index 49175036f..002d994bc 100644 --- a/libc/thread/pthread_cancel.c +++ b/libc/thread/pthread_cancel.c @@ -291,7 +291,7 @@ static errno_t _pthread_cancel_everyone(void) { * Consider using Cosmopolitan Libc's garbage collector since it will be * executed when a thread exits due to a cancelation. * - * void *p = _gc(malloc(123)); + * void *p = gc(malloc(123)); * read(0, p, 123); * * It's possible to put a thread in asynchronous cancelation mode with diff --git a/libc/thread/pthread_exit.c b/libc/thread/pthread_exit.c index 733a0e4a3..06e9a8943 100644 --- a/libc/thread/pthread_exit.c +++ b/libc/thread/pthread_exit.c @@ -84,8 +84,8 @@ void _pthread_unkey(struct CosmoTib *tib) { * the callback function that was supplied to pthread_create(). This may * be used if the thread wishes to exit at any other point in the thread * lifecycle, in which case this function is responsible for ensuring we - * invoke _gc(), _defer(), and pthread_cleanup_push() callbacks, as well - * as pthread_key_create() destructors. + * invoke gc(), _defer(), and pthread_cleanup_push() callbacks, and also + * pthread_key_create() destructors. * * If the current thread is an orphaned thread, or is the main thread * when no other threads were created, then this will terminated your diff --git a/libc/thread/tls.h b/libc/thread/tls.h index a713b050c..485fcd9d5 100644 --- a/libc/thread/tls.h +++ b/libc/thread/tls.h @@ -65,7 +65,7 @@ void __set_tls(struct CosmoTib *); * * This can't be used in privileged functions. */ -__funline pureconst struct CosmoTib *__get_tls(void) { +forceinline pureconst struct CosmoTib *__get_tls(void) { #ifdef __chibicc__ return 0; #elif __x86_64__ diff --git a/libc/thread/tls2.internal.h b/libc/thread/tls2.internal.h index b96693276..e91ce33d7 100644 --- a/libc/thread/tls2.internal.h +++ b/libc/thread/tls2.internal.h @@ -11,7 +11,7 @@ COSMOPOLITAN_C_START_ * This should be favored over __get_tls() for .privileged code that * can't be self-modified by __enable_tls(). */ -__funline struct CosmoTib *__get_tls_privileged(void) { +forceinline struct CosmoTib *__get_tls_privileged(void) { char *tib, *lin = (char *)0x30; if (IsLinux() || IsFreebsd() || IsNetbsd() || IsOpenbsd() || IsMetal()) { if (!__tls_morphed) { @@ -28,14 +28,14 @@ __funline struct CosmoTib *__get_tls_privileged(void) { return (struct CosmoTib *)tib; } -__funline struct CosmoTib *__get_tls_win32(void) { +forceinline struct CosmoTib *__get_tls_win32(void) { char *tib, *lin = (char *)0x30; asm("mov\t%%gs:(%1),%0" : "=a"(tib) : "r"(lin) : "memory"); tib = *(char **)(tib + 0x1480 + __tls_index * 8); return (struct CosmoTib *)tib; } -__funline void __set_tls_win32(void *tls) { +forceinline void __set_tls_win32(void *tls) { asm("mov\t%1,%%gs:%0" : "=m"(*((long *)0x1480 + __tls_index)) : "r"(tls)); } diff --git a/libc/x/xbasename.c b/libc/x/xbasename.c index 53a2a3de3..9b82c20d1 100644 --- a/libc/x/xbasename.c +++ b/libc/x/xbasename.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/libgen.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/x/x.h" diff --git a/net/https/chaincertificate.c b/net/https/chaincertificate.c index 1ac7884d7..dbc166712 100644 --- a/net/https/chaincertificate.c +++ b/net/https/chaincertificate.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/log/log.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "net/https/https.h" bool ChainCertificate(mbedtls_x509_crt *cert, mbedtls_x509_crt *parent) { diff --git a/net/https/finishcertificate.c b/net/https/finishcertificate.c index f14d83d34..22949810b 100644 --- a/net/https/finishcertificate.c +++ b/net/https/finishcertificate.c @@ -37,8 +37,8 @@ struct Cert FinishCertificate(struct Cert *ca, mbedtls_x509write_cert *wcert, if ((rc = mbedtls_pk_check_pair(&cert->pk, key))) { FATALF("generate key (grep -0x%04x)", -rc); } - LogCertificate(_gc(xasprintf("generated %s certificate", - mbedtls_pk_get_name(&cert->pk))), - cert); + LogCertificate( + gc(xasprintf("generated %s certificate", mbedtls_pk_get_name(&cert->pk))), + cert); return (struct Cert){cert, key}; } diff --git a/net/turfwar/turfwar.c b/net/turfwar/turfwar.c index 182ab8963..f50da64b4 100644 --- a/net/turfwar/turfwar.c +++ b/net/turfwar/turfwar.c @@ -32,7 +32,6 @@ #include "libc/fmt/conv.h" #include "libc/fmt/itoa.h" #include "libc/intrin/atomic.h" -#include "libc/serialize.h" #include "libc/intrin/bsr.h" #include "libc/intrin/hilbert.h" #include "libc/intrin/kprintf.h" @@ -49,6 +48,7 @@ #include "libc/runtime/runtime.h" #include "libc/runtime/stack.h" #include "libc/runtime/sysconf.h" +#include "libc/serialize.h" #include "libc/sock/sock.h" #include "libc/sock/struct/pollfd.h" #include "libc/sock/struct/sockaddr.h" @@ -815,13 +815,13 @@ void *ListenWorker(void *arg) { void *HttpWorker(void *arg) { struct Client client; int id = (intptr_t)arg; - char *msgbuf = _gc(xmalloc(MSG_BUF)); + char *msgbuf = gc(xmalloc(MSG_BUF)); char *inbuf = NewSafeBuffer(INBUF_SIZE); char *outbuf = NewSafeBuffer(OUTBUF_SIZE); - struct HttpMessage *msg = _gc(xcalloc(1, sizeof(struct HttpMessage))); + struct HttpMessage *msg = gc(xcalloc(1, sizeof(struct HttpMessage))); BlockSignals(); - pthread_setname_np(pthread_self(), _gc(xasprintf("HTTP%d", id))); + pthread_setname_np(pthread_self(), gc(xasprintf("HTTP%d", id))); // connection loop while (GetClient(&g_clients, &client)) { @@ -1761,7 +1761,7 @@ void *ClaimWorker(void *arg) { long processed; sqlite3_stmt *stmt; bool warmedup = false; - struct Claim *v = _gc(xcalloc(BATCH_MAX, sizeof(struct Claim))); + struct Claim *v = gc(xcalloc(BATCH_MAX, sizeof(struct Claim))); BlockSignals(); pthread_setname_np(pthread_self(), "ClaimWorker"); LOG("%P ClaimWorker started\n"); diff --git a/test/dsp/core/alaw_test.c b/test/dsp/core/alaw_test.c index 9d9941c86..ec434c8da 100644 --- a/test/dsp/core/alaw_test.c +++ b/test/dsp/core/alaw_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "dsp/core/core.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/dsp/core/getintegercoefficients_test.c b/test/dsp/core/getintegercoefficients_test.c index eb3babe63..4fa0e3009 100644 --- a/test/dsp/core/getintegercoefficients_test.c +++ b/test/dsp/core/getintegercoefficients_test.c @@ -20,7 +20,7 @@ #include "dsp/core/q.h" #include "libc/dce.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" diff --git a/test/dsp/scale/magikarp_test.c b/test/dsp/scale/magikarp_test.c index f835c181f..03850f289 100644 --- a/test/dsp/scale/magikarp_test.c +++ b/test/dsp/scale/magikarp_test.c @@ -23,7 +23,7 @@ #include "libc/fmt/bing.internal.h" #include "libc/log/check.h" #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/x86feature.h" #include "libc/str/str.h" diff --git a/test/dsp/scale/scale_test.c b/test/dsp/scale/scale_test.c index dfaf988e9..be2ae9d6e 100644 --- a/test/dsp/scale/scale_test.c +++ b/test/dsp/scale/scale_test.c @@ -23,7 +23,7 @@ #include "dsp/core/half.h" #include "libc/fmt/bing.internal.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/test/libc/calls/access_test.c b/test/libc/calls/access_test.c index 7e8cbd2ac..1766ff0d5 100644 --- a/test/libc/calls/access_test.c +++ b/test/libc/calls/access_test.c @@ -20,7 +20,7 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/mem/alloca.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/auxv.h" diff --git a/test/libc/calls/cachestat_test.c b/test/libc/calls/cachestat_test.c index 2e77d33ba..22316cdff 100644 --- a/test/libc/calls/cachestat_test.c +++ b/test/libc/calls/cachestat_test.c @@ -25,7 +25,7 @@ #include "libc/errno.h" #include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/runtime/sysconf.h" #include "libc/stdio/rand.h" diff --git a/test/libc/calls/copy_file_range_test.c b/test/libc/calls/copy_file_range_test.c index 3a79325dc..cfca0f830 100644 --- a/test/libc/calls/copy_file_range_test.c +++ b/test/libc/calls/copy_file_range_test.c @@ -38,7 +38,7 @@ void SetUpOnce(void) { void Make(const char *path, int mode) { int fd, n = lemur64() & 0xfffff; - char *data = _gc(malloc(n)); + char *data = gc(malloc(n)); rngset(data, n, lemur64, -1); ASSERT_NE(-1, (fd = creat(path, mode))); ASSERT_SYS(0, n, write(fd, data, n)); @@ -77,8 +77,8 @@ TEST(copy_file_range, test) { size_t n, m; Make("foo", 0644); Copy("foo", "bar"); - p = _gc(xslurp("foo", &n)); - q = _gc(xslurp("bar", &m)); + p = gc(xslurp("foo", &n)); + q = gc(xslurp("bar", &m)); ASSERT_EQ(n, m); ASSERT_EQ(0, memcmp(p, q, n)); } diff --git a/test/libc/calls/fchdir_test.c b/test/libc/calls/fchdir_test.c index 1df4d5809..51cb96207 100644 --- a/test/libc/calls/fchdir_test.c +++ b/test/libc/calls/fchdir_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/sysv/consts/o.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/calls/ftruncate_test.c b/test/libc/calls/ftruncate_test.c index fb9e0484b..70fc5e3bf 100644 --- a/test/libc/calls/ftruncate_test.c +++ b/test/libc/calls/ftruncate_test.c @@ -23,7 +23,7 @@ #include "libc/errno.h" #include "libc/intrin/safemacros.internal.h" #include "libc/limits.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/nexgen32e/vendor.internal.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" diff --git a/test/libc/calls/getcwd_test.c b/test/libc/calls/getcwd_test.c index 86a17b8ef..875aaea1d 100644 --- a/test/libc/calls/getcwd_test.c +++ b/test/libc/calls/getcwd_test.c @@ -22,7 +22,7 @@ #include "libc/fmt/libgen.h" #include "libc/limits.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/serialize.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/calls/getrandom_test.c b/test/libc/calls/getrandom_test.c index c3aea86dd..f3cfbc7ca 100644 --- a/test/libc/calls/getrandom_test.c +++ b/test/libc/calls/getrandom_test.c @@ -22,7 +22,6 @@ #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigset.h" #include "libc/errno.h" -#include "libc/serialize.h" #include "libc/log/check.h" #include "libc/macros.internal.h" #include "libc/math.h" @@ -30,6 +29,7 @@ #include "libc/mem/mem.h" #include "libc/nexgen32e/x86feature.h" #include "libc/runtime/runtime.h" +#include "libc/serialize.h" #include "libc/stdio/lcg.internal.h" #include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" @@ -70,7 +70,7 @@ void *TortureWorker(void *arg) { TEST(getrandom, test) { int i, n = 999; double e, w = 7.7; - char *buf = _gc(calloc(1, n)); + char *buf = gc(calloc(1, n)); ASSERT_SYS(0, 0, getrandom(0, 0, 0)); ASSERT_SYS(0, n, getrandom(buf, n, 0)); ASSERT_SYS(EFAULT, -1, getrandom(0, n, 0)); @@ -92,7 +92,7 @@ TEST(getrandom, test2) { double e, w = 7.7; struct sigaction sa; int i, k, m, n = 999; - char *buf = _gc(calloc(1, n)); + char *buf = gc(calloc(1, n)); sa.sa_flags = 0; sa.sa_handler = OnSig; sigemptyset(&sa.sa_mask); diff --git a/test/libc/calls/ioctl_test.c b/test/libc/calls/ioctl_test.c index 27748ed17..417be7519 100644 --- a/test/libc/calls/ioctl_test.c +++ b/test/libc/calls/ioctl_test.c @@ -20,7 +20,7 @@ #include "libc/calls/internal.h" #include "libc/log/check.h" #include "libc/log/log.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" diff --git a/test/libc/calls/makedirs_test.c b/test/libc/calls/makedirs_test.c index 4b8f04c9c..3c08e745f 100644 --- a/test/libc/calls/makedirs_test.c +++ b/test/libc/calls/makedirs_test.c @@ -19,7 +19,7 @@ #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" diff --git a/test/libc/calls/mkdir_test.c b/test/libc/calls/mkdir_test.c index ac0988452..9e278c4fe 100644 --- a/test/libc/calls/mkdir_test.c +++ b/test/libc/calls/mkdir_test.c @@ -20,7 +20,7 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/log/check.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" diff --git a/test/libc/calls/mkntcmdline_test.c b/test/libc/calls/mkntcmdline_test.c index ecc45e066..f4830ce44 100644 --- a/test/libc/calls/mkntcmdline_test.c +++ b/test/libc/calls/mkntcmdline_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/errno.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/proc/ntspawn.h" #include "libc/str/str.h" diff --git a/test/libc/calls/mkntenvblock_test.c b/test/libc/calls/mkntenvblock_test.c index 5a38f3065..ec8752a71 100644 --- a/test/libc/calls/mkntenvblock_test.c +++ b/test/libc/calls/mkntenvblock_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/proc/ntspawn.h" #include "libc/runtime/runtime.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/calls/mkntpath_test.c b/test/libc/calls/mkntpath_test.c index fa0031272..96f4c5e7a 100644 --- a/test/libc/calls/mkntpath_test.c +++ b/test/libc/calls/mkntpath_test.c @@ -19,7 +19,7 @@ #include "libc/calls/internal.h" #include "libc/calls/syscall_support-nt.internal.h" #include "libc/dce.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #if SupportsWindows() diff --git a/test/libc/calls/open_test.c b/test/libc/calls/open_test.c index 0eaa811b8..dcdec159f 100644 --- a/test/libc/calls/open_test.c +++ b/test/libc/calls/open_test.c @@ -24,7 +24,7 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/test/libc/calls/openatemp_test.c b/test/libc/calls/openatemp_test.c index 9543dbb11..4ebf17b90 100644 --- a/test/libc/calls/openatemp_test.c +++ b/test/libc/calls/openatemp_test.c @@ -21,7 +21,7 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/limits.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "libc/sysv/consts/at.h" diff --git a/test/libc/calls/poll_test.c b/test/libc/calls/poll_test.c index 62111dac5..97e7b2202 100644 --- a/test/libc/calls/poll_test.c +++ b/test/libc/calls/poll_test.c @@ -96,7 +96,7 @@ TEST(poll, testNegativeOneFd_isIgnored) { EXPECT_SYS(0, 0, poll(fds, ARRAYLEN(fds), 1)); EXPECT_STREQ("fd:-1 revents:\n" "fd:3 revents:\n", - _gc(FormatPollFd(&fds[0]))); + gc(FormatPollFd(&fds[0]))); ASSERT_SYS(0, 0, close(3)); } diff --git a/test/libc/calls/readlinkat_test.c b/test/libc/calls/readlinkat_test.c index ece15964f..8da142e5f 100644 --- a/test/libc/calls/readlinkat_test.c +++ b/test/libc/calls/readlinkat_test.c @@ -23,7 +23,7 @@ #include "libc/limits.h" #include "libc/log/log.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/runtime/symbols.internal.h" #include "libc/str/str.h" #include "libc/sysv/consts/at.h" diff --git a/test/libc/calls/stackoverflow1_test.c b/test/libc/calls/stackoverflow1_test.c index 2e943dc8c..080e3b76d 100644 --- a/test/libc/calls/stackoverflow1_test.c +++ b/test/libc/calls/stackoverflow1_test.c @@ -23,7 +23,7 @@ #include "libc/dce.h" #include "libc/intrin/kprintf.h" #include "libc/limits.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/runtime/sysconf.h" diff --git a/test/libc/calls/stackoverflow2_test.c b/test/libc/calls/stackoverflow2_test.c index bc09fede7..6888c0ad1 100644 --- a/test/libc/calls/stackoverflow2_test.c +++ b/test/libc/calls/stackoverflow2_test.c @@ -22,7 +22,7 @@ #include "libc/dce.h" #include "libc/intrin/kprintf.h" #include "libc/limits.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/runtime/sysconf.h" diff --git a/test/libc/calls/stackoverflow3_test.c b/test/libc/calls/stackoverflow3_test.c index 8277f9cea..10cc75784 100644 --- a/test/libc/calls/stackoverflow3_test.c +++ b/test/libc/calls/stackoverflow3_test.c @@ -23,7 +23,7 @@ #include "libc/calls/ucontext.h" #include "libc/intrin/kprintf.h" #include "libc/limits.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/runtime/sysconf.h" diff --git a/test/libc/calls/stackoverflow4_test.c b/test/libc/calls/stackoverflow4_test.c index 1bf74dd84..8547d4b24 100644 --- a/test/libc/calls/stackoverflow4_test.c +++ b/test/libc/calls/stackoverflow4_test.c @@ -23,7 +23,7 @@ #include "libc/calls/ucontext.h" #include "libc/intrin/kprintf.h" #include "libc/limits.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/runtime/sysconf.h" diff --git a/test/libc/calls/stat_test.c b/test/libc/calls/stat_test.c index 512cbe754..be1cd4b49 100644 --- a/test/libc/calls/stat_test.c +++ b/test/libc/calls/stat_test.c @@ -25,7 +25,7 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/limits.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/nt/files.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" diff --git a/test/libc/calls/writev_test.c b/test/libc/calls/writev_test.c index 5f7875ff8..53b64499c 100644 --- a/test/libc/calls/writev_test.c +++ b/test/libc/calls/writev_test.c @@ -23,7 +23,7 @@ #include "libc/limits.h" #include "libc/macros.internal.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" @@ -55,7 +55,7 @@ TEST(writev, negative_einvalOrEfault) { TEST(writev, exceedsIovMax_einval) { if (IsWindows()) return; // it's complicated int i, n = IOV_MAX + 1; - struct iovec *v = _gc(malloc(sizeof(struct iovec) * n)); + struct iovec *v = gc(malloc(sizeof(struct iovec) * n)); for (i = 0; i < n; ++i) { v[i].iov_base = "x"; v[i].iov_len = 1; diff --git a/test/libc/fmt/stripexts_test.c b/test/libc/fmt/stripexts_test.c index ac98ac56f..3ecdb26d2 100644 --- a/test/libc/fmt/stripexts_test.c +++ b/test/libc/fmt/stripexts_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/conv.h" #include "libc/fmt/libgen.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/fmt/zleb64_test.c b/test/libc/fmt/zleb64_test.c index 3205724ff..78491b5ca 100644 --- a/test/libc/fmt/zleb64_test.c +++ b/test/libc/fmt/zleb64_test.c @@ -19,7 +19,7 @@ #include "libc/fmt/leb128.h" #include "libc/limits.h" #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" TEST(zleb64, testZero) { diff --git a/test/libc/intrin/cosmo_once_test.c b/test/libc/intrin/cosmo_once_test.c index 583f37b91..c0e7d54ee 100644 --- a/test/libc/intrin/cosmo_once_test.c +++ b/test/libc/intrin/cosmo_once_test.c @@ -20,7 +20,7 @@ #include "libc/cosmo.h" #include "libc/dce.h" #include "libc/intrin/atomic.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" diff --git a/test/libc/intrin/countbits_test.c b/test/libc/intrin/countbits_test.c index b2ad3233c..4e282d6f2 100644 --- a/test/libc/intrin/countbits_test.c +++ b/test/libc/intrin/countbits_test.c @@ -19,7 +19,7 @@ #include "libc/calls/calls.h" #include "libc/intrin/popcnt.h" #include "libc/limits.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" diff --git a/test/libc/intrin/memcmp_test.c b/test/libc/intrin/memcmp_test.c index 4157b2de1..1fed4eb29 100644 --- a/test/libc/intrin/memcmp_test.c +++ b/test/libc/intrin/memcmp_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/runtime/sysconf.h" diff --git a/test/libc/intrin/memmove_test.c b/test/libc/intrin/memmove_test.c index 68a1e4b0e..33b2ea6ad 100644 --- a/test/libc/intrin/memmove_test.c +++ b/test/libc/intrin/memmove_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/runtime/runtime.h" diff --git a/test/libc/intrin/memset_test.c b/test/libc/intrin/memset_test.c index aec468ce6..5a2f5194d 100644 --- a/test/libc/intrin/memset_test.c +++ b/test/libc/intrin/memset_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/rand.h" #include "libc/str/str.h" diff --git a/test/libc/intrin/pthread_mutex_lock2_test.c b/test/libc/intrin/pthread_mutex_lock2_test.c index b8bd37553..1b0a3279a 100644 --- a/test/libc/intrin/pthread_mutex_lock2_test.c +++ b/test/libc/intrin/pthread_mutex_lock2_test.c @@ -21,7 +21,7 @@ #include "libc/calls/calls.h" #include "libc/calls/struct/timespec.h" #include "libc/intrin/atomic.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/intrin/pthread_mutex_lock_test.c b/test/libc/intrin/pthread_mutex_lock_test.c index 282c1099c..b45d2a20a 100644 --- a/test/libc/intrin/pthread_mutex_lock_test.c +++ b/test/libc/intrin/pthread_mutex_lock_test.c @@ -25,7 +25,7 @@ #include "libc/log/check.h" #include "libc/macros.internal.h" #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/internal.h" #include "libc/runtime/runtime.h" diff --git a/test/libc/intrin/strcmp_test.c b/test/libc/intrin/strcmp_test.c index ee9fc8d0f..fe7a4efac 100644 --- a/test/libc/intrin/strcmp_test.c +++ b/test/libc/intrin/strcmp_test.c @@ -19,7 +19,7 @@ #include "libc/assert.h" #include "libc/dce.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/cachesize.h" #include "libc/nexgen32e/x86feature.h" diff --git a/test/libc/log/backtrace_test.c b/test/libc/log/backtrace_test.c index b3b5fab1d..22ee61e97 100644 --- a/test/libc/log/backtrace_test.c +++ b/test/libc/log/backtrace_test.c @@ -115,7 +115,7 @@ TEST(ShowCrashReports, testMemoryLeakCrash) { } close(fds[0]); ASSERT_NE(-1, wait(&ws)); - // tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL); + // tinyprint(2, gc(IndentLines(output, -1, 0, 4)), "\n", NULL); EXPECT_EQ(78 << 8, ws); ASSERT_TRUE(!!strstr(output, "UNFREED MEMORY")); if (IsAsan()) { @@ -207,7 +207,7 @@ TEST(ShowCrashReports, testDivideByZero) { } close(fds[0]); ASSERT_NE(-1, wait(&ws)); - // tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL); + // tinyprint(2, gc(IndentLines(output, -1, 0, 4)), "\n", NULL); if (IsModeDbg()) { EXPECT_EQ(77 << 8, ws); } else { @@ -222,32 +222,32 @@ TEST(ShowCrashReports, testDivideByZero) { // UBSAN handled it } else { // ShowCrashReports() handled it - if (!strstr(output, _gc(xasprintf("%d", pid)))) { + if (!strstr(output, gc(xasprintf("%d", pid)))) { fprintf(stderr, "ERROR: crash report didn't have pid\n%s\n", - _gc(IndentLines(output, -1, 0, 4))); + gc(IndentLines(output, -1, 0, 4))); __die(); } if (!strstr(output, "SIGFPE")) { fprintf(stderr, "ERROR: crash report didn't have signal name\n%s\n", - _gc(IndentLines(output, -1, 0, 4))); + gc(IndentLines(output, -1, 0, 4))); __die(); } // XXX: WSL doesn't save and restore x87 registers to ucontext_t if (!__iswsl1()) { if (!strstr(output, "3.141")) { fprintf(stderr, "ERROR: crash report didn't have fpu register\n%s\n", - _gc(IndentLines(output, -1, 0, 4))); + gc(IndentLines(output, -1, 0, 4))); __die(); } } if (!strstr(output, "0f0e0d0c0b0a09080706050403020100")) { fprintf(stderr, "ERROR: crash report didn't have sse register\n%s\n", - _gc(IndentLines(output, -1, 0, 4))); + gc(IndentLines(output, -1, 0, 4))); __die(); } if (!strstr(output, "3133731337")) { fprintf(stderr, "ERROR: crash report didn't have general register\n%s\n", - _gc(IndentLines(output, -1, 0, 4))); + gc(IndentLines(output, -1, 0, 4))); __die(); } } @@ -332,7 +332,7 @@ TEST(ShowCrashReports, testBssOverrunCrash) { } close(fds[0]); ASSERT_NE(-1, wait(&ws)); - // tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL); + // tinyprint(2, gc(IndentLines(output, -1, 0, 4)), "\n", NULL); EXPECT_EQ(77 << 8, ws); /* NULL is stopgap until we can copy symbol tablces into binary */ #ifdef __FNO_OMIT_FRAME_POINTER__ @@ -407,7 +407,7 @@ TEST(ShowCrashReports, testNpeCrash) { } close(fds[0]); ASSERT_NE(-1, wait(&ws)); - // tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL); + // tinyprint(2, gc(IndentLines(output, -1, 0, 4)), "\n", NULL); EXPECT_EQ(77 << 8, ws); /* NULL is stopgap until we can copy symbol tables into binary */ ASSERT_TRUE(!!strstr(output, "null pointer")); @@ -451,7 +451,7 @@ TEST(ShowCrashReports, testDataOverrunCrash) { } close(fds[0]); ASSERT_NE(-1, wait(&ws)); - // tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL); + // tinyprint(2, gc(IndentLines(output, -1, 0, 4)), "\n", NULL); EXPECT_EQ(77 << 8, ws); /* NULL is stopgap until we can copy symbol tablces into binary */ #ifdef __FNO_OMIT_FRAME_POINTER__ @@ -499,7 +499,7 @@ TEST(ShowCrashReports, testNpeCrashAfterFinalize) { } close(fds[0]); ASSERT_NE(-1, wait(&ws)); - // tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL); + // tinyprint(2, gc(IndentLines(output, -1, 0, 4)), "\n", NULL); if (IsModeDbg()) { EXPECT_EQ(77 << 8, ws); } else { @@ -509,13 +509,13 @@ TEST(ShowCrashReports, testNpeCrashAfterFinalize) { /* NULL is stopgap until we can copy symbol tables into binary */ if (!strstr(output, IsAsan() ? "null pointer" : "Uncaught SIGSEGV (SEGV_")) { fprintf(stderr, "ERROR: crash report didn't diagnose the problem\n%s\n", - _gc(IndentLines(output, -1, 0, 4))); + gc(IndentLines(output, -1, 0, 4))); __die(); } #ifdef __FNO_OMIT_FRAME_POINTER__ if (!OutputHasSymbol(output, "NpeCrash")) { fprintf(stderr, "ERROR: crash report didn't have backtrace\n%s\n", - _gc(IndentLines(output, -1, 0, 4))); + gc(IndentLines(output, -1, 0, 4))); __die(); } #endif diff --git a/test/libc/mem/djbsort_test.c b/test/libc/mem/djbsort_test.c index decb133f4..e56195642 100644 --- a/test/libc/mem/djbsort_test.c +++ b/test/libc/mem/djbsort_test.c @@ -54,9 +54,9 @@ void insertionsort(int32_t *a, size_t n) { TEST(djbsort, test4) { static const int kA[] = {4, 3, 2, 1}; n = ARRAYLEN(kA); - a = memcpy(_gc(malloc(n * 4)), kA, n * 4); - b = memcpy(_gc(malloc(n * 4)), kA, n * 4); - c = memcpy(_gc(malloc(n * 4)), kA, n * 4); + a = memcpy(gc(malloc(n * 4)), kA, n * 4); + b = memcpy(gc(malloc(n * 4)), kA, n * 4); + c = memcpy(gc(malloc(n * 4)), kA, n * 4); insertionsort(a, n); djbsort_avx2(b, n); djbsort(c, n); @@ -82,9 +82,9 @@ TEST(djbsort, test64) { -1323943608, -1219421355, -582289873, 1062699814, }; n = ARRAYLEN(kA); - a = memcpy(_gc(malloc(n * 4)), kA, n * 4); - b = memcpy(_gc(malloc(n * 4)), kA, n * 4); - c = memcpy(_gc(malloc(n * 4)), kA, n * 4); + a = memcpy(gc(malloc(n * 4)), kA, n * 4); + b = memcpy(gc(malloc(n * 4)), kA, n * 4); + c = memcpy(gc(malloc(n * 4)), kA, n * 4); insertionsort(a, n); djbsort(c, n); ASSERT_EQ(0, memcmp(a, c, n * 4)); @@ -104,7 +104,7 @@ static int CompareInt(const void *a, const void *b) { BENCH(djbsort, bench) { n = 256; - a = _gc(memalign(32, n * 4)); + a = gc(memalign(32, n * 4)); EZBENCH2("insertionsort[255]", rngset(a, n * 4, _rand64, -1), insertionsort(a, n)); EZBENCH2("djbsort[255]", rngset(a, n * 4, _rand64, -1), djbsort(a, n)); diff --git a/test/libc/mem/malloc_test.c b/test/libc/mem/malloc_test.c index 6b694507f..327975b69 100644 --- a/test/libc/mem/malloc_test.c +++ b/test/libc/mem/malloc_test.c @@ -26,7 +26,7 @@ #include "libc/intrin/safemacros.internal.h" #include "libc/macros.internal.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/internal.h" #include "libc/runtime/memtrack.internal.h" @@ -210,7 +210,7 @@ void *Worker(void *arg) { BENCH(malloc, torture) { int i, n = __get_cpu_count() * 2; - pthread_t *t = _gc(malloc(sizeof(pthread_t) * n)); + pthread_t *t = gc(malloc(sizeof(pthread_t) * n)); if (!n) return; printf("\nmalloc torture test w/ %d threads and %d iterations\n", n, ITERATIONS); diff --git a/test/libc/mem/qsort_test.c b/test/libc/mem/qsort_test.c index ac646694b..197653bdd 100644 --- a/test/libc/mem/qsort_test.c +++ b/test/libc/mem/qsort_test.c @@ -19,7 +19,7 @@ #include "libc/macros.internal.h" #include "libc/mem/alg.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/rand.h" diff --git a/test/libc/mem/realpath_test.c b/test/libc/mem/realpath_test.c index 87c84897e..e24060045 100644 --- a/test/libc/mem/realpath_test.c +++ b/test/libc/mem/realpath_test.c @@ -19,7 +19,7 @@ #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" diff --git a/test/libc/nexgen32e/gclongjmp_test.c b/test/libc/nexgen32e/gclongjmp_test.c index e50e2c4c2..a31f4a786 100644 --- a/test/libc/nexgen32e/gclongjmp_test.c +++ b/test/libc/nexgen32e/gclongjmp_test.c @@ -18,9 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/log/log.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" #include "libc/mem/mem.h" -#include "libc/nexgen32e/gc.internal.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" @@ -32,7 +30,7 @@ #ifdef __x86_64__ // TODO(jart): get gclongjmp() working properly on aarch64 -#define GC(x) _defer(Free, x) +#define GC(x) defer(Free, x) char *x; char *y; @@ -83,7 +81,7 @@ TEST(gclongjmp, test) { void crawl(const char *path) { if (!strcmp(path, "/") || !strcmp(path, ".")) return; - crawl(_gc(xdirname(path))); + crawl(gc(xdirname(path))); } void *Worker(void *arg) { @@ -99,8 +97,8 @@ TEST(gc, torture) { } void crawl2(jmp_buf jb, const char *path) { - if (!strcmp(path, "/") || !strcmp(path, ".")) _gclongjmp(jb, 1); - crawl2(jb, _gc(xdirname(path))); + if (!strcmp(path, "/") || !strcmp(path, ".")) gclongjmp(jb, 1); + crawl2(jb, gc(xdirname(path))); } void *Worker2(void *arg) { @@ -111,7 +109,7 @@ void *Worker2(void *arg) { return 0; } -TEST(_gclongjmp, torture) { +TEST(gclongjmp, torture) { int i, n = 32; pthread_t *t = gc(malloc(sizeof(pthread_t) * n)); for (i = 0; i < n; ++i) { diff --git a/test/libc/nexgen32e/lz4decode_test.c b/test/libc/nexgen32e/lz4decode_test.c index 73b33f6a5..c652ad0e2 100644 --- a/test/libc/nexgen32e/lz4decode_test.c +++ b/test/libc/nexgen32e/lz4decode_test.c @@ -19,7 +19,7 @@ #include "libc/calls/calls.h" #include "libc/intrin/safemacros.internal.h" #include "libc/log/check.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/kompressor.h" #include "libc/nexgen32e/lz4.h" diff --git a/test/libc/nexgen32e/memset_test.c b/test/libc/nexgen32e/memset_test.c index e7698dfd3..d624beae0 100644 --- a/test/libc/nexgen32e/memset_test.c +++ b/test/libc/nexgen32e/memset_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/nexgen32e/strsak32_test.c b/test/libc/nexgen32e/strsak32_test.c index 24eb01722..18e0be763 100644 --- a/test/libc/nexgen32e/strsak32_test.c +++ b/test/libc/nexgen32e/strsak32_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/nexgen32e/nexgen32e.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/libc/proc/posix_spawn_test.c b/test/libc/proc/posix_spawn_test.c index 058012f4e..d4fe8aa7f 100644 --- a/test/libc/proc/posix_spawn_test.c +++ b/test/libc/proc/posix_spawn_test.c @@ -36,7 +36,7 @@ #include "libc/intrin/safemacros.internal.h" #include "libc/limits.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/proc/proc.internal.h" #include "libc/runtime/internal.h" @@ -245,7 +245,7 @@ void *Torturer(void *arg) { TEST(posix_spawn, agony) { int i, n = 4; - pthread_t *t = _gc(malloc(sizeof(pthread_t) * n)); + pthread_t *t = gc(malloc(sizeof(pthread_t) * n)); testlib_extract("/zip/echo.com", "echo.com", 0755); for (i = 0; i < n; ++i) { ASSERT_EQ(0, pthread_create(t + i, 0, Torturer, 0)); diff --git a/test/libc/proc/system_test.c b/test/libc/proc/system_test.c index c49c9c258..70d2ae73d 100644 --- a/test/libc/proc/system_test.c +++ b/test/libc/proc/system_test.c @@ -21,7 +21,7 @@ #include "libc/dce.h" #include "libc/intrin/kprintf.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/paths.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" @@ -73,7 +73,7 @@ TEST(system, haveShell) { TEST(system, echo) { ASSERT_EQ(0, system("echo hello >\"hello there.txt\"")); - EXPECT_STREQ("hello\n", _gc(xslurp("hello there.txt", 0))); + EXPECT_STREQ("hello\n", gc(xslurp("hello there.txt", 0))); } TEST(system, exit) { @@ -83,13 +83,13 @@ TEST(system, exit) { TEST(system, testStdoutRedirect) { testlib_extract("/zip/echo.com", "echo.com", 0755); ASSERT_EQ(0, system("./echo.com hello >hello.txt")); - EXPECT_STREQ("hello\n", _gc(xslurp("hello.txt", 0))); + EXPECT_STREQ("hello\n", gc(xslurp("hello.txt", 0))); } TEST(system, testStdoutRedirect_withSpacesInFilename) { testlib_extract("/zip/echo.com", "echo.com", 0755); ASSERT_EQ(0, system("./echo.com hello >\"hello there.txt\"")); - EXPECT_STREQ("hello\n", _gc(xslurp("hello there.txt", 0))); + EXPECT_STREQ("hello\n", gc(xslurp("hello there.txt", 0))); } TEST(system, testStderrRedirect_toStdout) { diff --git a/test/libc/release/BUILD.mk b/test/libc/release/BUILD.mk index 102bc233b..e98174d41 100644 --- a/test/libc/release/BUILD.mk +++ b/test/libc/release/BUILD.mk @@ -33,8 +33,10 @@ o/$(MODE)/test/libc/release/smoke.o: \ -o $@ \ -c \ -Os \ + -Werror \ -fno-pie \ -nostdinc \ + -D_COSMO_SOURCE \ -Wl,--gc-sections \ -fno-omit-frame-pointer \ -include o/cosmopolitan.h \ @@ -114,10 +116,12 @@ o/$(MODE)/test/libc/release/smoke-chibicc.o: \ -c \ -Os \ -static \ + -Werror \ -fno-pie \ -nostdlib \ -nostdinc \ -mno-red-zone \ + -D_COSMO_SOURCE \ -fno-omit-frame-pointer \ -include o/cosmopolitan.h \ $< @@ -188,9 +192,11 @@ o/$(MODE)/test/libc/release/smokeansi.o: \ -c \ -Os \ -ansi \ + -Werror \ -static \ -fno-pie \ -nostdinc \ + -D_COSMO_SOURCE \ -Wl,--gc-sections \ -fno-omit-frame-pointer \ -include o/cosmopolitan.h \ diff --git a/test/libc/release/smoke.c b/test/libc/release/smoke.c index 71d8f1952..993bc73b2 100644 --- a/test/libc/release/smoke.c +++ b/test/libc/release/smoke.c @@ -6,8 +6,8 @@ int main(int argc, char *argv[]) { s = strdup(argv[0]); s[0] = 'Z'; f = fopen("/dev/null", "w"); - fputs(_gc(xiso8601ts(NULL)), f); - fputs(_gc(xasprintf("hello world %d %s\n", argc, s)), f); + /* fputs(gc(xiso8601ts(NULL)), f); */ + fputs(gc(xasprintf("hello world %d %s\n", argc, s)), f); fclose(f); free(s); return 0; diff --git a/test/libc/release/smokecxx.cc b/test/libc/release/smokecxx.cc index a31736b12..4ff237bec 100644 --- a/test/libc/release/smokecxx.cc +++ b/test/libc/release/smokecxx.cc @@ -1,6 +1,4 @@ int main() { - int rc; - FILE *f; int *x = new int[32]; x[0] = 2; x[1] = 2; diff --git a/test/libc/runtime/ftrace_test.c b/test/libc/runtime/ftrace_test.c index 95a67234f..85313d889 100644 --- a/test/libc/runtime/ftrace_test.c +++ b/test/libc/runtime/ftrace_test.c @@ -35,7 +35,7 @@ TEST(ftrace, test) { } const char *ftraceasm; testlib_extract("/zip/ftraceasm.txt", "ftraceasm.txt", 0755); - ftraceasm = _gc(xslurp("ftraceasm.txt", 0)); + ftraceasm = gc(xslurp("ftraceasm.txt", 0)); #ifdef __x86_64__ if (strstr(ftraceasm, "%xmm") || // strstr(ftraceasm, "%ymm") || // diff --git a/test/libc/runtime/mmap_test.c b/test/libc/runtime/mmap_test.c index 131d5cc0b..1136a91c1 100644 --- a/test/libc/runtime/mmap_test.c +++ b/test/libc/runtime/mmap_test.c @@ -236,15 +236,15 @@ TEST(isheap, nullPtr) { } TEST(isheap, malloc) { - ASSERT_TRUE(_isheap(_gc(malloc(1)))); + ASSERT_TRUE(_isheap(gc(malloc(1)))); } /* TEST(isheap, emptyMalloc) { */ -/* ASSERT_TRUE(_isheap(_gc(malloc(0)))); */ +/* ASSERT_TRUE(_isheap(gc(malloc(0)))); */ /* } */ /* TEST(isheap, mallocOffset) { */ -/* char *p = _gc(malloc(131072)); */ +/* char *p = gc(malloc(131072)); */ /* ASSERT_TRUE(_isheap(p + 100000)); */ /* } */ diff --git a/test/libc/runtime/mprotect_test.c b/test/libc/runtime/mprotect_test.c index 217208e1d..b4c8a82cc 100644 --- a/test/libc/runtime/mprotect_test.c +++ b/test/libc/runtime/mprotect_test.c @@ -23,7 +23,7 @@ #include "libc/errno.h" #include "libc/intrin/describeflags.internal.h" #include "libc/log/log.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" diff --git a/test/libc/runtime/zipos_test.c b/test/libc/runtime/zipos_test.c index b87e54bd7..c172a737d 100644 --- a/test/libc/runtime/zipos_test.c +++ b/test/libc/runtime/zipos_test.c @@ -21,7 +21,7 @@ #include "libc/errno.h" #include "libc/limits.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/runtime/zipos.internal.h" diff --git a/test/libc/sock/sendfile_test.c b/test/libc/sock/sendfile_test.c index 77ea37441..95d65b1aa 100644 --- a/test/libc/sock/sendfile_test.c +++ b/test/libc/sock/sendfile_test.c @@ -22,7 +22,7 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/limits.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/internal.h" #include "libc/runtime/runtime.h" diff --git a/test/libc/sock/sendrecvmsg_test.c b/test/libc/sock/sendrecvmsg_test.c index a72184f53..5f2445004 100644 --- a/test/libc/sock/sendrecvmsg_test.c +++ b/test/libc/sock/sendrecvmsg_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/struct/iovec.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/sock/sock.h" #include "libc/sock/struct/msghdr.h" diff --git a/test/libc/stdio/devrand_test.c b/test/libc/stdio/devrand_test.c index e588e7989..0eca6ac64 100644 --- a/test/libc/stdio/devrand_test.c +++ b/test/libc/stdio/devrand_test.c @@ -19,7 +19,7 @@ #include "libc/dce.h" #include "libc/mem/mem.h" #include "libc/stdio/rand.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/stdio/dirstream_test.c b/test/libc/stdio/dirstream_test.c index 15cd6e5ef..75625c564 100644 --- a/test/libc/stdio/dirstream_test.c +++ b/test/libc/stdio/dirstream_test.c @@ -27,7 +27,7 @@ #include "libc/limits.h" #include "libc/mem/critbit0.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/append.h" diff --git a/test/libc/stdio/dtoa_test.c b/test/libc/stdio/dtoa_test.c index d5895c02c..738dbc841 100644 --- a/test/libc/stdio/dtoa_test.c +++ b/test/libc/stdio/dtoa_test.c @@ -21,7 +21,7 @@ #include "libc/dce.h" #include "libc/macros.internal.h" #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/vendor.internal.h" #include "libc/runtime/internal.h" diff --git a/test/libc/stdio/dumphexc_test.c b/test/libc/stdio/dumphexc_test.c index 51ce7b5e7..5ad6d0f0d 100644 --- a/test/libc/stdio/dumphexc_test.c +++ b/test/libc/stdio/dumphexc_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/stdio/hex.internal.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/libc/stdio/ecvt_test.c b/test/libc/stdio/ecvt_test.c index ee4501e2c..2813d8d3c 100644 --- a/test/libc/stdio/ecvt_test.c +++ b/test/libc/stdio/ecvt_test.c @@ -25,7 +25,7 @@ TEST(fcvt, test) { int decpt, sign; ASSERT_STREQ("3.14159265358979", - _gc(xasprintf("%.14f", 3.14159265358979323846))); + gc(xasprintf("%.14f", 3.14159265358979323846))); ASSERT_STREQ("3141592653589793", fcvt(3.14159265358979323846, 15, &decpt, &sign)); ASSERT_EQ(1, decpt); diff --git a/test/libc/stdio/fgetln_test.c b/test/libc/stdio/fgetln_test.c index 0de27fe38..90890256d 100644 --- a/test/libc/stdio/fgetln_test.c +++ b/test/libc/stdio/fgetln_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/test/libc/stdio/fgets_test.c b/test/libc/stdio/fgets_test.c index 9fab60fd1..ee248ee09 100644 --- a/test/libc/stdio/fgets_test.c +++ b/test/libc/stdio/fgets_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/test/libc/stdio/fmemopen_test.c b/test/libc/stdio/fmemopen_test.c index d272b733d..f93ffd8f4 100644 --- a/test/libc/stdio/fmemopen_test.c +++ b/test/libc/stdio/fmemopen_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/errno.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/temp.h" diff --git a/test/libc/stdio/fmt_test.c b/test/libc/stdio/fmt_test.c index 3183306f8..026ff761d 100644 --- a/test/libc/stdio/fmt_test.c +++ b/test/libc/stdio/fmt_test.c @@ -25,52 +25,52 @@ #include "libc/x/xasprintf.h" TEST(fmt, d) { - EXPECT_STREQ("-123", _gc(xasprintf("%d", -123))); - EXPECT_STREQ("-1", _gc(xasprintf("%d", -1))); - EXPECT_STREQ("1", _gc(xasprintf("%d", 1))); - EXPECT_STREQ("16", _gc(xasprintf("%d", 16))); - EXPECT_STREQ("2147483647", _gc(xasprintf("%d", INT_MAX))); - EXPECT_STREQ("-2147483648", _gc(xasprintf("%d", INT_MIN))); - EXPECT_STREQ(" -123", _gc(xasprintf("%10d", -123))); - EXPECT_STREQ(" -1", _gc(xasprintf("%10d", -1))); - EXPECT_STREQ(" 1", _gc(xasprintf("%10d", 1))); - EXPECT_STREQ(" 16", _gc(xasprintf("%10d", 16))); - EXPECT_STREQ("2147483647", _gc(xasprintf("%10d", INT_MAX))); - EXPECT_STREQ("-2147483648", _gc(xasprintf("%10d", INT_MIN))); - EXPECT_STREQ("-000000123", _gc(xasprintf("%010d", -123))); - EXPECT_STREQ("-000000001", _gc(xasprintf("%010d", -1))); - EXPECT_STREQ("0000000001", _gc(xasprintf("%010d", 1))); - EXPECT_STREQ("0000000016", _gc(xasprintf("%010d", 16))); - EXPECT_STREQ("2147483647", _gc(xasprintf("%010d", INT_MAX))); - EXPECT_STREQ("-2147483648", _gc(xasprintf("%010d", INT_MIN))); - EXPECT_STREQ("-123 ", _gc(xasprintf("%-10d", -123))); - EXPECT_STREQ("-1 ", _gc(xasprintf("%-10d", -1))); - EXPECT_STREQ("1 ", _gc(xasprintf("%-10d", 1))); - EXPECT_STREQ("16 ", _gc(xasprintf("%-10d", 16))); - EXPECT_STREQ("2147483647", _gc(xasprintf("%-10d", INT_MAX))); - EXPECT_STREQ("-2147483648", _gc(xasprintf("%-10d", INT_MIN))); - EXPECT_STREQ(" -123", _gc(xasprintf("%+10d", -123))); - EXPECT_STREQ(" -1", _gc(xasprintf("%+10d", -1))); - EXPECT_STREQ(" +1", _gc(xasprintf("%+10d", 1))); - EXPECT_STREQ(" +16", _gc(xasprintf("%+10d", 16))); - EXPECT_STREQ("+2147483647", _gc(xasprintf("%+10d", INT_MAX))); - EXPECT_STREQ("-2147483648", _gc(xasprintf("%+10d", INT_MIN))); - EXPECT_STREQ("-123", _gc(xasprintf("% d", -123))); - EXPECT_STREQ("-1", _gc(xasprintf("% d", -1))); - EXPECT_STREQ(" 1", _gc(xasprintf("% d", 1))); - EXPECT_STREQ(" 16", _gc(xasprintf("% d", 16))); - EXPECT_STREQ(" 2147483647", _gc(xasprintf("% d", INT_MAX))); - EXPECT_STREQ("-2147483648", _gc(xasprintf("% d", INT_MIN))); - EXPECT_STREQ("042 ", _gc(xasprintf("%-4.3d", 42))); - EXPECT_STREQ("-00054", _gc(xasprintf("%-1.5lld", -54ll))); - EXPECT_STREQ("00109", _gc(xasprintf("%-.5lld", 109ll))); - EXPECT_STREQ("-00116", _gc(xasprintf("%-.5lld", -116ll))); - EXPECT_STREQ("00108 ", _gc(xasprintf("%-8.5lld", 108ll))); - EXPECT_STREQ("-00054 ", _gc(xasprintf("%-8.5lld", -54ll))); + EXPECT_STREQ("-123", gc(xasprintf("%d", -123))); + EXPECT_STREQ("-1", gc(xasprintf("%d", -1))); + EXPECT_STREQ("1", gc(xasprintf("%d", 1))); + EXPECT_STREQ("16", gc(xasprintf("%d", 16))); + EXPECT_STREQ("2147483647", gc(xasprintf("%d", INT_MAX))); + EXPECT_STREQ("-2147483648", gc(xasprintf("%d", INT_MIN))); + EXPECT_STREQ(" -123", gc(xasprintf("%10d", -123))); + EXPECT_STREQ(" -1", gc(xasprintf("%10d", -1))); + EXPECT_STREQ(" 1", gc(xasprintf("%10d", 1))); + EXPECT_STREQ(" 16", gc(xasprintf("%10d", 16))); + EXPECT_STREQ("2147483647", gc(xasprintf("%10d", INT_MAX))); + EXPECT_STREQ("-2147483648", gc(xasprintf("%10d", INT_MIN))); + EXPECT_STREQ("-000000123", gc(xasprintf("%010d", -123))); + EXPECT_STREQ("-000000001", gc(xasprintf("%010d", -1))); + EXPECT_STREQ("0000000001", gc(xasprintf("%010d", 1))); + EXPECT_STREQ("0000000016", gc(xasprintf("%010d", 16))); + EXPECT_STREQ("2147483647", gc(xasprintf("%010d", INT_MAX))); + EXPECT_STREQ("-2147483648", gc(xasprintf("%010d", INT_MIN))); + EXPECT_STREQ("-123 ", gc(xasprintf("%-10d", -123))); + EXPECT_STREQ("-1 ", gc(xasprintf("%-10d", -1))); + EXPECT_STREQ("1 ", gc(xasprintf("%-10d", 1))); + EXPECT_STREQ("16 ", gc(xasprintf("%-10d", 16))); + EXPECT_STREQ("2147483647", gc(xasprintf("%-10d", INT_MAX))); + EXPECT_STREQ("-2147483648", gc(xasprintf("%-10d", INT_MIN))); + EXPECT_STREQ(" -123", gc(xasprintf("%+10d", -123))); + EXPECT_STREQ(" -1", gc(xasprintf("%+10d", -1))); + EXPECT_STREQ(" +1", gc(xasprintf("%+10d", 1))); + EXPECT_STREQ(" +16", gc(xasprintf("%+10d", 16))); + EXPECT_STREQ("+2147483647", gc(xasprintf("%+10d", INT_MAX))); + EXPECT_STREQ("-2147483648", gc(xasprintf("%+10d", INT_MIN))); + EXPECT_STREQ("-123", gc(xasprintf("% d", -123))); + EXPECT_STREQ("-1", gc(xasprintf("% d", -1))); + EXPECT_STREQ(" 1", gc(xasprintf("% d", 1))); + EXPECT_STREQ(" 16", gc(xasprintf("% d", 16))); + EXPECT_STREQ(" 2147483647", gc(xasprintf("% d", INT_MAX))); + EXPECT_STREQ("-2147483648", gc(xasprintf("% d", INT_MIN))); + EXPECT_STREQ("042 ", gc(xasprintf("%-4.3d", 42))); + EXPECT_STREQ("-00054", gc(xasprintf("%-1.5lld", -54ll))); + EXPECT_STREQ("00109", gc(xasprintf("%-.5lld", 109ll))); + EXPECT_STREQ("-00116", gc(xasprintf("%-.5lld", -116ll))); + EXPECT_STREQ("00108 ", gc(xasprintf("%-8.5lld", 108ll))); + EXPECT_STREQ("-00054 ", gc(xasprintf("%-8.5lld", -54ll))); } TEST(fmt, u) { - EXPECT_STREQ("042 ", _gc(xasprintf("%-4.3u", 42))); + EXPECT_STREQ("042 ", gc(xasprintf("%-4.3u", 42))); } TEST(fmt, c) { @@ -92,314 +92,309 @@ TEST(fmt, c) { } TEST(fmt, x) { - EXPECT_STREQ("0x01 ", _gc(xasprintf("%#-07.2x", 1))); - EXPECT_STREQ("0x00136d ", _gc(xasprintf("%#-010.6x", 4973))); - EXPECT_STREQ("0X1", _gc(xasprintf("%#X", 1))); - EXPECT_STREQ("0XA", _gc(xasprintf("%#X", 10))); - EXPECT_STREQ("0XFFFF", _gc(xasprintf("%#X", 65535))); - EXPECT_STREQ("0XABCDEF", _gc(xasprintf("%#X", 0xABCDEF))); - EXPECT_STREQ("0X1", _gc(xasprintf("%#hX", (short)1))); - EXPECT_STREQ("0XA", _gc(xasprintf("%#hX", (short)10))); - EXPECT_STREQ("0XFFFF", _gc(xasprintf("%#hX", (short)65535))); - EXPECT_STREQ("0XABCD", _gc(xasprintf("%#hX", (short)0xABCD))); - EXPECT_STREQ(" 0X308C6705", _gc(xasprintf("%#20X", 814507781))); - EXPECT_STREQ("0X0000000000308C6705", _gc(xasprintf("%#020X", 814507781))); + EXPECT_STREQ("0x01 ", gc(xasprintf("%#-07.2x", 1))); + EXPECT_STREQ("0x00136d ", gc(xasprintf("%#-010.6x", 4973))); + EXPECT_STREQ("0X1", gc(xasprintf("%#X", 1))); + EXPECT_STREQ("0XA", gc(xasprintf("%#X", 10))); + EXPECT_STREQ("0XFFFF", gc(xasprintf("%#X", 65535))); + EXPECT_STREQ("0XABCDEF", gc(xasprintf("%#X", 0xABCDEF))); + EXPECT_STREQ("0X1", gc(xasprintf("%#hX", (short)1))); + EXPECT_STREQ("0XA", gc(xasprintf("%#hX", (short)10))); + EXPECT_STREQ("0XFFFF", gc(xasprintf("%#hX", (short)65535))); + EXPECT_STREQ("0XABCD", gc(xasprintf("%#hX", (short)0xABCD))); + EXPECT_STREQ(" 0X308C6705", gc(xasprintf("%#20X", 814507781))); + EXPECT_STREQ("0X0000000000308C6705", gc(xasprintf("%#020X", 814507781))); EXPECT_STREQ(" 0X6705", - _gc(xasprintf("%#20hX", (short)814507781))); + gc(xasprintf("%#20hX", (short)814507781))); EXPECT_STREQ("0X000000000000006705", - _gc(xasprintf("%#020hX", (short)814507781))); - EXPECT_STREQ(" 0XABCDEF", _gc(xasprintf("%#20X", 0xABCDEF))); - EXPECT_STREQ("0X000000000000ABCDEF", _gc(xasprintf("%#020X", 0xABCDEF))); + gc(xasprintf("%#020hX", (short)814507781))); + EXPECT_STREQ(" 0XABCDEF", gc(xasprintf("%#20X", 0xABCDEF))); + EXPECT_STREQ("0X000000000000ABCDEF", gc(xasprintf("%#020X", 0xABCDEF))); EXPECT_STREQ(" 0XCDEF", - _gc(xasprintf("%#20hX", (short)0xABCDEF))); + gc(xasprintf("%#20hX", (short)0xABCDEF))); EXPECT_STREQ("0X00000000000000CDEF", - _gc(xasprintf("%#020hX", (short)0xABCDEF))); + gc(xasprintf("%#020hX", (short)0xABCDEF))); } TEST(fmt, o) { - EXPECT_STREQ("0000000000000037777777634", _gc(xasprintf("%#.25o", -100))); - EXPECT_STREQ("0001777777777777777777634", _gc(xasprintf("%#.25lo", -100L))); - EXPECT_STREQ("0001777777777777777777634", _gc(xasprintf("%#.25llo", -100LL))); - EXPECT_STREQ("0", _gc(xasprintf("%#.o", 0))); - EXPECT_STREQ(" 056520", _gc(xasprintf("%#8.6o", 23888))); - EXPECT_STREQ("00144 ", _gc(xasprintf("%#-8.5llo", 100ll))); - EXPECT_STREQ("0 ", _gc(xasprintf("%-#02lo", 0l))); - EXPECT_STREQ("0", _gc(xasprintf("%#01lo", 0l))); - EXPECT_STREQ("00", _gc(xasprintf("%#02lo", 0l))); + EXPECT_STREQ("0000000000000037777777634", gc(xasprintf("%#.25o", -100))); + EXPECT_STREQ("0001777777777777777777634", gc(xasprintf("%#.25lo", -100L))); + EXPECT_STREQ("0001777777777777777777634", gc(xasprintf("%#.25llo", -100LL))); + EXPECT_STREQ("0", gc(xasprintf("%#.o", 0))); + EXPECT_STREQ(" 056520", gc(xasprintf("%#8.6o", 23888))); + EXPECT_STREQ("00144 ", gc(xasprintf("%#-8.5llo", 100ll))); + EXPECT_STREQ("0 ", gc(xasprintf("%-#02lo", 0l))); + EXPECT_STREQ("0", gc(xasprintf("%#01lo", 0l))); + EXPECT_STREQ("00", gc(xasprintf("%#02lo", 0l))); } TEST(fmt, b) { - EXPECT_STREQ("000010100 ", _gc(xasprintf("%-14.9b", 20))); - EXPECT_STREQ("0b110", _gc(xasprintf("%#b", 6))); + EXPECT_STREQ("000010100 ", gc(xasprintf("%-14.9b", 20))); + EXPECT_STREQ("0b110", gc(xasprintf("%#b", 6))); } TEST(fmt, s) { - EXPECT_STREQ("123456", _gc(xasprintf("%4.*s", -5, "123456"))); - EXPECT_STREQ("123456789", _gc(xasprintf("%4.*s", -5, "123456789"))); + EXPECT_STREQ("123456", gc(xasprintf("%4.*s", -5, "123456"))); + EXPECT_STREQ("123456789", gc(xasprintf("%4.*s", -5, "123456789"))); EXPECT_STREQ("12345678901234567890", - _gc(xasprintf("%4.*s", -5, "12345678901234567890"))); + gc(xasprintf("%4.*s", -5, "12345678901234567890"))); EXPECT_STREQ("123456789012345678901234567890", - _gc(xasprintf("%4.*s", -5, "123456789012345678901234567890"))); + gc(xasprintf("%4.*s", -5, "123456789012345678901234567890"))); EXPECT_STREQ( "1234567890123456789012345678901234567890", - _gc(xasprintf("%4.*s", -5, "1234567890123456789012345678901234567890"))); + gc(xasprintf("%4.*s", -5, "1234567890123456789012345678901234567890"))); EXPECT_STREQ( "12345678901234567890123456789012345678901234567890", - _gc(xasprintf("%4.*s", -5, - "12345678901234567890123456789012345678901234567890"))); + gc(xasprintf("%4.*s", -5, + "12345678901234567890123456789012345678901234567890"))); EXPECT_STREQ( "123456789012345678901234567890123456789012345678901234567890", - _gc(xasprintf( + gc(xasprintf( "%4.*s", -5, "123456789012345678901234567890123456789012345678901234567890"))); EXPECT_STREQ("Wide character output test", - _gc(xasprintf("%S", L"Wide character output test"))); + gc(xasprintf("%S", L"Wide character output test"))); } TEST(fmt, g) { - EXPECT_STREQ("1", _gc(xasprintf("%g", 1.))); - EXPECT_STREQ(" 1", _gc(xasprintf("% g", 1.))); - EXPECT_STREQ("+1", _gc(xasprintf("%+g", 1.))); - EXPECT_STREQ("-1", _gc(xasprintf("%g", -1.))); - EXPECT_STREQ("10", _gc(xasprintf("%g", 10.))); - EXPECT_STREQ("-10", _gc(xasprintf("%g", -10.))); - EXPECT_STREQ("1e+01", _gc(xasprintf("%.0g", 10.))); - EXPECT_STREQ("-1e+01", _gc(xasprintf("%.0g", -10.))); - EXPECT_STREQ("1", _gc(xasprintf("%.0g", 1.0))); - EXPECT_STREQ("1e-05", _gc(xasprintf("%.0g", 0.00001))); - EXPECT_STREQ("0.0001", _gc(xasprintf("%.0g", 0.0001))); - EXPECT_STREQ("1e+01", _gc(xasprintf("%.1g", 10.))); - EXPECT_STREQ("-1e+01", _gc(xasprintf("%.1g", -10.))); - EXPECT_STREQ("1", _gc(xasprintf("%.1g", 1.0))); - EXPECT_STREQ("1e-05", _gc(xasprintf("%.1g", 0.00001))); - EXPECT_STREQ("0.0001", _gc(xasprintf("%.1g", 0.0001))); - EXPECT_STREQ("0.007812", _gc(xasprintf("%.4g", 0.0078125))); - EXPECT_STREQ("0.023438", _gc(xasprintf("%.5g", 0.0234375))); - EXPECT_STREQ("1e+100", _gc(xasprintf("%g", 1e100))); - EXPECT_STREQ("1e-100", _gc(xasprintf("%g", 1e-100))); - EXPECT_STREQ("-1e-100", _gc(xasprintf("%g", -1e-100))); - EXPECT_STREQ("0.123456", _gc(xasprintf("%g", 0.1234564))); - EXPECT_STREQ("0.123457", _gc(xasprintf("%g", 0.1234566))); - EXPECT_STREQ("3.14159", _gc(xasprintf("%g", 0x1.921fb54442d1846ap+1))); - EXPECT_STREQ("0", _gc(xasprintf("%g", 0.))); - EXPECT_STREQ("-0", _gc(xasprintf("%g", -0.))); - EXPECT_STREQ("nan", _gc(xasprintf("%g", NAN))); - EXPECT_STREQ("-nan", _gc(xasprintf("%g", -NAN))); - EXPECT_STREQ("inf", _gc(xasprintf("%g", INFINITY))); - EXPECT_STREQ("-inf", _gc(xasprintf("%g", -INFINITY))); - EXPECT_STREQ("2.22507e-308", _gc(xasprintf("%g", __DBL_MIN__))); - EXPECT_STREQ("1.79769e+308", _gc(xasprintf("%g", __DBL_MAX__))); - EXPECT_STREQ("0", _gc(xasprintf("%G", 0.))); - EXPECT_STREQ("-0", _gc(xasprintf("%G", -0.))); - EXPECT_STREQ("NAN", _gc(xasprintf("%G", NAN))); - EXPECT_STREQ("-NAN", _gc(xasprintf("%G", -NAN))); - EXPECT_STREQ("INF", _gc(xasprintf("%G", INFINITY))); - EXPECT_STREQ("-INF", _gc(xasprintf("%G", -INFINITY))); - EXPECT_STREQ("2.22507E-308", _gc(xasprintf("%G", __DBL_MIN__))); - EXPECT_STREQ("1.79769E+308", _gc(xasprintf("%G", __DBL_MAX__))); - EXPECT_STREQ(" 0", _gc(xasprintf("%13g", 0.))); - EXPECT_STREQ(" -0", _gc(xasprintf("%13g", -0.))); - EXPECT_STREQ(" nan", _gc(xasprintf("%13g", NAN))); - EXPECT_STREQ(" -nan", _gc(xasprintf("%13g", -NAN))); - EXPECT_STREQ(" inf", _gc(xasprintf("%13g", INFINITY))); - EXPECT_STREQ(" -inf", _gc(xasprintf("%13g", -INFINITY))); - EXPECT_STREQ(" 2.22507e-308", _gc(xasprintf("%13g", __DBL_MIN__))); - EXPECT_STREQ(" 1.79769e+308", _gc(xasprintf("%13g", __DBL_MAX__))); - EXPECT_STREQ(" 0", _gc(xasprintf("%13G", 0.))); - EXPECT_STREQ(" -0", _gc(xasprintf("%13G", -0.))); - EXPECT_STREQ(" NAN", _gc(xasprintf("%13G", NAN))); - EXPECT_STREQ(" -NAN", _gc(xasprintf("%13G", -NAN))); - EXPECT_STREQ(" INF", _gc(xasprintf("%13G", INFINITY))); - EXPECT_STREQ(" -INF", _gc(xasprintf("%13G", -INFINITY))); - EXPECT_STREQ(" 2.22507E-308", _gc(xasprintf("%13G", __DBL_MIN__))); - EXPECT_STREQ(" 1.79769E+308", _gc(xasprintf("%13G", __DBL_MAX__))); + EXPECT_STREQ("1", gc(xasprintf("%g", 1.))); + EXPECT_STREQ(" 1", gc(xasprintf("% g", 1.))); + EXPECT_STREQ("+1", gc(xasprintf("%+g", 1.))); + EXPECT_STREQ("-1", gc(xasprintf("%g", -1.))); + EXPECT_STREQ("10", gc(xasprintf("%g", 10.))); + EXPECT_STREQ("-10", gc(xasprintf("%g", -10.))); + EXPECT_STREQ("1e+01", gc(xasprintf("%.0g", 10.))); + EXPECT_STREQ("-1e+01", gc(xasprintf("%.0g", -10.))); + EXPECT_STREQ("1", gc(xasprintf("%.0g", 1.0))); + EXPECT_STREQ("1e-05", gc(xasprintf("%.0g", 0.00001))); + EXPECT_STREQ("0.0001", gc(xasprintf("%.0g", 0.0001))); + EXPECT_STREQ("1e+01", gc(xasprintf("%.1g", 10.))); + EXPECT_STREQ("-1e+01", gc(xasprintf("%.1g", -10.))); + EXPECT_STREQ("1", gc(xasprintf("%.1g", 1.0))); + EXPECT_STREQ("1e-05", gc(xasprintf("%.1g", 0.00001))); + EXPECT_STREQ("0.0001", gc(xasprintf("%.1g", 0.0001))); + EXPECT_STREQ("0.007812", gc(xasprintf("%.4g", 0.0078125))); + EXPECT_STREQ("0.023438", gc(xasprintf("%.5g", 0.0234375))); + EXPECT_STREQ("1e+100", gc(xasprintf("%g", 1e100))); + EXPECT_STREQ("1e-100", gc(xasprintf("%g", 1e-100))); + EXPECT_STREQ("-1e-100", gc(xasprintf("%g", -1e-100))); + EXPECT_STREQ("0.123456", gc(xasprintf("%g", 0.1234564))); + EXPECT_STREQ("0.123457", gc(xasprintf("%g", 0.1234566))); + EXPECT_STREQ("3.14159", gc(xasprintf("%g", 0x1.921fb54442d1846ap+1))); + EXPECT_STREQ("0", gc(xasprintf("%g", 0.))); + EXPECT_STREQ("-0", gc(xasprintf("%g", -0.))); + EXPECT_STREQ("nan", gc(xasprintf("%g", NAN))); + EXPECT_STREQ("-nan", gc(xasprintf("%g", -NAN))); + EXPECT_STREQ("inf", gc(xasprintf("%g", INFINITY))); + EXPECT_STREQ("-inf", gc(xasprintf("%g", -INFINITY))); + EXPECT_STREQ("2.22507e-308", gc(xasprintf("%g", __DBL_MIN__))); + EXPECT_STREQ("1.79769e+308", gc(xasprintf("%g", __DBL_MAX__))); + EXPECT_STREQ("0", gc(xasprintf("%G", 0.))); + EXPECT_STREQ("-0", gc(xasprintf("%G", -0.))); + EXPECT_STREQ("NAN", gc(xasprintf("%G", NAN))); + EXPECT_STREQ("-NAN", gc(xasprintf("%G", -NAN))); + EXPECT_STREQ("INF", gc(xasprintf("%G", INFINITY))); + EXPECT_STREQ("-INF", gc(xasprintf("%G", -INFINITY))); + EXPECT_STREQ("2.22507E-308", gc(xasprintf("%G", __DBL_MIN__))); + EXPECT_STREQ("1.79769E+308", gc(xasprintf("%G", __DBL_MAX__))); + EXPECT_STREQ(" 0", gc(xasprintf("%13g", 0.))); + EXPECT_STREQ(" -0", gc(xasprintf("%13g", -0.))); + EXPECT_STREQ(" nan", gc(xasprintf("%13g", NAN))); + EXPECT_STREQ(" -nan", gc(xasprintf("%13g", -NAN))); + EXPECT_STREQ(" inf", gc(xasprintf("%13g", INFINITY))); + EXPECT_STREQ(" -inf", gc(xasprintf("%13g", -INFINITY))); + EXPECT_STREQ(" 2.22507e-308", gc(xasprintf("%13g", __DBL_MIN__))); + EXPECT_STREQ(" 1.79769e+308", gc(xasprintf("%13g", __DBL_MAX__))); + EXPECT_STREQ(" 0", gc(xasprintf("%13G", 0.))); + EXPECT_STREQ(" -0", gc(xasprintf("%13G", -0.))); + EXPECT_STREQ(" NAN", gc(xasprintf("%13G", NAN))); + EXPECT_STREQ(" -NAN", gc(xasprintf("%13G", -NAN))); + EXPECT_STREQ(" INF", gc(xasprintf("%13G", INFINITY))); + EXPECT_STREQ(" -INF", gc(xasprintf("%13G", -INFINITY))); + EXPECT_STREQ(" 2.22507E-308", gc(xasprintf("%13G", __DBL_MIN__))); + EXPECT_STREQ(" 1.79769E+308", gc(xasprintf("%13G", __DBL_MAX__))); } TEST(fmt, f) { - EXPECT_STREQ("3.141593", _gc(xasprintf("%f", 0x1.921fb54442d1846ap+1))); + EXPECT_STREQ("3.141593", gc(xasprintf("%f", 0x1.921fb54442d1846ap+1))); EXPECT_STREQ("3.1415926535897931", - _gc(xasprintf("%.16f", 0x1.921fb54442d1846ap+1))); + gc(xasprintf("%.16f", 0x1.921fb54442d1846ap+1))); EXPECT_STREQ("100000000000000001590289110975991804683608085639452813" "89781327557747838772170381060813469985856815104.000000", - _gc(xasprintf("%f", 1e100))); - EXPECT_STREQ("0.000000", _gc(xasprintf("%f", 0.))); - EXPECT_STREQ("-0.000000", _gc(xasprintf("%f", -0.))); - EXPECT_STREQ("nan", _gc(xasprintf("%f", NAN))); - EXPECT_STREQ("-nan", _gc(xasprintf("%f", -NAN))); - EXPECT_STREQ("inf", _gc(xasprintf("%f", INFINITY))); - EXPECT_STREQ("-inf", _gc(xasprintf("%f", -INFINITY))); - EXPECT_STREQ("0.000000", _gc(xasprintf("%f", __DBL_MIN__))); + gc(xasprintf("%f", 1e100))); + EXPECT_STREQ("0.000000", gc(xasprintf("%f", 0.))); + EXPECT_STREQ("-0.000000", gc(xasprintf("%f", -0.))); + EXPECT_STREQ("nan", gc(xasprintf("%f", NAN))); + EXPECT_STREQ("-nan", gc(xasprintf("%f", -NAN))); + EXPECT_STREQ("inf", gc(xasprintf("%f", INFINITY))); + EXPECT_STREQ("-inf", gc(xasprintf("%f", -INFINITY))); + EXPECT_STREQ("0.000000", gc(xasprintf("%f", __DBL_MIN__))); EXPECT_STREQ( "179769313486231570814527423731704356798070567525844996598917476803157260" "780028538760589558632766878171540458953514382464234321326889464182768467" "546703537516986049910576551282076245490090389328944075868508455133942304" "583236903222948165808559332123348274797826204144723168738177180919299881" "250404026184124858368.000000", - _gc(xasprintf("%f", __DBL_MAX__))); - EXPECT_STREQ("0.000000", _gc(xasprintf("%F", 0.))); - EXPECT_STREQ("-0.000000", _gc(xasprintf("%F", -0.))); - EXPECT_STREQ("NAN", _gc(xasprintf("%F", NAN))); - EXPECT_STREQ("-NAN", _gc(xasprintf("%F", -NAN))); - EXPECT_STREQ("INF", _gc(xasprintf("%F", INFINITY))); - EXPECT_STREQ("-INF", _gc(xasprintf("%F", -INFINITY))); - EXPECT_STREQ("0.000000", _gc(xasprintf("%F", __DBL_MIN__))); + gc(xasprintf("%f", __DBL_MAX__))); + EXPECT_STREQ("0.000000", gc(xasprintf("%F", 0.))); + EXPECT_STREQ("-0.000000", gc(xasprintf("%F", -0.))); + EXPECT_STREQ("NAN", gc(xasprintf("%F", NAN))); + EXPECT_STREQ("-NAN", gc(xasprintf("%F", -NAN))); + EXPECT_STREQ("INF", gc(xasprintf("%F", INFINITY))); + EXPECT_STREQ("-INF", gc(xasprintf("%F", -INFINITY))); + EXPECT_STREQ("0.000000", gc(xasprintf("%F", __DBL_MIN__))); EXPECT_STREQ( "179769313486231570814527423731704356798070567525844996598917476803157260" "780028538760589558632766878171540458953514382464234321326889464182768467" "546703537516986049910576551282076245490090389328944075868508455133942304" "583236903222948165808559332123348274797826204144723168738177180919299881" "250404026184124858368.000000", - _gc(xasprintf("%F", __DBL_MAX__))); - EXPECT_STREQ(" 0.000000", _gc(xasprintf("%10f", 0.))); - EXPECT_STREQ(" -0.000000", _gc(xasprintf("%10f", -0.))); - EXPECT_STREQ(" nan", _gc(xasprintf("%10f", NAN))); - EXPECT_STREQ(" -nan", _gc(xasprintf("%10f", -NAN))); - EXPECT_STREQ(" inf", _gc(xasprintf("%10f", INFINITY))); - EXPECT_STREQ(" -inf", _gc(xasprintf("%10f", -INFINITY))); - EXPECT_STREQ(" 0.000000", _gc(xasprintf("%10f", __DBL_MIN__))); + gc(xasprintf("%F", __DBL_MAX__))); + EXPECT_STREQ(" 0.000000", gc(xasprintf("%10f", 0.))); + EXPECT_STREQ(" -0.000000", gc(xasprintf("%10f", -0.))); + EXPECT_STREQ(" nan", gc(xasprintf("%10f", NAN))); + EXPECT_STREQ(" -nan", gc(xasprintf("%10f", -NAN))); + EXPECT_STREQ(" inf", gc(xasprintf("%10f", INFINITY))); + EXPECT_STREQ(" -inf", gc(xasprintf("%10f", -INFINITY))); + EXPECT_STREQ(" 0.000000", gc(xasprintf("%10f", __DBL_MIN__))); EXPECT_STREQ( "179769313486231570814527423731704356798070567525844996598917476803157260" "780028538760589558632766878171540458953514382464234321326889464182768467" "546703537516986049910576551282076245490090389328944075868508455133942304" "583236903222948165808559332123348274797826204144723168738177180919299881" "250404026184124858368.000000", - _gc(xasprintf("%10f", __DBL_MAX__))); - EXPECT_STREQ(" 0.000000", _gc(xasprintf("%10F", 0.))); - EXPECT_STREQ(" -0.000000", _gc(xasprintf("%10F", -0.))); - EXPECT_STREQ(" NAN", _gc(xasprintf("%10F", NAN))); - EXPECT_STREQ(" -NAN", _gc(xasprintf("%10F", -NAN))); - EXPECT_STREQ(" INF", _gc(xasprintf("%10F", INFINITY))); - EXPECT_STREQ(" -INF", _gc(xasprintf("%10F", -INFINITY))); - EXPECT_STREQ(" 0.000000", _gc(xasprintf("%10F", __DBL_MIN__))); + gc(xasprintf("%10f", __DBL_MAX__))); + EXPECT_STREQ(" 0.000000", gc(xasprintf("%10F", 0.))); + EXPECT_STREQ(" -0.000000", gc(xasprintf("%10F", -0.))); + EXPECT_STREQ(" NAN", gc(xasprintf("%10F", NAN))); + EXPECT_STREQ(" -NAN", gc(xasprintf("%10F", -NAN))); + EXPECT_STREQ(" INF", gc(xasprintf("%10F", INFINITY))); + EXPECT_STREQ(" -INF", gc(xasprintf("%10F", -INFINITY))); + EXPECT_STREQ(" 0.000000", gc(xasprintf("%10F", __DBL_MIN__))); EXPECT_STREQ( "179769313486231570814527423731704356798070567525844996598917476803157260" "780028538760589558632766878171540458953514382464234321326889464182768467" "546703537516986049910576551282076245490090389328944075868508455133942304" "583236903222948165808559332123348274797826204144723168738177180919299881" "250404026184124858368.000000", - _gc(xasprintf("%10F", __DBL_MAX__))); + gc(xasprintf("%10F", __DBL_MAX__))); } TEST(fmt, e) { - EXPECT_STREQ("3.14159", _gc(xasprintf("%g", 0x1.921fb54442d1846ap+1))); + EXPECT_STREQ("3.14159", gc(xasprintf("%g", 0x1.921fb54442d1846ap+1))); EXPECT_STREQ("3.141592653589793", - _gc(xasprintf("%.16g", 0x1.921fb54442d1846ap+1))); - EXPECT_STREQ("1.000000e+100", _gc(xasprintf("%e", 1e100))); - EXPECT_STREQ("1.000000E+100", _gc(xasprintf("%E", 1e100))); - EXPECT_STREQ(" 0.000000e+00", _gc(xasprintf("%24e", 0.))); - EXPECT_STREQ(" -0.000000e+00", _gc(xasprintf("%24e", -0.))); - EXPECT_STREQ(" nan", _gc(xasprintf("%24e", NAN))); - EXPECT_STREQ(" -nan", _gc(xasprintf("%24e", -NAN))); - EXPECT_STREQ(" inf", _gc(xasprintf("%24e", INFINITY))); - EXPECT_STREQ(" -inf", _gc(xasprintf("%24e", -INFINITY))); - EXPECT_STREQ(" 2.225074e-308", _gc(xasprintf("%24e", __DBL_MIN__))); - EXPECT_STREQ(" 1.797693e+308", _gc(xasprintf("%24e", __DBL_MAX__))); - EXPECT_STREQ(" 0.000000E+00", _gc(xasprintf("%24E", 0.))); - EXPECT_STREQ(" -0.000000E+00", _gc(xasprintf("%24E", -0.))); - EXPECT_STREQ(" NAN", _gc(xasprintf("%24E", NAN))); - EXPECT_STREQ(" -NAN", _gc(xasprintf("%24E", -NAN))); - EXPECT_STREQ(" INF", _gc(xasprintf("%24E", INFINITY))); - EXPECT_STREQ(" -INF", _gc(xasprintf("%24E", -INFINITY))); - EXPECT_STREQ(" 2.225074E-308", _gc(xasprintf("%24E", __DBL_MIN__))); - EXPECT_STREQ(" 1.797693E+308", _gc(xasprintf("%24E", __DBL_MAX__))); - EXPECT_STREQ(" +0.000000e+00", _gc(xasprintf("%+24e", 0.))); - EXPECT_STREQ(" -0.000000e+00", _gc(xasprintf("%+24e", -0.))); - EXPECT_STREQ(" +nan", _gc(xasprintf("%+24e", NAN))); - EXPECT_STREQ(" -nan", _gc(xasprintf("%+24e", -NAN))); - EXPECT_STREQ(" +inf", _gc(xasprintf("%+24e", INFINITY))); - EXPECT_STREQ(" -inf", _gc(xasprintf("%+24e", -INFINITY))); - EXPECT_STREQ(" +2.225074e-308", - _gc(xasprintf("%+24e", __DBL_MIN__))); - EXPECT_STREQ(" +1.797693e+308", - _gc(xasprintf("%+24e", __DBL_MAX__))); - EXPECT_STREQ(" +0.000000E+00", _gc(xasprintf("%+24E", 0.))); - EXPECT_STREQ(" -0.000000E+00", _gc(xasprintf("%+24E", -0.))); - EXPECT_STREQ(" +NAN", _gc(xasprintf("%+24E", NAN))); - EXPECT_STREQ(" -NAN", _gc(xasprintf("%+24E", -NAN))); - EXPECT_STREQ(" +INF", _gc(xasprintf("%+24E", INFINITY))); - EXPECT_STREQ(" -INF", _gc(xasprintf("%+24E", -INFINITY))); - EXPECT_STREQ(" +2.225074E-308", - _gc(xasprintf("%+24E", __DBL_MIN__))); - EXPECT_STREQ(" +1.797693E+308", - _gc(xasprintf("%+24E", __DBL_MAX__))); + gc(xasprintf("%.16g", 0x1.921fb54442d1846ap+1))); + EXPECT_STREQ("1.000000e+100", gc(xasprintf("%e", 1e100))); + EXPECT_STREQ("1.000000E+100", gc(xasprintf("%E", 1e100))); + EXPECT_STREQ(" 0.000000e+00", gc(xasprintf("%24e", 0.))); + EXPECT_STREQ(" -0.000000e+00", gc(xasprintf("%24e", -0.))); + EXPECT_STREQ(" nan", gc(xasprintf("%24e", NAN))); + EXPECT_STREQ(" -nan", gc(xasprintf("%24e", -NAN))); + EXPECT_STREQ(" inf", gc(xasprintf("%24e", INFINITY))); + EXPECT_STREQ(" -inf", gc(xasprintf("%24e", -INFINITY))); + EXPECT_STREQ(" 2.225074e-308", gc(xasprintf("%24e", __DBL_MIN__))); + EXPECT_STREQ(" 1.797693e+308", gc(xasprintf("%24e", __DBL_MAX__))); + EXPECT_STREQ(" 0.000000E+00", gc(xasprintf("%24E", 0.))); + EXPECT_STREQ(" -0.000000E+00", gc(xasprintf("%24E", -0.))); + EXPECT_STREQ(" NAN", gc(xasprintf("%24E", NAN))); + EXPECT_STREQ(" -NAN", gc(xasprintf("%24E", -NAN))); + EXPECT_STREQ(" INF", gc(xasprintf("%24E", INFINITY))); + EXPECT_STREQ(" -INF", gc(xasprintf("%24E", -INFINITY))); + EXPECT_STREQ(" 2.225074E-308", gc(xasprintf("%24E", __DBL_MIN__))); + EXPECT_STREQ(" 1.797693E+308", gc(xasprintf("%24E", __DBL_MAX__))); + EXPECT_STREQ(" +0.000000e+00", gc(xasprintf("%+24e", 0.))); + EXPECT_STREQ(" -0.000000e+00", gc(xasprintf("%+24e", -0.))); + EXPECT_STREQ(" +nan", gc(xasprintf("%+24e", NAN))); + EXPECT_STREQ(" -nan", gc(xasprintf("%+24e", -NAN))); + EXPECT_STREQ(" +inf", gc(xasprintf("%+24e", INFINITY))); + EXPECT_STREQ(" -inf", gc(xasprintf("%+24e", -INFINITY))); + EXPECT_STREQ(" +2.225074e-308", gc(xasprintf("%+24e", __DBL_MIN__))); + EXPECT_STREQ(" +1.797693e+308", gc(xasprintf("%+24e", __DBL_MAX__))); + EXPECT_STREQ(" +0.000000E+00", gc(xasprintf("%+24E", 0.))); + EXPECT_STREQ(" -0.000000E+00", gc(xasprintf("%+24E", -0.))); + EXPECT_STREQ(" +NAN", gc(xasprintf("%+24E", NAN))); + EXPECT_STREQ(" -NAN", gc(xasprintf("%+24E", -NAN))); + EXPECT_STREQ(" +INF", gc(xasprintf("%+24E", INFINITY))); + EXPECT_STREQ(" -INF", gc(xasprintf("%+24E", -INFINITY))); + EXPECT_STREQ(" +2.225074E-308", gc(xasprintf("%+24E", __DBL_MIN__))); + EXPECT_STREQ(" +1.797693E+308", gc(xasprintf("%+24E", __DBL_MAX__))); } TEST(fmt, a) { - EXPECT_STREQ("0x0p+0", _gc(xasprintf("%a", 0.))); - EXPECT_STREQ("0x0p+0", _gc(xasprintf("%.a", 0.))); - EXPECT_STREQ(" 0x0p+0", _gc(xasprintf("%7.a", 0.))); - EXPECT_STREQ("0x0.000p+0", _gc(xasprintf("%.3a", 0.))); - // EXPECT_STREQ(" 0x0.000p+0\n", _gc(xasprintf("%11.3a\n", 0.))); // TODO - EXPECT_STREQ("inf\n", _gc(xasprintf("%g\n", INFINITY))); - EXPECT_STREQ(" inf\n", _gc(xasprintf("%5g\n", INFINITY))); - EXPECT_STREQ(" +inf\n", _gc(xasprintf("%+5g\n", INFINITY))); - EXPECT_STREQ(" inf\n", _gc(xasprintf("% g\n", INFINITY))); - EXPECT_STREQ("-inf\n", _gc(xasprintf("% g\n", -INFINITY))); + EXPECT_STREQ("0x0p+0", gc(xasprintf("%a", 0.))); + EXPECT_STREQ("0x0p+0", gc(xasprintf("%.a", 0.))); + EXPECT_STREQ(" 0x0p+0", gc(xasprintf("%7.a", 0.))); + EXPECT_STREQ("0x0.000p+0", gc(xasprintf("%.3a", 0.))); + // EXPECT_STREQ(" 0x0.000p+0\n", gc(xasprintf("%11.3a\n", 0.))); // TODO + EXPECT_STREQ("inf\n", gc(xasprintf("%g\n", INFINITY))); + EXPECT_STREQ(" inf\n", gc(xasprintf("%5g\n", INFINITY))); + EXPECT_STREQ(" +inf\n", gc(xasprintf("%+5g\n", INFINITY))); + EXPECT_STREQ(" inf\n", gc(xasprintf("% g\n", INFINITY))); + EXPECT_STREQ("-inf\n", gc(xasprintf("% g\n", -INFINITY))); EXPECT_STREQ("0x1.921fb54442d18p+1", - _gc(xasprintf("%a", 0x1.921fb54442d1846ap+1))); + gc(xasprintf("%a", 0x1.921fb54442d1846ap+1))); EXPECT_STREQ("0X1.921FB54442D18P+1", - _gc(xasprintf("%A", 0x1.921fb54442d1846ap+1))); - EXPECT_STREQ(" 0x0p+0", _gc(xasprintf("%24a", 0.))); - EXPECT_STREQ(" -0x0p+0", _gc(xasprintf("%24a", -0.))); - EXPECT_STREQ(" nan", _gc(xasprintf("%24a", NAN))); - EXPECT_STREQ(" -nan", _gc(xasprintf("%24a", -NAN))); - EXPECT_STREQ(" inf", _gc(xasprintf("%24a", INFINITY))); - EXPECT_STREQ(" -inf", _gc(xasprintf("%24a", -INFINITY))); - EXPECT_STREQ(" 0x1p-1022", _gc(xasprintf("%24a", __DBL_MIN__))); - EXPECT_STREQ(" 0x1.fffffffffffffp+1023", _gc(xasprintf("%24a", __DBL_MAX__))); - EXPECT_STREQ(" 0X0P+0", _gc(xasprintf("%24A", 0.))); - EXPECT_STREQ(" -0X0P+0", _gc(xasprintf("%24A", -0.))); - EXPECT_STREQ(" NAN", _gc(xasprintf("%24A", NAN))); - EXPECT_STREQ(" -NAN", _gc(xasprintf("%24A", -NAN))); - EXPECT_STREQ(" INF", _gc(xasprintf("%24A", INFINITY))); - EXPECT_STREQ(" -INF", _gc(xasprintf("%24A", -INFINITY))); - EXPECT_STREQ(" 0X1P-1022", _gc(xasprintf("%24A", __DBL_MIN__))); - EXPECT_STREQ(" 0X1.FFFFFFFFFFFFFP+1023", _gc(xasprintf("%24A", __DBL_MAX__))); - EXPECT_STREQ(" 0X1.E9A488E8A71DEP+14", _gc(xasprintf("%24A", 31337.1337))); - EXPECT_STREQ(" -0X1.E9A488E8A71DEP+14", _gc(xasprintf("%24A", -31337.1337))); + gc(xasprintf("%A", 0x1.921fb54442d1846ap+1))); + EXPECT_STREQ(" 0x0p+0", gc(xasprintf("%24a", 0.))); + EXPECT_STREQ(" -0x0p+0", gc(xasprintf("%24a", -0.))); + EXPECT_STREQ(" nan", gc(xasprintf("%24a", NAN))); + EXPECT_STREQ(" -nan", gc(xasprintf("%24a", -NAN))); + EXPECT_STREQ(" inf", gc(xasprintf("%24a", INFINITY))); + EXPECT_STREQ(" -inf", gc(xasprintf("%24a", -INFINITY))); + EXPECT_STREQ(" 0x1p-1022", gc(xasprintf("%24a", __DBL_MIN__))); + EXPECT_STREQ(" 0x1.fffffffffffffp+1023", gc(xasprintf("%24a", __DBL_MAX__))); + EXPECT_STREQ(" 0X0P+0", gc(xasprintf("%24A", 0.))); + EXPECT_STREQ(" -0X0P+0", gc(xasprintf("%24A", -0.))); + EXPECT_STREQ(" NAN", gc(xasprintf("%24A", NAN))); + EXPECT_STREQ(" -NAN", gc(xasprintf("%24A", -NAN))); + EXPECT_STREQ(" INF", gc(xasprintf("%24A", INFINITY))); + EXPECT_STREQ(" -INF", gc(xasprintf("%24A", -INFINITY))); + EXPECT_STREQ(" 0X1P-1022", gc(xasprintf("%24A", __DBL_MIN__))); + EXPECT_STREQ(" 0X1.FFFFFFFFFFFFFP+1023", gc(xasprintf("%24A", __DBL_MAX__))); + EXPECT_STREQ(" 0X1.E9A488E8A71DEP+14", gc(xasprintf("%24A", 31337.1337))); + EXPECT_STREQ(" -0X1.E9A488E8A71DEP+14", gc(xasprintf("%24A", -31337.1337))); } TEST(fmt, p) { - EXPECT_STREQ("0x1", _gc(xasprintf("%p", 1))); - EXPECT_STREQ("0x10", _gc(xasprintf("%p", 16))); - EXPECT_STREQ("0x31337", _gc(xasprintf("%p", 0x31337))); - EXPECT_STREQ("0xffffffff", _gc(xasprintf("%p", 0xffffffff))); - EXPECT_STREQ("0xffff800000031337", _gc(xasprintf("%p", 0xffff800000031337))); - EXPECT_STREQ(" 0x1", _gc(xasprintf("%10p", 1))); - EXPECT_STREQ(" 0x10", _gc(xasprintf("%10p", 16))); - EXPECT_STREQ(" 0x31337", _gc(xasprintf("%10p", 0x31337))); - EXPECT_STREQ("0xffffffff", _gc(xasprintf("%10p", 0xffffffff))); + EXPECT_STREQ("0x1", gc(xasprintf("%p", 1))); + EXPECT_STREQ("0x10", gc(xasprintf("%p", 16))); + EXPECT_STREQ("0x31337", gc(xasprintf("%p", 0x31337))); + EXPECT_STREQ("0xffffffff", gc(xasprintf("%p", 0xffffffff))); + EXPECT_STREQ("0xffff800000031337", gc(xasprintf("%p", 0xffff800000031337))); + EXPECT_STREQ(" 0x1", gc(xasprintf("%10p", 1))); + EXPECT_STREQ(" 0x10", gc(xasprintf("%10p", 16))); + EXPECT_STREQ(" 0x31337", gc(xasprintf("%10p", 0x31337))); + EXPECT_STREQ("0xffffffff", gc(xasprintf("%10p", 0xffffffff))); + EXPECT_STREQ("0xffff800000031337", gc(xasprintf("%10p", 0xffff800000031337))); + EXPECT_STREQ("0x00000001", gc(xasprintf("%010p", 1))); + EXPECT_STREQ("0x00000010", gc(xasprintf("%010p", 16))); + EXPECT_STREQ("0x00031337", gc(xasprintf("%010p", 0x31337))); + EXPECT_STREQ("0xffffffff", gc(xasprintf("%010p", 0xffffffff))); EXPECT_STREQ("0xffff800000031337", - _gc(xasprintf("%10p", 0xffff800000031337))); - EXPECT_STREQ("0x00000001", _gc(xasprintf("%010p", 1))); - EXPECT_STREQ("0x00000010", _gc(xasprintf("%010p", 16))); - EXPECT_STREQ("0x00031337", _gc(xasprintf("%010p", 0x31337))); - EXPECT_STREQ("0xffffffff", _gc(xasprintf("%010p", 0xffffffff))); + gc(xasprintf("%010p", 0xffff800000031337))); + EXPECT_STREQ("0x1 ", gc(xasprintf("%-10p", 1))); + EXPECT_STREQ("0x10 ", gc(xasprintf("%-10p", 16))); + EXPECT_STREQ("0x31337 ", gc(xasprintf("%-10p", 0x31337))); + EXPECT_STREQ("0xffffffff", gc(xasprintf("%-10p", 0xffffffff))); EXPECT_STREQ("0xffff800000031337", - _gc(xasprintf("%010p", 0xffff800000031337))); - EXPECT_STREQ("0x1 ", _gc(xasprintf("%-10p", 1))); - EXPECT_STREQ("0x10 ", _gc(xasprintf("%-10p", 16))); - EXPECT_STREQ("0x31337 ", _gc(xasprintf("%-10p", 0x31337))); - EXPECT_STREQ("0xffffffff", _gc(xasprintf("%-10p", 0xffffffff))); + gc(xasprintf("%-10p", 0xffff800000031337))); + EXPECT_STREQ(" 0x1", gc(xasprintf("%+10p", 1))); + EXPECT_STREQ(" 0x10", gc(xasprintf("%+10p", 16))); + EXPECT_STREQ(" 0x31337", gc(xasprintf("%+10p", 0x31337))); + EXPECT_STREQ("0xffffffff", gc(xasprintf("%+10p", 0xffffffff))); EXPECT_STREQ("0xffff800000031337", - _gc(xasprintf("%-10p", 0xffff800000031337))); - EXPECT_STREQ(" 0x1", _gc(xasprintf("%+10p", 1))); - EXPECT_STREQ(" 0x10", _gc(xasprintf("%+10p", 16))); - EXPECT_STREQ(" 0x31337", _gc(xasprintf("%+10p", 0x31337))); - EXPECT_STREQ("0xffffffff", _gc(xasprintf("%+10p", 0xffffffff))); + gc(xasprintf("%+10p", 0xffff800000031337))); + EXPECT_STREQ(" 0x1", gc(xasprintf("% 10p", 1))); + EXPECT_STREQ(" 0x10", gc(xasprintf("% 10p", 16))); + EXPECT_STREQ(" 0x31337", gc(xasprintf("% 10p", 0x31337))); + EXPECT_STREQ("0xffffffff", gc(xasprintf("% 10p", 0xffffffff))); EXPECT_STREQ("0xffff800000031337", - _gc(xasprintf("%+10p", 0xffff800000031337))); - EXPECT_STREQ(" 0x1", _gc(xasprintf("% 10p", 1))); - EXPECT_STREQ(" 0x10", _gc(xasprintf("% 10p", 16))); - EXPECT_STREQ(" 0x31337", _gc(xasprintf("% 10p", 0x31337))); - EXPECT_STREQ("0xffffffff", _gc(xasprintf("% 10p", 0xffffffff))); - EXPECT_STREQ("0xffff800000031337", - _gc(xasprintf("% 10p", 0xffff800000031337))); + gc(xasprintf("% 10p", 0xffff800000031337))); } TEST(fmt, quoted) { - ASSERT_STREQ(" \"hello\"", _gc(xasprintf("%`*.*s", 10, 5, "hello"))); - ASSERT_STREQ("\"hello\" ", _gc(xasprintf("%-`*.*s", 10, 5, "hello"))); + ASSERT_STREQ(" \"hello\"", gc(xasprintf("%`*.*s", 10, 5, "hello"))); + ASSERT_STREQ("\"hello\" ", gc(xasprintf("%-`*.*s", 10, 5, "hello"))); } TEST(fmt, nulCharacter) { diff --git a/test/libc/stdio/fprintf_test.c b/test/libc/stdio/fprintf_test.c index 66cd258c5..55011e438 100644 --- a/test/libc/stdio/fprintf_test.c +++ b/test/libc/stdio/fprintf_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" #include "libc/x/xasprintf.h" diff --git a/test/libc/stdio/fputs_test.c b/test/libc/stdio/fputs_test.c index b04946740..052f3c94d 100644 --- a/test/libc/stdio/fputs_test.c +++ b/test/libc/stdio/fputs_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/test/libc/stdio/ftell_test.c b/test/libc/stdio/ftell_test.c index f15b5303c..ee95748e9 100644 --- a/test/libc/stdio/ftell_test.c +++ b/test/libc/stdio/ftell_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/stdio/fwrite_test.c b/test/libc/stdio/fwrite_test.c index d4aa47f15..e06d10dca 100644 --- a/test/libc/stdio/fwrite_test.c +++ b/test/libc/stdio/fwrite_test.c @@ -21,7 +21,7 @@ #include "libc/calls/struct/sigset.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/rand.h" diff --git a/test/libc/stdio/getentropy_test.c b/test/libc/stdio/getentropy_test.c index 6d9c19b68..73b860e39 100644 --- a/test/libc/stdio/getentropy_test.c +++ b/test/libc/stdio/getentropy_test.c @@ -64,7 +64,7 @@ TEST(getentropy, test) { double e, w = 7.7; struct sigaction sa; int i, k, m, n = 999; - char *buf = _gc(calloc(1, n)); + char *buf = gc(calloc(1, n)); sa.sa_flags = 0; sa.sa_handler = OnSig; sigemptyset(&sa.sa_mask); diff --git a/test/libc/stdio/iconv_test.c b/test/libc/stdio/iconv_test.c index c6a8799f6..15684679d 100644 --- a/test/libc/stdio/iconv_test.c +++ b/test/libc/stdio/iconv_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/stdio/iconv.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/test/libc/stdio/memory_test.c b/test/libc/stdio/memory_test.c index 0c02299c7..97656acb2 100644 --- a/test/libc/stdio/memory_test.c +++ b/test/libc/stdio/memory_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/internal.h" #include "libc/stdio/stdio.h" diff --git a/test/libc/stdio/mt19937_test.c b/test/libc/stdio/mt19937_test.c index 1e022dfb1..696685a74 100644 --- a/test/libc/stdio/mt19937_test.c +++ b/test/libc/stdio/mt19937_test.c @@ -19,7 +19,7 @@ #include "libc/errno.h" #include "libc/log/check.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/rand.h" diff --git a/test/libc/stdio/palandprintf_test.c b/test/libc/stdio/palandprintf_test.c index 05accd051..9a67f6732 100644 --- a/test/libc/stdio/palandprintf_test.c +++ b/test/libc/stdio/palandprintf_test.c @@ -39,7 +39,7 @@ #include "libc/x/xasprintf.h" char buffer[1000]; -/* #define Format(...) _gc(xasprintf(__VA_ARGS__)) */ +/* #define Format(...) gc(xasprintf(__VA_ARGS__)) */ #define Format(...) (snprintf(buffer, sizeof(buffer), __VA_ARGS__), buffer) TEST(sprintf, test_space_flag) { @@ -572,13 +572,13 @@ TEST(xasprintf, hugeNtoa) { ASSERT_STREQ( "0b1111111111111111111111111111111111111111111111111111111111111111111111" "1111111111111111111111111111111111111111111111111111111111", - _gc(xasprintf("%#jjb", UINT128_MAX))); + gc(xasprintf("%#jjb", UINT128_MAX))); } TEST(xasprintf, twosBane) { - ASSERT_STREQ("-2147483648", _gc(xasprintf("%d", 0x80000000))); + ASSERT_STREQ("-2147483648", gc(xasprintf("%d", 0x80000000))); ASSERT_STREQ("-9223372036854775808", - _gc(xasprintf("%ld", 0x8000000000000000))); + gc(xasprintf("%ld", 0x8000000000000000))); } TEST(snprintf, testFixedWidthString_wontOverrunInput) { diff --git a/test/libc/stdio/popen_test.c b/test/libc/stdio/popen_test.c index 8b5ab630c..f214149b7 100644 --- a/test/libc/stdio/popen_test.c +++ b/test/libc/stdio/popen_test.c @@ -162,7 +162,7 @@ TEST(popen, torture) { return; } int i, n = 4; - pthread_t *t = _gc(malloc(sizeof(pthread_t) * n)); + pthread_t *t = gc(malloc(sizeof(pthread_t) * n)); testlib_extract("/zip/echo.com", "echo.com", 0755); for (i = 0; i < n; ++i) ASSERT_EQ(0, pthread_create(t + i, 0, Worker, 0)); for (i = 0; i < n; ++i) ASSERT_EQ(0, pthread_join(t[i], 0)); diff --git a/test/libc/stdio/sprintf_s_test.c b/test/libc/stdio/sprintf_s_test.c index 325979d90..2d38cd53f 100644 --- a/test/libc/stdio/sprintf_s_test.c +++ b/test/libc/stdio/sprintf_s_test.c @@ -22,7 +22,7 @@ #include "libc/x/x.h" #include "libc/x/xasprintf.h" -#define Format(...) _gc(xasprintf(__VA_ARGS__)) +#define Format(...) gc(xasprintf(__VA_ARGS__)) /** * @fileoverview String formatting tests. diff --git a/test/libc/stdio/tmpfile_test.c b/test/libc/stdio/tmpfile_test.c index a7eedea9f..7b976ccc7 100644 --- a/test/libc/stdio/tmpfile_test.c +++ b/test/libc/stdio/tmpfile_test.c @@ -88,7 +88,7 @@ TEST(tmpfile, renameToRealFile) { f = tmpfile(); ASSERT_EQ(2, fputs("hi", f)); ASSERT_SYS(0, 0, - linkat(AT_FDCWD, _gc(xasprintf("/proc/self/fd/%d", fileno(f))), + linkat(AT_FDCWD, gc(xasprintf("/proc/self/fd/%d", fileno(f))), AT_FDCWD, "real", AT_SYMLINK_FOLLOW)); ASSERT_EQ(0, fclose(f)); ASSERT_NE(NULL, (f = fopen("real", "r"))); diff --git a/test/libc/stdio/zipdir_test.c b/test/libc/stdio/zipdir_test.c index 24fe15694..387ffbfd7 100644 --- a/test/libc/stdio/zipdir_test.c +++ b/test/libc/stdio/zipdir_test.c @@ -21,7 +21,7 @@ #include "libc/calls/struct/stat.h" #include "libc/errno.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/runtime/zipos.internal.h" diff --git a/test/libc/str/bzero_test.c b/test/libc/str/bzero_test.c index 69547c080..25ba4df63 100644 --- a/test/libc/str/bzero_test.c +++ b/test/libc/str/bzero_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" diff --git a/test/libc/str/crc32c_test.c b/test/libc/str/crc32c_test.c index 2f563efc7..84e583621 100644 --- a/test/libc/str/crc32c_test.c +++ b/test/libc/str/crc32c_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/crc32.h" #include "libc/nexgen32e/x86feature.h" diff --git a/test/libc/str/crc32z_test.c b/test/libc/str/crc32z_test.c index 4358396d1..7099a5a11 100644 --- a/test/libc/str/crc32z_test.c +++ b/test/libc/str/crc32z_test.c @@ -19,7 +19,7 @@ #include "libc/assert.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/crc32.h" #include "libc/nexgen32e/x86feature.h" diff --git a/test/libc/str/longsort_test.c b/test/libc/str/longsort_test.c index 38254000a..bacb49301 100644 --- a/test/libc/str/longsort_test.c +++ b/test/libc/str/longsort_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/alg.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/rand.h" diff --git a/test/libc/str/memcasecmp_test.c b/test/libc/str/memcasecmp_test.c index 7b556b55c..63406e466 100644 --- a/test/libc/str/memcasecmp_test.c +++ b/test/libc/str/memcasecmp_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" diff --git a/test/libc/str/regex_test.c b/test/libc/str/regex_test.c index 5cf4d736c..8523190c3 100644 --- a/test/libc/str/regex_test.c +++ b/test/libc/str/regex_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "third_party/regex/regex.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" diff --git a/test/libc/str/strcasestr_test.c b/test/libc/str/strcasestr_test.c index 881dfcd08..32f9ae339 100644 --- a/test/libc/str/strcasestr_test.c +++ b/test/libc/str/strcasestr_test.c @@ -19,7 +19,7 @@ #include "libc/str/str.h" #include "libc/dce.h" #include "libc/mem/alg.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/x86feature.h" #include "libc/str/tab.internal.h" diff --git a/test/libc/str/strlcpy_test.c b/test/libc/str/strlcpy_test.c index ef93d3bf4..e65600119 100644 --- a/test/libc/str/strlcpy_test.c +++ b/test/libc/str/strlcpy_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" diff --git a/test/libc/str/strstr_test.c b/test/libc/str/strstr_test.c index 9910d9283..0d40cae36 100644 --- a/test/libc/str/strstr_test.c +++ b/test/libc/str/strstr_test.c @@ -19,7 +19,7 @@ #include "libc/str/str.h" #include "libc/dce.h" #include "libc/mem/alg.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/x86feature.h" #include "libc/testlib/ezbench.h" diff --git a/test/libc/thread/makecontext_test.c b/test/libc/thread/makecontext_test.c index a4bf9575f..9b6171029 100644 --- a/test/libc/thread/makecontext_test.c +++ b/test/libc/thread/makecontext_test.c @@ -20,7 +20,7 @@ #include "libc/calls/ucontext.h" #include "libc/dce.h" #include "libc/limits.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/nt/createfile.h" #include "libc/nt/enum/accessmask.h" #include "libc/nt/enum/creationdisposition.h" diff --git a/test/libc/thread/pthread_atfork_test.c b/test/libc/thread/pthread_atfork_test.c index 8cb66e6e3..06b87cded 100644 --- a/test/libc/thread/pthread_atfork_test.c +++ b/test/libc/thread/pthread_atfork_test.c @@ -19,7 +19,7 @@ #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/internal.h" #include "libc/runtime/runtime.h" diff --git a/test/libc/thread/pthread_barrier_wait_test.c b/test/libc/thread/pthread_barrier_wait_test.c index 29d984f88..d4e570c04 100644 --- a/test/libc/thread/pthread_barrier_wait_test.c +++ b/test/libc/thread/pthread_barrier_wait_test.c @@ -20,7 +20,7 @@ #include "libc/atomic.h" #include "libc/errno.h" #include "libc/intrin/atomic.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/thread/pthread_cancel_test.c b/test/libc/thread/pthread_cancel_test.c index 19eef2df1..62604d327 100644 --- a/test/libc/thread/pthread_cancel_test.c +++ b/test/libc/thread/pthread_cancel_test.c @@ -232,7 +232,7 @@ void *CpuBoundWorker(void *arg) { wontleak1 = malloc(123); (void)wontleak1; pthread_cleanup_push(free, wontleak1); - wontleak2 = _gc(malloc(123)); + wontleak2 = gc(malloc(123)); (void)wontleak2; ASSERT_EQ(0, pthread_setspecific(key, (void *)31337)); ASSERT_EQ(0, pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0)); diff --git a/test/libc/thread/pthread_create_test.c b/test/libc/thread/pthread_create_test.c index 43d9f212a..bb6c974bb 100644 --- a/test/libc/thread/pthread_create_test.c +++ b/test/libc/thread/pthread_create_test.c @@ -29,7 +29,7 @@ #include "libc/limits.h" #include "libc/macros.internal.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/nexgen32e/vendor.internal.h" @@ -177,8 +177,8 @@ TEST(pthread_create, testCustomStack_withReallySmallSize) { void *JoinMainWorker(void *arg) { void *rc; pthread_t main_thread = (pthread_t)arg; - _gc(malloc(32)); - _gc(malloc(32)); + gc(malloc(32)); + gc(malloc(32)); ASSERT_EQ(0, pthread_join(main_thread, &rc)); ASSERT_EQ(123, (intptr_t)rc); return 0; @@ -186,8 +186,8 @@ void *JoinMainWorker(void *arg) { TEST(pthread_join, mainThread) { pthread_t id; - _gc(malloc(32)); - _gc(malloc(32)); + gc(malloc(32)); + gc(malloc(32)); SPAWN(fork); ASSERT_EQ(0, pthread_create(&id, 0, JoinMainWorker, (void *)pthread_self())); pthread_exit((void *)123); @@ -196,8 +196,8 @@ TEST(pthread_join, mainThread) { TEST(pthread_join, mainThreadDelayed) { pthread_t id; - _gc(malloc(32)); - _gc(malloc(32)); + gc(malloc(32)); + gc(malloc(32)); SPAWN(fork); ASSERT_EQ(0, pthread_create(&id, 0, JoinMainWorker, (void *)pthread_self())); usleep(10000); diff --git a/test/libc/thread/pthread_rwlock_rdlock_test.c b/test/libc/thread/pthread_rwlock_rdlock_test.c index d7a8b8548..9c7b8c165 100644 --- a/test/libc/thread/pthread_rwlock_rdlock_test.c +++ b/test/libc/thread/pthread_rwlock_rdlock_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/atomic.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" diff --git a/test/libc/thread/sem_open_test.c b/test/libc/thread/sem_open_test.c index df0b5bd3f..90348275e 100644 --- a/test/libc/thread/sem_open_test.c +++ b/test/libc/thread/sem_open_test.c @@ -86,7 +86,7 @@ void *Worker(void *arg) { TEST(sem_open, test) { sem_t *a, *b; int i, r, n = 8; - pthread_t *t = _gc(malloc(sizeof(pthread_t) * n)); + pthread_t *t = gc(malloc(sizeof(pthread_t) * n)); errno = 0; ASSERT_EQ(0, pthread_barrier_init(&barrier, 0, n)); ASSERT_NE(SEM_FAILED, (a = sem_open(name1, O_CREAT, 0644, 0))); diff --git a/test/libc/thread/sem_timedwait_test.c b/test/libc/thread/sem_timedwait_test.c index de003e961..c8a5ef101 100644 --- a/test/libc/thread/sem_timedwait_test.c +++ b/test/libc/thread/sem_timedwait_test.c @@ -104,7 +104,7 @@ void *Worker(void *arg) { TEST(sem_timedwait, threads) { int i, r, n = 4; sem_t sm[2], *s[2] = {sm, sm + 1}; - pthread_t *t = _gc(malloc(sizeof(pthread_t) * n)); + pthread_t *t = gc(malloc(sizeof(pthread_t) * n)); ASSERT_SYS(0, 0, sem_init(s[0], 0, 0)); ASSERT_SYS(0, 0, sem_init(s[1], 0, 0)); for (i = 0; i < n; ++i) ASSERT_EQ(0, pthread_create(t + i, 0, Worker, s)); diff --git a/test/libc/tinymath/acos_test.c b/test/libc/tinymath/acos_test.c index 0c2565833..84e62a9ae 100644 --- a/test/libc/tinymath/acos_test.c +++ b/test/libc/tinymath/acos_test.c @@ -28,12 +28,12 @@ float _acosf(float) asm("acosf"); long double _acosl(long double) asm("acosl"); TEST(acos, test) { - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", _acos(0.)))); - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", _acos(-0.)))); - EXPECT_STREQ("1.0471975511966", _gc(xasprintf("%.15g", _acos(.5)))); - EXPECT_STREQ("2.0943951023932", _gc(xasprintf("%.15g", _acos(-.5)))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _acos(1.)))); - EXPECT_STREQ("3.14159265358979", _gc(xasprintf("%.15g", _acos(-1.)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _acos(0.)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _acos(-0.)))); + EXPECT_STREQ("1.0471975511966", gc(xasprintf("%.15g", _acos(.5)))); + EXPECT_STREQ("2.0943951023932", gc(xasprintf("%.15g", _acos(-.5)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _acos(1.)))); + EXPECT_STREQ("3.14159265358979", gc(xasprintf("%.15g", _acos(-1.)))); EXPECT_TRUE(isnan(_acos(1.5))); EXPECT_TRUE(isnan(_acos(-1.5))); EXPECT_TRUE(isnan(_acos(2.))); @@ -41,7 +41,7 @@ TEST(acos, test) { EXPECT_TRUE(isnan(_acos(-NAN))); EXPECT_TRUE(isnan(_acos(INFINITY))); EXPECT_TRUE(isnan(_acos(-INFINITY))); - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", _acos(__DBL_MIN__)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _acos(__DBL_MIN__)))); EXPECT_TRUE(isnan(_acos(__DBL_MAX__))); } diff --git a/test/libc/tinymath/acosh_test.c b/test/libc/tinymath/acosh_test.c index 6faa91dfd..008972047 100644 --- a/test/libc/tinymath/acosh_test.c +++ b/test/libc/tinymath/acosh_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/asin_test.c b/test/libc/tinymath/asin_test.c index 2fff866d8..2025b24a2 100644 --- a/test/libc/tinymath/asin_test.c +++ b/test/libc/tinymath/asin_test.c @@ -27,12 +27,12 @@ double asin_(double) asm("asin"); #define asin asin_ TEST(asin, test) { - EXPECT_STREQ("0", _gc(xasprintf("%.15g", asin(0.)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", asin(-0.)))); - EXPECT_STREQ("0.523598775598299", _gc(xasprintf("%.15g", asin(.5)))); - EXPECT_STREQ("-0.523598775598299", _gc(xasprintf("%.15g", asin(-.5)))); - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", asin(1.)))); - EXPECT_STREQ("-1.5707963267949", _gc(xasprintf("%.15g", asin(-1.)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", asin(0.)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", asin(-0.)))); + EXPECT_STREQ("0.523598775598299", gc(xasprintf("%.15g", asin(.5)))); + EXPECT_STREQ("-0.523598775598299", gc(xasprintf("%.15g", asin(-.5)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", asin(1.)))); + EXPECT_STREQ("-1.5707963267949", gc(xasprintf("%.15g", asin(-1.)))); EXPECT_TRUE(isnan(asin(1.5))); EXPECT_TRUE(isnan(asin(-1.5))); EXPECT_TRUE(isnan(asin(NAN))); @@ -40,7 +40,7 @@ TEST(asin, test) { EXPECT_TRUE(isnan(asin(INFINITY))); EXPECT_TRUE(isnan(asin(-INFINITY))); EXPECT_STREQ("2.2250738585072e-308", - _gc(xasprintf("%.15g", asin(__DBL_MIN__)))); + gc(xasprintf("%.15g", asin(__DBL_MIN__)))); EXPECT_TRUE(isnan(asin(__DBL_MAX__))); } diff --git a/test/libc/tinymath/asinh_test.c b/test/libc/tinymath/asinh_test.c index 19dd314e7..1584a1ad6 100644 --- a/test/libc/tinymath/asinh_test.c +++ b/test/libc/tinymath/asinh_test.c @@ -28,29 +28,29 @@ float _asinhf(float) asm("asinhf"); long double _asinhl(long double) asm("asinhl"); TEST(asinh, test) { - EXPECT_STREQ(".481211825059603", _gc(xdtoa(_asinh(+.5)))); - EXPECT_STREQ("-.481211825059603", _gc(xdtoa(_asinh(-.5)))); - EXPECT_STREQ("0", _gc(xdtoa(_asinh(0)))); - EXPECT_STREQ("NAN", _gc(xdtoa(_asinh(NAN)))); - EXPECT_STREQ("INFINITY", _gc(xdtoa(_asinh(INFINITY)))); + EXPECT_STREQ(".481211825059603", gc(xdtoa(_asinh(+.5)))); + EXPECT_STREQ("-.481211825059603", gc(xdtoa(_asinh(-.5)))); + EXPECT_STREQ("0", gc(xdtoa(_asinh(0)))); + EXPECT_STREQ("NAN", gc(xdtoa(_asinh(NAN)))); + EXPECT_STREQ("INFINITY", gc(xdtoa(_asinh(INFINITY)))); EXPECT_STREQ("-2.1073424255447e-08", - _gc(xasprintf("%.15g", _asinh(-2.1073424255447e-08)))); + gc(xasprintf("%.15g", _asinh(-2.1073424255447e-08)))); } TEST(asinhf, test) { - EXPECT_STREQ(".481212", _gc(xdtoaf(_asinhf(+.5)))); - EXPECT_STREQ("-.481212", _gc(xdtoaf(_asinhf(-.5)))); - EXPECT_STREQ("0", _gc(xdtoaf(_asinhf(0)))); - EXPECT_STREQ("NAN", _gc(xdtoaf(_asinhf(NAN)))); - EXPECT_STREQ("INFINITY", _gc(xdtoaf(_asinhf(INFINITY)))); + EXPECT_STREQ(".481212", gc(xdtoaf(_asinhf(+.5)))); + EXPECT_STREQ("-.481212", gc(xdtoaf(_asinhf(-.5)))); + EXPECT_STREQ("0", gc(xdtoaf(_asinhf(0)))); + EXPECT_STREQ("NAN", gc(xdtoaf(_asinhf(NAN)))); + EXPECT_STREQ("INFINITY", gc(xdtoaf(_asinhf(INFINITY)))); } TEST(asinhl, test) { - EXPECT_STREQ(".4812118250596034", _gc(xdtoal(_asinhl(+.5)))); - EXPECT_STREQ("-.4812118250596034", _gc(xdtoal(_asinhl(-.5)))); - EXPECT_STREQ("0", _gc(xdtoal(_asinhl(0)))); - EXPECT_STREQ("NAN", _gc(xdtoal(_asinhl(NAN)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(_asinhl(INFINITY)))); + EXPECT_STREQ(".4812118250596034", gc(xdtoal(_asinhl(+.5)))); + EXPECT_STREQ("-.4812118250596034", gc(xdtoal(_asinhl(-.5)))); + EXPECT_STREQ("0", gc(xdtoal(_asinhl(0)))); + EXPECT_STREQ("NAN", gc(xdtoal(_asinhl(NAN)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(_asinhl(INFINITY)))); } BENCH(asinh, bench) { diff --git a/test/libc/tinymath/atan2_test.c b/test/libc/tinymath/atan2_test.c index 1f7ab1b2f..bd24440f6 100644 --- a/test/libc/tinymath/atan2_test.c +++ b/test/libc/tinymath/atan2_test.c @@ -27,145 +27,143 @@ float _atan2f(float, float) asm("atan2f"); long double _atan2l(long double, long double) asm("atan2l"); TEST(atan2, yx) { - EXPECT_STREQ("-0.321750554396642", _gc(xasprintf("%.15g", atan(-.5 / 1.5)))); - EXPECT_STREQ("-0.321750554396642", _gc(xasprintf("%.15g", _atan2(-.5, 1.5)))); + EXPECT_STREQ("-0.321750554396642", gc(xasprintf("%.15g", atan(-.5 / 1.5)))); + EXPECT_STREQ("-0.321750554396642", gc(xasprintf("%.15g", _atan2(-.5, 1.5)))); } TEST(atan2, test) { - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(0., 0.)))); - EXPECT_STREQ("3.14159265358979", _gc(xasprintf("%.15g", _atan2(0., -0.)))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(0., .5)))); - EXPECT_STREQ("3.14159265358979", _gc(xasprintf("%.15g", _atan2(0., -.5)))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(0., 1.)))); - EXPECT_STREQ("3.14159265358979", _gc(xasprintf("%.15g", _atan2(0., -1.)))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(0., 1.5)))); - EXPECT_STREQ("3.14159265358979", _gc(xasprintf("%.15g", _atan2(0., -1.5)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(0., 0.)))); + EXPECT_STREQ("3.14159265358979", gc(xasprintf("%.15g", _atan2(0., -0.)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(0., .5)))); + EXPECT_STREQ("3.14159265358979", gc(xasprintf("%.15g", _atan2(0., -.5)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(0., 1.)))); + EXPECT_STREQ("3.14159265358979", gc(xasprintf("%.15g", _atan2(0., -1.)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(0., 1.5)))); + EXPECT_STREQ("3.14159265358979", gc(xasprintf("%.15g", _atan2(0., -1.5)))); EXPECT_TRUE(isnan(_atan2(0., NAN))); EXPECT_TRUE(isnan(_atan2(0., -NAN))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(0., INFINITY)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(0., INFINITY)))); EXPECT_STREQ("3.14159265358979", - _gc(xasprintf("%.15g", _atan2(0., -INFINITY)))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(0., __DBL_MIN__)))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(0., __DBL_MAX__)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _atan2(-0., 0.)))); - EXPECT_STREQ("-3.14159265358979", _gc(xasprintf("%.15g", _atan2(-0., -0.)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _atan2(-0., .5)))); - EXPECT_STREQ("-3.14159265358979", _gc(xasprintf("%.15g", _atan2(-0., -.5)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _atan2(-0., 1.)))); - EXPECT_STREQ("-3.14159265358979", _gc(xasprintf("%.15g", _atan2(-0., -1.)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _atan2(-0., 1.5)))); - EXPECT_STREQ("-3.14159265358979", _gc(xasprintf("%.15g", _atan2(-0., -1.5)))); + gc(xasprintf("%.15g", _atan2(0., -INFINITY)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(0., __DBL_MIN__)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(0., __DBL_MAX__)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _atan2(-0., 0.)))); + EXPECT_STREQ("-3.14159265358979", gc(xasprintf("%.15g", _atan2(-0., -0.)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _atan2(-0., .5)))); + EXPECT_STREQ("-3.14159265358979", gc(xasprintf("%.15g", _atan2(-0., -.5)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _atan2(-0., 1.)))); + EXPECT_STREQ("-3.14159265358979", gc(xasprintf("%.15g", _atan2(-0., -1.)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _atan2(-0., 1.5)))); + EXPECT_STREQ("-3.14159265358979", gc(xasprintf("%.15g", _atan2(-0., -1.5)))); EXPECT_TRUE(isnan(_atan2(-0., NAN))); EXPECT_TRUE(isnan(_atan2(-0., -NAN))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _atan2(-0., INFINITY)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _atan2(-0., INFINITY)))); EXPECT_STREQ("-3.14159265358979", - _gc(xasprintf("%.15g", _atan2(-0., -INFINITY)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _atan2(-0., __DBL_MIN__)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _atan2(-0., __DBL_MAX__)))); - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", _atan2(.5, 0.)))); - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", _atan2(.5, -0.)))); - EXPECT_STREQ("0.785398163397448", _gc(xasprintf("%.15g", _atan2(.5, .5)))); - EXPECT_STREQ("2.35619449019234", _gc(xasprintf("%.15g", _atan2(.5, -.5)))); - EXPECT_STREQ("0.463647609000806", _gc(xasprintf("%.15g", _atan2(.5, 1.)))); - EXPECT_STREQ("2.67794504458899", _gc(xasprintf("%.15g", _atan2(.5, -1.)))); - EXPECT_STREQ("0.321750554396642", _gc(xasprintf("%.15g", _atan2(.5, 1.5)))); - EXPECT_STREQ("2.81984209919315", _gc(xasprintf("%.15g", _atan2(.5, -1.5)))); + gc(xasprintf("%.15g", _atan2(-0., -INFINITY)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _atan2(-0., __DBL_MIN__)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _atan2(-0., __DBL_MAX__)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _atan2(.5, 0.)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _atan2(.5, -0.)))); + EXPECT_STREQ("0.785398163397448", gc(xasprintf("%.15g", _atan2(.5, .5)))); + EXPECT_STREQ("2.35619449019234", gc(xasprintf("%.15g", _atan2(.5, -.5)))); + EXPECT_STREQ("0.463647609000806", gc(xasprintf("%.15g", _atan2(.5, 1.)))); + EXPECT_STREQ("2.67794504458899", gc(xasprintf("%.15g", _atan2(.5, -1.)))); + EXPECT_STREQ("0.321750554396642", gc(xasprintf("%.15g", _atan2(.5, 1.5)))); + EXPECT_STREQ("2.81984209919315", gc(xasprintf("%.15g", _atan2(.5, -1.5)))); EXPECT_TRUE(isnan(_atan2(.5, NAN))); EXPECT_TRUE(isnan(_atan2(.5, -NAN))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(.5, INFINITY)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(.5, INFINITY)))); EXPECT_STREQ("3.14159265358979", - _gc(xasprintf("%.15g", _atan2(.5, -INFINITY)))); + gc(xasprintf("%.15g", _atan2(.5, -INFINITY)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(.5, __DBL_MIN__)))); + gc(xasprintf("%.15g", _atan2(.5, __DBL_MIN__)))); EXPECT_STREQ("2.781342323134e-309", - _gc(xasprintf("%.15g", _atan2(.5, __DBL_MAX__)))); - EXPECT_STREQ("-1.5707963267949", _gc(xasprintf("%.15g", _atan2(-.5, 0.)))); - EXPECT_STREQ("-1.5707963267949", _gc(xasprintf("%.15g", _atan2(-.5, -0.)))); - EXPECT_STREQ("-0.785398163397448", _gc(xasprintf("%.15g", _atan2(-.5, .5)))); - EXPECT_STREQ("-2.35619449019234", _gc(xasprintf("%.15g", _atan2(-.5, -.5)))); - EXPECT_STREQ("-0.463647609000806", _gc(xasprintf("%.15g", _atan2(-.5, 1.)))); - EXPECT_STREQ("-2.67794504458899", _gc(xasprintf("%.15g", _atan2(-.5, -1.)))); - EXPECT_STREQ("-0.321750554396642", _gc(xasprintf("%.15g", _atan2(-.5, 1.5)))); - EXPECT_STREQ("-2.81984209919315", _gc(xasprintf("%.15g", _atan2(-.5, -1.5)))); + gc(xasprintf("%.15g", _atan2(.5, __DBL_MAX__)))); + EXPECT_STREQ("-1.5707963267949", gc(xasprintf("%.15g", _atan2(-.5, 0.)))); + EXPECT_STREQ("-1.5707963267949", gc(xasprintf("%.15g", _atan2(-.5, -0.)))); + EXPECT_STREQ("-0.785398163397448", gc(xasprintf("%.15g", _atan2(-.5, .5)))); + EXPECT_STREQ("-2.35619449019234", gc(xasprintf("%.15g", _atan2(-.5, -.5)))); + EXPECT_STREQ("-0.463647609000806", gc(xasprintf("%.15g", _atan2(-.5, 1.)))); + EXPECT_STREQ("-2.67794504458899", gc(xasprintf("%.15g", _atan2(-.5, -1.)))); + EXPECT_STREQ("-0.321750554396642", gc(xasprintf("%.15g", _atan2(-.5, 1.5)))); + EXPECT_STREQ("-2.81984209919315", gc(xasprintf("%.15g", _atan2(-.5, -1.5)))); EXPECT_TRUE(isnan(_atan2(-.5, NAN))); EXPECT_TRUE(isnan(_atan2(-.5, -NAN))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _atan2(-.5, INFINITY)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _atan2(-.5, INFINITY)))); EXPECT_STREQ("-3.14159265358979", - _gc(xasprintf("%.15g", _atan2(-.5, -INFINITY)))); + gc(xasprintf("%.15g", _atan2(-.5, -INFINITY)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-.5, __DBL_MIN__)))); + gc(xasprintf("%.15g", _atan2(-.5, __DBL_MIN__)))); EXPECT_STREQ("-2.781342323134e-309", - _gc(xasprintf("%.15g", _atan2(-.5, __DBL_MAX__)))); - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", _atan2(1., 0.)))); - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", _atan2(1., -0.)))); - EXPECT_STREQ("1.10714871779409", _gc(xasprintf("%.15g", _atan2(1., .5)))); - EXPECT_STREQ("2.0344439357957", _gc(xasprintf("%.15g", _atan2(1., -.5)))); - EXPECT_STREQ("0.785398163397448", _gc(xasprintf("%.15g", _atan2(1., 1.)))); - EXPECT_STREQ("2.35619449019234", _gc(xasprintf("%.15g", _atan2(1., -1.)))); - EXPECT_STREQ("0.588002603547568", _gc(xasprintf("%.15g", _atan2(1., 1.5)))); - EXPECT_STREQ("2.55359005004223", _gc(xasprintf("%.15g", _atan2(1., -1.5)))); + gc(xasprintf("%.15g", _atan2(-.5, __DBL_MAX__)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _atan2(1., 0.)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _atan2(1., -0.)))); + EXPECT_STREQ("1.10714871779409", gc(xasprintf("%.15g", _atan2(1., .5)))); + EXPECT_STREQ("2.0344439357957", gc(xasprintf("%.15g", _atan2(1., -.5)))); + EXPECT_STREQ("0.785398163397448", gc(xasprintf("%.15g", _atan2(1., 1.)))); + EXPECT_STREQ("2.35619449019234", gc(xasprintf("%.15g", _atan2(1., -1.)))); + EXPECT_STREQ("0.588002603547568", gc(xasprintf("%.15g", _atan2(1., 1.5)))); + EXPECT_STREQ("2.55359005004223", gc(xasprintf("%.15g", _atan2(1., -1.5)))); EXPECT_TRUE(isnan(_atan2(1., NAN))); EXPECT_TRUE(isnan(_atan2(1., -NAN))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(1., INFINITY)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(1., INFINITY)))); EXPECT_STREQ("3.14159265358979", - _gc(xasprintf("%.15g", _atan2(1., -INFINITY)))); + gc(xasprintf("%.15g", _atan2(1., -INFINITY)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(1., __DBL_MIN__)))); + gc(xasprintf("%.15g", _atan2(1., __DBL_MIN__)))); EXPECT_STREQ("5.562684646268e-309", - _gc(xasprintf("%.15g", _atan2(1., __DBL_MAX__)))); - EXPECT_STREQ("-1.5707963267949", _gc(xasprintf("%.15g", _atan2(-1., 0.)))); - EXPECT_STREQ("-1.5707963267949", _gc(xasprintf("%.15g", _atan2(-1., -0.)))); - EXPECT_STREQ("-1.10714871779409", _gc(xasprintf("%.15g", _atan2(-1., .5)))); - EXPECT_STREQ("-2.0344439357957", _gc(xasprintf("%.15g", _atan2(-1., -.5)))); - EXPECT_STREQ("-0.785398163397448", _gc(xasprintf("%.15g", _atan2(-1., 1.)))); - EXPECT_STREQ("-2.35619449019234", _gc(xasprintf("%.15g", _atan2(-1., -1.)))); - EXPECT_STREQ("-0.588002603547568", _gc(xasprintf("%.15g", _atan2(-1., 1.5)))); - EXPECT_STREQ("-2.55359005004223", _gc(xasprintf("%.15g", _atan2(-1., -1.5)))); + gc(xasprintf("%.15g", _atan2(1., __DBL_MAX__)))); + EXPECT_STREQ("-1.5707963267949", gc(xasprintf("%.15g", _atan2(-1., 0.)))); + EXPECT_STREQ("-1.5707963267949", gc(xasprintf("%.15g", _atan2(-1., -0.)))); + EXPECT_STREQ("-1.10714871779409", gc(xasprintf("%.15g", _atan2(-1., .5)))); + EXPECT_STREQ("-2.0344439357957", gc(xasprintf("%.15g", _atan2(-1., -.5)))); + EXPECT_STREQ("-0.785398163397448", gc(xasprintf("%.15g", _atan2(-1., 1.)))); + EXPECT_STREQ("-2.35619449019234", gc(xasprintf("%.15g", _atan2(-1., -1.)))); + EXPECT_STREQ("-0.588002603547568", gc(xasprintf("%.15g", _atan2(-1., 1.5)))); + EXPECT_STREQ("-2.55359005004223", gc(xasprintf("%.15g", _atan2(-1., -1.5)))); EXPECT_TRUE(isnan(_atan2(-1., NAN))); EXPECT_TRUE(isnan(_atan2(-1., -NAN))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _atan2(-1., INFINITY)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _atan2(-1., INFINITY)))); EXPECT_STREQ("-3.14159265358979", - _gc(xasprintf("%.15g", _atan2(-1., -INFINITY)))); + gc(xasprintf("%.15g", _atan2(-1., -INFINITY)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-1., __DBL_MIN__)))); + gc(xasprintf("%.15g", _atan2(-1., __DBL_MIN__)))); EXPECT_STREQ("-5.562684646268e-309", - _gc(xasprintf("%.15g", _atan2(-1., __DBL_MAX__)))); - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", _atan2(1.5, 0.)))); - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", _atan2(1.5, -0.)))); - EXPECT_STREQ("1.24904577239825", _gc(xasprintf("%.15g", _atan2(1.5, .5)))); - EXPECT_STREQ("1.89254688119154", _gc(xasprintf("%.15g", _atan2(1.5, -.5)))); - EXPECT_STREQ("0.982793723247329", _gc(xasprintf("%.15g", _atan2(1.5, 1.)))); - EXPECT_STREQ("2.15879893034246", _gc(xasprintf("%.15g", _atan2(1.5, -1.)))); - EXPECT_STREQ("0.785398163397448", _gc(xasprintf("%.15g", _atan2(1.5, 1.5)))); - EXPECT_STREQ("2.35619449019234", _gc(xasprintf("%.15g", _atan2(1.5, -1.5)))); + gc(xasprintf("%.15g", _atan2(-1., __DBL_MAX__)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _atan2(1.5, 0.)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _atan2(1.5, -0.)))); + EXPECT_STREQ("1.24904577239825", gc(xasprintf("%.15g", _atan2(1.5, .5)))); + EXPECT_STREQ("1.89254688119154", gc(xasprintf("%.15g", _atan2(1.5, -.5)))); + EXPECT_STREQ("0.982793723247329", gc(xasprintf("%.15g", _atan2(1.5, 1.)))); + EXPECT_STREQ("2.15879893034246", gc(xasprintf("%.15g", _atan2(1.5, -1.)))); + EXPECT_STREQ("0.785398163397448", gc(xasprintf("%.15g", _atan2(1.5, 1.5)))); + EXPECT_STREQ("2.35619449019234", gc(xasprintf("%.15g", _atan2(1.5, -1.5)))); EXPECT_TRUE(isnan(_atan2(1.5, NAN))); EXPECT_TRUE(isnan(_atan2(1.5, -NAN))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(1.5, INFINITY)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(1.5, INFINITY)))); EXPECT_STREQ("3.14159265358979", - _gc(xasprintf("%.15g", _atan2(1.5, -INFINITY)))); + gc(xasprintf("%.15g", _atan2(1.5, -INFINITY)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(1.5, __DBL_MIN__)))); + gc(xasprintf("%.15g", _atan2(1.5, __DBL_MIN__)))); EXPECT_STREQ("8.34402696940201e-309", - _gc(xasprintf("%.15g", _atan2(1.5, __DBL_MAX__)))); - EXPECT_STREQ("-1.5707963267949", _gc(xasprintf("%.15g", _atan2(-1.5, 0.)))); - EXPECT_STREQ("-1.5707963267949", _gc(xasprintf("%.15g", _atan2(-1.5, -0.)))); - EXPECT_STREQ("-1.24904577239825", _gc(xasprintf("%.15g", _atan2(-1.5, .5)))); - EXPECT_STREQ("-1.89254688119154", _gc(xasprintf("%.15g", _atan2(-1.5, -.5)))); - EXPECT_STREQ("-0.982793723247329", _gc(xasprintf("%.15g", _atan2(-1.5, 1.)))); - EXPECT_STREQ("-2.15879893034246", _gc(xasprintf("%.15g", _atan2(-1.5, -1.)))); - EXPECT_STREQ("-0.785398163397448", - _gc(xasprintf("%.15g", _atan2(-1.5, 1.5)))); - EXPECT_STREQ("-2.35619449019234", - _gc(xasprintf("%.15g", _atan2(-1.5, -1.5)))); + gc(xasprintf("%.15g", _atan2(1.5, __DBL_MAX__)))); + EXPECT_STREQ("-1.5707963267949", gc(xasprintf("%.15g", _atan2(-1.5, 0.)))); + EXPECT_STREQ("-1.5707963267949", gc(xasprintf("%.15g", _atan2(-1.5, -0.)))); + EXPECT_STREQ("-1.24904577239825", gc(xasprintf("%.15g", _atan2(-1.5, .5)))); + EXPECT_STREQ("-1.89254688119154", gc(xasprintf("%.15g", _atan2(-1.5, -.5)))); + EXPECT_STREQ("-0.982793723247329", gc(xasprintf("%.15g", _atan2(-1.5, 1.)))); + EXPECT_STREQ("-2.15879893034246", gc(xasprintf("%.15g", _atan2(-1.5, -1.)))); + EXPECT_STREQ("-0.785398163397448", gc(xasprintf("%.15g", _atan2(-1.5, 1.5)))); + EXPECT_STREQ("-2.35619449019234", gc(xasprintf("%.15g", _atan2(-1.5, -1.5)))); EXPECT_TRUE(isnan(_atan2(-1.5, NAN))); EXPECT_TRUE(isnan(_atan2(-1.5, -NAN))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _atan2(-1.5, INFINITY)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _atan2(-1.5, INFINITY)))); EXPECT_STREQ("-3.14159265358979", - _gc(xasprintf("%.15g", _atan2(-1.5, -INFINITY)))); + gc(xasprintf("%.15g", _atan2(-1.5, -INFINITY)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-1.5, __DBL_MIN__)))); + gc(xasprintf("%.15g", _atan2(-1.5, __DBL_MIN__)))); EXPECT_STREQ("-8.34402696940201e-309", - _gc(xasprintf("%.15g", _atan2(-1.5, __DBL_MAX__)))); + gc(xasprintf("%.15g", _atan2(-1.5, __DBL_MAX__)))); EXPECT_TRUE(isnan(_atan2(NAN, 0.))); EXPECT_TRUE(isnan(_atan2(NAN, -0.))); EXPECT_TRUE(isnan(_atan2(NAN, .5))); @@ -194,114 +192,111 @@ TEST(atan2, test) { EXPECT_TRUE(isnan(_atan2(-NAN, -INFINITY))); EXPECT_TRUE(isnan(_atan2(-NAN, __DBL_MIN__))); EXPECT_TRUE(isnan(_atan2(-NAN, __DBL_MAX__))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _atan2(INFINITY, 0.)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(INFINITY, 0.)))); + gc(xasprintf("%.15g", _atan2(INFINITY, -0.)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _atan2(INFINITY, .5)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(INFINITY, -0.)))); + gc(xasprintf("%.15g", _atan2(INFINITY, -.5)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", _atan2(INFINITY, 1.)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(INFINITY, .5)))); + gc(xasprintf("%.15g", _atan2(INFINITY, -1.)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(INFINITY, -.5)))); + gc(xasprintf("%.15g", _atan2(INFINITY, 1.5)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(INFINITY, 1.)))); - EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(INFINITY, -1.)))); - EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(INFINITY, 1.5)))); - EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(INFINITY, -1.5)))); + gc(xasprintf("%.15g", _atan2(INFINITY, -1.5)))); EXPECT_TRUE(isnan(_atan2(INFINITY, NAN))); EXPECT_TRUE(isnan(_atan2(INFINITY, -NAN))); EXPECT_STREQ("0.785398163397448", - _gc(xasprintf("%.15g", _atan2(INFINITY, INFINITY)))); + gc(xasprintf("%.15g", _atan2(INFINITY, INFINITY)))); EXPECT_STREQ("2.35619449019234", - _gc(xasprintf("%.15g", _atan2(INFINITY, -INFINITY)))); + gc(xasprintf("%.15g", _atan2(INFINITY, -INFINITY)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(INFINITY, __DBL_MIN__)))); + gc(xasprintf("%.15g", _atan2(INFINITY, __DBL_MIN__)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(INFINITY, __DBL_MAX__)))); + gc(xasprintf("%.15g", _atan2(INFINITY, __DBL_MAX__)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-INFINITY, 0.)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, 0.)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-INFINITY, -0.)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, -0.)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-INFINITY, .5)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, .5)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-INFINITY, -.5)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, -.5)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-INFINITY, 1.)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, 1.)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-INFINITY, -1.)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, -1.)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-INFINITY, 1.5)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, 1.5)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-INFINITY, -1.5)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, -1.5)))); EXPECT_TRUE(isnan(_atan2(-INFINITY, NAN))); EXPECT_TRUE(isnan(_atan2(-INFINITY, -NAN))); EXPECT_STREQ("-0.785398163397448", - _gc(xasprintf("%.15g", _atan2(-INFINITY, INFINITY)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, INFINITY)))); EXPECT_STREQ("-2.35619449019234", - _gc(xasprintf("%.15g", _atan2(-INFINITY, -INFINITY)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, -INFINITY)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-INFINITY, __DBL_MIN__)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, __DBL_MIN__)))); EXPECT_STREQ("-1.5707963267949", - _gc(xasprintf("%.15g", _atan2(-INFINITY, __DBL_MAX__)))); + gc(xasprintf("%.15g", _atan2(-INFINITY, __DBL_MAX__)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, 0.)))); + gc(xasprintf("%.15g", _atan2(__DBL_MIN__, 0.)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, -0.)))); + gc(xasprintf("%.15g", _atan2(__DBL_MIN__, -0.)))); EXPECT_STREQ("4.4501477170144e-308", - _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, .5)))); + gc(xasprintf("%.15g", _atan2(__DBL_MIN__, .5)))); EXPECT_STREQ("3.14159265358979", - _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, -.5)))); + gc(xasprintf("%.15g", _atan2(__DBL_MIN__, -.5)))); EXPECT_STREQ("2.2250738585072e-308", - _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, 1.)))); + gc(xasprintf("%.15g", _atan2(__DBL_MIN__, 1.)))); EXPECT_STREQ("3.14159265358979", - _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, -1.)))); + gc(xasprintf("%.15g", _atan2(__DBL_MIN__, -1.)))); EXPECT_STREQ("1.48338257233813e-308", - _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, 1.5)))); + gc(xasprintf("%.15g", _atan2(__DBL_MIN__, 1.5)))); EXPECT_STREQ("3.14159265358979", - _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, -1.5)))); + gc(xasprintf("%.15g", _atan2(__DBL_MIN__, -1.5)))); EXPECT_TRUE(isnan(_atan2(__DBL_MIN__, NAN))); EXPECT_TRUE(isnan(_atan2(__DBL_MIN__, -NAN))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, INFINITY)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(__DBL_MIN__, INFINITY)))); EXPECT_STREQ("3.14159265358979", - _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, -INFINITY)))); + gc(xasprintf("%.15g", _atan2(__DBL_MIN__, -INFINITY)))); EXPECT_STREQ("0.785398163397448", - _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, __DBL_MIN__)))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(__DBL_MIN__, __DBL_MAX__)))); + gc(xasprintf("%.15g", _atan2(__DBL_MIN__, __DBL_MIN__)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(__DBL_MIN__, __DBL_MAX__)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, 0.)))); + gc(xasprintf("%.15g", _atan2(__DBL_MAX__, 0.)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, -0.)))); + gc(xasprintf("%.15g", _atan2(__DBL_MAX__, -0.)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, .5)))); + gc(xasprintf("%.15g", _atan2(__DBL_MAX__, .5)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, -.5)))); + gc(xasprintf("%.15g", _atan2(__DBL_MAX__, -.5)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, 1.)))); + gc(xasprintf("%.15g", _atan2(__DBL_MAX__, 1.)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, -1.)))); + gc(xasprintf("%.15g", _atan2(__DBL_MAX__, -1.)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, 1.5)))); + gc(xasprintf("%.15g", _atan2(__DBL_MAX__, 1.5)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, -1.5)))); + gc(xasprintf("%.15g", _atan2(__DBL_MAX__, -1.5)))); EXPECT_TRUE(isnan(_atan2(__DBL_MAX__, NAN))); EXPECT_TRUE(isnan(_atan2(__DBL_MAX__, -NAN))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, INFINITY)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _atan2(__DBL_MAX__, INFINITY)))); EXPECT_STREQ("3.14159265358979", - _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, -INFINITY)))); + gc(xasprintf("%.15g", _atan2(__DBL_MAX__, -INFINITY)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, __DBL_MIN__)))); + gc(xasprintf("%.15g", _atan2(__DBL_MAX__, __DBL_MIN__)))); EXPECT_STREQ("0.785398163397448", - _gc(xasprintf("%.15g", _atan2(__DBL_MAX__, __DBL_MAX__)))); + gc(xasprintf("%.15g", _atan2(__DBL_MAX__, __DBL_MAX__)))); EXPECT_STREQ("-0", - _gc(xasprintf("%.15g", _atan2(-0.000000000000001, INFINITY)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _atan2(-1, INFINITY)))); + gc(xasprintf("%.15g", _atan2(-0.000000000000001, INFINITY)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _atan2(-1, INFINITY)))); EXPECT_STREQ( - "-0", _gc(xasprintf("%.15g", _atan2(-1.7976931348623157e308, INFINITY)))); + "-0", gc(xasprintf("%.15g", _atan2(-1.7976931348623157e308, INFINITY)))); EXPECT_STREQ("1.5707963267949", - _gc(xasprintf("%.15g", _atan2(1.4142135623731, 0)))); + gc(xasprintf("%.15g", _atan2(1.4142135623731, 0)))); } BENCH(atan2, bench) { diff --git a/test/libc/tinymath/atan2l_test.c b/test/libc/tinymath/atan2l_test.c index e7a27223f..67dcbd0fc 100644 --- a/test/libc/tinymath/atan2l_test.c +++ b/test/libc/tinymath/atan2l_test.c @@ -25,35 +25,35 @@ TEST(atan2l, test) { volatile double a = -.9816175436063843; volatile double b = -.1908585813741899; - EXPECT_STREQ("-2.95", _gc(xasprintf("%.2f", atan2f(b, a)))); - EXPECT_STREQ("-2.95", _gc(xasprintf("%.2f", atan2(b, a)))); + EXPECT_STREQ("-2.95", gc(xasprintf("%.2f", atan2f(b, a)))); + EXPECT_STREQ("-2.95", gc(xasprintf("%.2f", atan2(b, a)))); #ifndef __aarch64__ // TODO: implement quad floating point into printf - EXPECT_STREQ("-2.95", _gc(xasprintf("%.2Lf", atan2l(b, a)))); + EXPECT_STREQ("-2.95", gc(xasprintf("%.2Lf", atan2l(b, a)))); #endif } TEST(atan2, testSpecialCases) { - ASSERT_STREQ("NAN", _gc(xdtoa(atan2(NAN, 0)))); - ASSERT_STREQ("NAN", _gc(xdtoa(atan2(0, NAN)))); - ASSERT_STREQ("0", _gc(xdtoa(atan2(+0., +0.)))); - ASSERT_STREQ("0", _gc(xdtoa(atan2(+0., +1.)))); - ASSERT_STREQ("0", _gc(xdtoa(atan2(+0., +2.)))); - ASSERT_STREQ("0", _gc(xdtoa(atan2(1, INFINITY)))); - ASSERT_STREQ("3.141592653589793", _gc(xdtoal(atan2(+0., -0.)))); - ASSERT_STREQ("3.141592653589793", _gc(xdtoal(atan2(+0., -1.)))); - ASSERT_STREQ("3.141592653589793", _gc(xdtoal(atan2(+0., -2.)))); - ASSERT_STREQ("-1.570796326794897", _gc(xdtoal(atan2(-1., -0.)))); - ASSERT_STREQ("-1.570796326794897", _gc(xdtoal(atan2(-1., +0.)))); - ASSERT_STREQ("-1.570796326794897", _gc(xdtoal(atan2(-2., -0.)))); - ASSERT_STREQ("-1.570796326794897", _gc(xdtoal(atan2(-2., +0.)))); - ASSERT_STREQ("1.570796326794897", _gc(xdtoal(atan2(+1., -0.)))); - ASSERT_STREQ("1.570796326794897", _gc(xdtoal(atan2(+1., +0.)))); - ASSERT_STREQ("1.570796326794897", _gc(xdtoal(atan2(+2., -0.)))); - ASSERT_STREQ("1.570796326794897", _gc(xdtoal(atan2(+2., +0.)))); - ASSERT_STREQ("1.570796326794897", _gc(xdtoal(atan2(INFINITY, 1)))); - ASSERT_STREQ("1.570796326794897", _gc(xdtoal(atan2(INFINITY, -1)))); - ASSERT_STREQ("3.141592653589793", _gc(xdtoal(atan2(1, -INFINITY)))); - ASSERT_STREQ("2.356194490192345", _gc(xdtoal(atan2(INFINITY, -INFINITY)))); - ASSERT_STREQ(".7853981633974483", _gc(xdtoal(atan2(INFINITY, INFINITY)))); + ASSERT_STREQ("NAN", gc(xdtoa(atan2(NAN, 0)))); + ASSERT_STREQ("NAN", gc(xdtoa(atan2(0, NAN)))); + ASSERT_STREQ("0", gc(xdtoa(atan2(+0., +0.)))); + ASSERT_STREQ("0", gc(xdtoa(atan2(+0., +1.)))); + ASSERT_STREQ("0", gc(xdtoa(atan2(+0., +2.)))); + ASSERT_STREQ("0", gc(xdtoa(atan2(1, INFINITY)))); + ASSERT_STREQ("3.141592653589793", gc(xdtoal(atan2(+0., -0.)))); + ASSERT_STREQ("3.141592653589793", gc(xdtoal(atan2(+0., -1.)))); + ASSERT_STREQ("3.141592653589793", gc(xdtoal(atan2(+0., -2.)))); + ASSERT_STREQ("-1.570796326794897", gc(xdtoal(atan2(-1., -0.)))); + ASSERT_STREQ("-1.570796326794897", gc(xdtoal(atan2(-1., +0.)))); + ASSERT_STREQ("-1.570796326794897", gc(xdtoal(atan2(-2., -0.)))); + ASSERT_STREQ("-1.570796326794897", gc(xdtoal(atan2(-2., +0.)))); + ASSERT_STREQ("1.570796326794897", gc(xdtoal(atan2(+1., -0.)))); + ASSERT_STREQ("1.570796326794897", gc(xdtoal(atan2(+1., +0.)))); + ASSERT_STREQ("1.570796326794897", gc(xdtoal(atan2(+2., -0.)))); + ASSERT_STREQ("1.570796326794897", gc(xdtoal(atan2(+2., +0.)))); + ASSERT_STREQ("1.570796326794897", gc(xdtoal(atan2(INFINITY, 1)))); + ASSERT_STREQ("1.570796326794897", gc(xdtoal(atan2(INFINITY, -1)))); + ASSERT_STREQ("3.141592653589793", gc(xdtoal(atan2(1, -INFINITY)))); + ASSERT_STREQ("2.356194490192345", gc(xdtoal(atan2(INFINITY, -INFINITY)))); + ASSERT_STREQ(".7853981633974483", gc(xdtoal(atan2(INFINITY, INFINITY)))); } diff --git a/test/libc/tinymath/atan_test.c b/test/libc/tinymath/atan_test.c index 8a273f1c1..248cffc9e 100644 --- a/test/libc/tinymath/atan_test.c +++ b/test/libc/tinymath/atan_test.c @@ -23,21 +23,21 @@ #include "libc/x/xasprintf.h" TEST(atan, test) { - EXPECT_STREQ("0", _gc(xasprintf("%.15g", atan(0.)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", atan(-0.)))); - EXPECT_STREQ("0.463647609000806", _gc(xasprintf("%.15g", atan(.5)))); - EXPECT_STREQ("-0.463647609000806", _gc(xasprintf("%.15g", atan(-.5)))); - EXPECT_STREQ("0.785398163397448", _gc(xasprintf("%.15g", atan(1.)))); - EXPECT_STREQ("-0.785398163397448", _gc(xasprintf("%.15g", atan(-1.)))); - EXPECT_STREQ("0.982793723247329", _gc(xasprintf("%.15g", atan(1.5)))); - EXPECT_STREQ("-0.982793723247329", _gc(xasprintf("%.15g", atan(-1.5)))); - EXPECT_STREQ("nan", _gc(xasprintf("%.15g", atan(NAN)))); - EXPECT_STREQ("-nan", _gc(xasprintf("%.15g", atan(-NAN)))); - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", atan(INFINITY)))); - EXPECT_STREQ("-1.5707963267949", _gc(xasprintf("%.15g", atan(-INFINITY)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", atan(0.)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", atan(-0.)))); + EXPECT_STREQ("0.463647609000806", gc(xasprintf("%.15g", atan(.5)))); + EXPECT_STREQ("-0.463647609000806", gc(xasprintf("%.15g", atan(-.5)))); + EXPECT_STREQ("0.785398163397448", gc(xasprintf("%.15g", atan(1.)))); + EXPECT_STREQ("-0.785398163397448", gc(xasprintf("%.15g", atan(-1.)))); + EXPECT_STREQ("0.982793723247329", gc(xasprintf("%.15g", atan(1.5)))); + EXPECT_STREQ("-0.982793723247329", gc(xasprintf("%.15g", atan(-1.5)))); + EXPECT_STREQ("nan", gc(xasprintf("%.15g", atan(NAN)))); + EXPECT_STREQ("-nan", gc(xasprintf("%.15g", atan(-NAN)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", atan(INFINITY)))); + EXPECT_STREQ("-1.5707963267949", gc(xasprintf("%.15g", atan(-INFINITY)))); EXPECT_STREQ("2.2250738585072e-308", - _gc(xasprintf("%.15g", atan(__DBL_MIN__)))); - EXPECT_STREQ("1.5707963267949", _gc(xasprintf("%.15g", atan(__DBL_MAX__)))); + gc(xasprintf("%.15g", atan(__DBL_MIN__)))); + EXPECT_STREQ("1.5707963267949", gc(xasprintf("%.15g", atan(__DBL_MAX__)))); } BENCH(atanl, bench) { diff --git a/test/libc/tinymath/atanh_test.c b/test/libc/tinymath/atanh_test.c index 95104671f..afbbe1f7d 100644 --- a/test/libc/tinymath/atanh_test.c +++ b/test/libc/tinymath/atanh_test.c @@ -28,36 +28,36 @@ float _atanhf(float) asm("atanhf"); long double _atanhl(long double) asm("atanhl"); TEST(atanh, test) { - EXPECT_STREQ("0", _gc(xdtoa(_atanh(0)))); - EXPECT_STREQ("-0", _gc(xdtoa(_atanh(-0.)))); - EXPECT_STREQ(".549306144334055", _gc(xdtoa(_atanh(.5)))); - EXPECT_STREQ("-.549306144334055", _gc(xdtoa(_atanh(-.5)))); - EXPECT_STREQ("INFINITY", _gc(xdtoa(_atanh(+1)))); - EXPECT_STREQ("-INFINITY", _gc(xdtoa(_atanh(-1)))); + EXPECT_STREQ("0", gc(xdtoa(_atanh(0)))); + EXPECT_STREQ("-0", gc(xdtoa(_atanh(-0.)))); + EXPECT_STREQ(".549306144334055", gc(xdtoa(_atanh(.5)))); + EXPECT_STREQ("-.549306144334055", gc(xdtoa(_atanh(-.5)))); + EXPECT_STREQ("INFINITY", gc(xdtoa(_atanh(+1)))); + EXPECT_STREQ("-INFINITY", gc(xdtoa(_atanh(-1)))); EXPECT_TRUE(isnan(_atanh(+1.1))); EXPECT_TRUE(isnan(_atanh(-1.1))); EXPECT_STREQ("-2.1073424255447e-08", - _gc(xasprintf("%.15g", _atanh(-2.1073424255447e-08)))); + gc(xasprintf("%.15g", _atanh(-2.1073424255447e-08)))); } TEST(atanhl, test) { - EXPECT_STREQ("0", _gc(xdtoal(_atanhl(0)))); - EXPECT_STREQ("-0", _gc(xdtoal(_atanhl(-0.)))); - EXPECT_STREQ(".5493061443340548", _gc(xdtoal(_atanhl(.5)))); - EXPECT_STREQ("-.5493061443340548", _gc(xdtoal(_atanhl(-.5)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(_atanhl(+1)))); - EXPECT_STREQ("-INFINITY", _gc(xdtoal(_atanhl(-1)))); + EXPECT_STREQ("0", gc(xdtoal(_atanhl(0)))); + EXPECT_STREQ("-0", gc(xdtoal(_atanhl(-0.)))); + EXPECT_STREQ(".5493061443340548", gc(xdtoal(_atanhl(.5)))); + EXPECT_STREQ("-.5493061443340548", gc(xdtoal(_atanhl(-.5)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(_atanhl(+1)))); + EXPECT_STREQ("-INFINITY", gc(xdtoal(_atanhl(-1)))); EXPECT_TRUE(isnan(_atanhl(+1.1))); EXPECT_TRUE(isnan(_atanhl(-1.1))); } TEST(atanhf, test) { - EXPECT_STREQ("0", _gc(xdtoaf(_atanhf(0)))); - EXPECT_STREQ("-0", _gc(xdtoaf(_atanhf(-0.)))); - EXPECT_STREQ(".549306", _gc(xdtoaf(_atanhf(.5)))); - EXPECT_STREQ("-.549306", _gc(xdtoaf(_atanhf(-.5)))); - EXPECT_STREQ("INFINITY", _gc(xdtoaf(_atanhf(+1)))); - EXPECT_STREQ("-INFINITY", _gc(xdtoaf(_atanhf(-1)))); + EXPECT_STREQ("0", gc(xdtoaf(_atanhf(0)))); + EXPECT_STREQ("-0", gc(xdtoaf(_atanhf(-0.)))); + EXPECT_STREQ(".549306", gc(xdtoaf(_atanhf(.5)))); + EXPECT_STREQ("-.549306", gc(xdtoaf(_atanhf(-.5)))); + EXPECT_STREQ("INFINITY", gc(xdtoaf(_atanhf(+1)))); + EXPECT_STREQ("-INFINITY", gc(xdtoaf(_atanhf(-1)))); EXPECT_TRUE(isnan(_atanhf(+1.1))); EXPECT_TRUE(isnan(_atanhf(-1.1))); } diff --git a/test/libc/tinymath/cbrt_test.c b/test/libc/tinymath/cbrt_test.c index 2cd54b725..c70be9275 100644 --- a/test/libc/tinymath/cbrt_test.c +++ b/test/libc/tinymath/cbrt_test.c @@ -29,22 +29,22 @@ float _cbrtf(float) asm("cbrtf"); long double _cbrtl(long double) asm("cbrtl"); TEST(cbrt, test) { - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _cbrt(0.)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _cbrt(-0.)))); - EXPECT_STREQ("0.7937005259841", _gc(xasprintf("%.15g", _cbrt(.5)))); - EXPECT_STREQ("-0.7937005259841", _gc(xasprintf("%.15g", _cbrt(-.5)))); - EXPECT_STREQ("1", _gc(xasprintf("%.15g", _cbrt(1.)))); - EXPECT_STREQ("-1", _gc(xasprintf("%.15g", _cbrt(-1.)))); - EXPECT_STREQ("1.14471424255333", _gc(xasprintf("%.15g", _cbrt(1.5)))); - EXPECT_STREQ("-1.14471424255333", _gc(xasprintf("%.15g", _cbrt(-1.5)))); - EXPECT_STREQ("nan", _gc(xasprintf("%.15g", _cbrt(NAN)))); - EXPECT_STREQ("-nan", _gc(xasprintf("%.15g", _cbrt(-NAN)))); - EXPECT_STREQ("inf", _gc(xasprintf("%.15g", _cbrt(INFINITY)))); - EXPECT_STREQ("-inf", _gc(xasprintf("%.15g", _cbrt(-INFINITY)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _cbrt(0.)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _cbrt(-0.)))); + EXPECT_STREQ("0.7937005259841", gc(xasprintf("%.15g", _cbrt(.5)))); + EXPECT_STREQ("-0.7937005259841", gc(xasprintf("%.15g", _cbrt(-.5)))); + EXPECT_STREQ("1", gc(xasprintf("%.15g", _cbrt(1.)))); + EXPECT_STREQ("-1", gc(xasprintf("%.15g", _cbrt(-1.)))); + EXPECT_STREQ("1.14471424255333", gc(xasprintf("%.15g", _cbrt(1.5)))); + EXPECT_STREQ("-1.14471424255333", gc(xasprintf("%.15g", _cbrt(-1.5)))); + EXPECT_STREQ("nan", gc(xasprintf("%.15g", _cbrt(NAN)))); + EXPECT_STREQ("-nan", gc(xasprintf("%.15g", _cbrt(-NAN)))); + EXPECT_STREQ("inf", gc(xasprintf("%.15g", _cbrt(INFINITY)))); + EXPECT_STREQ("-inf", gc(xasprintf("%.15g", _cbrt(-INFINITY)))); EXPECT_STREQ("2.81264428523626e-103", - _gc(xasprintf("%.15g", _cbrt(__DBL_MIN__)))); + gc(xasprintf("%.15g", _cbrt(__DBL_MIN__)))); EXPECT_STREQ("5.64380309412236e+102", - _gc(xasprintf("%.15g", _cbrt(__DBL_MAX__)))); + gc(xasprintf("%.15g", _cbrt(__DBL_MAX__)))); } BENCH(cbrt, bench) { diff --git a/test/libc/tinymath/ceil_test.c b/test/libc/tinymath/ceil_test.c index 313b6a2d2..e326fb8c8 100644 --- a/test/libc/tinymath/ceil_test.c +++ b/test/libc/tinymath/ceil_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/copysign_test.c b/test/libc/tinymath/copysign_test.c index d1c1c999d..88e048450 100644 --- a/test/libc/tinymath/copysign_test.c +++ b/test/libc/tinymath/copysign_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/cos_test.c b/test/libc/tinymath/cos_test.c index f02ce451a..0934a4000 100644 --- a/test/libc/tinymath/cos_test.c +++ b/test/libc/tinymath/cos_test.c @@ -27,26 +27,26 @@ float _cosf(float) asm("cosf"); long double _cosl(long double) asm("cosl"); TEST(cos, test) { - EXPECT_STREQ("1", _gc(xasprintf("%.15g", _cos(0.)))); - EXPECT_STREQ("1", _gc(xasprintf("%.15g", _cos(-0.)))); - EXPECT_STREQ("0.995004165278026", _gc(xasprintf("%.15g", _cos(.1)))); - EXPECT_STREQ("0.995004165278026", _gc(xasprintf("%.15g", _cos(-.1)))); - EXPECT_STREQ("0.877582561890373", _gc(xasprintf("%.15g", _cos(.5)))); - EXPECT_STREQ("0.877582561890373", _gc(xasprintf("%.15g", _cos(-.5)))); - EXPECT_STREQ("0.54030230586814", _gc(xasprintf("%.15g", _cos(1.)))); - EXPECT_STREQ("0.54030230586814", _gc(xasprintf("%.15g", _cos(-1.)))); - EXPECT_STREQ("0.0707372016677029", _gc(xasprintf("%.15g", _cos(1.5)))); - EXPECT_STREQ("0.0707372016677029", _gc(xasprintf("%.15g", _cos(-1.5)))); - EXPECT_STREQ("-0.416146836547142", _gc(xasprintf("%.15g", _cos(2.)))); + EXPECT_STREQ("1", gc(xasprintf("%.15g", _cos(0.)))); + EXPECT_STREQ("1", gc(xasprintf("%.15g", _cos(-0.)))); + EXPECT_STREQ("0.995004165278026", gc(xasprintf("%.15g", _cos(.1)))); + EXPECT_STREQ("0.995004165278026", gc(xasprintf("%.15g", _cos(-.1)))); + EXPECT_STREQ("0.877582561890373", gc(xasprintf("%.15g", _cos(.5)))); + EXPECT_STREQ("0.877582561890373", gc(xasprintf("%.15g", _cos(-.5)))); + EXPECT_STREQ("0.54030230586814", gc(xasprintf("%.15g", _cos(1.)))); + EXPECT_STREQ("0.54030230586814", gc(xasprintf("%.15g", _cos(-1.)))); + EXPECT_STREQ("0.0707372016677029", gc(xasprintf("%.15g", _cos(1.5)))); + EXPECT_STREQ("0.0707372016677029", gc(xasprintf("%.15g", _cos(-1.5)))); + EXPECT_STREQ("-0.416146836547142", gc(xasprintf("%.15g", _cos(2.)))); EXPECT_TRUE(isnan(_cos(NAN))); EXPECT_TRUE(isnan(_cos(-NAN))); EXPECT_TRUE(isnan(_cos(INFINITY))); EXPECT_TRUE(isnan(_cos(-INFINITY))); - EXPECT_STREQ("1", _gc(xasprintf("%.15g", _cos(__DBL_MIN__)))); - EXPECT_STREQ("-0.99998768942656", _gc(xasprintf("%.15g", _cos(__DBL_MAX__)))); + EXPECT_STREQ("1", gc(xasprintf("%.15g", _cos(__DBL_MIN__)))); + EXPECT_STREQ("-0.99998768942656", gc(xasprintf("%.15g", _cos(__DBL_MAX__)))); EXPECT_STREQ("0.54030230586814", - _gc(xasprintf("%.15g", _cos(-1.0000000000000002)))); - EXPECT_STREQ("1", _gc(xasprintf("%.15g", _cos(-2.1073424255447e-08)))); + gc(xasprintf("%.15g", _cos(-1.0000000000000002)))); + EXPECT_STREQ("1", gc(xasprintf("%.15g", _cos(-2.1073424255447e-08)))); } BENCH(cos, bench) { diff --git a/test/libc/tinymath/cosh_test.c b/test/libc/tinymath/cosh_test.c index a2263d709..babdb08ff 100644 --- a/test/libc/tinymath/cosh_test.c +++ b/test/libc/tinymath/cosh_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/csqrt_test.c b/test/libc/tinymath/csqrt_test.c index 8d8dfc40f..4f22f9c77 100644 --- a/test/libc/tinymath/csqrt_test.c +++ b/test/libc/tinymath/csqrt_test.c @@ -23,5 +23,5 @@ TEST(csqrt, test) { complex double x = csqrt(-1); - EXPECT_STREQ("0 1", _gc(xasprintf("%g %g", creal(x), cimag(x)))); + EXPECT_STREQ("0 1", gc(xasprintf("%g %g", creal(x), cimag(x)))); } diff --git a/test/libc/tinymath/erf_test.c b/test/libc/tinymath/erf_test.c index f3badda9d..ac3fbaa90 100644 --- a/test/libc/tinymath/erf_test.c +++ b/test/libc/tinymath/erf_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/exp10_test.c b/test/libc/tinymath/exp10_test.c index 85f3c5dae..43f7ae58d 100644 --- a/test/libc/tinymath/exp10_test.c +++ b/test/libc/tinymath/exp10_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/exp2_test.c b/test/libc/tinymath/exp2_test.c index abe8b6e8a..7a7be0c50 100644 --- a/test/libc/tinymath/exp2_test.c +++ b/test/libc/tinymath/exp2_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/exp2l_test.c b/test/libc/tinymath/exp2l_test.c index 412b6461c..52a2d4d8e 100644 --- a/test/libc/tinymath/exp2l_test.c +++ b/test/libc/tinymath/exp2l_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/exp_test.c b/test/libc/tinymath/exp_test.c index 8db4c382b..fc20cab78 100644 --- a/test/libc/tinymath/exp_test.c +++ b/test/libc/tinymath/exp_test.c @@ -29,39 +29,39 @@ float _expf(float) asm("expf"); long double _expl(long double) asm("expl"); TEST(expl, test) { - EXPECT_STREQ("1", _gc(xdtoal(_expl(0)))); - EXPECT_STREQ("1", _gc(xdtoal(_expl(-0.)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(_expl(INFINITY)))); - EXPECT_STREQ("0", _gc(xdtoal(_expl(-INFINITY)))); - EXPECT_STREQ("NAN", _gc(xdtoal(_expl(NAN)))); - // EXPECT_STREQ("0", _gc(xdtoal(_expl(-132098844872390)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(_expl(132098844872390)))); + EXPECT_STREQ("1", gc(xdtoal(_expl(0)))); + EXPECT_STREQ("1", gc(xdtoal(_expl(-0.)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(_expl(INFINITY)))); + EXPECT_STREQ("0", gc(xdtoal(_expl(-INFINITY)))); + EXPECT_STREQ("NAN", gc(xdtoal(_expl(NAN)))); + // EXPECT_STREQ("0", gc(xdtoal(_expl(-132098844872390)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(_expl(132098844872390)))); } TEST(exp, test) { - EXPECT_STREQ("1", _gc(xdtoa(_exp(0)))); - EXPECT_STREQ("1", _gc(xdtoa(_exp(-0.)))); - EXPECT_STREQ("INFINITY", _gc(xdtoa(_exp(INFINITY)))); - EXPECT_STREQ("0", _gc(xdtoa(_exp(-INFINITY)))); - EXPECT_STREQ("NAN", _gc(xdtoa(_exp(NAN)))); - EXPECT_STREQ("0", _gc(xdtoa(_exp(-132098844872390)))); - EXPECT_STREQ("INFINITY", _gc(xdtoa(_exp(132098844872390)))); + EXPECT_STREQ("1", gc(xdtoa(_exp(0)))); + EXPECT_STREQ("1", gc(xdtoa(_exp(-0.)))); + EXPECT_STREQ("INFINITY", gc(xdtoa(_exp(INFINITY)))); + EXPECT_STREQ("0", gc(xdtoa(_exp(-INFINITY)))); + EXPECT_STREQ("NAN", gc(xdtoa(_exp(NAN)))); + EXPECT_STREQ("0", gc(xdtoa(_exp(-132098844872390)))); + EXPECT_STREQ("INFINITY", gc(xdtoa(_exp(132098844872390)))); } TEST(expf, test) { - EXPECT_STREQ("1", _gc(xdtoaf(_expf(0)))); - EXPECT_STREQ("1", _gc(xdtoaf(_expf(-0.)))); - EXPECT_STREQ("INFINITY", _gc(xdtoaf(_expf(INFINITY)))); - EXPECT_STREQ("0", _gc(xdtoaf(_expf(-INFINITY)))); - EXPECT_STREQ("NAN", _gc(xdtoaf(_expf(NAN)))); - EXPECT_STREQ("0", _gc(xdtoaf(_expf(-132098844872390)))); - EXPECT_STREQ("INFINITY", _gc(xdtoaf(_expf(132098844872390)))); + EXPECT_STREQ("1", gc(xdtoaf(_expf(0)))); + EXPECT_STREQ("1", gc(xdtoaf(_expf(-0.)))); + EXPECT_STREQ("INFINITY", gc(xdtoaf(_expf(INFINITY)))); + EXPECT_STREQ("0", gc(xdtoaf(_expf(-INFINITY)))); + EXPECT_STREQ("NAN", gc(xdtoaf(_expf(NAN)))); + EXPECT_STREQ("0", gc(xdtoaf(_expf(-132098844872390)))); + EXPECT_STREQ("INFINITY", gc(xdtoaf(_expf(132098844872390)))); } TEST(exp, fun) { - ASSERT_STREQ("7.389056", _gc(xasprintf("%f", _exp(2.0)))); - ASSERT_STREQ("6.389056", _gc(xasprintf("%f", expm1(2.0)))); - ASSERT_STREQ("6.389056", _gc(xasprintf("%f", _exp(2.0) - 1.0))); + ASSERT_STREQ("7.389056", gc(xasprintf("%f", _exp(2.0)))); + ASSERT_STREQ("6.389056", gc(xasprintf("%f", expm1(2.0)))); + ASSERT_STREQ("6.389056", gc(xasprintf("%f", _exp(2.0) - 1.0))); } BENCH(expl, bench) { diff --git a/test/libc/tinymath/expm1_test.c b/test/libc/tinymath/expm1_test.c index 1846b8dad..d1a8b70b0 100644 --- a/test/libc/tinymath/expm1_test.c +++ b/test/libc/tinymath/expm1_test.c @@ -28,51 +28,51 @@ float _expm1f(float) asm("expm1f"); long double _expm1l(long double) asm("expm1l"); TEST(expm1, test) { - EXPECT_STREQ("0", _gc(xdtoa(_expm1(0)))); - EXPECT_STREQ("-0", _gc(xdtoa(_expm1(-0.)))); - EXPECT_STREQ("NAN", _gc(xdtoa(_expm1(NAN)))); - EXPECT_STREQ("-1", _gc(xdtoa(_expm1(-INFINITY)))); - EXPECT_STREQ("INFINITY", _gc(xdtoa(_expm1(INFINITY)))); - /* EXPECT_STREQ("-INFINITY", _gc(xdtoa(_expm1(-132098844872390)))); */ - /* EXPECT_STREQ("INFINITY", _gc(xdtoa(_expm1(132098844872390)))); */ - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _expm1(0.)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _expm1(-0.)))); - EXPECT_STREQ("0.648721270700128", _gc(xasprintf("%.15g", _expm1(.5)))); - EXPECT_STREQ("-0.393469340287367", _gc(xasprintf("%.15g", _expm1(-.5)))); - EXPECT_STREQ("1.71828182845905", _gc(xasprintf("%.15g", _expm1(1.)))); - EXPECT_STREQ("-0.632120558828558", _gc(xasprintf("%.15g", _expm1(-1.)))); - EXPECT_STREQ("3.48168907033806", _gc(xasprintf("%.15g", _expm1(1.5)))); - EXPECT_STREQ("-0.77686983985157", _gc(xasprintf("%.15g", _expm1(-1.5)))); - EXPECT_STREQ("6.38905609893065", _gc(xasprintf("%.15g", _expm1(2.)))); + EXPECT_STREQ("0", gc(xdtoa(_expm1(0)))); + EXPECT_STREQ("-0", gc(xdtoa(_expm1(-0.)))); + EXPECT_STREQ("NAN", gc(xdtoa(_expm1(NAN)))); + EXPECT_STREQ("-1", gc(xdtoa(_expm1(-INFINITY)))); + EXPECT_STREQ("INFINITY", gc(xdtoa(_expm1(INFINITY)))); + /* EXPECT_STREQ("-INFINITY", gc(xdtoa(_expm1(-132098844872390)))); */ + /* EXPECT_STREQ("INFINITY", gc(xdtoa(_expm1(132098844872390)))); */ + EXPECT_STREQ("0", gc(xasprintf("%.15g", _expm1(0.)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _expm1(-0.)))); + EXPECT_STREQ("0.648721270700128", gc(xasprintf("%.15g", _expm1(.5)))); + EXPECT_STREQ("-0.393469340287367", gc(xasprintf("%.15g", _expm1(-.5)))); + EXPECT_STREQ("1.71828182845905", gc(xasprintf("%.15g", _expm1(1.)))); + EXPECT_STREQ("-0.632120558828558", gc(xasprintf("%.15g", _expm1(-1.)))); + EXPECT_STREQ("3.48168907033806", gc(xasprintf("%.15g", _expm1(1.5)))); + EXPECT_STREQ("-0.77686983985157", gc(xasprintf("%.15g", _expm1(-1.5)))); + EXPECT_STREQ("6.38905609893065", gc(xasprintf("%.15g", _expm1(2.)))); EXPECT_TRUE(isnan(_expm1(NAN))); EXPECT_TRUE(isnan(_expm1(-NAN))); - EXPECT_STREQ("inf", _gc(xasprintf("%.15g", _expm1(INFINITY)))); - EXPECT_STREQ("-1", _gc(xasprintf("%.15g", _expm1(-INFINITY)))); + EXPECT_STREQ("inf", gc(xasprintf("%.15g", _expm1(INFINITY)))); + EXPECT_STREQ("-1", gc(xasprintf("%.15g", _expm1(-INFINITY)))); EXPECT_STREQ("2.2250738585072e-308", - _gc(xasprintf("%.15g", _expm1(__DBL_MIN__)))); - EXPECT_STREQ("inf", _gc(xasprintf("%.15g", _expm1(__DBL_MAX__)))); + gc(xasprintf("%.15g", _expm1(__DBL_MIN__)))); + EXPECT_STREQ("inf", gc(xasprintf("%.15g", _expm1(__DBL_MAX__)))); } TEST(expm1l, test) { - EXPECT_STREQ("1.718281828459045", _gc(xdtoal(_expm1l(1)))); - EXPECT_STREQ("1.718281828459045", _gc(xdtoal(expl(1) - 1))); - EXPECT_STREQ("0", _gc(xdtoal(_expm1l(0)))); - EXPECT_STREQ("-0", _gc(xdtoal(_expm1l(-0.)))); - EXPECT_STREQ("NAN", _gc(xdtoal(_expm1l(NAN)))); - EXPECT_STREQ("-1", _gc(xdtoal(_expm1l(-INFINITY)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(_expm1l(INFINITY)))); - /* EXPECT_STREQ("-INFINITY", _gc(xdtoal(_expm1l(-132098844872390)))); */ - /* EXPECT_STREQ("INFINITY", _gc(xdtoal(_expm1l(132098844872390)))); */ + EXPECT_STREQ("1.718281828459045", gc(xdtoal(_expm1l(1)))); + EXPECT_STREQ("1.718281828459045", gc(xdtoal(expl(1) - 1))); + EXPECT_STREQ("0", gc(xdtoal(_expm1l(0)))); + EXPECT_STREQ("-0", gc(xdtoal(_expm1l(-0.)))); + EXPECT_STREQ("NAN", gc(xdtoal(_expm1l(NAN)))); + EXPECT_STREQ("-1", gc(xdtoal(_expm1l(-INFINITY)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(_expm1l(INFINITY)))); + /* EXPECT_STREQ("-INFINITY", gc(xdtoal(_expm1l(-132098844872390)))); */ + /* EXPECT_STREQ("INFINITY", gc(xdtoal(_expm1l(132098844872390)))); */ } TEST(expm1f, test) { - EXPECT_STREQ("0", _gc(xdtoaf(_expm1f(0)))); - EXPECT_STREQ("-0", _gc(xdtoaf(_expm1f(-0.)))); - EXPECT_STREQ("NAN", _gc(xdtoaf(_expm1f(NAN)))); - EXPECT_STREQ("-1", _gc(xdtoaf(_expm1f(-INFINITY)))); - EXPECT_STREQ("INFINITY", _gc(xdtoaf(_expm1f(INFINITY)))); - /* EXPECT_STREQ("-INFINITY", _gc(xdtoaf(_expm1f(-132098844872390)))); */ - /* EXPECT_STREQ("INFINITY", _gc(xdtoaf(_expm1f(132098844872390)))); */ + EXPECT_STREQ("0", gc(xdtoaf(_expm1f(0)))); + EXPECT_STREQ("-0", gc(xdtoaf(_expm1f(-0.)))); + EXPECT_STREQ("NAN", gc(xdtoaf(_expm1f(NAN)))); + EXPECT_STREQ("-1", gc(xdtoaf(_expm1f(-INFINITY)))); + EXPECT_STREQ("INFINITY", gc(xdtoaf(_expm1f(INFINITY)))); + /* EXPECT_STREQ("-INFINITY", gc(xdtoaf(_expm1f(-132098844872390)))); */ + /* EXPECT_STREQ("INFINITY", gc(xdtoaf(_expm1f(132098844872390)))); */ } BENCH(expm1, bench) { diff --git a/test/libc/tinymath/fabs_test.c b/test/libc/tinymath/fabs_test.c index 90d04e4d7..c0564c76e 100644 --- a/test/libc/tinymath/fabs_test.c +++ b/test/libc/tinymath/fabs_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/floor_test.c b/test/libc/tinymath/floor_test.c index 90cf22885..8fc16684b 100644 --- a/test/libc/tinymath/floor_test.c +++ b/test/libc/tinymath/floor_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/fmod_test.c b/test/libc/tinymath/fmod_test.c index 3bd2d3445..9e850d3fb 100644 --- a/test/libc/tinymath/fmod_test.c +++ b/test/libc/tinymath/fmod_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/stdio/rand.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/tinymath/fsum_test.c b/test/libc/tinymath/fsum_test.c index 7756cc7a4..7936e440a 100644 --- a/test/libc/tinymath/fsum_test.c +++ b/test/libc/tinymath/fsum_test.c @@ -41,11 +41,11 @@ void SetUp(void) { } TEST(fsum, test) { - EXPECT_STREQ("500000000.6", _gc(xasprintf("%.15g", fsum(D, N) / N))); + EXPECT_STREQ("500000000.6", gc(xasprintf("%.15g", fsum(D, N) / N))); } TEST(fsumf, test) { - EXPECT_STREQ("500.6", _gc(xasprintf("%.7g", fsumf(F, N) / N))); + EXPECT_STREQ("500.6", gc(xasprintf("%.7g", fsumf(F, N) / N))); } BENCH(fsum, bench) { diff --git a/test/libc/tinymath/gamma_test.c b/test/libc/tinymath/gamma_test.c index 002487fcf..b396d1de4 100644 --- a/test/libc/tinymath/gamma_test.c +++ b/test/libc/tinymath/gamma_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/hypot_test.c b/test/libc/tinymath/hypot_test.c index 3b1898f01..802d994ed 100644 --- a/test/libc/tinymath/hypot_test.c +++ b/test/libc/tinymath/hypot_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/ldexp_test.c b/test/libc/tinymath/ldexp_test.c index 2b1938d08..88f1cd2f1 100644 --- a/test/libc/tinymath/ldexp_test.c +++ b/test/libc/tinymath/ldexp_test.c @@ -37,84 +37,84 @@ void SetUp(void) { TEST(ldexpl, test) { EXPECT_EQ(rando, _ldexpl(rando, 0)); - EXPECT_STREQ("NAN", _gc(xdtoal(_ldexpl(NAN, 0)))); - EXPECT_STREQ("-NAN", _gc(xdtoal(_ldexpl(-NAN, 0)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(_ldexpl(INFINITY, 0)))); - EXPECT_STREQ("-INFINITY", _gc(xdtoal(_ldexpl(-INFINITY, 0)))); - EXPECT_STREQ("NAN", _gc(xdtoal(_ldexpl(NAN, 1)))); - EXPECT_STREQ("-NAN", _gc(xdtoal(_ldexpl(-NAN, 1)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(_ldexpl(INFINITY, 1)))); - EXPECT_STREQ("-INFINITY", _gc(xdtoal(_ldexpl(-INFINITY, 1)))); - EXPECT_STREQ("16384", _gc(xdtoal(log2l(LDBL_MAX)))); - EXPECT_STREQ(".00390625", _gc(xdtoal(_ldexpl(1, -8)))); - EXPECT_STREQ("0", _gc(xdtoal(_ldexpl(0, -8)))); - EXPECT_STREQ("0", _gc(xdtoal(_ldexpl(0, 8)))); - EXPECT_STREQ("256", _gc(xdtoal(_ldexpl(1, 8)))); - EXPECT_STREQ("512", _gc(xdtoal(_ldexpl(2, 8)))); - EXPECT_STREQ("768", _gc(xdtoal(_ldexpl(3, 8)))); - EXPECT_STREQ("6.997616471358197e+3461", _gc(xdtoal(_ldexpl(1, 11500)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(_ldexpl(1, 999999)))); - // EXPECT_STREQ("0", _gc(xdtoal(_ldexpl(1, -999999)))); + EXPECT_STREQ("NAN", gc(xdtoal(_ldexpl(NAN, 0)))); + EXPECT_STREQ("-NAN", gc(xdtoal(_ldexpl(-NAN, 0)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(_ldexpl(INFINITY, 0)))); + EXPECT_STREQ("-INFINITY", gc(xdtoal(_ldexpl(-INFINITY, 0)))); + EXPECT_STREQ("NAN", gc(xdtoal(_ldexpl(NAN, 1)))); + EXPECT_STREQ("-NAN", gc(xdtoal(_ldexpl(-NAN, 1)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(_ldexpl(INFINITY, 1)))); + EXPECT_STREQ("-INFINITY", gc(xdtoal(_ldexpl(-INFINITY, 1)))); + EXPECT_STREQ("16384", gc(xdtoal(log2l(LDBL_MAX)))); + EXPECT_STREQ(".00390625", gc(xdtoal(_ldexpl(1, -8)))); + EXPECT_STREQ("0", gc(xdtoal(_ldexpl(0, -8)))); + EXPECT_STREQ("0", gc(xdtoal(_ldexpl(0, 8)))); + EXPECT_STREQ("256", gc(xdtoal(_ldexpl(1, 8)))); + EXPECT_STREQ("512", gc(xdtoal(_ldexpl(2, 8)))); + EXPECT_STREQ("768", gc(xdtoal(_ldexpl(3, 8)))); + EXPECT_STREQ("6.997616471358197e+3461", gc(xdtoal(_ldexpl(1, 11500)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(_ldexpl(1, 999999)))); + // EXPECT_STREQ("0", gc(xdtoal(_ldexpl(1, -999999)))); } TEST(ldexp, test) { EXPECT_EQ(rando, _ldexp(rando, 0)); - EXPECT_STREQ("NAN", _gc(xdtoa(_ldexp(NAN, 0)))); - EXPECT_STREQ("-NAN", _gc(xdtoa(_ldexp(-NAN, 0)))); - EXPECT_STREQ("INFINITY", _gc(xdtoa(_ldexp(INFINITY, 0)))); - EXPECT_STREQ("-INFINITY", _gc(xdtoa(_ldexp(-INFINITY, 0)))); - EXPECT_STREQ("NAN", _gc(xdtoa(_ldexp(NAN, 1)))); - EXPECT_STREQ("-NAN", _gc(xdtoa(_ldexp(-NAN, 1)))); - EXPECT_STREQ("INFINITY", _gc(xdtoa(_ldexp(INFINITY, 1)))); - EXPECT_STREQ("-INFINITY", _gc(xdtoa(_ldexp(-INFINITY, 1)))); - EXPECT_STREQ("16384", _gc(xdtoa(log2l(LDBL_MAX)))); - EXPECT_STREQ(".00390625", _gc(xdtoa(_ldexp(1, -8)))); - EXPECT_STREQ("0", _gc(xdtoa(_ldexp(0, -8)))); - EXPECT_STREQ("0", _gc(xdtoa(_ldexp(0, 8)))); - EXPECT_STREQ("256", _gc(xdtoa(_ldexp(1, 8)))); - EXPECT_STREQ("512", _gc(xdtoa(_ldexp(2, 8)))); - EXPECT_STREQ("768", _gc(xdtoa(_ldexp(3, 8)))); - EXPECT_STREQ("INFINITY", _gc(xdtoa(_ldexp(1, 999999)))); - EXPECT_STREQ("0", _gc(xdtoa(_ldexp(1, -999999)))); + EXPECT_STREQ("NAN", gc(xdtoa(_ldexp(NAN, 0)))); + EXPECT_STREQ("-NAN", gc(xdtoa(_ldexp(-NAN, 0)))); + EXPECT_STREQ("INFINITY", gc(xdtoa(_ldexp(INFINITY, 0)))); + EXPECT_STREQ("-INFINITY", gc(xdtoa(_ldexp(-INFINITY, 0)))); + EXPECT_STREQ("NAN", gc(xdtoa(_ldexp(NAN, 1)))); + EXPECT_STREQ("-NAN", gc(xdtoa(_ldexp(-NAN, 1)))); + EXPECT_STREQ("INFINITY", gc(xdtoa(_ldexp(INFINITY, 1)))); + EXPECT_STREQ("-INFINITY", gc(xdtoa(_ldexp(-INFINITY, 1)))); + EXPECT_STREQ("16384", gc(xdtoa(log2l(LDBL_MAX)))); + EXPECT_STREQ(".00390625", gc(xdtoa(_ldexp(1, -8)))); + EXPECT_STREQ("0", gc(xdtoa(_ldexp(0, -8)))); + EXPECT_STREQ("0", gc(xdtoa(_ldexp(0, 8)))); + EXPECT_STREQ("256", gc(xdtoa(_ldexp(1, 8)))); + EXPECT_STREQ("512", gc(xdtoa(_ldexp(2, 8)))); + EXPECT_STREQ("768", gc(xdtoa(_ldexp(3, 8)))); + EXPECT_STREQ("INFINITY", gc(xdtoa(_ldexp(1, 999999)))); + EXPECT_STREQ("0", gc(xdtoa(_ldexp(1, -999999)))); } TEST(ldexpf, test) { EXPECT_EQ(rando, _ldexpf(rando, 0)); - EXPECT_STREQ("NAN", _gc(xdtoaf(_ldexpf(NAN, 0)))); - EXPECT_STREQ("-NAN", _gc(xdtoaf(_ldexpf(-NAN, 0)))); - EXPECT_STREQ("INFINITY", _gc(xdtoaf(_ldexpf(INFINITY, 0)))); - EXPECT_STREQ("-INFINITY", _gc(xdtoaf(_ldexpf(-INFINITY, 0)))); - EXPECT_STREQ("NAN", _gc(xdtoaf(_ldexpf(NAN, 1)))); - EXPECT_STREQ("-NAN", _gc(xdtoaf(_ldexpf(-NAN, 1)))); - EXPECT_STREQ("INFINITY", _gc(xdtoaf(_ldexpf(INFINITY, 1)))); - EXPECT_STREQ("-INFINITY", _gc(xdtoaf(_ldexpf(-INFINITY, 1)))); - EXPECT_STREQ("16384", _gc(xdtoaf(log2l(LDBL_MAX)))); - EXPECT_STREQ(".00390625", _gc(xdtoaf(_ldexpf(1, -8)))); - EXPECT_STREQ("0", _gc(xdtoaf(_ldexpf(0, -8)))); - EXPECT_STREQ("0", _gc(xdtoaf(_ldexpf(0, 8)))); - EXPECT_STREQ("256", _gc(xdtoaf(_ldexpf(1, 8)))); - EXPECT_STREQ("512", _gc(xdtoaf(_ldexpf(2, 8)))); - EXPECT_STREQ("768", _gc(xdtoaf(_ldexpf(3, 8)))); - EXPECT_STREQ("INFINITY", _gc(xdtoaf(_ldexpf(1, 999999)))); - EXPECT_STREQ("0", _gc(xdtoaf(_ldexpf(1, -999999)))); + EXPECT_STREQ("NAN", gc(xdtoaf(_ldexpf(NAN, 0)))); + EXPECT_STREQ("-NAN", gc(xdtoaf(_ldexpf(-NAN, 0)))); + EXPECT_STREQ("INFINITY", gc(xdtoaf(_ldexpf(INFINITY, 0)))); + EXPECT_STREQ("-INFINITY", gc(xdtoaf(_ldexpf(-INFINITY, 0)))); + EXPECT_STREQ("NAN", gc(xdtoaf(_ldexpf(NAN, 1)))); + EXPECT_STREQ("-NAN", gc(xdtoaf(_ldexpf(-NAN, 1)))); + EXPECT_STREQ("INFINITY", gc(xdtoaf(_ldexpf(INFINITY, 1)))); + EXPECT_STREQ("-INFINITY", gc(xdtoaf(_ldexpf(-INFINITY, 1)))); + EXPECT_STREQ("16384", gc(xdtoaf(log2l(LDBL_MAX)))); + EXPECT_STREQ(".00390625", gc(xdtoaf(_ldexpf(1, -8)))); + EXPECT_STREQ("0", gc(xdtoaf(_ldexpf(0, -8)))); + EXPECT_STREQ("0", gc(xdtoaf(_ldexpf(0, 8)))); + EXPECT_STREQ("256", gc(xdtoaf(_ldexpf(1, 8)))); + EXPECT_STREQ("512", gc(xdtoaf(_ldexpf(2, 8)))); + EXPECT_STREQ("768", gc(xdtoaf(_ldexpf(3, 8)))); + EXPECT_STREQ("INFINITY", gc(xdtoaf(_ldexpf(1, 999999)))); + EXPECT_STREQ("0", gc(xdtoaf(_ldexpf(1, -999999)))); } TEST(ldexp, stuff) { volatile int twopow = 5; volatile double pi = 3.14; - ASSERT_STREQ("100.48", _gc(xasprintf("%.2f", _ldexp(pi, twopow)))); - ASSERT_STREQ("100.48", _gc(xasprintf("%.2f", _ldexpf(pi, twopow)))); - ASSERT_STREQ("100.48", _gc(xasprintf("%.2f", scalb(pi, twopow)))); - ASSERT_STREQ("100.48", _gc(xasprintf("%.2f", scalbf(pi, twopow)))); - ASSERT_STREQ("100.48", _gc(xasprintf("%.2f", scalbn(pi, twopow)))); - ASSERT_STREQ("100.48", _gc(xasprintf("%.2f", scalbnf(pi, twopow)))); - ASSERT_STREQ("100.48", _gc(xasprintf("%.2f", scalbln(pi, twopow)))); - ASSERT_STREQ("100.48", _gc(xasprintf("%.2f", scalblnf(pi, twopow)))); + ASSERT_STREQ("100.48", gc(xasprintf("%.2f", _ldexp(pi, twopow)))); + ASSERT_STREQ("100.48", gc(xasprintf("%.2f", _ldexpf(pi, twopow)))); + ASSERT_STREQ("100.48", gc(xasprintf("%.2f", scalb(pi, twopow)))); + ASSERT_STREQ("100.48", gc(xasprintf("%.2f", scalbf(pi, twopow)))); + ASSERT_STREQ("100.48", gc(xasprintf("%.2f", scalbn(pi, twopow)))); + ASSERT_STREQ("100.48", gc(xasprintf("%.2f", scalbnf(pi, twopow)))); + ASSERT_STREQ("100.48", gc(xasprintf("%.2f", scalbln(pi, twopow)))); + ASSERT_STREQ("100.48", gc(xasprintf("%.2f", scalblnf(pi, twopow)))); #ifndef __aarch64__ // TODO: implement quad floating point in printf - ASSERT_STREQ("100.48", _gc(xasprintf("%.2Lf", _ldexpl(pi, twopow)))); - ASSERT_STREQ("100.48", _gc(xasprintf("%.2Lf", scalbnl(pi, twopow)))); - ASSERT_STREQ("100.48", _gc(xasprintf("%.2Lf", scalblnl(pi, twopow)))); + ASSERT_STREQ("100.48", gc(xasprintf("%.2Lf", _ldexpl(pi, twopow)))); + ASSERT_STREQ("100.48", gc(xasprintf("%.2Lf", scalbnl(pi, twopow)))); + ASSERT_STREQ("100.48", gc(xasprintf("%.2Lf", scalblnl(pi, twopow)))); #endif } diff --git a/test/libc/tinymath/log10_test.c b/test/libc/tinymath/log10_test.c index eefcf756a..4fab5d0dc 100644 --- a/test/libc/tinymath/log10_test.c +++ b/test/libc/tinymath/log10_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/log1p_test.c b/test/libc/tinymath/log1p_test.c index 8eb93ccbc..51d029b27 100644 --- a/test/libc/tinymath/log1p_test.c +++ b/test/libc/tinymath/log1p_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/log2_test.c b/test/libc/tinymath/log2_test.c index 46d822140..8af6a798a 100644 --- a/test/libc/tinymath/log2_test.c +++ b/test/libc/tinymath/log2_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/log_test.c b/test/libc/tinymath/log_test.c index 5e2586d52..bf31388b6 100644 --- a/test/libc/tinymath/log_test.c +++ b/test/libc/tinymath/log_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/measureentropy_test.c b/test/libc/tinymath/measureentropy_test.c index 366579c0e..75389c14f 100644 --- a/test/libc/tinymath/measureentropy_test.c +++ b/test/libc/tinymath/measureentropy_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" #include "libc/stdio/rand.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/tinymath/powl_test.c b/test/libc/tinymath/powl_test.c index e650ae8c5..0c2f3bada 100644 --- a/test/libc/tinymath/powl_test.c +++ b/test/libc/tinymath/powl_test.c @@ -55,57 +55,57 @@ static char *fmtf(float x) { } TEST(powl, test) { - EXPECT_STREQ("27", _gc(xdtoal(powl(3, 3)))); - EXPECT_STREQ("-27", _gc(xdtoal(powl(-3, 3)))); - EXPECT_STREQ("1e+4932", _gc(xdtoal(powl(10, 4932)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(10, 4933)))); - // EXPECT_STREQ("0", _gc(xdtoal(powl(10, -5000)))); - EXPECT_STREQ("1.063382396627933e+37", _gc(xdtoal(powl(2, 123)))); - EXPECT_STARTSWITH(".4248496805467504", _gc(xdtoal(powl(.7, 2.4)))); - EXPECT_STREQ("1", _gc(xdtoal(powl(1, NAN)))); - EXPECT_STREQ("1", _gc(xdtoal(powl(1, rando)))); - EXPECT_STREQ("1", _gc(xdtoal(powl(NAN, 0)))); - EXPECT_STREQ("1", _gc(xdtoal(powl(rando, 0)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(0, 1)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(0, 2)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(0, 2.1)))); - EXPECT_STREQ("1", _gc(xdtoal(powl(-1, INFINITY)))); - EXPECT_STREQ("1", _gc(xdtoal(powl(-1, -INFINITY)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(1. / MAX(2, rando), -INFINITY)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(1.1, -INFINITY)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(MAX(2, rando), -INFINITY)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(1. / MAX(2, rando), INFINITY)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(MAX(2, rando), INFINITY)))); - EXPECT_STREQ("-0", _gc(xdtoal(powl(-INFINITY, -1)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(-INFINITY, -1.1)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(-INFINITY, -2)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(-INFINITY, -2.1)))); - EXPECT_STREQ("-0", _gc(xdtoal(powl(-INFINITY, -3)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(-INFINITY, -3.1)))); - EXPECT_STREQ("-INFINITY", _gc(xdtoal(powl(-INFINITY, 1)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(-INFINITY, 1.1)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(-INFINITY, 2)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(-INFINITY, 2.1)))); - EXPECT_STREQ("-INFINITY", _gc(xdtoal(powl(-INFINITY, 3)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(-INFINITY, 3.1)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(INFINITY, -1)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(INFINITY, -.1)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(INFINITY, 1)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(INFINITY, .1)))); - EXPECT_STREQ("1", _gc(xdtoal(powl(INFINITY, 0)))); - EXPECT_STREQ("1", _gc(xdtoal(powl(INFINITY, -0.)))); - EXPECT_STREQ("1", _gc(xdtoal(powl(0, 0)))); - EXPECT_STREQ("1", _gc(xdtoal(powl(0, -0.)))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(0, -(MAX(rando, 1) | 1))))); - EXPECT_STREQ("-INFINITY", _gc(xdtoal(powl(-0., -(MAX(rando, 1) | 1))))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(0, -(rando & -2))))); - EXPECT_STREQ("INFINITY", _gc(xdtoal(powl(-0., -(rando & -2))))); + EXPECT_STREQ("27", gc(xdtoal(powl(3, 3)))); + EXPECT_STREQ("-27", gc(xdtoal(powl(-3, 3)))); + EXPECT_STREQ("1e+4932", gc(xdtoal(powl(10, 4932)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(10, 4933)))); + // EXPECT_STREQ("0", gc(xdtoal(powl(10, -5000)))); + EXPECT_STREQ("1.063382396627933e+37", gc(xdtoal(powl(2, 123)))); + EXPECT_STARTSWITH(".4248496805467504", gc(xdtoal(powl(.7, 2.4)))); + EXPECT_STREQ("1", gc(xdtoal(powl(1, NAN)))); + EXPECT_STREQ("1", gc(xdtoal(powl(1, rando)))); + EXPECT_STREQ("1", gc(xdtoal(powl(NAN, 0)))); + EXPECT_STREQ("1", gc(xdtoal(powl(rando, 0)))); + EXPECT_STREQ("0", gc(xdtoal(powl(0, 1)))); + EXPECT_STREQ("0", gc(xdtoal(powl(0, 2)))); + EXPECT_STREQ("0", gc(xdtoal(powl(0, 2.1)))); + EXPECT_STREQ("1", gc(xdtoal(powl(-1, INFINITY)))); + EXPECT_STREQ("1", gc(xdtoal(powl(-1, -INFINITY)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(1. / MAX(2, rando), -INFINITY)))); + EXPECT_STREQ("0", gc(xdtoal(powl(1.1, -INFINITY)))); + EXPECT_STREQ("0", gc(xdtoal(powl(MAX(2, rando), -INFINITY)))); + EXPECT_STREQ("0", gc(xdtoal(powl(1. / MAX(2, rando), INFINITY)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(MAX(2, rando), INFINITY)))); + EXPECT_STREQ("-0", gc(xdtoal(powl(-INFINITY, -1)))); + EXPECT_STREQ("0", gc(xdtoal(powl(-INFINITY, -1.1)))); + EXPECT_STREQ("0", gc(xdtoal(powl(-INFINITY, -2)))); + EXPECT_STREQ("0", gc(xdtoal(powl(-INFINITY, -2.1)))); + EXPECT_STREQ("-0", gc(xdtoal(powl(-INFINITY, -3)))); + EXPECT_STREQ("0", gc(xdtoal(powl(-INFINITY, -3.1)))); + EXPECT_STREQ("-INFINITY", gc(xdtoal(powl(-INFINITY, 1)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(-INFINITY, 1.1)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(-INFINITY, 2)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(-INFINITY, 2.1)))); + EXPECT_STREQ("-INFINITY", gc(xdtoal(powl(-INFINITY, 3)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(-INFINITY, 3.1)))); + EXPECT_STREQ("0", gc(xdtoal(powl(INFINITY, -1)))); + EXPECT_STREQ("0", gc(xdtoal(powl(INFINITY, -.1)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(INFINITY, 1)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(INFINITY, .1)))); + EXPECT_STREQ("1", gc(xdtoal(powl(INFINITY, 0)))); + EXPECT_STREQ("1", gc(xdtoal(powl(INFINITY, -0.)))); + EXPECT_STREQ("1", gc(xdtoal(powl(0, 0)))); + EXPECT_STREQ("1", gc(xdtoal(powl(0, -0.)))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(0, -(MAX(rando, 1) | 1))))); + EXPECT_STREQ("-INFINITY", gc(xdtoal(powl(-0., -(MAX(rando, 1) | 1))))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(0, -(rando & -2))))); + EXPECT_STREQ("INFINITY", gc(xdtoal(powl(-0., -(rando & -2))))); EXPECT_TRUE(isnan(powl(-3, 1. / MAX(rando, 2)))); EXPECT_TRUE(isnan(powl(-3, -(1. / MAX(rando, 2))))); - EXPECT_STREQ("-.3333333333333333", _gc(xdtoal(powl(-3, -1)))); - EXPECT_STREQ(".1111111111111111", _gc(xdtoal(powl(-3, -2)))); - EXPECT_STREQ("-0", _gc(xdtoal(powl(-0., MAX(1, rando) | 1)))); - EXPECT_STREQ("0", _gc(xdtoal(powl(-0., MAX(1, rando) & ~1)))); + EXPECT_STREQ("-.3333333333333333", gc(xdtoal(powl(-3, -1)))); + EXPECT_STREQ(".1111111111111111", gc(xdtoal(powl(-3, -2)))); + EXPECT_STREQ("-0", gc(xdtoal(powl(-0., MAX(1, rando) | 1)))); + EXPECT_STREQ("0", gc(xdtoal(powl(-0., MAX(1, rando) & ~1)))); } TEST(pow, test) { @@ -156,8 +156,8 @@ TEST(pow, test) { EXPECT_STREQ("inf", fmtd(pow(-0., -(rando & -2)))); EXPECT_STREQ("-0.333333333333333", fmtd(pow(-3, -1))); EXPECT_STREQ("0.111111111111111", fmtd(pow(-3, -2))); - EXPECT_STREQ("-0", _gc(xdtoa(pow(-0., MAX(1, rando) | 1)))); - EXPECT_STREQ("0", _gc(xdtoa(pow(-0., MAX(1, rando) & ~1)))); + EXPECT_STREQ("-0", gc(xdtoa(pow(-0., MAX(1, rando) | 1)))); + EXPECT_STREQ("0", gc(xdtoa(pow(-0., MAX(1, rando) & ~1)))); } TEST(powf, test) { @@ -208,8 +208,8 @@ TEST(powf, test) { EXPECT_STREQ("inf", fmtf(powf(-0., -(rando & -2)))); EXPECT_STREQ("-0.333333", fmtf(powf(-3, -1))); EXPECT_STREQ("0.111111", fmtf(powf(-3, -2))); - EXPECT_STREQ("-0", _gc(xdtoaf(powf(-0., MAX(1, rando) | 1)))); - EXPECT_STREQ("0", _gc(xdtoaf(powf(-0., MAX(1, rando) & ~1)))); + EXPECT_STREQ("-0", gc(xdtoaf(powf(-0., MAX(1, rando) | 1)))); + EXPECT_STREQ("0", gc(xdtoaf(powf(-0., MAX(1, rando) & ~1)))); } #if 0 @@ -548,15 +548,15 @@ TEST(powl, errors) { errno = 0; EXPECT_STREQ("inf", fmtd(POW(__DBL_MAX__, __DBL_MAX__))); /* EXPECT_EQ(ERANGE, errno); */ - EXPECT_STREQ("1", _gc(xasprintf("%.15g", POW(0., 0)))); - EXPECT_STREQ("1", _gc(xasprintf("%.15g", POW(-0., 0)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", POW(-0., 1)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", POW(-0., 11)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", POW(-0., 111)))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", POW(-0., 2)))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", POW(-0., 22)))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", POW(-0., 222)))); - EXPECT_STREQ("0", _gc(xasprintf("%.15g", POW(-0., 2.5)))); + EXPECT_STREQ("1", gc(xasprintf("%.15g", POW(0., 0)))); + EXPECT_STREQ("1", gc(xasprintf("%.15g", POW(-0., 0)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", POW(-0., 1)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", POW(-0., 11)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", POW(-0., 111)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", POW(-0., 2)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", POW(-0., 22)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", POW(-0., 222)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", POW(-0., 2.5)))); } #endif diff --git a/test/libc/tinymath/remainder_test.c b/test/libc/tinymath/remainder_test.c index 224feebef..50261f039 100644 --- a/test/libc/tinymath/remainder_test.c +++ b/test/libc/tinymath/remainder_test.c @@ -36,7 +36,7 @@ TEST(remainder, test) { EXPECT_TRUE(isnan(_remainder(NAN, 7))); EXPECT_TRUE(isnan(_remainder(INFINITY, 7))); EXPECT_TRUE(isnan(_remainder(7, 0))); - EXPECT_STREQ("-1", _gc(xdtoa(_remainder(7, 4)))); + EXPECT_STREQ("-1", gc(xdtoa(_remainder(7, 4)))); } TEST(remainderf, test) { @@ -44,7 +44,7 @@ TEST(remainderf, test) { EXPECT_TRUE(isnan(_remainderf(NAN, 7))); EXPECT_TRUE(isnan(_remainderf(INFINITY, 7))); EXPECT_TRUE(isnan(_remainderf(7, 0))); - EXPECT_STREQ("-1", _gc(xdtoaf(_remainderf(7, 4)))); + EXPECT_STREQ("-1", gc(xdtoaf(_remainderf(7, 4)))); } TEST(remainderl, test) { @@ -52,7 +52,7 @@ TEST(remainderl, test) { EXPECT_TRUE(isnan(_remainderl(NAN, 7))); EXPECT_TRUE(isnan(_remainderl(INFINITY, 7))); EXPECT_TRUE(isnan(_remainderl(7, 0))); - EXPECT_STREQ("-1", _gc(xdtoal(_remainderl(7, 4)))); + EXPECT_STREQ("-1", gc(xdtoal(_remainderl(7, 4)))); } static inline float i2f(uint32_t i) { @@ -95,10 +95,10 @@ TEST(remainderf, brute) { x = f2i(a); y = f2i(b); if (abs(x - y) > 1) { - kprintf("bah %#lx %s %#lx %d\n", i, _gc(xdtoaf(i2f(i))), j, - _gc(xdtoaf(i2f(j))), abs(x - y)); - kprintf(" %-12s %#x\n", _gc(xdtoaf(i2f(x))), x); - kprintf(" %-12s %#x\n", _gc(xdtoaf(i2f(y))), y); + kprintf("bah %#lx %s %#lx %d\n", i, gc(xdtoaf(i2f(i))), j, + gc(xdtoaf(i2f(j))), abs(x - y)); + kprintf(" %-12s %#x\n", gc(xdtoaf(i2f(x))), x); + kprintf(" %-12s %#x\n", gc(xdtoaf(i2f(y))), y); if (!--lim) break; } } diff --git a/test/libc/tinymath/round_test.c b/test/libc/tinymath/round_test.c index bc82b7b42..0d710f42d 100644 --- a/test/libc/tinymath/round_test.c +++ b/test/libc/tinymath/round_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/nexgen32e/x86feature.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" diff --git a/test/libc/tinymath/sin_test.c b/test/libc/tinymath/sin_test.c index a98da613f..5f4477a31 100644 --- a/test/libc/tinymath/sin_test.c +++ b/test/libc/tinymath/sin_test.c @@ -28,50 +28,50 @@ float _sinf(float) asm("sinf"); long double _sinl(long double) asm("sinl"); TEST(sinl, test) { - EXPECT_STREQ("NAN", _gc(xdtoal(_sinl(NAN)))); + EXPECT_STREQ("NAN", gc(xdtoal(_sinl(NAN)))); EXPECT_TRUE(isnan(_sinl(+INFINITY))); EXPECT_TRUE(isnan(_sinl(-INFINITY))); - EXPECT_STREQ(".479425538604203", _gc(xdtoal(_sinl(.5)))); - EXPECT_STREQ("-.479425538604203", _gc(xdtoal(_sinl(-.5)))); - EXPECT_STREQ(".8414709794048734", _gc(xdtoal(_sinl(.99999999)))); - /* EXPECT_STREQ("-.998836772397", _gc(xdtoal(_sinl(555555555555)))); */ - /* EXPECT_STREQ("1", _gc(xdtoal(_sinl(5.319372648326541e+255L)))); */ + EXPECT_STREQ(".479425538604203", gc(xdtoal(_sinl(.5)))); + EXPECT_STREQ("-.479425538604203", gc(xdtoal(_sinl(-.5)))); + EXPECT_STREQ(".8414709794048734", gc(xdtoal(_sinl(.99999999)))); + /* EXPECT_STREQ("-.998836772397", gc(xdtoal(_sinl(555555555555)))); */ + /* EXPECT_STREQ("1", gc(xdtoal(_sinl(5.319372648326541e+255L)))); */ } TEST(sin, test) { - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _sin(0.)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _sin(-0.)))); - EXPECT_STREQ("0.0998334166468282", _gc(xasprintf("%.15g", _sin(.1)))); - EXPECT_STREQ("-0.0998334166468282", _gc(xasprintf("%.15g", _sin(-.1)))); - EXPECT_STREQ("0.479425538604203", _gc(xasprintf("%.15g", _sin(.5)))); - EXPECT_STREQ("-0.479425538604203", _gc(xasprintf("%.15g", _sin(-.5)))); - EXPECT_STREQ("0.841470984807897", _gc(xasprintf("%.15g", _sin(1.)))); - EXPECT_STREQ("-0.841470984807897", _gc(xasprintf("%.15g", _sin(-1.)))); - EXPECT_STREQ("0.997494986604054", _gc(xasprintf("%.15g", _sin(1.5)))); - EXPECT_STREQ("-0.997494986604054", _gc(xasprintf("%.15g", _sin(-1.5)))); - EXPECT_STREQ("0.909297426825682", _gc(xasprintf("%.15g", _sin(2.)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _sin(0.)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _sin(-0.)))); + EXPECT_STREQ("0.0998334166468282", gc(xasprintf("%.15g", _sin(.1)))); + EXPECT_STREQ("-0.0998334166468282", gc(xasprintf("%.15g", _sin(-.1)))); + EXPECT_STREQ("0.479425538604203", gc(xasprintf("%.15g", _sin(.5)))); + EXPECT_STREQ("-0.479425538604203", gc(xasprintf("%.15g", _sin(-.5)))); + EXPECT_STREQ("0.841470984807897", gc(xasprintf("%.15g", _sin(1.)))); + EXPECT_STREQ("-0.841470984807897", gc(xasprintf("%.15g", _sin(-1.)))); + EXPECT_STREQ("0.997494986604054", gc(xasprintf("%.15g", _sin(1.5)))); + EXPECT_STREQ("-0.997494986604054", gc(xasprintf("%.15g", _sin(-1.5)))); + EXPECT_STREQ("0.909297426825682", gc(xasprintf("%.15g", _sin(2.)))); EXPECT_TRUE(isnan(_sin(NAN))); EXPECT_TRUE(isnan(_sin(-NAN))); EXPECT_TRUE(isnan(_sin(INFINITY))); EXPECT_TRUE(isnan(_sin(-INFINITY))); EXPECT_STREQ("2.2250738585072e-308", - _gc(xasprintf("%.15g", _sin(__DBL_MIN__)))); + gc(xasprintf("%.15g", _sin(__DBL_MIN__)))); EXPECT_STREQ("0.00496195478918406", - _gc(xasprintf("%.15g", _sin(__DBL_MAX__)))); + gc(xasprintf("%.15g", _sin(__DBL_MAX__)))); EXPECT_STREQ("-0.841470984807897", - _gc(xasprintf("%.15g", _sin(-1.0000000000000002)))); + gc(xasprintf("%.15g", _sin(-1.0000000000000002)))); EXPECT_STREQ("-2.1073424255447e-08", - _gc(xasprintf("%.15g", _sin(-2.1073424255447e-08)))); + gc(xasprintf("%.15g", _sin(-2.1073424255447e-08)))); } TEST(sinf, test) { EXPECT_TRUE(isnan(_sinf(NAN))); EXPECT_TRUE(isnan(_sinf(+INFINITY))); EXPECT_TRUE(isnan(_sinf(-INFINITY))); - EXPECT_STREQ("NAN", _gc(xdtoaf(_sinf(NAN)))); - EXPECT_STARTSWITH(".479426", _gc(xdtoaf(_sinf(.5f)))); - EXPECT_STARTSWITH("-.479426", _gc(xdtoaf(_sinf(-.5f)))); - EXPECT_STARTSWITH(".873283", _gc(xdtoaf(_sinf(555)))); + EXPECT_STREQ("NAN", gc(xdtoaf(_sinf(NAN)))); + EXPECT_STARTSWITH(".479426", gc(xdtoaf(_sinf(.5f)))); + EXPECT_STARTSWITH("-.479426", gc(xdtoaf(_sinf(-.5f)))); + EXPECT_STARTSWITH(".873283", gc(xdtoaf(_sinf(555)))); } BENCH(_sin, bench) { diff --git a/test/libc/tinymath/sincos_test.c b/test/libc/tinymath/sincos_test.c index 6b932f6f6..0a62443a5 100644 --- a/test/libc/tinymath/sincos_test.c +++ b/test/libc/tinymath/sincos_test.c @@ -25,15 +25,15 @@ TEST(sincos, test) { double sine, cosine; sincos(.1, &sine, &cosine); - EXPECT_STREQ("0.0998334166468282", _gc(xasprintf("%.15g", sine))); - EXPECT_STREQ("0.995004165278026", _gc(xasprintf("%.15g", cosine))); + EXPECT_STREQ("0.0998334166468282", gc(xasprintf("%.15g", sine))); + EXPECT_STREQ("0.995004165278026", gc(xasprintf("%.15g", cosine))); } TEST(sincosf, test) { float sine, cosine; sincosf(.1, &sine, &cosine); - EXPECT_STREQ("0.0998334", _gc(xasprintf("%.6g", sine))); - EXPECT_STREQ("0.995004", _gc(xasprintf("%.6g", cosine))); + EXPECT_STREQ("0.0998334", gc(xasprintf("%.6g", sine))); + EXPECT_STREQ("0.995004", gc(xasprintf("%.6g", cosine))); } TEST(sincosl, test) { @@ -41,8 +41,8 @@ TEST(sincosl, test) { sincosl(.1, &sine, &cosine); #ifndef __aarch64__ // TODO(jart): get quad floats working with printf - EXPECT_STREQ("0.0998334166468282", _gc(xasprintf("%.15Lg", sine))); - EXPECT_STREQ("0.995004165278026", _gc(xasprintf("%.15Lg", cosine))); + EXPECT_STREQ("0.0998334166468282", gc(xasprintf("%.15Lg", sine))); + EXPECT_STREQ("0.995004165278026", gc(xasprintf("%.15Lg", cosine))); #endif } diff --git a/test/libc/tinymath/sinh_test.c b/test/libc/tinymath/sinh_test.c index 06183f5b2..99e52a253 100644 --- a/test/libc/tinymath/sinh_test.c +++ b/test/libc/tinymath/sinh_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/sqrt_test.c b/test/libc/tinymath/sqrt_test.c index 43238c771..6639af368 100644 --- a/test/libc/tinymath/sqrt_test.c +++ b/test/libc/tinymath/sqrt_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/tinymath/strtod_test.c b/test/libc/tinymath/strtod_test.c index ffe1aa11a..05e46173e 100644 --- a/test/libc/tinymath/strtod_test.c +++ b/test/libc/tinymath/strtod_test.c @@ -394,19 +394,19 @@ TEST(strtod, test) { TEST(strtod, testNearest) { fesetround(FE_TONEAREST); EXPECT_STREQ("-1.79769313486231e+308", - _gc(xasprintf("%.15g", strtod("-1.79769313486231e+308", NULL)))); + gc(xasprintf("%.15g", strtod("-1.79769313486231e+308", NULL)))); } TEST(strtod, testDownward) { fesetround(FE_DOWNWARD); EXPECT_STREQ("-1.79769313486232e+308", - _gc(xasprintf("%.15g", strtod("-1.79769313486231e+308", NULL)))); + gc(xasprintf("%.15g", strtod("-1.79769313486231e+308", NULL)))); } TEST(strtod, testUpward) { fesetround(FE_UPWARD); EXPECT_STREQ("-1.7976931348623e+308", - _gc(xasprintf("%.15g", strtod("-1.79769313486231e+308", NULL)))); + gc(xasprintf("%.15g", strtod("-1.79769313486231e+308", NULL)))); } TEST(strtod, testTowardzero) { diff --git a/test/libc/tinymath/tan_test.c b/test/libc/tinymath/tan_test.c index 3e96a63cf..69915dab4 100644 --- a/test/libc/tinymath/tan_test.c +++ b/test/libc/tinymath/tan_test.c @@ -27,22 +27,22 @@ float _tanf(float) asm("tanf"); long double _tanl(long double) asm("tanl"); TEST(tan, test) { - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _tan(0.)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _tan(-0.)))); - EXPECT_STREQ("0.54630248984379", _gc(xasprintf("%.15g", _tan(.5)))); - EXPECT_STREQ("-0.54630248984379", _gc(xasprintf("%.15g", _tan(-.5)))); - EXPECT_STREQ("1.5574077246549", _gc(xasprintf("%.15g", _tan(1.)))); - EXPECT_STREQ("-1.5574077246549", _gc(xasprintf("%.15g", _tan(-1.)))); - EXPECT_STREQ("14.1014199471717", _gc(xasprintf("%.15g", _tan(1.5)))); - EXPECT_STREQ("-14.1014199471717", _gc(xasprintf("%.15g", _tan(-1.5)))); - EXPECT_STREQ("nan", _gc(xasprintf("%.15g", _tan(NAN)))); - EXPECT_STREQ("-nan", _gc(xasprintf("%.15g", _tan(-NAN)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _tan(0.)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _tan(-0.)))); + EXPECT_STREQ("0.54630248984379", gc(xasprintf("%.15g", _tan(.5)))); + EXPECT_STREQ("-0.54630248984379", gc(xasprintf("%.15g", _tan(-.5)))); + EXPECT_STREQ("1.5574077246549", gc(xasprintf("%.15g", _tan(1.)))); + EXPECT_STREQ("-1.5574077246549", gc(xasprintf("%.15g", _tan(-1.)))); + EXPECT_STREQ("14.1014199471717", gc(xasprintf("%.15g", _tan(1.5)))); + EXPECT_STREQ("-14.1014199471717", gc(xasprintf("%.15g", _tan(-1.5)))); + EXPECT_STREQ("nan", gc(xasprintf("%.15g", _tan(NAN)))); + EXPECT_STREQ("-nan", gc(xasprintf("%.15g", _tan(-NAN)))); EXPECT_TRUE(isnan(_tan(INFINITY))); EXPECT_TRUE(isnan(_tan(-INFINITY))); EXPECT_STREQ("2.2250738585072e-308", - _gc(xasprintf("%.15g", _tan(__DBL_MIN__)))); + gc(xasprintf("%.15g", _tan(__DBL_MIN__)))); EXPECT_STREQ("-0.0049620158744449", - _gc(xasprintf("%.15g", _tan(__DBL_MAX__)))); + gc(xasprintf("%.15g", _tan(__DBL_MAX__)))); } BENCH(tan, bench) { diff --git a/test/libc/tinymath/tanh_test.c b/test/libc/tinymath/tanh_test.c index 03baf699a..c59e5511c 100644 --- a/test/libc/tinymath/tanh_test.c +++ b/test/libc/tinymath/tanh_test.c @@ -32,48 +32,48 @@ float _tanhf(float) asm("tanhf"); long double _tanhl(long double) asm("tanhl"); TEST(tanh, test) { - EXPECT_STREQ("0", _gc(xasprintf("%.15g", _tanh(0.)))); - EXPECT_STREQ("-0", _gc(xasprintf("%.15g", _tanh(-0.)))); - EXPECT_STREQ("0.0996679946249558", _gc(xasprintf("%.15g", _tanh(.1)))); - EXPECT_STREQ("-0.0996679946249558", _gc(xasprintf("%.15g", _tanh(-.1)))); - EXPECT_STREQ("0.46211715726001", _gc(xasprintf("%.15g", _tanh(.5)))); - EXPECT_STREQ("-0.46211715726001", _gc(xasprintf("%.15g", _tanh(-.5)))); - EXPECT_STREQ("0.761594155955765", _gc(xasprintf("%.15g", _tanh(1.)))); - EXPECT_STREQ("-0.761594155955765", _gc(xasprintf("%.15g", _tanh(-1.)))); - EXPECT_STREQ("0.905148253644866", _gc(xasprintf("%.15g", _tanh(1.5)))); - EXPECT_STREQ("-0.905148253644866", _gc(xasprintf("%.15g", _tanh(-1.5)))); - EXPECT_STREQ("0.964027580075817", _gc(xasprintf("%.15g", _tanh(2.)))); + EXPECT_STREQ("0", gc(xasprintf("%.15g", _tanh(0.)))); + EXPECT_STREQ("-0", gc(xasprintf("%.15g", _tanh(-0.)))); + EXPECT_STREQ("0.0996679946249558", gc(xasprintf("%.15g", _tanh(.1)))); + EXPECT_STREQ("-0.0996679946249558", gc(xasprintf("%.15g", _tanh(-.1)))); + EXPECT_STREQ("0.46211715726001", gc(xasprintf("%.15g", _tanh(.5)))); + EXPECT_STREQ("-0.46211715726001", gc(xasprintf("%.15g", _tanh(-.5)))); + EXPECT_STREQ("0.761594155955765", gc(xasprintf("%.15g", _tanh(1.)))); + EXPECT_STREQ("-0.761594155955765", gc(xasprintf("%.15g", _tanh(-1.)))); + EXPECT_STREQ("0.905148253644866", gc(xasprintf("%.15g", _tanh(1.5)))); + EXPECT_STREQ("-0.905148253644866", gc(xasprintf("%.15g", _tanh(-1.5)))); + EXPECT_STREQ("0.964027580075817", gc(xasprintf("%.15g", _tanh(2.)))); EXPECT_TRUE(isnan(_tanh(NAN))); EXPECT_TRUE(isnan(_tanh(-NAN))); - EXPECT_STREQ("1", _gc(xasprintf("%.15g", _tanh(INFINITY)))); - EXPECT_STREQ("-1", _gc(xasprintf("%.15g", _tanh(-INFINITY)))); + EXPECT_STREQ("1", gc(xasprintf("%.15g", _tanh(INFINITY)))); + EXPECT_STREQ("-1", gc(xasprintf("%.15g", _tanh(-INFINITY)))); EXPECT_STREQ("2.2250738585072e-308", - _gc(xasprintf("%.15g", _tanh(__DBL_MIN__)))); - EXPECT_STREQ("1", _gc(xasprintf("%.15g", _tanh(__DBL_MAX__)))); + gc(xasprintf("%.15g", _tanh(__DBL_MIN__)))); + EXPECT_STREQ("1", gc(xasprintf("%.15g", _tanh(__DBL_MAX__)))); EXPECT_STREQ("-0.761594155955765", - _gc(xasprintf("%.15g", _tanh(-1.0000000000000002)))); + gc(xasprintf("%.15g", _tanh(-1.0000000000000002)))); EXPECT_STREQ("-2.1073424255447e-08", - _gc(xasprintf("%.15g", _tanh(-2.1073424255447e-08)))); + gc(xasprintf("%.15g", _tanh(-2.1073424255447e-08)))); } TEST(tanhf, test) { - EXPECT_STREQ(".099668", _gc(xdtoaf(_tanhf(+.1)))); - EXPECT_STREQ("-.099668", _gc(xdtoaf(_tanhf(-.1)))); - EXPECT_STREQ("0", _gc(xdtoaf(_tanhf(0)))); - EXPECT_STREQ("-0", _gc(xdtoaf(_tanhf(-0.)))); + EXPECT_STREQ(".099668", gc(xdtoaf(_tanhf(+.1)))); + EXPECT_STREQ("-.099668", gc(xdtoaf(_tanhf(-.1)))); + EXPECT_STREQ("0", gc(xdtoaf(_tanhf(0)))); + EXPECT_STREQ("-0", gc(xdtoaf(_tanhf(-0.)))); EXPECT_TRUE(isnan(_tanhf(NAN))); - EXPECT_STREQ("1", _gc(xdtoaf(_tanhf(INFINITY)))); - EXPECT_STREQ("-1", _gc(xdtoaf(_tanhf(-INFINITY)))); + EXPECT_STREQ("1", gc(xdtoaf(_tanhf(INFINITY)))); + EXPECT_STREQ("-1", gc(xdtoaf(_tanhf(-INFINITY)))); } TEST(tanhl, test) { - EXPECT_STREQ(".09966799462495582", _gc(xdtoal(_tanhl(+.1)))); - EXPECT_STREQ("-.09966799462495582", _gc(xdtoal(_tanhl(-.1)))); - EXPECT_STREQ("0", _gc(xdtoal(_tanhl(0)))); - EXPECT_STREQ("-0", _gc(xdtoal(_tanhl(-0.)))); + EXPECT_STREQ(".09966799462495582", gc(xdtoal(_tanhl(+.1)))); + EXPECT_STREQ("-.09966799462495582", gc(xdtoal(_tanhl(-.1)))); + EXPECT_STREQ("0", gc(xdtoal(_tanhl(0)))); + EXPECT_STREQ("-0", gc(xdtoal(_tanhl(-0.)))); EXPECT_TRUE(isnan(_tanhl(NAN))); - EXPECT_STREQ("1", _gc(xdtoal(_tanhl(INFINITY)))); - EXPECT_STREQ("-1", _gc(xdtoal(_tanhl(-INFINITY)))); + EXPECT_STREQ("1", gc(xdtoal(_tanhl(INFINITY)))); + EXPECT_STREQ("-1", gc(xdtoal(_tanhl(-INFINITY)))); } BENCH(tanhl, bench) { @@ -107,9 +107,9 @@ TEST(tanhf, brute) { x = f2i(tanhf(i2f(i))); y = f2i(tanhf2(i2f(i))); if (abs(x - y) > 2) { - kprintf("bah %#lx %s %d\n", i, _gc(xdtoaf(i2f(i))), abs(x - y)); - kprintf(" %-12s %#x\n", _gc(xdtoaf(i2f(x))), x); - kprintf(" %-12s %#x\n", _gc(xdtoaf(i2f(y))), y); + kprintf("bah %#lx %s %d\n", i, gc(xdtoaf(i2f(i))), abs(x - y)); + kprintf(" %-12s %#x\n", gc(xdtoaf(i2f(x))), x); + kprintf(" %-12s %#x\n", gc(xdtoaf(i2f(y))), y); if (!--lim) break; } } diff --git a/test/libc/tinymath/tgamma_test.c b/test/libc/tinymath/tgamma_test.c index 6de87c2e3..c1b038ad9 100644 --- a/test/libc/tinymath/tgamma_test.c +++ b/test/libc/tinymath/tgamma_test.c @@ -22,26 +22,26 @@ #include "libc/x/xasprintf.h" TEST(tgamma, test) { - EXPECT_STREQ("inf", _gc(xasprintf("%.15g", tgamma(0.)))); - EXPECT_STREQ("-inf", _gc(xasprintf("%.15g", tgamma(-0.)))); - EXPECT_STREQ("9.51350769866873", _gc(xasprintf("%.15g", tgamma(.1)))); - EXPECT_STREQ("-10.6862870211932", _gc(xasprintf("%.15g", tgamma(-.1)))); - EXPECT_STREQ("1.77245385090552", _gc(xasprintf("%.15g", tgamma(.5)))); - EXPECT_STREQ("-3.54490770181103", _gc(xasprintf("%.15g", tgamma(-.5)))); - EXPECT_STREQ("1", _gc(xasprintf("%.15g", tgamma(1.)))); + EXPECT_STREQ("inf", gc(xasprintf("%.15g", tgamma(0.)))); + EXPECT_STREQ("-inf", gc(xasprintf("%.15g", tgamma(-0.)))); + EXPECT_STREQ("9.51350769866873", gc(xasprintf("%.15g", tgamma(.1)))); + EXPECT_STREQ("-10.6862870211932", gc(xasprintf("%.15g", tgamma(-.1)))); + EXPECT_STREQ("1.77245385090552", gc(xasprintf("%.15g", tgamma(.5)))); + EXPECT_STREQ("-3.54490770181103", gc(xasprintf("%.15g", tgamma(-.5)))); + EXPECT_STREQ("1", gc(xasprintf("%.15g", tgamma(1.)))); EXPECT_TRUE(isnan(tgamma(-1.))); - EXPECT_STREQ("0.886226925452758", _gc(xasprintf("%.15g", tgamma(1.5)))); - EXPECT_STREQ("2.36327180120735", _gc(xasprintf("%.15g", tgamma(-1.5)))); - EXPECT_STREQ("1", _gc(xasprintf("%.15g", tgamma(2.)))); + EXPECT_STREQ("0.886226925452758", gc(xasprintf("%.15g", tgamma(1.5)))); + EXPECT_STREQ("2.36327180120735", gc(xasprintf("%.15g", tgamma(-1.5)))); + EXPECT_STREQ("1", gc(xasprintf("%.15g", tgamma(2.)))); EXPECT_TRUE(isnan(tgamma(NAN))); EXPECT_TRUE(isnan(tgamma(-NAN))); - EXPECT_STREQ("inf", _gc(xasprintf("%.15g", tgamma(INFINITY)))); + EXPECT_STREQ("inf", gc(xasprintf("%.15g", tgamma(INFINITY)))); EXPECT_TRUE(isnan(tgamma(-INFINITY))); EXPECT_STREQ("4.49423283715579e+307", - _gc(xasprintf("%.15g", tgamma(__DBL_MIN__)))); - EXPECT_STREQ("inf", _gc(xasprintf("%.15g", tgamma(__DBL_MAX__)))); + gc(xasprintf("%.15g", tgamma(__DBL_MIN__)))); + EXPECT_STREQ("inf", gc(xasprintf("%.15g", tgamma(__DBL_MAX__)))); EXPECT_STREQ("4.5035996273705e+15", - _gc(xasprintf("%.14g", tgamma(-1.0000000000000002)))); + gc(xasprintf("%.14g", tgamma(-1.0000000000000002)))); EXPECT_STREQ("-47453133.3893415", - _gc(xasprintf("%.15g", tgamma(-2.1073424255447e-08)))); + gc(xasprintf("%.15g", tgamma(-2.1073424255447e-08)))); } diff --git a/test/libc/tinymath/trunc_test.c b/test/libc/tinymath/trunc_test.c index afb30f073..5c3e63c9f 100644 --- a/test/libc/tinymath/trunc_test.c +++ b/test/libc/tinymath/trunc_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/x/utf16to32_test.c b/test/libc/x/utf16to32_test.c index 00bf95f0a..7fa1a6b54 100644 --- a/test/libc/x/utf16to32_test.c +++ b/test/libc/x/utf16to32_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/libc/x/utf16to8_test.c b/test/libc/x/utf16to8_test.c index bdf74394c..fc7196566 100644 --- a/test/libc/x/utf16to8_test.c +++ b/test/libc/x/utf16to8_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/x/utf8to16_test.c b/test/libc/x/utf8to16_test.c index cd96ef944..ce3c21072 100644 --- a/test/libc/x/utf8to16_test.c +++ b/test/libc/x/utf8to16_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/x/utf8to32_test.c b/test/libc/x/utf8to32_test.c index d417dc748..9cdfa2647 100644 --- a/test/libc/x/utf8to32_test.c +++ b/test/libc/x/utf8to32_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" #include "libc/mem/shuffle.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/stdio/rand.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/libc/x/xasprintf_test.c b/test/libc/x/xasprintf_test.c index 3c714f039..f285bc77f 100644 --- a/test/libc/x/xasprintf_test.c +++ b/test/libc/x/xasprintf_test.c @@ -16,10 +16,10 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/x/xasprintf.h" #include "libc/mem/gc.h" #include "libc/testlib/testlib.h" -#include "libc/x/xasprintf.h" TEST(xasprintf, test) { - EXPECT_STREQ("hi.there", _gc(xasprintf("%s.%s", "hi", "there"))); + EXPECT_STREQ("hi.there", gc(xasprintf("%s.%s", "hi", "there"))); } diff --git a/test/libc/x/xjoinpaths_test.c b/test/libc/x/xjoinpaths_test.c index 2cae0848e..38cc8a3d0 100644 --- a/test/libc/x/xjoinpaths_test.c +++ b/test/libc/x/xjoinpaths_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/x/xslurp_test.c b/test/libc/x/xslurp_test.c index e2e6fad6c..57a485603 100644 --- a/test/libc/x/xslurp_test.c +++ b/test/libc/x/xslurp_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/x/xstrcat_test.c b/test/libc/x/xstrcat_test.c index 3b96a5c4d..3821a60d6 100644 --- a/test/libc/x/xstrcat_test.c +++ b/test/libc/x/xstrcat_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" diff --git a/test/libc/xed/x86ild_lib.c b/test/libc/xed/x86ild_lib.c index bfb9e8924..e7cc1b0e7 100644 --- a/test/libc/xed/x86ild_lib.c +++ b/test/libc/xed/x86ild_lib.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/bing.internal.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/test/libc/xed/x86ild_test.c b/test/libc/xed/x86ild_test.c index 91ad69335..f517c12c3 100644 --- a/test/libc/xed/x86ild_test.c +++ b/test/libc/xed/x86ild_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "test/libc/xed/lib.h" diff --git a/test/net/http/decodebase64_test.c b/test/net/http/decodebase64_test.c index c1f578ce6..a5306ee7c 100644 --- a/test/net/http/decodebase64_test.c +++ b/test/net/http/decodebase64_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" #include "net/http/escape.h" diff --git a/test/net/http/decodelatin1_test.c b/test/net/http/decodelatin1_test.c index f9bb55df7..e2a40c909 100644 --- a/test/net/http/decodelatin1_test.c +++ b/test/net/http/decodelatin1_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/net/http/encodebase64_test.c b/test/net/http/encodebase64_test.c index 4b798a54e..3c755aed0 100644 --- a/test/net/http/encodebase64_test.c +++ b/test/net/http/encodebase64_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/rand.h" #include "libc/str/str.h" diff --git a/test/net/http/encodehttpheadervalue_test.c b/test/net/http/encodehttpheadervalue_test.c index 410c5a205..faa1c40d5 100644 --- a/test/net/http/encodehttpheadervalue_test.c +++ b/test/net/http/encodehttpheadervalue_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" diff --git a/test/net/http/escapehtml_test.c b/test/net/http/escapehtml_test.c index b21e40daf..95cf2729e 100644 --- a/test/net/http/escapehtml_test.c +++ b/test/net/http/escapehtml_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/net/http/escapejsstringliteral_test.c b/test/net/http/escapejsstringliteral_test.c index 274f35546..c71718b77 100644 --- a/test/net/http/escapejsstringliteral_test.c +++ b/test/net/http/escapejsstringliteral_test.c @@ -19,7 +19,7 @@ #include "libc/calls/calls.h" #include "libc/log/check.h" #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/stdio/stdio.h" #include "libc/temp.h" #include "libc/str/str.h" diff --git a/test/net/http/escapeurlparam_test.c b/test/net/http/escapeurlparam_test.c index b164ea756..c6fffedb7 100644 --- a/test/net/http/escapeurlparam_test.c +++ b/test/net/http/escapeurlparam_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/net/http/indentlines_test.c b/test/net/http/indentlines_test.c index 7c6c7b9e6..79599d678 100644 --- a/test/net/http/indentlines_test.c +++ b/test/net/http/indentlines_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/net/http/isacceptablepath_test.c b/test/net/http/isacceptablepath_test.c index 21428994d..ed732cd43 100644 --- a/test/net/http/isacceptablepath_test.c +++ b/test/net/http/isacceptablepath_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "net/http/escape.h" diff --git a/test/net/http/parsehttpmessage_test.c b/test/net/http/parsehttpmessage_test.c index 31d12ae8d..f5b9e3449 100644 --- a/test/net/http/parsehttpmessage_test.c +++ b/test/net/http/parsehttpmessage_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" #include "libc/log/check.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" diff --git a/test/net/http/parseurl_test.c b/test/net/http/parseurl_test.c index 226acd6d4..594303be8 100644 --- a/test/net/http/parseurl_test.c +++ b/test/net/http/parseurl_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/limits.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/rand.h" #include "libc/str/str.h" diff --git a/test/net/http/underlong_test.c b/test/net/http/underlong_test.c index aa021c207..246aafe97 100644 --- a/test/net/http/underlong_test.c +++ b/test/net/http/underlong_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" diff --git a/test/net/http/visualizecontrolcodes_test.c b/test/net/http/visualizecontrolcodes_test.c index 026cddb09..89042b4ef 100644 --- a/test/net/http/visualizecontrolcodes_test.c +++ b/test/net/http/visualizecontrolcodes_test.c @@ -26,26 +26,26 @@ TEST(VisualizeControlCodes, test) { size_t n; - EXPECT_STREQ("hello", _gc(VisualizeControlCodes("hello", -1, 0))); - EXPECT_STREQ("hello\r\n", _gc(VisualizeControlCodes("hello\r\n", -1, 0))); - EXPECT_STREQ("hello␁␂␡", _gc(VisualizeControlCodes("hello\1\2\177", -1, 0))); + EXPECT_STREQ("hello", gc(VisualizeControlCodes("hello", -1, 0))); + EXPECT_STREQ("hello\r\n", gc(VisualizeControlCodes("hello\r\n", -1, 0))); + EXPECT_STREQ("hello␁␂␡", gc(VisualizeControlCodes("hello\1\2\177", -1, 0))); EXPECT_STREQ("hello\\u0085", - _gc(VisualizeControlCodes("hello\302\205", -1, 0))); - EXPECT_STREQ("hi", _gc(VisualizeControlCodes("hi", -1, &n))); + gc(VisualizeControlCodes("hello\302\205", -1, 0))); + EXPECT_STREQ("hi", gc(VisualizeControlCodes("hi", -1, &n))); EXPECT_EQ(2, n); } TEST(VisualizeControlCodes, testOom_returnsNullAndSetsSizeToZero) { size_t n = 31337; - EXPECT_EQ(NULL, _gc(VisualizeControlCodes("hello", 0x1000000000000, &n))); + EXPECT_EQ(NULL, gc(VisualizeControlCodes("hello", 0x1000000000000, &n))); EXPECT_EQ(0, n); } TEST(VisualizeControlCodes, testWeirdHttp) { size_t n = 31337; char *p, B[] = "\0GET /redbean.lua\n\n"; - ASSERT_NE(0, (p = _gc(VisualizeControlCodes(B, sizeof(B), &n)))); - EXPECT_STREQ("\"␀GET /redbean.lua\\n\\n␀\"", _gc(xasprintf("%`'.*s", n, p))); + ASSERT_NE(0, (p = gc(VisualizeControlCodes(B, sizeof(B), &n)))); + EXPECT_STREQ("\"␀GET /redbean.lua\\n\\n␀\"", gc(xasprintf("%`'.*s", n, p))); } BENCH(VisualizeControlCodes, bench) { diff --git a/test/net/https/mbedtls_test.c b/test/net/https/mbedtls_test.c index fd64d7a1a..fa355e5f2 100644 --- a/test/net/https/mbedtls_test.c +++ b/test/net/https/mbedtls_test.c @@ -169,7 +169,7 @@ BENCH(p256, bench) { #ifdef MBEDTLS_ECP_C mbedtls_ecp_group_init(&grp); mbedtls_ecp_group_load(&grp, MBEDTLS_ECP_DP_SECP256R1); - mbedtls_mpi x = {1, 8, _gc(calloc(8, 8))}; + mbedtls_mpi x = {1, 8, gc(calloc(8, 8))}; rngset(x.p, 8 * 8, _rand64, -1); EZBENCH2("P-256 modulus MbedTLS MPI lib", donothing, P256_MPI(&x)); EZBENCH2("P-256 modulus Justine rewrite", donothing, P256_JUSTINE(&x)); @@ -181,7 +181,7 @@ BENCH(p384, bench) { #ifdef MBEDTLS_ECP_C mbedtls_ecp_group_init(&grp); mbedtls_ecp_group_load(&grp, MBEDTLS_ECP_DP_SECP384R1); - mbedtls_mpi x = {1, 12, _gc(calloc(12, 8))}; + mbedtls_mpi x = {1, 12, gc(calloc(12, 8))}; EZBENCH2("P-384 modulus MbedTLS MPI lib", donothing, P384_MPI(&x)); EZBENCH2("P-384 modulus Justine rewrite", donothing, P384_JUSTINE(&x)); mbedtls_ecp_group_free(&grp); @@ -394,7 +394,7 @@ BENCH(quickjs_remainder, bench) { "2331094682317528819996876363073536047370469375", NULL, BF_PREC_INF, BF_RNDZ | BF_ATOF_NO_NAN_INF); bfdec_rem(&r, &x, &y, BF_PREC_INF, 0, BF_RNDF); - t = _gc(bfdec_ftoa(0, &r, BF_PREC_INF, BF_RNDZ | BF_FTOA_FORMAT_FREE)); + t = gc(bfdec_ftoa(0, &r, BF_PREC_INF, BF_RNDZ | BF_FTOA_FORMAT_FREE)); ASSERT_STREQ("327339060789614187001318969682759915221664204604306478" "948329136809613379640467455488327009232590415715088668" "4127560071009217256545885393053328527589375", @@ -410,7 +410,7 @@ BENCH(quickjs_remainder, bench) { BENCH(mpi_remainder, bench) { mbedtls_mpi *x, *y, r; - x = _gc(str2mpi( + x = gc(str2mpi( "131820409343094310010388979423659136318401916109327276909280345024175692" "811283445510797521231721220331409407564807168230384468176942405812817310" "624525121840385446744443868889563289706427719939300365865529242495144888" @@ -453,7 +453,7 @@ BENCH(mpi_remainder, bench) { "409401269127676106581410793787580434036114254547441805771508552049371634" "609025127325512605396392214570059772472666763440181556475095153967113514" "87546062479444592779055555421362722504575706910949375")); - y = _gc(str2mpi( + y = gc(str2mpi( "402702961953621844286950607555369624422784868935557056881131335461307658" "701727371551406721502307932123276358395008895125652043531209418099658895" "323804953421455502359439932416245276659698167468088937570774479761417692" @@ -488,7 +488,7 @@ BENCH(mpi_remainder, bench) { BENCH(mpi_mul_int, bench) { mbedtls_mpi *x, y; - x = _gc(str2mpi( + x = gc(str2mpi( "131820409343094310010388979423659136318401916109327276909280345024175692" "811283445510797521231721220331409407564807168230384468176942405812817310" "624525121840385446744443868889563289706427719939300365865529242495144888" @@ -676,7 +676,7 @@ BENCH(gcd, bench) { BENCH(inv_mod, bench3) { mbedtls_mpi g = {0}; - mbedtls_mpi *x = _gc(str2mpi16( + mbedtls_mpi *x = gc(str2mpi16( "837B3E23091602B5D14D619D9B2CD79DD039BC9A9F46F0CA1FFD01B398EE42C8EE2142CB" "B295109FC4278DB8AB84A6ADBF319D3297216C349D0EB92925E2794C5FF1AAF664034CB2" "5C15CDA49B7947278AA96BEF9D995C5F99AA4809B12568A1513D8E0A37BB338DC44A1722" @@ -685,7 +685,7 @@ BENCH(inv_mod, bench3) { "68ED274FA7F7D5BC3E014DDC7BEA4A60DF24805B5F94C998CAF28441FB4A5831755CE935" "2F17F5416647A81A78899E5B2C4D3F6C84A81CEB463C1593392ABCF6BF708A55578EB0EF" "E9ABF572")); - mbedtls_mpi *y = _gc(str2mpi16( + mbedtls_mpi *y = gc(str2mpi16( "C14DA3DDE7CD1DD104D74972B899AC0E78E43A3C4ACF3A1316D05AE4CDA30088A7EE1E6B" "96A752B490EF2D727A3E249AFCB634AC24F577E026648C9CB0287DA1DAEA8CE6C91C96BC" "FEC10452B336D4A3FAE1B176D890C161B4665236A22653AAAB745E077D1982DB2AD81FA0" diff --git a/test/tool/build/lib/interner_test.c b/test/tool/build/lib/interner_test.c index d2488b50c..23d2966fe 100644 --- a/test/tool/build/lib/interner_test.c +++ b/test/tool/build/lib/interner_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" diff --git a/test/tool/build/lib/javadown_test.c b/test/tool/build/lib/javadown_test.c index d333fe0e2..41e885ae5 100644 --- a/test/tool/build/lib/javadown_test.c +++ b/test/tool/build/lib/javadown_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "tool/build/lib/javadown.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/test/tool/net/redbean_test.c b/test/tool/net/redbean_test.c index c5a1bbec0..64ad6a317 100644 --- a/test/tool/net/redbean_test.c +++ b/test/tool/net/redbean_test.c @@ -20,7 +20,7 @@ #include "libc/calls/struct/sigset.h" #include "libc/dce.h" #include "libc/fmt/conv.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/sock/goodsocket.internal.h" #include "libc/sock/sock.h" diff --git a/test/tool/net/sqlite_test.c b/test/tool/net/sqlite_test.c index 6aed804be..803806b9d 100644 --- a/test/tool/net/sqlite_test.c +++ b/test/tool/net/sqlite_test.c @@ -122,7 +122,7 @@ TEST(sqlite, test) { ")")); ASSERT_EQ(SQLITE_OK, sqlite3_close(db)); int i, n = 4; - pthread_t *t = _gc(malloc(sizeof(pthread_t) * n)); + pthread_t *t = gc(malloc(sizeof(pthread_t) * n)); for (i = 0; i < n; ++i) { ASSERT_EQ(0, pthread_create(t + i, 0, Worker, 0)); } diff --git a/test/tool/viz/lib/bilinearscale_test.c b/test/tool/viz/lib/bilinearscale_test.c index 212b5ee0d..07900b4ba 100644 --- a/test/tool/viz/lib/bilinearscale_test.c +++ b/test/tool/viz/lib/bilinearscale_test.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "tool/viz/lib/bilinearscale.h" #include "libc/log/log.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/rand.h" #include "libc/testlib/ezbench.h" diff --git a/test/tool/viz/lib/convoindex_test.c b/test/tool/viz/lib/convoindex_test.c index 00f276a3b..b68a02fc7 100644 --- a/test/tool/viz/lib/convoindex_test.c +++ b/test/tool/viz/lib/convoindex_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "tool/viz/lib/convolution.h" diff --git a/test/tool/viz/lib/fun_test.c b/test/tool/viz/lib/fun_test.c index 81cb56a59..64fbcffb2 100644 --- a/test/tool/viz/lib/fun_test.c +++ b/test/tool/viz/lib/fun_test.c @@ -19,7 +19,7 @@ #include "libc/log/check.h" #include "libc/macros.internal.h" #include "libc/stdio/rand.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" diff --git a/test/tool/viz/lib/halfblit_test.c b/test/tool/viz/lib/halfblit_test.c index 169fad3eb..c0689c80a 100644 --- a/test/tool/viz/lib/halfblit_test.c +++ b/test/tool/viz/lib/halfblit_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/bing.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" #include "tool/viz/lib/halfblit.h" diff --git a/third_party/bzip2/blocksort.c b/third_party/bzip2/blocksort.c index e223dc8cb..62e5252d4 100644 --- a/third_party/bzip2/blocksort.c +++ b/third_party/bzip2/blocksort.c @@ -19,7 +19,7 @@ ------------------------------------------------------------------ */ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "third_party/bzip2/bzlib_private.inc" diff --git a/third_party/bzip2/bzip2.c b/third_party/bzip2/bzip2.c index 05bd38afe..c18094ff6 100644 --- a/third_party/bzip2/bzip2.c +++ b/third_party/bzip2/bzip2.c @@ -4,7 +4,7 @@ #include "libc/calls/struct/stat.macros.h" #include "libc/errno.h" #include "libc/log/log.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" diff --git a/third_party/bzip2/huffman.c b/third_party/bzip2/huffman.c index bbfcfae73..54f707e72 100644 --- a/third_party/bzip2/huffman.c +++ b/third_party/bzip2/huffman.c @@ -19,7 +19,7 @@ ------------------------------------------------------------------ */ -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "third_party/bzip2/bzlib_private.inc" diff --git a/third_party/chibicc/chibicc.c b/third_party/chibicc/chibicc.c index bdf07f1cc..3273b3077 100644 --- a/third_party/chibicc/chibicc.c +++ b/third_party/chibicc/chibicc.c @@ -4,7 +4,7 @@ #include "libc/calls/struct/siginfo.h" #include "libc/calls/ucontext.h" #include "libc/fmt/libgen.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/sig.h" #include "libc/x/xasprintf.h" diff --git a/third_party/chibicc/dox1.c b/third_party/chibicc/dox1.c index 31995b3b5..1efe96008 100644 --- a/third_party/chibicc/dox1.c +++ b/third_party/chibicc/dox1.c @@ -107,15 +107,15 @@ static char *DescribeType(struct Type *ty) { case TY_LDOUBLE: return DescribeScalar(ty, "long double"); case TY_FUNC: - return xasprintf("%s(*)()", _gc(DescribeType(ty->return_ty))); + return xasprintf("%s(*)()", gc(DescribeType(ty->return_ty))); case TY_PTR: if (ty->base->kind == TY_FUNC) { return DescribeType(ty->base); } else { - return xasprintf("%s*", _gc(DescribeType(ty->base))); + return xasprintf("%s*", gc(DescribeType(ty->base))); } case TY_ARRAY: - return xasprintf("%s[%d]", _gc(DescribeType(ty->base)), ty->array_len); + return xasprintf("%s[%d]", gc(DescribeType(ty->base)), ty->array_len); case TY_ENUM: if (ty->name) { return xasprintf("enum %.*s", ty->name->len, ty->name->loc); diff --git a/third_party/chibicc/pybind.c b/third_party/chibicc/pybind.c index cbe54e8f2..7f2b728e2 100644 --- a/third_party/chibicc/pybind.c +++ b/third_party/chibicc/pybind.c @@ -538,7 +538,7 @@ const struct _inittab _PyImport_Inittab_%s = {\n\ };\n\ ", module, module, - tok->file->javadown ? _gc(xasprintf("pb_%s_doc", module)) : "0", + tok->file->javadown ? gc(xasprintf("pb_%s_doc", module)) : "0", module, module, module, module, module, module); CHECK_NE(-1, (fd = creat(path, 0644))); CHECK_NE(-1, xwrite(fd, b, appendz(b).i)); diff --git a/third_party/hiredis/hiredis.c b/third_party/hiredis/hiredis.c index 7f551c990..372da65d9 100644 --- a/third_party/hiredis/hiredis.c +++ b/third_party/hiredis/hiredis.c @@ -976,7 +976,7 @@ redisPushFn *redisSetPushCallback(redisContext *c, redisPushFn *fn) { * After this function is called, you may use redisGetReplyFromReader to * see if there is a reply available. */ int redisBufferRead(redisContext *c) { - char *buf = _gc(malloc(1024*16)); + char *buf = gc(malloc(1024*16)); int nread; /* Return early when the context has seen an error. */ diff --git a/third_party/lua/ldo.c b/third_party/lua/ldo.c index ab5960bb3..1978b1ff4 100644 --- a/third_party/lua/ldo.c +++ b/third_party/lua/ldo.c @@ -86,14 +86,14 @@ asm(".include \"libc/disclaimer.inc\""); #elif defined(LUA_USE_POSIX) /* }{ */ /* in POSIX, try _longjmp/_setjmp (more efficient) */ -#define LUAI_THROW(L,c) _gclongjmp((c)->b, 1) +#define LUAI_THROW(L,c) gclongjmp((c)->b, 1) #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } #define luai_jmpbuf jmp_buf #else /* }{ */ /* ISO C handling with long jumps */ -#define LUAI_THROW(L,c) _gclongjmp((c)->b, 1) +#define LUAI_THROW(L,c) gclongjmp((c)->b, 1) #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } #define luai_jmpbuf jmp_buf diff --git a/third_party/lua/ltests.c b/third_party/lua/ltests.c index 6ec77ab9c..b96967efb 100644 --- a/third_party/lua/ltests.c +++ b/third_party/lua/ltests.c @@ -1262,7 +1262,7 @@ static int panicback (lua_State *L) { b = (struct Aux *)lua_touserdata(L, -1); lua_pop(L, 1); /* remove 'Aux' struct */ runC(b->L, L, b->paniccode); /* run optional panic code */ - _gclongjmp(b->jb, 1); + gclongjmp(b->jb, 1); return 1; /* to avoid warnings */ } diff --git a/third_party/lua/luaencodejsondata.c b/third_party/lua/luaencodejsondata.c index 95c4e0698..c17566467 100644 --- a/third_party/lua/luaencodejsondata.c +++ b/third_party/lua/luaencodejsondata.c @@ -22,7 +22,7 @@ #include "libc/intrin/likely.h" #include "libc/log/log.h" #include "libc/log/rop.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/runtime/stack.h" diff --git a/third_party/musl/crypt_blowfish.c b/third_party/musl/crypt_blowfish.c index 5954bb608..9dfec80c0 100644 --- a/third_party/musl/crypt_blowfish.c +++ b/third_party/musl/crypt_blowfish.c @@ -29,7 +29,7 @@ #include "libc/limits.h" #include "libc/literal.h" #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "third_party/musl/crypt.internal.h" diff --git a/third_party/python/Modules/_decimal/libmpdec/transpose.c b/third_party/python/Modules/_decimal/libmpdec/transpose.c index e2566b65f..4419b6063 100644 --- a/third_party/python/Modules/_decimal/libmpdec/transpose.c +++ b/third_party/python/Modules/_decimal/libmpdec/transpose.c @@ -28,7 +28,7 @@ │ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "third_party/python/Modules/_decimal/libmpdec/transpose.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "third_party/python/Modules/_decimal/libmpdec/bits.h" #include "third_party/python/Modules/_decimal/libmpdec/constants.h" diff --git a/third_party/python/Modules/_threadmodule.c b/third_party/python/Modules/_threadmodule.c index 161d0031a..0ab3c2e04 100644 --- a/third_party/python/Modules/_threadmodule.c +++ b/third_party/python/Modules/_threadmodule.c @@ -27,7 +27,7 @@ #include "libc/errno.h" #include "libc/log/log.h" #include "libc/mem/alg.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/nt/createfile.h" #include "libc/nt/dll.h" #include "libc/nt/enum/creationdisposition.h" diff --git a/third_party/python/Modules/getpath.c b/third_party/python/Modules/getpath.c index ac1026039..9ea7cb9c8 100644 --- a/third_party/python/Modules/getpath.c +++ b/third_party/python/Modules/getpath.c @@ -11,7 +11,7 @@ #include "libc/intrin/cmpxchg.h" #include "libc/log/log.h" #include "libc/mem/alloca.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" diff --git a/third_party/python/Modules/posixmodule.c b/third_party/python/Modules/posixmodule.c index 8a22f36d1..98d55bd8f 100644 --- a/third_party/python/Modules/posixmodule.c +++ b/third_party/python/Modules/posixmodule.c @@ -29,7 +29,7 @@ #include "libc/errno.h" #include "libc/log/log.h" #include "libc/mem/alg.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/nt/createfile.h" #include "libc/nt/dll.h" #include "libc/nt/enum/creationdisposition.h" diff --git a/third_party/python/Modules/selectmodule.c b/third_party/python/Modules/selectmodule.c index fb698d445..37ba974fa 100644 --- a/third_party/python/Modules/selectmodule.c +++ b/third_party/python/Modules/selectmodule.c @@ -7,7 +7,7 @@ #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nt/efi.h" #include "libc/sock/epoll.h" diff --git a/third_party/python/Modules/tlsmodule.c b/third_party/python/Modules/tlsmodule.c index 1deb05349..1fca255fa 100644 --- a/third_party/python/Modules/tlsmodule.c +++ b/third_party/python/Modules/tlsmodule.c @@ -20,7 +20,7 @@ #include "libc/calls/calls.h" #include "libc/errno.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "net/https/https.h" #include "third_party/mbedtls/ctr_drbg.h" diff --git a/third_party/python/Objects/listobject.c b/third_party/python/Objects/listobject.c index 761a60e23..4a017cd11 100644 --- a/third_party/python/Objects/listobject.c +++ b/third_party/python/Objects/listobject.c @@ -6,7 +6,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/accu.h" #include "third_party/python/Include/boolobject.h" diff --git a/third_party/python/Python/import.c b/third_party/python/Python/import.c index 7c1744a9a..1ed177be9 100644 --- a/third_party/python/Python/import.c +++ b/third_party/python/Python/import.c @@ -886,7 +886,7 @@ PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co, else if (cpathobj != NULL) { // cpathobj != NULL means cpathname != NULL size_t cpathlen = strlen(cpathname); - char *pathname2 = _gc(strdup(cpathname)); + char *pathname2 = gc(strdup(cpathname)); if (_endswith(pathname2, ".pyc")) { pathname2[cpathlen-2] = '\0'; // so now ends with .py @@ -2152,7 +2152,7 @@ static PyObject *_imp_path_isdir(PyObject *module, PyObject *arg) { Py_ssize_t n; const char *path; if (!PyArg_Parse(arg, "z#:_path_isdir", &path, &n)) return 0; - if (path == NULL) path = _gc(getcwd(NULL, 0)); + if (path == NULL) path = gc(getcwd(NULL, 0)); return _check_path_mode(path, S_IFDIR); } PyDoc_STRVAR(_imp_path_isdir_doc, "check if path is dir"); @@ -2172,7 +2172,7 @@ static PyObject *_imp_calc_mtime_and_size(PyObject *module, PyObject *arg) { Py_ssize_t n; const char *path; if (!PyArg_Parse(arg, "z#:_calc_mtime_and_size", &path, &n)) return 0; - if (path == NULL) path = _gc(getcwd(NULL, 0)); + if (path == NULL) path = gc(getcwd(NULL, 0)); if (stat(path, &stinfo)) return PyTuple_Pack(2, PyLong_FromLong((long)-1), PyLong_FromLong((long)0)); return PyTuple_Pack(2, PyLong_FromLong((long)stinfo.st_mtime), @@ -2774,7 +2774,7 @@ static PyObject *CosmoImporter_find_spec(PyObject *cls, PyObject **args, */ newpathsize = sizeof(basepath) + cnamelen + sizeof("/__init__.pyc") + 1; - newpath = _gc(malloc(newpathsize)); + newpath = gc(malloc(newpathsize)); bzero(newpath, newpathsize); /* performing a memccpy sequence equivalent to: * snprintf(newpath, newpathsize, "/zip/.python/%s.pyc", cname); */ diff --git a/third_party/python/Python/marshal.c b/third_party/python/Python/marshal.c index 24ef415d3..573e7689b 100644 --- a/third_party/python/Python/marshal.c +++ b/third_party/python/Python/marshal.c @@ -9,7 +9,7 @@ #include "libc/calls/calls.h" #include "libc/calls/weirdtypes.h" #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/boolobject.h" #include "third_party/python/Include/code.h" diff --git a/third_party/python/Python/sysmodule.c b/third_party/python/Python/sysmodule.c index 964badbc7..9cf5f5cf1 100644 --- a/third_party/python/Python/sysmodule.c +++ b/third_party/python/Python/sysmodule.c @@ -6,7 +6,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/dce.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nt/dll.h" #include "libc/nt/version.h" diff --git a/third_party/python/pycomp.c b/third_party/python/pycomp.c index 7ab42e417..5acb9ae47 100644 --- a/third_party/python/pycomp.c +++ b/third_party/python/pycomp.c @@ -118,15 +118,15 @@ main(int argc, char *argv[]) GetOpts(argc, argv); marshalled = 0; if (stat(inpath, &st) == -1) perror(inpath), exit(1); - CHECK_NOTNULL((p = _gc(xslurp(inpath, &n)))); + CHECK_NOTNULL((p = gc(xslurp(inpath, &n)))); Py_NoUserSiteDirectory++; Py_NoSiteFlag++; Py_IgnoreEnvironmentFlag++; Py_FrozenFlag++; /* Py_VerboseFlag++; */ - Py_SetProgramName(_gc(utf8to32(argv[0], -1, 0))); + Py_SetProgramName(gc(utf8to32(argv[0], -1, 0))); _Py_InitializeEx_Private(1, 0); - name = _gc(xjoinpaths("/zip/.python", StripComponents(inpath, 3))); + name = gc(xjoinpaths("/zip/.python", StripComponents(inpath, 3))); code = Py_CompileStringExFlags(p, name, Py_file_input, NULL, optimize); if (!code) goto error; marshalled = PyMarshal_WriteObjectToString(code, Py_MARSHAL_VERSION); diff --git a/third_party/python/pyobj.c b/third_party/python/pyobj.c index 16ccb1ec2..d64aa7a81 100644 --- a/third_party/python/pyobj.c +++ b/third_party/python/pyobj.c @@ -25,7 +25,7 @@ #include "libc/log/check.h" #include "libc/log/log.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/runtime/stack.h" diff --git a/third_party/python/runpythonmodule.c b/third_party/python/runpythonmodule.c index c61927199..baf2a28ad 100644 --- a/third_party/python/runpythonmodule.c +++ b/third_party/python/runpythonmodule.c @@ -17,7 +17,7 @@ #include "libc/log/check.h" #include "libc/log/log.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/runtime/symbols.internal.h" diff --git a/third_party/quickjs/call.c b/third_party/quickjs/call.c index ea262ab6e..bdca43a6b 100644 --- a/third_party/quickjs/call.c +++ b/third_party/quickjs/call.c @@ -23,7 +23,7 @@ * THE SOFTWARE. */ #include "libc/assert.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "third_party/quickjs/internal.h" diff --git a/third_party/quickjs/qjsc.c b/third_party/quickjs/qjsc.c index 47d64c260..d24637d3b 100644 --- a/third_party/quickjs/qjsc.c +++ b/third_party/quickjs/qjsc.c @@ -477,7 +477,7 @@ int main(int argc, char **argv) { int c, i, verbose; const char *out_filename, *cname; - char *cfilename = _gc(malloc(1024)); + char *cfilename = gc(malloc(1024)); FILE *fo; JSRuntime *rt; JSContext *ctx; diff --git a/third_party/sed/compile.c b/third_party/sed/compile.c index d03736f00..c497c332e 100644 --- a/third_party/sed/compile.c +++ b/third_party/sed/compile.c @@ -46,7 +46,7 @@ #include "libc/calls/weirdtypes.h" #include "libc/sysv/consts/s.h" #include "libc/sysv/consts/utime.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/time/time.h" #include "libc/str/str.h" diff --git a/third_party/sed/process.c b/third_party/sed/process.c index 8d723bc61..1a50f1061 100644 --- a/third_party/sed/process.c +++ b/third_party/sed/process.c @@ -36,7 +36,7 @@ #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/log/bsd.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" diff --git a/third_party/smallz4/smallz4cat.c b/third_party/smallz4/smallz4cat.c index abfccac9c..6a4be692a 100644 --- a/third_party/smallz4/smallz4cat.c +++ b/third_party/smallz4/smallz4cat.c @@ -28,7 +28,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/third_party/tidy/config.c b/third_party/tidy/config.c index 3dc7b0486..3e6b9e85a 100644 --- a/third_party/tidy/config.c +++ b/third_party/tidy/config.c @@ -15,7 +15,7 @@ #include "libc/assert.h" #include "libc/assert.h" #include "libc/calls/calls.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "third_party/tidy/tags.h" diff --git a/third_party/unzip/unzip.c b/third_party/unzip/unzip.c index 1642f0bd4..a6bd55bd9 100644 --- a/third_party/unzip/unzip.c +++ b/third_party/unzip/unzip.c @@ -70,7 +70,7 @@ #include "third_party/unzip/crypt.h" #include "libc/log/log.h" #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "third_party/unzip/unzvers.h" #include "third_party/unzip/globals.h" diff --git a/tool/args/args.c b/tool/args/args.c index ac602dd36..d99ed8c26 100644 --- a/tool/args/args.c +++ b/tool/args/args.c @@ -20,7 +20,7 @@ #include "libc/assert.h" #include "libc/calls/calls.h" #include "libc/errno.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" diff --git a/tool/build/bigmul.c b/tool/build/bigmul.c index 0ef4409f8..36dd0a817 100644 --- a/tool/build/bigmul.c +++ b/tool/build/bigmul.c @@ -20,7 +20,7 @@ #include "libc/fmt/conv.h" #include "libc/log/log.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/tool/build/compile.c b/tool/build/compile.c index a06d36c00..a73baf964 100644 --- a/tool/build/compile.c +++ b/tool/build/compile.c @@ -41,7 +41,7 @@ #include "libc/macros.internal.h" #include "libc/math.h" #include "libc/mem/alg.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/kcpuids.h" #include "libc/nexgen32e/x86feature.h" diff --git a/tool/build/fixupobj.c b/tool/build/fixupobj.c index 6595edf73..f57192c16 100644 --- a/tool/build/fixupobj.c +++ b/tool/build/fixupobj.c @@ -32,7 +32,7 @@ #include "libc/limits.h" #include "libc/log/log.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/serialize.h" #include "libc/stdckdint.h" diff --git a/tool/build/lib/elfwriter.c b/tool/build/lib/elfwriter.c index 8ccccd53f..e90bcfad5 100644 --- a/tool/build/lib/elfwriter.c +++ b/tool/build/lib/elfwriter.c @@ -87,8 +87,8 @@ static void MakeRelaSection(struct ElfWriter *elf, size_t section) { elfwriter_align(elf, alignof(Elf64_Rela), sizeof(Elf64_Rela)); shdr = elfwriter_startsection( elf, - _gc(xasprintf("%s%s", ".rela", - &elf->shstrtab->p[elf->shdrs->p[section].sh_name])), + gc(xasprintf("%s%s", ".rela", + &elf->shstrtab->p[elf->shdrs->p[section].sh_name])), SHT_RELA, SHF_INFO_LINK); elf->shdrs->p[shdr].sh_info = section; elfwriter_reserve(elf, size); diff --git a/tool/build/lib/elfwriter_zip.c b/tool/build/lib/elfwriter_zip.c index 0e89ec93a..9afa5a0f7 100644 --- a/tool/build/lib/elfwriter_zip.c +++ b/tool/build/lib/elfwriter_zip.c @@ -19,15 +19,15 @@ #include "libc/dos.internal.h" #include "libc/elf/def.h" #include "libc/fmt/wintime.internal.h" -#include "libc/serialize.h" #include "libc/limits.h" #include "libc/log/check.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/crc32.h" #include "libc/nt/enum/fileflagandattributes.h" #include "libc/runtime/zipos.internal.h" +#include "libc/serialize.h" #include "libc/stdio/rand.h" #include "libc/str/str.h" #include "libc/sysv/consts/s.h" @@ -203,9 +203,9 @@ void elfwriter_zip(struct ElfWriter *elf, const char *symbol, const char *cname, EmitZipLfileHdr(lfile, name, namesize, crc, era, gflags, method, mtime, mdate, compsize, uncompsize); elfwriter_commit(elf, lfilehdrsize + compsize); - lfilesym = elfwriter_appendsym( - elf, _gc(xasprintf("%s%s", "zip+lfile:", name)), - ELF64_ST_INFO(STB_LOCAL, STT_OBJECT), STV_DEFAULT, 0, lfilehdrsize); + lfilesym = elfwriter_appendsym(elf, gc(xasprintf("%s%s", "zip+lfile:", name)), + ELF64_ST_INFO(STB_LOCAL, STT_OBJECT), + STV_DEFAULT, 0, lfilehdrsize); elfwriter_appendsym(elf, symbol, ELF64_ST_INFO(STB_GLOBAL, STT_OBJECT), STV_DEFAULT, lfilehdrsize, compsize); elfwriter_finishsection(elf); @@ -217,7 +217,7 @@ void elfwriter_zip(struct ElfWriter *elf, const char *symbol, const char *cname, (cfile = elfwriter_reserve(elf, ZIP_CFILE_HDR_SIZE + namesize)), name, namesize, crc, era, gflags, method, mtime, mdate, iattrs, dosmode, mode, compsize, uncompsize, commentsize, mtim, atim, ctim); - elfwriter_appendsym(elf, _gc(xasprintf("%s%s", "zip+cdir:", name)), + elfwriter_appendsym(elf, gc(xasprintf("%s%s", "zip+cdir:", name)), ELF64_ST_INFO(STB_LOCAL, STT_OBJECT), STV_DEFAULT, 0, ZIP_CFILE_HDR_SIZE + namesize); elfwriter_appendrela(elf, kZipCfileOffsetOffset, lfilesym, diff --git a/tool/build/lib/psk.c b/tool/build/lib/psk.c index 65db93cba..d1640b83c 100644 --- a/tool/build/lib/psk.c +++ b/tool/build/lib/psk.c @@ -16,17 +16,17 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "tool/build/lib/psk.h" #include "libc/calls/calls.h" #include "libc/calls/struct/stat.h" #include "libc/log/check.h" -#include "libc/mem/mem.h" #include "libc/mem/gc.h" +#include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/o.h" #include "libc/x/x.h" #include "libc/x/xasprintf.h" -#include "tool/build/lib/psk.h" /** * Returns preshared key for runit testing infrastructure. @@ -35,7 +35,7 @@ void *GetRunitPsk(void) { int fd; char *r, *p; struct stat st; - p = _gc(xasprintf("%s/.runit.psk", _gc(xhomedir()))); + p = gc(xasprintf("%s/.runit.psk", gc(xhomedir()))); if (stat(p, &st) == -1 || st.st_size != 32) { fprintf(stderr, "need o//examples/getrandom.com -bn32 >~/.runit.psk\n"); exit(1); diff --git a/tool/build/lz4toasm.c b/tool/build/lz4toasm.c index 86387e3c7..7e548db5a 100644 --- a/tool/build/lz4toasm.c +++ b/tool/build/lz4toasm.c @@ -22,7 +22,7 @@ #include "libc/log/check.h" #include "libc/log/log.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/kompressor.h" #include "libc/nexgen32e/lz4.h" diff --git a/tool/build/runit.c b/tool/build/runit.c index 9f885fbf4..9dc1a897e 100644 --- a/tool/build/runit.c +++ b/tool/build/runit.c @@ -149,7 +149,7 @@ void Connect(void) { int rc, err, expo; struct addrinfo *ai; struct timespec deadline; - if ((rc = getaddrinfo(g_hostname, _gc(xasprintf("%hu", g_runitdport)), + if ((rc = getaddrinfo(g_hostname, gc(xasprintf("%hu", g_runitdport)), &kResolvHints, &ai)) != 0) { FATALF("%s:%hu: EAI_%s %m", g_hostname, g_runitdport, gai_strerror(rc)); __builtin_unreachable(); @@ -210,7 +210,7 @@ bool Send(int tmpfd, const void *output, size_t outputsize) { static bool once; static z_stream zs; zsize = 32768; - zbuf = _gc(malloc(zsize)); + zbuf = gc(malloc(zsize)); if (!once) { CHECK_EQ(Z_OK, deflateInit2(&zs, 4, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY)); @@ -249,7 +249,7 @@ bool SendRequest(int tmpfd) { CHECK_NE(MAP_FAILED, (p = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0))); CHECK_LE((namesize = strlen((name = basename(g_prog)))), PATH_MAX); CHECK_LE((progsize = st.st_size), INT_MAX); - CHECK_NOTNULL((hdr = _gc(calloc(1, (hdrsize = 17 + namesize))))); + CHECK_NOTNULL((hdr = gc(calloc(1, (hdrsize = 17 + namesize))))); crc = crc32_z(0, (unsigned char *)p, st.st_size); q = hdr; q = WRITE32BE(q, RUNITD_MAGIC); @@ -269,7 +269,7 @@ bool SendRequest(int tmpfd) { void RelayRequest(void) { int i, rc, have, transferred; - char *buf = _gc(malloc(PIPE_BUF)); + char *buf = gc(malloc(PIPE_BUF)); for (transferred = 0;;) { rc = read(13, buf, PIPE_BUF); CHECK_NE(-1, rc); @@ -409,7 +409,7 @@ int SpawnSubprocesses(int argc, char *argv[]) { // create compressed network request ahead of time const char *tmpdir = firstnonnull(getenv("TMPDIR"), "/tmp"); - char *tpath = _gc(xasprintf("%s/runit.XXXXXX", tmpdir)); + char *tpath = gc(xasprintf("%s/runit.XXXXXX", tmpdir)); int tmpfd = mkstemp(tpath); CHECK_NE(-1, tmpfd); CHECK(SendRequest(tmpfd)); diff --git a/tool/build/runitd.c b/tool/build/runitd.c index 8077a1a42..0048fe9f1 100644 --- a/tool/build/runitd.c +++ b/tool/build/runitd.c @@ -36,7 +36,7 @@ #include "libc/log/check.h" #include "libc/macros.internal.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/crc32.h" #include "libc/proc/posix_spawn.h" diff --git a/tool/build/zipobj.c b/tool/build/zipobj.c index e976f581e..063447c6c 100644 --- a/tool/build/zipobj.c +++ b/tool/build/zipobj.c @@ -26,7 +26,7 @@ #include "libc/limits.h" #include "libc/log/check.h" #include "libc/log/log.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/tool/curl/curl.c b/tool/curl/curl.c index 5a1f7744a..ed5c494f8 100644 --- a/tool/curl/curl.c +++ b/tool/curl/curl.c @@ -15,7 +15,7 @@ #include "libc/fmt/itoa.h" #include "libc/fmt/magnumstrs.internal.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/sock/goodsocket.internal.h" diff --git a/tool/decode/elf.c b/tool/decode/elf.c index 23d9b2ef6..314603fb4 100644 --- a/tool/decode/elf.c +++ b/tool/decode/elf.c @@ -31,7 +31,7 @@ #include "libc/log/check.h" #include "libc/log/log.h" #include "libc/macros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" diff --git a/tool/decode/lib/asmcodegen.c b/tool/decode/lib/asmcodegen.c index b018caa2a..c969a53b9 100644 --- a/tool/decode/lib/asmcodegen.c +++ b/tool/decode/lib/asmcodegen.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "tool/decode/lib/asmcodegen.h" #include "libc/intrin/safemacros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/tool/decode/macho.c b/tool/decode/macho.c index 3a45fd38f..519179ec0 100644 --- a/tool/decode/macho.c +++ b/tool/decode/macho.c @@ -23,7 +23,7 @@ #include "libc/fmt/libgen.h" #include "libc/intrin/safemacros.internal.h" #include "libc/macho.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" diff --git a/tool/decode/pe2.c b/tool/decode/pe2.c index de3dd9852..f960f29b7 100644 --- a/tool/decode/pe2.c +++ b/tool/decode/pe2.c @@ -20,16 +20,16 @@ #include "libc/calls/struct/stat.h" #include "libc/fmt/conv.h" #include "libc/fmt/libgen.h" -#include "libc/serialize.h" #include "libc/intrin/safemacros.internal.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nt/struct/imagedosheader.internal.h" #include "libc/nt/struct/imagentheaders.internal.h" #include "libc/nt/struct/imageoptionalheader.internal.h" #include "libc/nt/struct/imagesectionheader.internal.h" #include "libc/runtime/runtime.h" +#include "libc/serialize.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/map.h" @@ -204,7 +204,7 @@ static void showpeoptionalheader(struct NtImageOptionalHeader *opt) { show(".long", \ format(b1, "%#X,%u", opt->DataDirectory[x].VirtualAddress, \ opt->DataDirectory[x].Size), \ - _gc(xasprintf("opt->DataDirectory[%s]", #x))); \ + gc(xasprintf("opt->DataDirectory[%s]", #x))); \ } \ } while (0) @@ -235,8 +235,8 @@ static void ShowIlt(uint32_t rva) { do { printf("\n"); show(".quad", format(b1, "%#lx", *ilt), - _gc(xasprintf("rva=%#lx off=%#lx", (char *)ilt - (char *)ilt0 + rva, - (intptr_t)ilt - (intptr_t)mz))); + gc(xasprintf("rva=%#lx off=%#lx", (char *)ilt - (char *)ilt0 + rva, + (intptr_t)ilt - (intptr_t)mz))); if (*ilt) { char *hint = GetRva(*ilt); printf("/\t.short\t%d\t\t\t# @%#lx\n", READ16LE(hint), @@ -256,13 +256,13 @@ static void ShowIdt(char *idt, size_t size) { for (p = idt, e = idt + size; p + 20 <= e; p += 20) { printf("\n"); show(".long", format(b1, "%#x", READ32LE(p)), - _gc(xasprintf("ImportLookupTable RVA @%#lx", - (intptr_t)p - (intptr_t)mz))); + gc(xasprintf("ImportLookupTable RVA @%#lx", + (intptr_t)p - (intptr_t)mz))); show(".long", format(b1, "%#x", READ32LE(p + 4)), "TimeDateStamp"); show(".long", format(b1, "%#x", READ32LE(p + 8)), "ForwarderChain"); show(".long", format(b1, "%#x", READ32LE(p + 12)), READ32LE(p + 12) - ? _gc(xasprintf("DllName RVA (%s)", GetRva(READ32LE(p + 12)))) + ? gc(xasprintf("DllName RVA (%s)", GetRva(READ32LE(p + 12)))) : "DllName RVA"); show(".long", format(b1, "%#x", READ32LE(p + 16)), "ImportAddressTable RVA"); diff --git a/tool/decode/zip.c b/tool/decode/zip.c index 44e121596..f83f99ff3 100644 --- a/tool/decode/zip.c +++ b/tool/decode/zip.c @@ -20,7 +20,6 @@ #include "libc/calls/struct/stat.h" #include "libc/fmt/libgen.h" #include "libc/fmt/wintime.internal.h" -#include "libc/serialize.h" #include "libc/intrin/kprintf.h" #include "libc/intrin/safemacros.internal.h" #include "libc/log/check.h" @@ -29,6 +28,7 @@ #include "libc/mem/mem.h" #include "libc/nexgen32e/crc32.h" #include "libc/nt/struct/filetime.h" +#include "libc/serialize.h" #include "libc/stdckdint.h" #include "libc/stdio/stdio.h" #include "libc/stdio/sysparam.h" @@ -86,9 +86,9 @@ void ShowGeneralFlag(uint16_t generalflag) { void ShowTimestamp(uint16_t time, uint16_t date) { show(".short", format(b1, "%#04hx", time), - _gc(xasprintf("%s (%s)", "lastmodifiedtime", _gc(FormatDosTime(time))))); + gc(xasprintf("%s (%s)", "lastmodifiedtime", gc(FormatDosTime(time))))); show(".short", format(b1, "%#04hx", date), - _gc(xasprintf("%s (%s)", "lastmodifieddate", _gc(FormatDosDate(date))))); + gc(xasprintf("%s (%s)", "lastmodifieddate", gc(FormatDosDate(date))))); } void ShowCompressionMethod(uint16_t compressmethod) { @@ -103,19 +103,18 @@ void ShowNtfs(uint8_t *ntfs, size_t n) { mtime = WindowsTimeToTimeSpec(READ64LE(ntfs + 8)); atime = WindowsTimeToTimeSpec(READ64LE(ntfs + 16)); ctime = WindowsTimeToTimeSpec(READ64LE(ntfs + 24)); - show(".long", _gc(xasprintf("%d", READ32LE(ntfs))), "ntfs reserved"); - show(".short", _gc(xasprintf("0x%04x", READ16LE(ntfs + 4))), + show(".long", gc(xasprintf("%d", READ32LE(ntfs))), "ntfs reserved"); + show(".short", gc(xasprintf("0x%04x", READ16LE(ntfs + 4))), "ntfs attribute tag value #1"); - show(".short", _gc(xasprintf("%hu", READ16LE(ntfs + 6))), + show(".short", gc(xasprintf("%hu", READ16LE(ntfs + 6))), "ntfs attribute tag size"); - show(".quad", _gc(xasprintf("%lu", READ64LE(ntfs + 8))), - _gc(xasprintf("%s (%s)", "ntfs last modified time", - _gc(xiso8601(&mtime))))); - show(".quad", _gc(xasprintf("%lu", READ64LE(ntfs + 16))), - _gc(xasprintf("%s (%s)", "ntfs last access time", - _gc(xiso8601(&atime))))); - show(".quad", _gc(xasprintf("%lu", READ64LE(ntfs + 24))), - _gc(xasprintf("%s (%s)", "ntfs creation time", _gc(xiso8601(&ctime))))); + show(".quad", gc(xasprintf("%lu", READ64LE(ntfs + 8))), + gc(xasprintf("%s (%s)", "ntfs last modified time", + gc(xiso8601(&mtime))))); + show(".quad", gc(xasprintf("%lu", READ64LE(ntfs + 16))), + gc(xasprintf("%s (%s)", "ntfs last access time", gc(xiso8601(&atime))))); + show(".quad", gc(xasprintf("%lu", READ64LE(ntfs + 24))), + gc(xasprintf("%s (%s)", "ntfs creation time", gc(xiso8601(&ctime))))); } void ShowExtendedTimestamp(uint8_t *p, size_t n, bool islocal) { @@ -123,28 +122,28 @@ void ShowExtendedTimestamp(uint8_t *p, size_t n, bool islocal) { if (n) { --n; flag = *p++; - show(".byte", _gc(xasprintf("0b%03hhb", flag)), "fields present in local"); + show(".byte", gc(xasprintf("0b%03hhb", flag)), "fields present in local"); if ((flag & 1) && n >= 4) { - show(".long", _gc(xasprintf("%u", READ32LE(p))), - _gc(xasprintf("%s (%s)", "last modified", - _gc(xiso8601(&(struct timespec){READ32LE(p)}))))); + show(".long", gc(xasprintf("%u", READ32LE(p))), + gc(xasprintf("%s (%s)", "last modified", + gc(xiso8601(&(struct timespec){READ32LE(p)}))))); p += 4; n -= 4; } flag >>= 1; if (islocal) { if ((flag & 1) && n >= 4) { - show(".long", _gc(xasprintf("%u", READ32LE(p))), - _gc(xasprintf("%s (%s)", "access time", - _gc(xiso8601(&(struct timespec){READ32LE(p)}))))); + show(".long", gc(xasprintf("%u", READ32LE(p))), + gc(xasprintf("%s (%s)", "access time", + gc(xiso8601(&(struct timespec){READ32LE(p)}))))); p += 4; n -= 4; } flag >>= 1; if ((flag & 1) && n >= 4) { - show(".long", _gc(xasprintf("%u", READ32LE(p))), - _gc(xasprintf("%s (%s)", "creation time", - _gc(xiso8601(&(struct timespec){READ32LE(p)}))))); + show(".long", gc(xasprintf("%u", READ32LE(p))), + gc(xasprintf("%s (%s)", "creation time", + gc(xiso8601(&(struct timespec){READ32LE(p)}))))); p += 4; n -= 4; } @@ -163,8 +162,8 @@ void ShowZip64(uint8_t *lf, uint8_t *p, size_t n, bool islocal) { } if (uncompsize == 0xffffffffu) { if (i + 8 <= n) { - show(".quad", _gc(xasprintf("0x%lx", READ64LE(p + i))), - _gc(xasprintf("uncompressed size (%,ld)", READ64LE(p + i)))); + show(".quad", gc(xasprintf("0x%lx", READ64LE(p + i))), + gc(xasprintf("uncompressed size (%,ld)", READ64LE(p + i)))); } else { kprintf("/\tWARNING: ZIP64 EXTRA MISSING UNCOMPRESSED SIZE\n"); } @@ -179,8 +178,8 @@ void ShowZip64(uint8_t *lf, uint8_t *p, size_t n, bool islocal) { } if (compsize == 0xffffffffu) { if (i + 8 <= n) { - show(".quad", _gc(xasprintf("0x%lx", READ64LE(p + i))), - _gc(xasprintf("compressed size (%,ld)", READ64LE(p + i)))); + show(".quad", gc(xasprintf("0x%lx", READ64LE(p + i))), + gc(xasprintf("compressed size (%,ld)", READ64LE(p + i)))); } else { kprintf("/\tWARNING: ZIP64 EXTRA MISSING COMPRESSED SIZE\n"); } @@ -192,8 +191,8 @@ void ShowZip64(uint8_t *lf, uint8_t *p, size_t n, bool islocal) { offset = ZIP_CFILE_OFFSET(lf); if (offset == 0xffffffffu) { if (i + 8 <= n) { - show(".quad", _gc(xasprintf("0x%lx", READ64LE(p + i))), - _gc(xasprintf("lfile offset (%,ld)", READ64LE(p + i)))); + show(".quad", gc(xasprintf("0x%lx", READ64LE(p + i))), + gc(xasprintf("lfile offset (%,ld)", READ64LE(p + i)))); } else { kprintf("/\tWARNING: ZIP64 EXTRA MISSING OFFSET\n"); } @@ -206,8 +205,8 @@ void ShowZip64(uint8_t *lf, uint8_t *p, size_t n, bool islocal) { disk = ZIP_CFILE_DISK(lf); if (disk == 0xffff) { if (i + 4 <= n) { - show(".long", _gc(xasprintf("0x%x", READ32LE(p + i))), - _gc(xasprintf("lfile disk (%,ld)", READ32LE(p + i)))); + show(".long", gc(xasprintf("0x%x", READ32LE(p + i))), + gc(xasprintf("lfile disk (%,ld)", READ32LE(p + i)))); } else { kprintf("/\tWARNING: ZIP64 EXTRA MISSING DISK\n"); } @@ -224,9 +223,9 @@ void ShowInfoZipNewUnixExtra(uint8_t *p, size_t n, bool islocal) { if (p[0] == 1 && p[1] == 4 && p[6] == 4) { show(".byte", "1", "version"); show(".byte", "4", "uid length"); - show(".long", _gc(xasprintf("%u", READ32LE(p + 2))), "uid"); + show(".long", gc(xasprintf("%u", READ32LE(p + 2))), "uid"); show(".byte", "4", "gid length"); - show(".long", _gc(xasprintf("%u", READ32LE(p + 7))), "gid"); + show(".long", gc(xasprintf("%u", READ32LE(p + 7))), "gid"); } else { disassemblehex(p, n, stdout); } @@ -279,11 +278,11 @@ void ShowExtras(uint8_t *lf, uint8_t *extras, uint16_t extrassize, p += ZIP_EXTRA_SIZE(p), ++i) { show(".short", firstnonnull(findnamebyid(kZipExtraNames, ZIP_EXTRA_HEADERID(p)), - _gc(xasprintf("0x%04hx", ZIP_EXTRA_HEADERID(p)))), - _gc(xasprintf("%s[%d].%s", "extras", i, "headerid"))); - show(".short", _gc(xasprintf("%df-%df", (i + 2) * 10, (i + 1) * 10)), - _gc(xasprintf("%s[%d].%s (%hd %s)", "extras", i, "contentsize", - ZIP_EXTRA_CONTENTSIZE(p), "bytes"))); + gc(xasprintf("0x%04hx", ZIP_EXTRA_HEADERID(p)))), + gc(xasprintf("%s[%d].%s", "extras", i, "headerid"))); + show(".short", gc(xasprintf("%df-%df", (i + 2) * 10, (i + 1) * 10)), + gc(xasprintf("%s[%d].%s (%hd %s)", "extras", i, "contentsize", + ZIP_EXTRA_CONTENTSIZE(p), "bytes"))); if (first) { first = false; printf("%d:", (i + 1) * 10); @@ -301,18 +300,18 @@ void ShowLocalFileHeader(uint8_t *lf, uint16_t idx) { show(".ascii", format(b1, "%`'.*s", 4, lf), "magic"); show(".byte", firstnonnull(findnamebyid(kZipEraNames, ZIP_LFILE_VERSIONNEED(lf)), - _gc(xasprintf("%d", ZIP_LFILE_VERSIONNEED(lf)))), + gc(xasprintf("%d", ZIP_LFILE_VERSIONNEED(lf)))), "pkzip version need"); show(".byte", firstnonnull(findnamebyid(kZipOsNames, ZIP_LFILE_OSNEED(lf)), - _gc(xasprintf("%d", ZIP_LFILE_OSNEED(lf)))), + gc(xasprintf("%d", ZIP_LFILE_OSNEED(lf)))), "os need"); ShowGeneralFlag(ZIP_LFILE_GENERALFLAG(lf)); ShowCompressionMethod(ZIP_LFILE_COMPRESSIONMETHOD(lf)); ShowTimestamp(ZIP_LFILE_LASTMODIFIEDTIME(lf), ZIP_LFILE_LASTMODIFIEDDATE(lf)); show( ".long", - format(b1, "%#x", ZIP_LFILE_CRC32(lf)), _gc(xasprintf("%s (%#x)", "crc32z", GetZipLfileCompressedSize(lf) /* crc32_z(0, ZIP_LFILE_CONTENT(lf), GetZipLfileCompressedSize(lf)) */))); + format(b1, "%#x", ZIP_LFILE_CRC32(lf)), gc(xasprintf("%s (%#x)", "crc32z", GetZipLfileCompressedSize(lf) /* crc32_z(0, ZIP_LFILE_CONTENT(lf), GetZipLfileCompressedSize(lf)) */))); if (ZIP_LFILE_COMPRESSEDSIZE(lf) == 0xFFFFFFFF) { show(".long", "0xFFFFFFFF", "compressedsize (zip64)"); } else { @@ -333,7 +332,7 @@ void ShowLocalFileHeader(uint8_t *lf, uint16_t idx) { printf("0:"); show(".ascii", format(b1, "%`'s", - _gc(strndup(ZIP_LFILE_NAME(lf), ZIP_LFILE_NAMESIZE(lf)))), + gc(strndup(ZIP_LFILE_NAME(lf), ZIP_LFILE_NAMESIZE(lf)))), "name"); printf("1:"); ShowExtras(lf, ZIP_LFILE_EXTRA(lf), ZIP_LFILE_EXTRASIZE(lf), true); @@ -347,19 +346,19 @@ void ShowCentralFileHeader(uint8_t *cf) { printf("\n/\t%s (%zu %s @ %#lx)\n", "central directory file header", ZIP_CFILE_HDRSIZE(cf), "bytes", cf - map); show(".ascii", format(b1, "%`'.*s", 4, cf), "magic"); - show(".byte", _gc(xasprintf("%d", ZIP_CFILE_VERSIONMADE(cf))), + show(".byte", gc(xasprintf("%d", ZIP_CFILE_VERSIONMADE(cf))), "zip version made"); show(".byte", firstnonnull(findnamebyid(kZipOsNames, ZIP_CFILE_FILEATTRCOMPAT(cf)), - _gc(xasprintf("%d", ZIP_CFILE_FILEATTRCOMPAT(cf)))), + gc(xasprintf("%d", ZIP_CFILE_FILEATTRCOMPAT(cf)))), "file attr compat"); show(".byte", firstnonnull(findnamebyid(kZipEraNames, ZIP_CFILE_VERSIONNEED(cf)), - _gc(xasprintf("%d", ZIP_CFILE_VERSIONNEED(cf)))), + gc(xasprintf("%d", ZIP_CFILE_VERSIONNEED(cf)))), "pkzip version need"); show(".byte", firstnonnull(findnamebyid(kZipOsNames, ZIP_CFILE_OSNEED(cf)), - _gc(xasprintf("%d", ZIP_CFILE_OSNEED(cf)))), + gc(xasprintf("%d", ZIP_CFILE_OSNEED(cf)))), "os need"); ShowGeneralFlag(ZIP_CFILE_GENERALFLAG(cf)); ShowCompressionMethod(ZIP_CFILE_COMPRESSIONMETHOD(cf)); @@ -398,7 +397,7 @@ void ShowCentralFileHeader(uint8_t *cf) { printf("0:"); show(".ascii", format(b1, "%`'s", - _gc(strndup(ZIP_CFILE_NAME(cf), ZIP_CFILE_NAMESIZE(cf)))), + gc(strndup(ZIP_CFILE_NAME(cf), ZIP_CFILE_NAMESIZE(cf)))), "name"); printf("1:"); ShowExtras(cf, ZIP_CFILE_EXTRA(cf), ZIP_CFILE_EXTRASIZE(cf), false); diff --git a/tool/net/fetch.inc b/tool/net/fetch.inc index 0084f4ace..e8dc1b322 100644 --- a/tool/net/fetch.inc +++ b/tool/net/fetch.inc @@ -95,7 +95,7 @@ static int LuaFetch(lua_State *L) { return LuaNilError(L, "invalid header name: %s", key); val = lua_tolstring(L, -1, &vallen); - if (!(hdr = _gc(EncodeHttpHeaderValue(val, vallen, 0)))) + if (!(hdr = gc(EncodeHttpHeaderValue(val, vallen, 0)))) return LuaNilError(L, "invalid header %s value encoding", key); // Content-Length will be overwritten; skip it to avoid duplicates; @@ -133,14 +133,14 @@ static int LuaFetch(lua_State *L) { if (bodylen > 0 || !(methodidx == kHttpGet || methodidx == kHttpHead || methodidx == kHttpTrace || methodidx == kHttpDelete || methodidx == kHttpConnect)) { - conlenhdr = _gc(xasprintf("Content-Length: %zu\r\n", bodylen)); + conlenhdr = gc(xasprintf("Content-Length: %zu\r\n", bodylen)); } /* * Parse URL. */ - _gc(ParseUrl(urlarg, urlarglen, &url, true)); - _gc(url.params.p); + gc(ParseUrl(urlarg, urlarglen, &url, true)); + gc(url.params.p); usingssl = false; if (url.scheme.n) { #ifndef UNSECURE @@ -160,9 +160,9 @@ static int LuaFetch(lua_State *L) { #endif if (url.host.n) { - host = _gc(strndup(url.host.p, url.host.n)); + host = gc(strndup(url.host.p, url.host.n)); if (url.port.n) { - port = _gc(strndup(url.port.p, url.port.n)); + port = gc(strndup(url.port.p, url.port.n)); #ifndef UNSECURE } else if (usingssl) { port = "443"; @@ -179,7 +179,7 @@ static int LuaFetch(lua_State *L) { if (!IsAcceptableHost(host, -1)) { return LuaNilError(L, "invalid host"); } - if (!hosthdr) hosthdr = _gc(xasprintf("%s:%s", host, port)); + if (!hosthdr) hosthdr = gc(xasprintf("%s:%s", host, port)); // check if hosthdr is in keepalive table if (keepalive && lua_istable(L, 2)) { @@ -207,7 +207,7 @@ static int LuaFetch(lua_State *L) { url.host.p = 0, url.host.n = 0; url.port.p = 0, url.port.n = 0; if (!url.path.n || url.path.p[0] != '/') { - void *p = _gc(xmalloc(1 + url.path.n)); + void *p = gc(xmalloc(1 + url.path.n)); mempcpy(mempcpy(p, "/", 1), url.path.p, url.path.n); url.path.p = p; ++url.path.n; @@ -224,14 +224,14 @@ static int LuaFetch(lua_State *L) { "User-Agent: %s\r\n" "%s%s" "\r\n", - method, _gc(EncodeUrl(&url, 0)), hosthdr, + method, gc(EncodeUrl(&url, 0)), hosthdr, (keepalive == kaNONE || keepalive == kaCLOSE) ? "close" : (connhdr ? connhdr : "keep-alive"), agenthdr, conlenhdr, headers ? headers : ""); appendd(&request, body, bodylen); requestlen = appendz(request).i; - _gc(request); + gc(request); if (keepalive == kaNONE || keepalive == kaOPEN) { /* @@ -274,7 +274,7 @@ static int LuaFetch(lua_State *L) { if (!evadedragnetsurveillance) { mbedtls_ssl_set_hostname(&sslcli, host); } - bio = _gc(malloc(sizeof(struct TlsBio))); + bio = gc(malloc(sizeof(struct TlsBio))); bio->fd = sock; bio->a = 0; bio->b = 0; @@ -524,7 +524,7 @@ VerifyFailed: LockInc(&shared->c.sslverifyfailed); close(sock); return LuaNilTlsError( - L, _gc(DescribeSslVerifyFailure(sslcli.session_negotiate->verify_result)), + L, gc(DescribeSslVerifyFailure(sslcli.session_negotiate->verify_result)), ret); #endif #undef ssl diff --git a/tool/net/lfuncs.c b/tool/net/lfuncs.c index 1eadcb92d..1e0633511 100644 --- a/tool/net/lfuncs.c +++ b/tool/net/lfuncs.c @@ -32,7 +32,7 @@ #include "libc/log/log.h" #include "libc/macros.internal.h" #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/bench.h" #include "libc/nexgen32e/crc32.h" diff --git a/tool/net/lsqlite3.c b/tool/net/lsqlite3.c index 25603bcb2..945560538 100644 --- a/tool/net/lsqlite3.c +++ b/tool/net/lsqlite3.c @@ -28,7 +28,7 @@ │ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/weirdtypes.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "third_party/lua/lauxlib.h" diff --git a/tool/net/redbean.c b/tool/net/redbean.c index 3f22d95e8..ca0937800 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -49,7 +49,7 @@ #include "libc/math.h" #include "libc/mem/alloca.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/crc32.h" #include "libc/nexgen32e/rdtsc.h" @@ -687,7 +687,7 @@ static void UseCertificate(mbedtls_ssl_config *c, struct Cert *kp, const char *role) { VERBOSEF("(ssl) using %s certificate %`'s for HTTPS %s", mbedtls_pk_get_name(&kp->cert->pk), - _gc(FormatX509Name(&kp->cert->subject)), role); + gc(FormatX509Name(&kp->cert->subject)), role); CHECK_EQ(0, mbedtls_ssl_conf_own_cert(c, kp->cert, kp->key)); } @@ -704,21 +704,21 @@ static void InternCertificate(mbedtls_x509_crt *cert, mbedtls_x509_crt *prev) { if (prev) { if (mbedtls_x509_crt_check_parent(prev, cert, 1)) { DEBUGF("(ssl) unbundling %`'s from %`'s", - _gc(FormatX509Name(&prev->subject)), - _gc(FormatX509Name(&cert->subject))); + gc(FormatX509Name(&prev->subject)), + gc(FormatX509Name(&cert->subject))); prev->next = 0; } else if ((r = mbedtls_x509_crt_check_signature(prev, cert, 0))) { WARNF("(ssl) invalid signature for %`'s -> %`'s (-0x%04x)", - _gc(FormatX509Name(&prev->subject)), - _gc(FormatX509Name(&cert->subject)), -r); + gc(FormatX509Name(&prev->subject)), + gc(FormatX509Name(&cert->subject)), -r); } } if (mbedtls_x509_time_is_past(&cert->valid_to)) { WARNF("(ssl) certificate %`'s is expired", - _gc(FormatX509Name(&cert->subject))); + gc(FormatX509Name(&cert->subject))); } else if (mbedtls_x509_time_is_future(&cert->valid_from)) { WARNF("(ssl) certificate %`'s is from the future", - _gc(FormatX509Name(&cert->subject))); + gc(FormatX509Name(&cert->subject))); } for (i = 0; i < certs.n; ++i) { if (!certs.p[i].cert && certs.p[i].key && @@ -1044,8 +1044,8 @@ static void ProgramCache(long x, const char *s) { } static void SetDefaults(void) { - ProgramBrand(_gc(xasprintf("%s/%hhd.%hhd.%hhd", REDBEAN, VERSION >> 020, - VERSION >> 010, VERSION >> 000))); + ProgramBrand(gc(xasprintf("%s/%hhd.%hhd.%hhd", REDBEAN, VERSION >> 020, + VERSION >> 010, VERSION >> 000))); __log_level = kLogInfo; maxpayloadsize = 64 * 1024; ProgramCache(-1, "must-revalidate"); @@ -1094,7 +1094,7 @@ static void UpdateLuaPath(const char *s) { // if the DEFAULT path is not found, append to the end respath = xasprintf("%s;%s/.lua/?.lua;%s/.lua/?/init.lua", curpath, s, s); } - lua_pushstring(L, _gc(respath)); + lua_pushstring(L, gc(respath)); lua_setfield(L, -3, "path"); } lua_settop(L, n); @@ -1210,7 +1210,7 @@ static void LuaEvalCode(const char *code) { // handle `-F PATH` arg static void LuaEvalFile(const char *path) { - char *f = _gc(xslurp(path, 0)); + char *f = gc(xslurp(path, 0)); if (!f) FATALF("(cfg) error: failed to read file %`'s", path); LuaEvalCode(f); } @@ -1731,7 +1731,7 @@ static bool TlsRouteFind(mbedtls_pk_type_t type, mbedtls_ssl_context *ssl, 0, mbedtls_ssl_set_hs_own_cert(ssl, certs.p[i].cert, certs.p[i].key)); DEBUGF("(ssl) TlsRoute(%s, %`'.*s) %s %`'s", mbedtls_pk_type_name(type), size, host, mbedtls_pk_get_name(&certs.p[i].cert->pk), - _gc(FormatX509Name(&certs.p[i].cert->subject))); + gc(FormatX509Name(&certs.p[i].cert->subject))); return true; } } @@ -1746,7 +1746,7 @@ static bool TlsRouteFirst(mbedtls_pk_type_t type, mbedtls_ssl_context *ssl) { 0, mbedtls_ssl_set_hs_own_cert(ssl, certs.p[i].cert, certs.p[i].key)); DEBUGF("(ssl) TlsRoute(%s) %s %`'s", mbedtls_pk_type_name(type), mbedtls_pk_get_name(&certs.p[i].cert->pk), - _gc(FormatX509Name(&certs.p[i].cert->subject))); + gc(FormatX509Name(&certs.p[i].cert->subject))); return true; } } @@ -1811,7 +1811,7 @@ static bool TlsSetup(void) { ssl.session->compression ? " COMPRESSED" : "", ssl.curve ? ssl.curve->name : "uncurved"); DEBUGF("(ssl) client ciphersuite preference was %s", - _gc(FormatSslClientCiphers(&ssl))); + gc(FormatSslClientCiphers(&ssl))); return true; } else if (r == MBEDTLS_ERR_SSL_WANT_READ) { LockInc(&shared->c.handshakeinterrupts); @@ -1835,12 +1835,12 @@ static bool TlsSetup(void) { case MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN: LockInc(&shared->c.sslnociphers); WARNF("(ssl) %s %s %s", DescribeClient(), "sslnociphers", - _gc(FormatSslClientCiphers(&ssl))); + gc(FormatSslClientCiphers(&ssl))); return false; case MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE: LockInc(&shared->c.sslcantciphers); WARNF("(ssl) %s %s %s", DescribeClient(), "sslcantciphers", - _gc(FormatSslClientCiphers(&ssl))); + gc(FormatSslClientCiphers(&ssl))); return false; case MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION: LockInc(&shared->c.sslnoversion); @@ -1859,7 +1859,7 @@ static bool TlsSetup(void) { case MBEDTLS_ERR_X509_CERT_VERIFY_FAILED: LockInc(&shared->c.sslverifyfailed); WARNF("(ssl) %s SSL %s", DescribeClient(), - _gc(DescribeSslVerifyFailure( + gc(DescribeSslVerifyFailure( ssl.session_negotiate->verify_result))); return false; case MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE: @@ -1904,7 +1904,7 @@ static void ConfigureCertificate(mbedtls_x509write_cert *cw, struct Cert *ca, struct sockaddr_in addr4 = {AF_INET, 0, {htonl(ip)}}; if (getnameinfo((struct sockaddr *)&addr4, sizeof(addr4), rname, sizeof(rname), 0, 0, NI_NAMEREQD) == 0) { - char *s = _gc(strdup(rname)); + char *s = gc(strdup(rname)); if (!name) name = s; bool isduplicate = false; for (int j = 0; j < nsan; ++j) { @@ -1919,7 +1919,7 @@ static void ConfigureCertificate(mbedtls_x509write_cert *cw, struct Cert *ca, san[nsan - 2].tag = MBEDTLS_X509_SAN_DNS_NAME; san[nsan - 2].val = s; san[nsan - 1].tag = MBEDTLS_X509_SAN_DNS_NAME; - san[nsan - 1].val = _gc(xasprintf("*.%s", s)); + san[nsan - 1].val = gc(xasprintf("*.%s", s)); } } } @@ -2050,7 +2050,7 @@ static void LoadCertificates(void) { if (!havecert && (!psks.n || ksk.key)) { if ((ksk = GetKeySigningKey()).key) { DEBUGF("(ssl) generating ssl certificates using %`'s", - _gc(FormatX509Name(&ksk.cert->subject))); + gc(FormatX509Name(&ksk.cert->subject))); } else { VERBOSEF("(ssl) could not find non-CA SSL certificate key pair with" " -addext keyUsage=digitalSignature" @@ -2913,10 +2913,10 @@ static void LaunchBrowser(const char *path) { } // assign a loopback address if no server or unknown server address if (!servers.n || !addr.s_addr) addr.s_addr = htonl(INADDR_LOOPBACK); - if (*path != '/') path = _gc(xasprintf("/%s", path)); - if ((prog = commandv(GetSystemUrlLauncherCommand(), _gc(malloc(PATH_MAX)), + if (*path != '/') path = gc(xasprintf("/%s", path)); + if ((prog = commandv(GetSystemUrlLauncherCommand(), gc(malloc(PATH_MAX)), PATH_MAX))) { - u = _gc(xasprintf("http://%s:%d%s", inet_ntoa(addr), port, path)); + u = gc(xasprintf("http://%s:%d%s", inet_ntoa(addr), port, path)); DEBUGF("(srvr) opening browser with command %`'s %s", prog, u); ignore.sa_flags = 0; ignore.sa_handler = SIG_IGN; @@ -3587,7 +3587,7 @@ static int LuaGetSslIdentity(lua_State *L) { psks.p[sslpskindex - 1].identity_len); } else { cert = mbedtls_ssl_get_peer_cert(&ssl); - lua_pushstring(L, cert ? _gc(FormatX509Name(&cert->subject)) : ""); + lua_pushstring(L, cert ? gc(FormatX509Name(&cert->subject)) : ""); } } return 1; @@ -3858,7 +3858,7 @@ static void StorePath(const char *dirpath) { while ((e = readdir(d))) { if (strcmp(e->d_name, ".") == 0) continue; if (strcmp(e->d_name, "..") == 0) continue; - path = _gc(xjoinpaths(dirpath, e->d_name)); + path = gc(xjoinpaths(dirpath, e->d_name)); if (e->d_type == DT_DIR) { StorePath(path); } else { @@ -3930,7 +3930,7 @@ static int LuaNilError(lua_State *L, const char *fmt, ...) { static int LuaNilTlsError(lua_State *L, const char *s, int r) { return LuaNilError(L, "tls %s failed (%s %s)", s, IsTiny() ? "grep" : GetTlsError(r), - _gc(xasprintf("-0x%04x", -r))); + gc(xasprintf("-0x%04x", -r))); } #include "tool/net/fetch.inc" @@ -4001,7 +4001,7 @@ static int LuaLog(lua_State *L) { module = ar.short_src; line = ar.currentline; } else { - module = _gc(strndup(effectivepath.p, effectivepath.n)); + module = gc(strndup(effectivepath.p, effectivepath.n)); line = -1; } flogf(level, module, line, NULL, "%s", msg); @@ -4298,7 +4298,7 @@ static int LuaSetHeader(lua_State *L) { static int LuaGetCookie(lua_State *L) { char *cookie = 0, *cookietmpl, *cookieval; OnlyCallDuringRequest(L, "GetCookie"); - cookietmpl = _gc(xasprintf(" %s=", luaL_checkstring(L, 1))); + cookietmpl = gc(xasprintf(" %s=", luaL_checkstring(L, 1))); if (HasHeader(kHttpCookie)) { appends(&cookie, " "); // prepend space to simplify cookie search appendd(&cookie, HeaderData(kHttpCookie), HeaderLength(kHttpCookie)); @@ -4343,7 +4343,7 @@ static int LuaSetCookie(lua_State *L) { if ((ishostpref || issecurepref) && !usingssl) { luaL_argerror( L, 1, - _gc(xasprintf("%s and %s prefixes require SSL", hostpref, securepref))); + gc(xasprintf("%s and %s prefixes require SSL", hostpref, securepref))); __builtin_unreachable(); } @@ -4674,7 +4674,7 @@ static int LuaProgramCertificate(lua_State *L) { static int LuaProgramHeader(lua_State *L) { ProgramHeader( - _gc(xasprintf("%s: %s", luaL_checkstring(L, 1), luaL_checkstring(L, 2)))); + gc(xasprintf("%s: %s", luaL_checkstring(L, 1), luaL_checkstring(L, 2)))); return 0; } @@ -5824,7 +5824,7 @@ static char *OpenAsset(struct Asset *a) { UnmapLater(fd, data, size); cpm.content = data; cpm.contentlength = size; - } else if ((st = _gc(malloc(sizeof(struct stat)))) && + } else if ((st = gc(malloc(sizeof(struct stat)))) && fstat(fd, st) != -1 && (data = malloc(st->st_size))) { /* probably empty file or zipos handle */ LockInc(&shared->c.slurps); diff --git a/tool/viz/cpuid.c b/tool/viz/cpuid.c index f6ce3b9a2..563a41549 100644 --- a/tool/viz/cpuid.c +++ b/tool/viz/cpuid.c @@ -75,15 +75,15 @@ void showcachesizes(void) { CPUID4_ITERATE(i, { printf("%-19s%s%s %u-way %,7u byte cache w/%s %,5u sets of %u byte lines " "shared across %u threads\n", - _gc(xasprintf("Level %u%s", CPUID4_CACHE_LEVEL, - CPUID4_CACHE_TYPE == 1 ? " data" - : CPUID4_CACHE_TYPE == 2 ? " code" - : "")), + gc(xasprintf("Level %u%s", CPUID4_CACHE_LEVEL, + CPUID4_CACHE_TYPE == 1 ? " data" + : CPUID4_CACHE_TYPE == 2 ? " code" + : "")), CPUID4_IS_FULLY_ASSOCIATIVE ? " fully-associative" : "", CPUID4_COMPLEX_INDEXING ? " complexly-indexed" : "", CPUID4_WAYS_OF_ASSOCIATIVITY, CPUID4_CACHE_SIZE_IN_BYTES, CPUID4_PHYSICAL_LINE_PARTITIONS > 1 - ? _gc(xasprintf(" %u physically partitioned")) + ? gc(xasprintf(" %u physically partitioned")) : "", CPUID4_NUMBER_OF_SETS, CPUID4_SYSTEM_COHERENCY_LINE_SIZE, CPUID4_MAX_THREADS_SHARING_CACHE); diff --git a/tool/viz/datauri.c b/tool/viz/datauri.c index 6b4706de3..8f8c92d3f 100644 --- a/tool/viz/datauri.c +++ b/tool/viz/datauri.c @@ -9,7 +9,7 @@ #endif #include "libc/errno.h" #include "libc/log/log.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/x/x.h" diff --git a/tool/viz/derasterize.c b/tool/viz/derasterize.c index 9f43b398d..07ac725f5 100644 --- a/tool/viz/derasterize.c +++ b/tool/viz/derasterize.c @@ -27,7 +27,7 @@ #include "libc/log/log.h" #include "libc/macros.internal.h" #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/x86feature.h" #include "libc/runtime/runtime.h" diff --git a/tool/viz/fontspace.c b/tool/viz/fontspace.c index fcd404012..51c3ebff3 100644 --- a/tool/viz/fontspace.c +++ b/tool/viz/fontspace.c @@ -87,8 +87,8 @@ int main(int argc, char *argv[]) { } n = end + 1 - start; m = ROUNDUP(n, 16); - present = _gc(malloc(m)); - intotal = _gc(calloc(1, m)); + present = gc(malloc(m)); + intotal = gc(calloc(1, m)); if (optind < argc) { for (arg = optind; arg < argc; ++arg) { ttf = xslurp(argv[arg], &ttfsize); diff --git a/tool/viz/generatetortureimage.c b/tool/viz/generatetortureimage.c index cb04e9a79..02b70a184 100644 --- a/tool/viz/generatetortureimage.c +++ b/tool/viz/generatetortureimage.c @@ -54,10 +54,10 @@ void *GenerateTortureImage(unsigned char RGB[YN][YM][XN][XM][3]) { int main(int argc, char *argv[]) { stbi_write_png( - _gc(xasprintf("maxwell_%dx%d_%dx%d.png", XN * XM, YN * YM, XM, YM)), + gc(xasprintf("maxwell_%dx%d_%dx%d.png", XN * XM, YN * YM, XM, YM)), XN * XM, YN * YM, 3, GenerateTortureImage( - _gc(xmemalign(32, sizeof(unsigned char) * XN * XM * YN * YM * 3))), + gc(xmemalign(32, sizeof(unsigned char) * XN * XM * YN * YM * 3))), XN * XM * 3); return 0; } diff --git a/tool/viz/getglyph.c b/tool/viz/getglyph.c index 91c060c63..10dcad506 100644 --- a/tool/viz/getglyph.c +++ b/tool/viz/getglyph.c @@ -137,14 +137,14 @@ int main(int argc, char *argv[]) { } } m = argc - optind; - w = _gc(calloc(m, sizeof(*w))); - h = _gc(calloc(m, sizeof(*h))); - ttf = _gc(calloc(m, sizeof(*ttf))); - font = _gc(calloc(m, sizeof(*font))); - rasters = _gc(calloc(m, sizeof(*rasters))); - fasters = _gc(calloc(m, sizeof(*fasters))); + w = gc(calloc(m, sizeof(*w))); + h = gc(calloc(m, sizeof(*h))); + ttf = gc(calloc(m, sizeof(*ttf))); + font = gc(calloc(m, sizeof(*font))); + rasters = gc(calloc(m, sizeof(*rasters))); + fasters = gc(calloc(m, sizeof(*fasters))); for (j = 0; j < m; ++j) { - ttf[j] = _gc(xslurp(argv[optind + j], &ttfsize)); + ttf[j] = gc(xslurp(argv[optind + j], &ttfsize)); if (!ttf[j]) { fprintf(stderr, "%s: not found\n", argv[optind + j]); exit(1); diff --git a/tool/viz/img.c b/tool/viz/img.c index 13c7e1033..99da68b44 100644 --- a/tool/viz/img.c +++ b/tool/viz/img.c @@ -46,15 +46,15 @@ void PrintImg(const char *path) { size_t n; int yn, xn, cn, w, h; void *img, *pix, *src; - if (!(img = _gc(xslurp(path, &n)))) exit(2); - if (!(pix = _gc(stbi_load_from_memory(img, n, &xn, &yn, &cn, 0)))) exit(3); + if (!(img = gc(xslurp(path, &n)))) exit(2); + if (!(pix = gc(stbi_load_from_memory(img, n, &xn, &yn, &cn, 0)))) exit(3); if (linktag) { printf("", path); } src = (void *)path; if (datauri) { src = xasprintf("data:%s;base64,%s", FindContentType(path, -1), - _gc(EncodeBase64(img, n, &n))); + gc(EncodeBase64(img, n, &n))); } w = (xn + (1 << scale) / 2) >> scale; h = (yn + (1 << scale) / 2) >> scale; diff --git a/tool/viz/lib/bilinearscale.c b/tool/viz/lib/bilinearscale.c index eb2207be3..f377db898 100644 --- a/tool/viz/lib/bilinearscale.c +++ b/tool/viz/lib/bilinearscale.c @@ -86,12 +86,12 @@ void *BilinearScale(long dcw, long dyw, long dxw, DCHECK_LT(_bsrl(cn) + _bsrl(dyn) + _bsrl(dxn), 32); BilinearScaler(dcw, dyw, dxw, dst, scw, syw, sxw, src, c0, cn, dyn, dxn, syn, sxn, ry, rx, oy, ox, - _gc(xmemalign(64, ROUNDUP(sizeof(int) * (dyn + 1), 64))), - _gc(xmemalign(64, ROUNDUP(dyn + 1, 64))), - _gc(xmemalign(64, ROUNDUP(sizeof(int) * (dxn + 1), 64))), - _gc(xmemalign(64, ROUNDUP(dxn + 1, 64))), - _gc(xmemalign(64, ROUNDUP(dxn, 64))), - _gc(xmemalign(64, ROUNDUP(sxn, 64) * 2))); + gc(xmemalign(64, ROUNDUP(sizeof(int) * (dyn + 1), 64))), + gc(xmemalign(64, ROUNDUP(dyn + 1, 64))), + gc(xmemalign(64, ROUNDUP(sizeof(int) * (dxn + 1), 64))), + gc(xmemalign(64, ROUNDUP(dxn + 1, 64))), + gc(xmemalign(64, ROUNDUP(dxn, 64))), + gc(xmemalign(64, ROUNDUP(sxn, 64) * 2))); } else { bzero(dst[c0], &dst[cn][0][0] - &dst[c0][0][0]); } diff --git a/tool/viz/lib/dither.c b/tool/viz/lib/dither.c index c8d432f75..d61a39049 100644 --- a/tool/viz/lib/dither.c +++ b/tool/viz/lib/dither.c @@ -22,7 +22,7 @@ #include "libc/log/log.h" #include "libc/macros.internal.h" #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "tool/viz/lib/graphic.h" diff --git a/tool/viz/lib/formatmatrix-byte.c b/tool/viz/lib/formatmatrix-byte.c index a97e8ee04..cc3cb1e9f 100644 --- a/tool/viz/lib/formatmatrix-byte.c +++ b/tool/viz/lib/formatmatrix-byte.c @@ -18,8 +18,8 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/math.h" -#include "libc/mem/mem.h" #include "libc/mem/gc.h" +#include "libc/mem/mem.h" #include "libc/x/xasprintf.h" #include "tool/viz/lib/formatstringtable.h" #include "tool/viz/lib/stringbuilder.h" @@ -44,7 +44,7 @@ void FormatMatrixByte(long yn, long xn, const unsigned char M[yn][xn], yn, xn, formatter(yn, xn, ConvertByteMatrixToStringTable( - yn, xn, _gc(calloc(yn * xn, sizeof(char *))), M), + yn, xn, gc(calloc(yn * xn, sizeof(char *))), M), emit, arg, param1, param2, param3)); } diff --git a/tool/viz/lib/formatmatrix-double.c b/tool/viz/lib/formatmatrix-double.c index d239cf9af..108c932e9 100644 --- a/tool/viz/lib/formatmatrix-double.c +++ b/tool/viz/lib/formatmatrix-double.c @@ -20,7 +20,7 @@ #include "libc/fmt/conv.h" #include "libc/log/check.h" #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/x/x.h" #include "third_party/gdtoa/gdtoa.h" diff --git a/tool/viz/lib/formatmatrix-float.c b/tool/viz/lib/formatmatrix-float.c index 284df946f..ce2aa1d0d 100644 --- a/tool/viz/lib/formatmatrix-float.c +++ b/tool/viz/lib/formatmatrix-float.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/x/x.h" #include "tool/viz/lib/formatstringtable.h" diff --git a/tool/viz/lib/formatmatrix-short.c b/tool/viz/lib/formatmatrix-short.c index 89965af87..586501cc1 100644 --- a/tool/viz/lib/formatmatrix-short.c +++ b/tool/viz/lib/formatmatrix-short.c @@ -18,8 +18,8 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/math.h" -#include "libc/mem/mem.h" #include "libc/mem/gc.h" +#include "libc/mem/mem.h" #include "libc/x/x.h" #include "libc/x/xasprintf.h" #include "tool/viz/lib/formatstringtable.h" @@ -45,7 +45,7 @@ void FormatMatrixShort(long yn, long xn, const short M[yn][xn], int emit(), yn, xn, formatter(yn, xn, ConvertShortMatrixToStringTable( - yn, xn, _gc(xcalloc(yn * xn, sizeof(char *))), M), + yn, xn, gc(xcalloc(yn * xn, sizeof(char *))), M), emit, arg, param1, param2, param3)); } diff --git a/tool/viz/lib/formatstringtable-assembly.c b/tool/viz/lib/formatstringtable-assembly.c index da28afa5d..267b50e3e 100644 --- a/tool/viz/lib/formatstringtable-assembly.c +++ b/tool/viz/lib/formatstringtable-assembly.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/itoa.h" #include "libc/intrin/safemacros.internal.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/str/strwidth.h" #include "libc/x/x.h" diff --git a/tool/viz/lib/ycbcr2rgb3.c b/tool/viz/lib/ycbcr2rgb3.c index 6c84dbd7d..44eb7963d 100644 --- a/tool/viz/lib/ycbcr2rgb3.c +++ b/tool/viz/lib/ycbcr2rgb3.c @@ -35,7 +35,7 @@ #include "libc/log/log.h" #include "libc/macros.internal.h" #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/gc.internal.h" #include "libc/nexgen32e/nexgen32e.h" diff --git a/tool/viz/maxmind.c b/tool/viz/maxmind.c index 3df09686b..e7e469b7a 100644 --- a/tool/viz/maxmind.c +++ b/tool/viz/maxmind.c @@ -20,7 +20,7 @@ #include "libc/serialize.h" #include "libc/log/check.h" #include "libc/log/log.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "net/http/http.h" diff --git a/tool/viz/printansi.c b/tool/viz/printansi.c index 810d8bb79..0347823c8 100644 --- a/tool/viz/printansi.c +++ b/tool/viz/printansi.c @@ -35,7 +35,7 @@ #include "libc/log/log.h" #include "libc/macros.internal.h" #include "libc/math.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" diff --git a/tool/viz/printimage.c b/tool/viz/printimage.c index 7c2d35c67..8cc472f6d 100644 --- a/tool/viz/printimage.c +++ b/tool/viz/printimage.c @@ -30,7 +30,7 @@ #include "libc/fmt/conv.h" #include "libc/log/check.h" #include "libc/log/log.h" -#include "libc/mem/gc.internal.h" +#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h"