Pay off more technical debt

This makes breaking changes to add underscores to many non-standard
function names provided by the c library. MODE=tiny is now tinier and
we now use smaller locks that are better for tiny apps in this mode.
Some headers have been renamed to be in the same folder as the build
package, so it'll be easier to know which build dependency is needed.
Certain old misguided interfaces have been removed. Intel intrinsics
headers are now listed in libc/isystem (but not in the amalgamation)
to help further improve open source compatibility. Header complexity
has also been reduced. Lastly, more shell scripts are now available.
This commit is contained in:
Justine Tunney 2022-09-12 23:10:38 -07:00
parent b69f3d2488
commit 6f7d0cb1c3
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
960 changed files with 4072 additions and 4873 deletions

View file

@ -18,6 +18,7 @@
*/
#include "libc/assert.h"
#include "libc/calls/calls.h"
#include "libc/calls/copyfd.internal.h"
#include "libc/calls/struct/iovec.h"
#include "libc/calls/struct/stat.h"
#include "libc/elf/elf.h"
@ -30,7 +31,6 @@
#include "libc/log/log.h"
#include "libc/macros.internal.h"
#include "libc/mem/arraylist2.internal.h"
#include "libc/mem/io.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/sock.h"
@ -232,8 +232,8 @@ int main(int argc, char *argv[]) {
for (i = 0;; ++i) {
TryAgain:
if (!(arg = getargs_next(&ga))) break;
if (endswith(arg, "/")) goto TryAgain;
if (endswith(arg, ".pkg")) goto TryAgain;
if (_endswith(arg, "/")) goto TryAgain;
if (_endswith(arg, ".pkg")) goto TryAgain;
CHECK_NE(-1, stat(arg, st), "%s", arg);
if (!st->st_size || S_ISDIR(st->st_mode)) goto TryAgain;
CHECK_NE(-1, (fd = open(arg, O_RDONLY)), "%s", arg);

View file

@ -21,7 +21,7 @@
#include "libc/log/log.h"
#include "libc/macros.internal.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"

View file

@ -41,6 +41,7 @@
#include "libc/intrin/pcmpeqb.h"
#include "libc/intrin/pmovmskb.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/intrin/tpenc.h"
#include "libc/limits.h"
#include "libc/log/check.h"
#include "libc/log/color.internal.h"
@ -49,18 +50,17 @@
#include "libc/macros.internal.h"
#include "libc/math.h"
#include "libc/mem/arraylist2.internal.h"
#include "libc/mem/gc.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/sock.h"
#include "libc/stdio/append.internal.h"
#include "libc/stdio/append.h"
#include "libc/stdio/rand.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/str/strwidth.h"
#include "libc/str/thompike.h"
#include "libc/str/tpdecode.internal.h"
#include "libc/str/tpenc.h"
#include "libc/str/tpencode.internal.h"
#include "libc/sysv/consts/auxv.h"
#include "libc/sysv/consts/ex.h"
@ -77,6 +77,8 @@
#include "libc/sysv/errfuns.h"
#include "libc/time/time.h"
#include "libc/x/x.h"
#include "libc/x/xasprintf.h"
#include "libc/x/xsigaction.h"
#include "third_party/gdtoa/gdtoa.h"
#include "third_party/getopt/getopt.h"
#include "tool/build/lib/address.h"
@ -589,14 +591,14 @@ static void ToggleMouseTracking(void) {
}
static void LeaveScreen(void) {
TtyWriteString(gc(xasprintf("\e[%d;%dH\e[S\r\n", tyn, txn)));
TtyWriteString(_gc(xasprintf("\e[%d;%dH\e[S\r\n", tyn, txn)));
}
static void GetTtySize(int fd) {
struct winsize wsize;
wsize.ws_row = tyn;
wsize.ws_col = txn;
getttysize(fd, &wsize);
_getttysize(fd, &wsize);
tyn = wsize.ws_row;
txn = wsize.ws_col;
}
@ -760,7 +762,7 @@ void TuiSetup(void) {
static bool once;
report = false;
if (!once) {
INFOF("loaded program %s\n%s", codepath, gc(FormatPml4t(m)));
INFOF("loaded program %s\n%s", codepath, _gc(FormatPml4t(m)));
CommonSetup();
ioctl(ttyout, TCGETS, &oldterm);
xsigaction(SIGINT, OnSigInt, 0, 0, oldsig + 3);
@ -776,7 +778,7 @@ void TuiSetup(void) {
DrainInput(ttyin);
y = 0;
if (GetCursorPosition(&y, NULL) != -1) {
TtyWriteString(gc(xasprintf("\e[%dS", y)));
TtyWriteString(_gc(xasprintf("\e[%dS", y)));
}
}
}
@ -1686,7 +1688,7 @@ static void DrawStatus(struct Panel *p) {
rw += AppendStat(s, "freed", a->freed, a->freed != b->freed);
rw += AppendStat(s, "tables", a->pagetables, a->pagetables != b->pagetables);
rw += AppendStat(s, "fds", m->fds.i, false);
AppendFmt(&p->lines[0], "\e[7m%-*s%s\e[0m", xn - rw, gc(GetStatus(xn - rw)),
AppendFmt(&p->lines[0], "\e[7m%-*s%s\e[0m", xn - rw, _gc(GetStatus(xn - rw)),
s->p);
free(s->p);
free(s);
@ -2258,7 +2260,7 @@ static void OnVidyaServiceWriteCharacter(void) {
p = buf;
p += FormatCga(m->bx[0], p);
p = stpcpy(p, "\e7");
w = tpenc(GetVidyaByte(m->ax[0]));
w = _tpenc(GetVidyaByte(m->ax[0]));
do {
*p++ = w;
} while ((w >>= 8));
@ -2286,7 +2288,7 @@ static void OnVidyaServiceTeletypeOutput(void) {
uint64_t w;
char buf[12];
n = 0 /* FormatCga(m->bx[0], buf) */;
w = tpenc(VidyaServiceXlatTeletype(m->ax[0]));
w = _tpenc(VidyaServiceXlatTeletype(m->ax[0]));
do buf[n++] = w;
while ((w >>= 8));
PtyWrite(pty, buf, n);

View file

@ -8,32 +8,32 @@
*/
#endif
#include "dsp/tty/tty.h"
#include "libc/mem/arraylist2.internal.h"
#include "libc/assert.h"
#include "libc/intrin/bits.h"
#include "libc/intrin/morton.h"
#include "libc/intrin/popcnt.h"
#include "libc/calls/calls.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/fmt.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/bits.h"
#include "libc/intrin/morton.h"
#include "libc/intrin/popcnt.h"
#include "libc/limits.h"
#include "libc/log/color.internal.h"
#include "libc/log/internal.h"
#include "libc/log/log.h"
#include "libc/macros.internal.h"
#include "libc/math.h"
#include "libc/mem/arraylist2.internal.h"
#include "libc/mem/mem.h"
#include "libc/stdio/rand.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/rand.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/ex.h"
#include "libc/sysv/consts/exit.h"
#include "libc/sysv/consts/sig.h"
#include "libc/tinymath/emodl.h"
#include "libc/x/x.h"
#include "libc/x/xsigaction.h"
#include "third_party/gdtoa/gdtoa.h"
#include "third_party/getopt/getopt.h"
@ -339,7 +339,7 @@ void OpMeminfo(void) {
OpCr();
OpCr();
fflush(stdout);
meminfo(fileno(stdout));
_meminfo(fileno(stdout));
}
void Glue2f(FLOAT fn(FLOAT, FLOAT)) {
@ -470,7 +470,7 @@ void ConsumeToken(void) {
token.i = 0;
if (history.i) history.p[history.i - 1].i = 0;
if (comment) return;
if (startswith(token.p, "#!")) return;
if (_startswith(token.p, "#!")) return;
switch (setjmp(thrower)) {
default:
if (CallFunction(token.p)) return;

View file

@ -22,7 +22,6 @@
#include "libc/fmt/conv.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/ex.h"
#include "libc/sysv/consts/exit.h"
@ -107,7 +106,7 @@ int main(int argc, char *argv[]) {
mode = strtol(argv[optind], 0, 8) & 07777;
for (i = optind + 1; i < argc; ++i) {
if (chmod(argv[i], mode) == -1) {
const char *s = strerdoc(errno);
const char *s = _strerdoc(errno);
fputs(prog, stderr);
fputs(": ", stderr);
fputs(argv[i], stderr);

View file

@ -23,7 +23,6 @@
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/o.h"
@ -72,7 +71,7 @@ wontreturn void SysExit(int rc, const char *call, const char *thing) {
const char *estr;
err = errno;
FormatInt32(ibuf, err);
estr = strerdoc(err);
estr = _strerdoc(err);
if (!estr) estr = "EUNKNOWN";
Write(thing, ": ", call, "() failed: ", estr, " (", ibuf, ")\n", 0);
exit(rc);

View file

@ -17,14 +17,17 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/calls.h"
#include "libc/calls/copyfd.internal.h"
#include "libc/calls/copyfile.h"
#include "libc/calls/ioctl.h"
#include "libc/calls/struct/itimerval.h"
#include "libc/calls/struct/rlimit.h"
#include "libc/calls/struct/rusage.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/calls/struct/sigset.h"
#include "libc/calls/struct/stat.h"
#include "libc/calls/struct/timeval.h"
#include "libc/calls/struct/winsize.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
@ -33,21 +36,20 @@
#include "libc/intrin/kprintf.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/limits.h"
#include "libc/log/appendresourcereport.internal.h"
#include "libc/log/color.internal.h"
#include "libc/log/log.h"
#include "libc/macros.internal.h"
#include "libc/math.h"
#include "libc/mem/alg.h"
#include "libc/mem/io.h"
#include "libc/mem/gc.internal.h"
#include "libc/mem/mem.h"
#include "libc/nexgen32e/kcpuids.h"
#include "libc/nexgen32e/x86feature.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/sysconf.h"
#include "libc/stdio/append.internal.h"
#include "libc/stdio/append.h"
#include "libc/stdio/stdio.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/auxv.h"
#include "libc/sysv/consts/clock.h"
@ -394,16 +396,16 @@ bool IsGccOnlyFlag(const char *s) {
return true;
}
}
if (startswith(s, "-ffixed-")) return true;
if (startswith(s, "-fcall-saved")) return true;
if (startswith(s, "-fcall-used")) return true;
if (startswith(s, "-fgcse-")) return true;
if (startswith(s, "-fvect-cost-model=")) return true;
if (startswith(s, "-fsimd-cost-model=")) return true;
if (startswith(s, "-fopt-info")) return true;
if (startswith(s, "-mstringop-strategy=")) return true;
if (startswith(s, "-mpreferred-stack-boundary=")) return true;
if (startswith(s, "-Wframe-larger-than=")) return true;
if (_startswith(s, "-ffixed-")) return true;
if (_startswith(s, "-fcall-saved")) return true;
if (_startswith(s, "-fcall-used")) return true;
if (_startswith(s, "-fgcse-")) return true;
if (_startswith(s, "-fvect-cost-model=")) return true;
if (_startswith(s, "-fsimd-cost-model=")) return true;
if (_startswith(s, "-fopt-info")) return true;
if (_startswith(s, "-mstringop-strategy=")) return true;
if (_startswith(s, "-mpreferred-stack-boundary=")) return true;
if (_startswith(s, "-Wframe-larger-than=")) return true;
return false;
}
@ -436,7 +438,7 @@ void AddEnv(char *s) {
}
char *StripPrefix(char *s, char *p) {
if (startswith(s, p)) {
if (_startswith(s, p)) {
return s + strlen(p);
} else {
return s;
@ -454,18 +456,18 @@ void AddArg(char *s) {
appendw(&shortened, ' ');
if ((isar || isbfd || ispkg) &&
(strcmp(args.p[args.n - 1], "-o") &&
(endswith(s, ".o") || endswith(s, ".pkg") ||
(endswith(s, ".a") && !isar)))) {
(_endswith(s, ".o") || _endswith(s, ".pkg") ||
(_endswith(s, ".a") && !isar)))) {
appends(&shortened, basename(s));
} else {
appends(&shortened, s);
}
} else if (/*
* a in ('-', '--') or
* a.startswith('-o') or
* a._startswith('-o') or
* c == 'ld' and a == '-T' or
* c == 'cc' and a.startswith('-O') or
* c == 'cc' and a.startswith('-x') or
* c == 'cc' and a._startswith('-O') or
* c == 'cc' and a._startswith('-x') or
* c == 'cc' and a in ('-c', '-E', '-S')
*/
s[0] == '-' && (!s[1] || s[1] == 'o' || (s[1] == '-' && !s[2]) ||
@ -592,7 +594,7 @@ int Launch(void) {
gotchld = 0;
if (pipe2(pipefds, O_CLOEXEC) == -1) {
kprintf("pipe2 failed: %s\n", strerrno(errno));
kprintf("pipe2 failed: %s\n", _strerrno(errno));
exit(1);
}
@ -605,7 +607,7 @@ int Launch(void) {
pid = vfork();
if (pid == -1) {
kprintf("vfork failed: %s\n", strerrno(errno));
kprintf("vfork failed: %s\n", _strerrno(errno));
exit(1);
}
@ -629,7 +631,7 @@ int Launch(void) {
dup2(pipefds[1], 2);
sigprocmask(SIG_SETMASK, &savemask, 0);
execve(cmd, args.p, env.p);
kprintf("execve(%#s) failed: %s\n", cmd, strerrno(errno));
kprintf("execve(%#s) failed: %s\n", cmd, _strerrno(errno));
_Exit(127);
}
close(pipefds[1]);
@ -956,7 +958,7 @@ int main(int argc, char *argv[]) {
/*
* capture flags
*/
if (startswith(argv[i], "-o")) {
if (_startswith(argv[i], "-o")) {
if (!strcmp(argv[i], "-o")) {
outpath = argv[++i];
} else {
@ -1040,25 +1042,25 @@ int main(int argc, char *argv[]) {
if (isgcc && ccversion >= 6) no_sanitize_alignment = true;
} else if (!strcmp(argv[i], "-fno-sanitize=pointer-overflow")) {
if (isgcc && ccversion >= 6) no_sanitize_pointer_overflow = true;
} else if (startswith(argv[i], "-fsanitize=implicit") &&
} else if (_startswith(argv[i], "-fsanitize=implicit") &&
strstr(argv[i], "integer")) {
if (isgcc) AddArg(argv[i]);
} else if (startswith(argv[i], "-fvect-cost") ||
startswith(argv[i], "-mstringop") ||
startswith(argv[i], "-gz") ||
} else if (_startswith(argv[i], "-fvect-cost") ||
_startswith(argv[i], "-mstringop") ||
_startswith(argv[i], "-gz") ||
strstr(argv[i], "stack-protector") ||
strstr(argv[i], "sanitize") ||
startswith(argv[i], "-fvect-cost") ||
startswith(argv[i], "-fvect-cost")) {
_startswith(argv[i], "-fvect-cost") ||
_startswith(argv[i], "-fvect-cost")) {
if (isgcc && ccversion >= 6) {
AddArg(argv[i]);
}
} else if (startswith(argv[i], "-fdiagnostic-color=")) {
} else if (_startswith(argv[i], "-fdiagnostic-color=")) {
colorflag = argv[i];
} else if (startswith(argv[i], "-R") ||
} else if (_startswith(argv[i], "-R") ||
!strcmp(argv[i], "-fsave-optimization-record")) {
if (isclang) AddArg(argv[i]);
} else if (isclang && startswith(argv[i], "--debug-prefix-map")) {
} else if (isclang && _startswith(argv[i], "--debug-prefix-map")) {
/* llvm doesn't provide a gas interface so simulate w/ clang */
AddArg(xstrcat("-f", argv[i] + 2));
} else if (isgcc && (!strcmp(argv[i], "-Os") || !strcmp(argv[i], "-O2") ||
@ -1143,7 +1145,7 @@ int main(int argc, char *argv[]) {
* scrub environment for determinism and great justice
*/
for (envp = environ; *envp; ++envp) {
if (startswith(*envp, "MODE=")) {
if (_startswith(*envp, "MODE=")) {
mode = *envp + 5;
}
if (IsSafeEnv(*envp)) {

View file

@ -17,16 +17,15 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/calls.h"
#include "libc/calls/copyfd.internal.h"
#include "libc/calls/copyfile.h"
#include "libc/calls/struct/stat.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/fmt.h"
#include "libc/mem/io.h"
#include "libc/runtime/gc.h"
#include "libc/mem/gc.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/at.h"
#include "libc/sysv/consts/ex.h"
@ -132,7 +131,7 @@ int Visit(const char *fpath, const struct stat *sb, int tflag,
strcpy(srcfile, fpath);
src = srcfile + striplen;
strcpy(dstfile, dstdir);
if (!endswith(dstfile, "/")) {
if (!_endswith(dstfile, "/")) {
strcat(dstfile, "/");
}
strcat(dstfile, src);
@ -210,7 +209,7 @@ void Cp(char *src, char *dst) {
if (nftw(src, Visit, 20, 0) == -1) {
fputs(prog, stderr);
fputs(": nftw failed: ", stderr);
fputs(strerdoc(errno), stderr);
fputs(_strerdoc(errno), stderr);
fputs("\n", stderr);
exit(1);
}
@ -231,7 +230,7 @@ void Cp(char *src, char *dst) {
}
return;
OnFail:
s = strerdoc(errno);
s = _strerdoc(errno);
fputs(prog, stderr);
fputs(": ", stderr);
fputs(src, stderr);

View file

@ -23,7 +23,6 @@
#include "libc/limits.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/o.h"
@ -36,7 +35,7 @@ wontreturn void SysFail(const char *func, const char *file) {
fputs(" failed: ", stderr);
fputs(file, stderr);
fputs(": ", stderr);
fputs(nulltoempty(strerdoc(e)), stderr);
fputs(nulltoempty(_strerdoc(e)), stderr);
fputs("\n", stderr);
exit(__COUNTER__ + 1);
}

View file

@ -28,7 +28,7 @@
#include "libc/sysv/consts/sa.h"
#include "libc/sysv/consts/sig.h"
#include "libc/time/time.h"
#include "libc/x/x.h"
#include "libc/x/xgetline.h"
static int pid;

View file

@ -30,7 +30,6 @@
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/runtime/runtime.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/map.h"
#include "libc/sysv/consts/msync.h"
@ -66,7 +65,7 @@ wontreturn void SysExit(int rc, const char *call, const char *thing) {
const char *estr;
err = errno;
FormatInt32(ibuf, err);
estr = strerdoc(err);
estr = _strerdoc(err);
if (!estr) estr = "EUNKNOWN";
Write(thing, ": ", call, "() failed: ", estr, " (", ibuf, ")\n", 0);
exit(rc);

View file

@ -21,7 +21,6 @@
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/ex.h"
#include "libc/sysv/consts/exit.h"
@ -171,7 +170,7 @@ void Compress(const char *inpath) {
if (!output) {
fputs(outpath, stderr);
fputs(": gzopen() failed\n", stderr);
fputs(strerdoc(errno), stderr);
fputs(_strerdoc(errno), stderr);
fputs("\n", stderr);
exit(1);
}
@ -181,7 +180,7 @@ void Compress(const char *inpath) {
errnum = 0;
fputs(inpath, stderr);
fputs(": read failed: ", stderr);
fputs(strerdoc(ferror(input)), stderr);
fputs(_strerdoc(ferror(input)), stderr);
fputs("\n", stderr);
_Exit(1);
}
@ -226,14 +225,14 @@ void Decompress(const char *inpath) {
if (!input) {
fputs(inpath, stderr);
fputs(": gzopen() failed\n", stderr);
fputs(strerdoc(errno), stderr);
fputs(_strerdoc(errno), stderr);
fputs("\n", stderr);
exit(1);
}
if (opt_usestdout) {
output = stdout;
outpath = "/dev/stdout";
} else if (endswith(inpath, ".gz")) {
} else if (_endswith(inpath, ".gz")) {
n = strlen(inpath);
if (n - 3 + 1 > PATH_MAX) _Exit(2);
memcpy(pathbuf, inpath, n - 3);
@ -242,7 +241,7 @@ void Decompress(const char *inpath) {
if (!(output = fopen(outpath, opt_append ? "wa" : "wb"))) {
fputs(outpath, stderr);
fputs(": open failed: ", stderr);
fputs(strerdoc(errno), stderr);
fputs(_strerdoc(errno), stderr);
fputs("\n", stderr);
_Exit(1);
}
@ -264,7 +263,7 @@ void Decompress(const char *inpath) {
if (fwrite(databuf, rc, 1, output) != 1) {
fputs(outpath, stderr);
fputs(": write failed: ", stderr);
fputs(strerdoc(ferror(output)), stderr);
fputs(_strerdoc(ferror(output)), stderr);
fputs("\n", stderr);
_Exit(1);
}

View file

@ -16,8 +16,8 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/safemacros.internal.h"
#include "libc/fmt/conv.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/macros.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
@ -331,7 +331,7 @@ void HandleOperand(const char *op) {
while (*op) {
found = false;
for (i = 0; i < ARRAYLEN(kDescriptors); ++i) {
if (startswith(op, kDescriptors[i].prefix)) {
if (_startswith(op, kDescriptors[i].prefix)) {
found = true;
op += strlen(kDescriptors[i].prefix);
if (succinct_) {

View file

@ -18,7 +18,7 @@
*/
#include "libc/log/check.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.internal.h"
#include "libc/str/str.h"
#include "tool/build/lib/endian.h"
#include "tool/build/lib/machine.h"

View file

@ -16,15 +16,15 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/mem/arraylist2.internal.h"
#include "libc/calls/calls.h"
#include "libc/errno.h"
#include "libc/fmt/fmt.h"
#include "libc/intrin/tpenc.h"
#include "libc/macros.internal.h"
#include "libc/mem/arraylist2.internal.h"
#include "libc/mem/fmt.h"
#include "libc/mem/mem.h"
#include "libc/str/str.h"
#include "libc/str/tpenc.h"
#include "tool/build/lib/buffer.h"
/* TODO(jart): replace with new append*() library */
@ -55,7 +55,7 @@ void AppendWide(struct Buffer *b, wint_t wc) {
uint64_t wb;
char buf[8];
i = 0;
wb = tpenc(wc);
wb = _tpenc(wc);
do {
buf[i++] = wb & 0xFF;
wb >>= 8;

View file

@ -16,7 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/nexgen32e/bsr.h"
#include "libc/intrin/bsr.h"
#include "libc/nexgen32e/x86feature.h"
#include "tool/build/lib/clmul.h"
#include "tool/build/lib/endian.h"
@ -33,7 +33,7 @@ struct clmul {
static struct clmul clmul(uint64_t a, uint64_t b) {
uint64_t t, x = 0, y = 0;
if (a && b) {
if (bsrl(a) < bsrl(b)) t = a, a = b, b = t;
if (_bsrl(a) < _bsrl(b)) t = a, a = b, b = t;
for (t = 0; b; a <<= 1, b >>= 1) {
if (b & 1) x ^= a, y ^= t;
t = t << 1 | a >> 63;

View file

@ -115,7 +115,7 @@ char *Demangle(char *p, const char *symbol, size_t n) {
char *r;
size_t sn;
sn = strlen(symbol);
if (startswith(symbol, "_Z")) {
if (_startswith(symbol, "_Z")) {
if ((r = DemangleCxxFilt(p, n, symbol, sn))) return r;
}
return CopySymbol(p, n, symbol, sn);

View file

@ -18,11 +18,11 @@
*/
#include "libc/fmt/bing.internal.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/tpenc.h"
#include "libc/log/check.h"
#include "libc/mem/arraylist2.internal.h"
#include "libc/mem/mem.h"
#include "libc/str/str.h"
#include "libc/str/tpenc.h"
#include "third_party/xed/x86.h"
#include "tool/build/lib/demangle.h"
#include "tool/build/lib/dis.h"
@ -151,7 +151,7 @@ static char *DisLineData(struct Dis *d, char *p, const uint8_t *b, size_t n) {
*p++ = '#';
*p++ = ' ';
for (i = 0; i < n; ++i) {
w = tpenc(bing(b[i], 0));
w = _tpenc(bing(b[i], 0));
do {
*p++ = w;
} while ((w >>= 8));

View file

@ -16,12 +16,12 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/mem/alg.h"
#include "libc/elf/elf.h"
#include "libc/elf/struct/sym.h"
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/macros.internal.h"
#include "libc/mem/alg.h"
#include "libc/mem/mem.h"
#include "libc/runtime/memtrack.internal.h"
#include "libc/str/str.h"
@ -85,7 +85,7 @@ static void DisLoadElfSyms(struct Dis *d, struct Elf *elf) {
for (i = 0; i < n; ++i) {
if (ELF64_ST_TYPE(st[i].st_info) == STT_SECTION ||
ELF64_ST_TYPE(st[i].st_info) == STT_FILE || !st[i].st_name ||
startswith(d->syms.stab + st[i].st_name, "v_") ||
_startswith(d->syms.stab + st[i].st_name, "v_") ||
!(0 <= st[i].st_name && st[i].st_name < stablen) || !st[i].st_value ||
!IsLegalPointer(st[i].st_value)) {
continue;

View file

@ -158,8 +158,8 @@ static char *DisName(struct Dis *d, char *bp, const char *name,
} else {
*p++ = 's';
}
} else if (wantsuffix || (ambiguous && !startswith(name, "f") &&
!startswith(name, "set"))) {
} else if (wantsuffix || (ambiguous && !_startswith(name, "f") &&
!_startswith(name, "set"))) {
if (Osz(rde)) {
if (ambiguous || Mode(rde) != XED_MODE_REAL) {
*p++ = 'w';

View file

@ -21,7 +21,7 @@
#include "libc/elf/def.h"
#include "libc/log/check.h"
#include "libc/mem/arraylist2.internal.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.h"
#include "libc/runtime/memtrack.internal.h"
#include "libc/stdalign.internal.h"
#include "libc/str/str.h"
@ -29,7 +29,7 @@
#include "libc/sysv/consts/msync.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/consts/prot.h"
#include "libc/x/x.h"
#include "libc/x/xasprintf.h"
#include "tool/build/lib/elfwriter.h"
static const Elf64_Ehdr kObjHeader = {
@ -86,8 +86,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);

View file

@ -22,12 +22,13 @@
#include "libc/log/check.h"
#include "libc/nexgen32e/crc32.h"
#include "libc/nt/enum/fileflagandattributes.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.h"
#include "libc/stdio/rand.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/s.h"
#include "libc/time/struct/tm.h"
#include "libc/x/x.h"
#include "libc/x/xasprintf.h"
#include "libc/zip.h"
#include "third_party/zlib/zlib.h"
#include "tool/build/lib/elfwriter.h"
@ -166,7 +167,7 @@ void elfwriter_zip(struct ElfWriter *elf, const char *symbol, const char *name,
/* emit embedded file content w/ pkzip local file header */
elfwriter_align(elf, 1, 0);
elfwriter_startsection(elf,
gc(xasprintf("%s%s", ZIP_LOCALFILE_SECTION, name)),
_gc(xasprintf("%s%s", ZIP_LOCALFILE_SECTION, name)),
SHT_PROGBITS, SHF_ALLOC);
if (method == kZipCompressionDeflate) {
CHECK_EQ(Z_OK, deflateInit2(memset(&zs, 0, sizeof(zs)),
@ -195,9 +196,9 @@ void elfwriter_zip(struct ElfWriter *elf, const char *symbol, const char *name,
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);
@ -205,13 +206,13 @@ void elfwriter_zip(struct ElfWriter *elf, const char *symbol, const char *name,
/* emit central directory record */
elfwriter_align(elf, 1, 0);
elfwriter_startsection(elf,
gc(xasprintf("%s%s", ZIP_DIRECTORY_SECTION, name)),
_gc(xasprintf("%s%s", ZIP_DIRECTORY_SECTION, name)),
SHT_PROGBITS, SHF_ALLOC);
EmitZipCdirHdr(
(cfile = elfwriter_reserve(elf, kZipCdirHdrLinkableSizeBootstrap)), 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,
kZipCdirHdrLinkableSizeBootstrap);
elfwriter_appendrela(elf, kZipCfileOffsetOffset, lfilesym, R_X86_64_32,

View file

@ -18,10 +18,12 @@
*/
#include "libc/calls/calls.h"
#include "libc/calls/struct/iovec.h"
#include "libc/errno.h"
#include "libc/log/log.h"
#include "libc/macros.internal.h"
#include "libc/sysv/consts/sig.h"
#include "libc/x/x.h"
#include "libc/x/xsigaction.h"
#include "net/https/https.h"
#include "third_party/mbedtls/net_sockets.h"
#include "third_party/mbedtls/ssl.h"

View file

@ -16,8 +16,8 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/bsf.h"
#include "libc/macros.internal.h"
#include "libc/nexgen32e/bsf.h"
#include "libc/str/str.h"
#include "third_party/xed/x86.h"
#include "tool/build/lib/address.h"
@ -33,7 +33,7 @@ static bool IsOpcodeEqual(struct XedDecodedInst *xedd, uint8_t *a) {
if (xedd->length) {
if (xedd->length <= 7) {
w = Read64(a) ^ Read64(xedd->bytes);
return !w || bsfl(w) >= (xedd->length << 3);
return !w || _bsfl(w) >= (xedd->length << 3);
} else {
return memcmp(a, xedd->bytes, xedd->length) == 0;
}

View file

@ -122,7 +122,7 @@ static void SplitLines(struct Lines *lines, char *p) {
static bool ConsumeFileOverview(struct Lines *lines) {
int i;
if (lines->n && lines->p[0].n >= strlen(FILEOVERVIEW) &&
startswith(lines->p[0].p, FILEOVERVIEW)) {
_startswith(lines->p[0].p, FILEOVERVIEW)) {
lines->p[0].p += strlen(FILEOVERVIEW);
lines->p[0].n -= strlen(FILEOVERVIEW);
while (lines->p[0].n &&

View file

@ -18,10 +18,10 @@
*/
#include "libc/calls/calls.h"
#include "libc/calls/struct/iovec.h"
#include "libc/intrin/bsr.h"
#include "libc/log/check.h"
#include "libc/macros.internal.h"
#include "libc/nexgen32e/bsr.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.h"
#include "libc/sock/sock.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/o.h"
@ -76,9 +76,9 @@ void PersistObject(const char *path, size_t align,
CHECK(IsWithin(sizeof(*obj->abi), obj->abi, obj->size, obj->p));
for (n = i = 0; obj->arrays[i].size; ++i) ++n;
iovlen = (n + 1) * 2;
pad = gc(xcalloc(align, 1));
hdr = gc(xmalloc(obj->size));
iov = gc(xcalloc(iovlen, sizeof(*iov)));
pad = _gc(xcalloc(align, 1));
hdr = _gc(xmalloc(obj->size));
iov = _gc(xcalloc(iovlen, sizeof(*iov)));
bytes = obj->size;
iov[0].iov_base = memcpy(hdr, obj->p, obj->size);
iov[0].iov_len = bytes;
@ -94,7 +94,7 @@ void PersistObject(const char *path, size_t align,
p2 = obj->arrays[i].pp;
arrayptroffset = p2 - p1;
arraydataoffset = filesize;
CHECK((!len || bsrl(len) + bsrl(size) < 31),
CHECK((!len || _bsrl(len) + _bsrl(size) < 31),
"path=%s i=%d len=%,lu size=%,lu", path, i, len, size);
CHECK(IsWithin(sizeof(void *), pp, obj->size, obj->p));
CHECK(!IsOverlapping(pp, pp + sizeof(void *), obj->magic,

View file

@ -20,10 +20,12 @@
#include "libc/calls/struct/stat.h"
#include "libc/log/check.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.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"
/**
@ -33,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);

View file

@ -19,12 +19,12 @@
#include "libc/fmt/itoa.h"
#include "libc/intrin/bits.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/intrin/tpenc.h"
#include "libc/log/check.h"
#include "libc/mem/arraylist2.internal.h"
#include "libc/mem/mem.h"
#include "libc/str/str.h"
#include "libc/str/thompike.h"
#include "libc/str/tpenc.h"
#include "libc/str/unicode.h"
#include "libc/sysv/errfuns.h"
#include "libc/x/x.h"
@ -1356,7 +1356,7 @@ int PtyAppendLine(struct Pty *pty, struct Buffer *buf, unsigned y) {
u = wc;
w = 1;
} else {
u = tpenc(wc);
u = _tpenc(wc);
w = max(1, wcwidth(wc));
}
} else {
@ -1367,7 +1367,7 @@ int PtyAppendLine(struct Pty *pty, struct Buffer *buf, unsigned y) {
if (u != ' ') {
np ^= kPtyFlip;
} else {
u = tpenc(u'');
u = _tpenc(u'');
if (pty->conf & kPtyBlinkcursor) {
np |= kPtyBlink;
}

View file

@ -42,7 +42,7 @@
#include "libc/macros.internal.h"
#include "libc/mem/mem.h"
#include "libc/nexgen32e/vendor.internal.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.internal.h"
#include "libc/runtime/pc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/select.h"

View file

@ -19,7 +19,7 @@
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/nexgen32e/vendor.internal.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "tool/build/lib/address.h"

View file

@ -26,7 +26,7 @@
#include "libc/nexgen32e/kompressor.h"
#include "libc/nexgen32e/lz4.h"
#include "libc/runtime/ezmap.internal.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"

View file

@ -33,14 +33,14 @@
#include "libc/mem/arraylist.internal.h"
#include "libc/mem/arraylist2.internal.h"
#include "libc/mem/bisectcarleft.internal.h"
#include "libc/mem/gc.internal.h"
#include "libc/mem/mem.h"
#include "libc/nexgen32e/crc32.h"
#include "libc/runtime/ezmap.internal.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/stack.h"
#include "libc/runtime/sysconf.h"
#include "libc/stdio/append.internal.h"
#include "libc/stdio/append.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/clone.h"
@ -166,8 +166,8 @@ void Crunch(void) {
free(sources.p);
sources.p = 0;
sources.i = j;
longsort((const long *)sauces, sources.i);
longsort((const long *)edges.p, edges.i);
_longsort((const long *)sauces, sources.i);
_longsort((const long *)edges.p, edges.i);
}
void Rehash(void) {
@ -221,7 +221,7 @@ unsigned GetSourceId(const char *name, size_t len) {
bool ShouldSkipSource(const char *src) {
unsigned j;
for (j = 0; j < ARRAYLEN(kIgnorePrefixes); ++j) {
if (startswith(src, kIgnorePrefixes[j])) {
if (_startswith(src, kIgnorePrefixes[j])) {
return true;
}
}
@ -345,7 +345,7 @@ const char *StripExt(char pathbuf[PATH_MAX], const char *s) {
bool IsObjectSource(const char *name) {
int i;
for (i = 0; i < ARRAYLEN(kSourceExts); ++i) {
if (endswith(name, kSourceExts[i])) return true;
if (_endswith(name, kSourceExts[i])) return true;
}
return false;
}
@ -390,7 +390,7 @@ int Diver(void *arg, int tid) {
path = strings.p + sauces[i].name;
if (!IsObjectSource(path)) continue;
appendw(&bout, '\n');
if (!startswith(path, "o/")) {
if (!_startswith(path, "o/")) {
appends(&bout, buildroot);
}
appends(&bout, StripExt(pathbuf, path));

View file

@ -12,7 +12,6 @@
#include "libc/fmt/conv.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/ex.h"
#include "libc/x/x.h"
@ -73,7 +72,7 @@ int main(int argc, char *argv[]) {
fputs(": cannot create directory '", stderr);
fputs(argv[i], stderr);
fputs("' ", stderr);
fputs(strerdoc(errno), stderr);
fputs(_strerdoc(errno), stderr);
fputc('\n', stderr);
exit(1);
}

View file

@ -21,10 +21,9 @@
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/fmt.h"
#include "libc/runtime/gc.h"
#include "libc/mem/gc.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/at.h"
#include "libc/sysv/consts/ex.h"
@ -117,7 +116,7 @@ int Visit(const char *fpath, const struct stat *sb, int tflag,
strcpy(srcfile, fpath);
src = srcfile + striplen;
strcpy(dstfile, dstdir);
if (!endswith(dstfile, "/")) {
if (!_endswith(dstfile, "/")) {
strcat(dstfile, "/");
}
strcat(dstfile, src);
@ -177,7 +176,7 @@ void Mv(char *src, char *dst) {
if (nftw(src, Visit, 20, 0) == -1) {
fputs(prog, stderr);
fputs(": nftw failed: ", stderr);
fputs(strerdoc(errno), stderr);
fputs(_strerdoc(errno), stderr);
fputs("\n", stderr);
exit(1);
}
@ -198,7 +197,7 @@ void Mv(char *src, char *dst) {
}
return;
OnFail:
s = strerdoc(errno);
s = _strerdoc(errno);
fputs(prog, stderr);
fputs(": ", stderr);
fputs(src, stderr);

View file

@ -17,11 +17,10 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/calls.h"
#include "libc/calls/copyfd.internal.h"
#include "libc/errno.h"
#include "libc/fmt/itoa.h"
#include "libc/mem/io.h"
#include "libc/runtime/runtime.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/ex.h"
#include "libc/sysv/consts/o.h"
@ -44,7 +43,7 @@ wontreturn void SysExit(int rc, const char *call, const char *thing) {
const char *estr;
err = errno;
FormatInt32(ibuf, err);
estr = strerdoc(err);
estr = _strerdoc(err);
if (!estr) estr = "EUNKNOWN";
Write(thing, ": ", call, "() failed: ", estr, " (", ibuf, ")\n", 0);
exit(rc);

View file

@ -228,21 +228,21 @@ void IndexSections(struct Object *obj) {
CHECK_NOTNULL((shdr = GetElfSectionHeaderAddress(obj->elf, obj->size, i)));
if (shdr->sh_type != SHT_NULL) {
CHECK_NOTNULL((name = GetElfSectionName(obj->elf, obj->size, shdr)));
if (startswith(name, ".sort.")) name += 5;
if (_startswith(name, ".sort.")) name += 5;
if ((strcmp(name, ".piro.relo") == 0 ||
startswith(name, ".piro.relo.")) ||
_startswith(name, ".piro.relo.")) ||
(strcmp(name, ".data.rel.ro") == 0 ||
startswith(name, ".data.rel.ro."))) {
_startswith(name, ".data.rel.ro."))) {
sect.kind = kPiroRelo;
} else if (strcmp(name, ".piro.data") == 0 ||
startswith(name, ".piro.data.")) {
_startswith(name, ".piro.data.")) {
sect.kind = kPiroData;
} else if (strcmp(name, ".piro.bss") == 0 ||
startswith(name, ".piro.bss.")) {
_startswith(name, ".piro.bss.")) {
sect.kind = kPiroBss;
} else if (strcmp(name, ".data") == 0 || startswith(name, ".data.")) {
} else if (strcmp(name, ".data") == 0 || _startswith(name, ".data.")) {
sect.kind = kData;
} else if (strcmp(name, ".bss") == 0 || startswith(name, ".bss.")) {
} else if (strcmp(name, ".bss") == 0 || _startswith(name, ".bss.")) {
sect.kind = kBss;
} else {
sect.kind = kText;

View file

@ -39,10 +39,10 @@
#include "libc/intrin/safemacros.internal.h"
#include "libc/macros.internal.h"
#include "libc/math.h"
#include "libc/mem/io.h"
#include "libc/calls/copyfd.internal.h"
#include "libc/mem/mem.h"
#include "libc/nexgen32e/kcpuids.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/sysconf.h"
#include "libc/sock/sock.h"

View file

@ -24,8 +24,8 @@
#include "libc/intrin/bits.h"
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/mem/gc.internal.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
@ -35,7 +35,8 @@
#include "libc/sysv/consts/o.h"
#include "libc/sysv/consts/sa.h"
#include "libc/sysv/consts/sig.h"
#include "libc/x/x.h"
#include "libc/x/xasprintf.h"
#include "libc/x/xgetline.h"
#include "third_party/dlmalloc/dlmalloc.h"
#include "third_party/getopt/getopt.h"
@ -635,7 +636,7 @@ static void Parse(struct Trace *t, const char *line, long lineno) {
CHECK_EQ('.', *p++, DEBUG);
us = strtol(p, &p, 10);
CHECK_EQ(' ', *p++, DEBUG);
if (startswith(p, "<... ")) {
if (_startswith(p, "<... ")) {
CHECK_NOTNULL((p = strchr(p, '>')));
++p;
for (event = t->events.n; event--;) {
@ -655,18 +656,18 @@ static void Parse(struct Trace *t, const char *line, long lineno) {
t->events.p[event].sec = sec;
t->events.p[event].us = us;
t->events.p[event].lineno = lineno;
if (startswith(p, "+++ exited with ")) {
if (_startswith(p, "+++ exited with ")) {
p += strlen("+++ exited with ");
t->events.p[event].kind = EK_EXIT;
t->events.p[event].ret = atoi(p);
return;
} else if (startswith(p, "+++ killed by ")) {
} else if (_startswith(p, "+++ killed by ")) {
p += strlen("+++ killed by ");
CHECK((q = strchr(p, ' ')), DEBUG);
t->events.p[event].kind = EK_KILLED;
t->events.p[event].ret = GetSignal(p, q - p);
return;
} else if (startswith(p, "--- ")) {
} else if (_startswith(p, "--- ")) {
p += 4;
CHECK(isalpha(*p), DEBUG);
CHECK((q = strchr(p, ' ')), DEBUG);
@ -683,7 +684,7 @@ static void Parse(struct Trace *t, const char *line, long lineno) {
if (*p == ',') ++p;
while (*p == ' ') ++p;
CHECK(*p, DEBUG);
if (startswith(p, "<unfinished ...>")) {
if (_startswith(p, "<unfinished ...>")) {
t->events.p[event].is_interrupted = true;
break;
} else if (*p == ')') {
@ -703,7 +704,7 @@ static void Parse(struct Trace *t, const char *line, long lineno) {
break;
}
CHECK_LT((arg = t->events.p[event].arity++), 6);
if (isalpha(*p) && !startswith(p, "NULL")) {
if (isalpha(*p) && !_startswith(p, "NULL")) {
bzero(&b, sizeof(b));
for (; isalpha(*p) || *p == '_'; ++p) {
AppendSlice(&b, *p);
@ -713,7 +714,7 @@ static void Parse(struct Trace *t, const char *line, long lineno) {
} else {
t->events.p[event].arg[arg].name = -1;
}
if (startswith(p, "NULL")) {
if (_startswith(p, "NULL")) {
p += 4;
t->events.p[event].arg[arg].kind = AK_LONG;
t->events.p[event].arg[arg].x = 0;

View file

@ -16,15 +16,15 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/mem/alg.h"
#include "libc/assert.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/dirent.h"
#include "libc/calls/struct/stat.h"
#include "libc/fmt/fmt.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/log/check.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/alg.h"
#include "libc/mem/gc.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/dt.h"
@ -115,7 +115,7 @@ void RefactorDir(const char *dpath) {
char *path = gc(xmalloc(4096));
CHECK_NOTNULL(dir = opendir(firstnonnull(dpath, ".")));
while ((ent = readdir(dir))) {
if (startswith(ent->d_name, ".")) continue;
if (_startswith(ent->d_name, ".")) continue;
if (strcmp(ent->d_name, "o") == 0) continue;
snprintf(path, 4096, "%s%s%s", dpath ? dpath : "", dpath ? "/" : "",
ent->d_name);

View file

@ -20,7 +20,6 @@
#include "libc/errno.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/ex.h"
#include "libc/sysv/consts/exit.h"
@ -74,7 +73,7 @@ void Remove(const char *path) {
return;
OnFail:
if (force && errno == ENOENT) return;
s = strerdoc(errno);
s = _strerdoc(errno);
fputs(prog, stderr);
fputs(": cannot remove '", stderr);
fputs(path, stderr);

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "ape/relocations.h"
#include "libc/mem/arraylist2.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/stat.h"
#include "libc/errno.h"
@ -25,9 +24,10 @@
#include "libc/intrin/kprintf.h"
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/mem/arraylist2.internal.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/append.internal.h"
#include "libc/stdio/append.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/map.h"
@ -97,13 +97,13 @@ void Visit(const char *path) {
char *map;
size_t size;
bool isheader;
if (!endswith(path, ".h") && !endswith(path, ".inc")) return;
if (endswith(path, ".internal.h")) return;
if (endswith(path, "/internal.h")) return;
if (endswith(path, ".internal.inc")) return;
if (endswith(path, "/internal.inc")) return;
if (startswith(path, "libc/isystem/")) return;
isheader = endswith(path, ".h");
if (!_endswith(path, ".h") && !_endswith(path, ".inc")) return;
if (_endswith(path, ".internal.h")) return;
if (_endswith(path, "/internal.h")) return;
if (_endswith(path, ".internal.inc")) return;
if (_endswith(path, "/internal.inc")) return;
if (_startswith(path, "libc/isystem/")) return;
isheader = _endswith(path, ".h");
if (isheader && isinterned(visited, path)) return;
appends(&output, "\n\f\n/*!BEGIN ");
appends(&output, path);

View file

@ -19,17 +19,19 @@
#include "libc/assert.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/itimerval.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/calls/struct/stat.h"
#include "libc/dns/dns.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/intrin/bits.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/limits.h"
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/mem/gc.h"
#include "libc/mem/mem.h"
#include "libc/nexgen32e/crc32.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/ipclassify.internal.h"
#include "libc/stdio/stdio.h"
@ -42,9 +44,11 @@
#include "libc/sysv/consts/map.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/consts/prot.h"
#include "libc/sysv/consts/sig.h"
#include "libc/sysv/consts/sock.h"
#include "libc/time/time.h"
#include "libc/x/x.h"
#include "libc/x/xasprintf.h"
#include "net/https/https.h"
#include "third_party/mbedtls/ssl.h"
#include "third_party/zlib/zlib.h"
@ -142,7 +146,7 @@ void Connect(void) {
int rc, err, expo;
long double t1, t2;
struct addrinfo *ai;
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));
unreachable;
@ -199,7 +203,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));
@ -241,7 +245,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, p, st.st_size);
q = hdr;
q = WRITE32BE(q, RUNITD_MAGIC);
@ -261,7 +265,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);
@ -381,7 +385,7 @@ int SpawnSubprocesses(int argc, char *argv[]) {
// create compressed network request ahead of time
CHECK_NE(-1, (tmpfd = open(
(tpath = gc(xasprintf(
(tpath = _gc(xasprintf(
"%s/runit.%d", firstnonnull(getenv("TMPDIR"), "/tmp"),
getpid()))),
O_WRONLY | O_CREAT | O_TRUNC, 0755)));

View file

@ -16,18 +16,19 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/bits.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/calls/struct/stat.h"
#include "libc/calls/struct/timeval.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/intrin/bits.h"
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/macros.internal.h"
#include "libc/mem/gc.h"
#include "libc/nexgen32e/crc32.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/sock.h"
#include "libc/sock/struct/pollfd.h"
@ -52,6 +53,7 @@
#include "libc/sysv/consts/w.h"
#include "libc/time/time.h"
#include "libc/x/x.h"
#include "libc/x/xasprintf.h"
#include "net/https/https.h"
#include "third_party/getopt/getopt.h"
#include "third_party/mbedtls/ssl.h"
@ -220,7 +222,7 @@ void StartTcpServer(void) {
CHECK_NE(-1, listen(g_servfd, 10));
asize = sizeof(g_servaddr);
CHECK_NE(-1, getsockname(g_servfd, &g_servaddr, &asize));
INFOF("%s:%s", "listening on tcp", gc(DescribeAddress(&g_servaddr)));
INFOF("%s:%s", "listening on tcp", _gc(DescribeAddress(&g_servaddr)));
if (g_sendready) {
printf("ready %hu\n", ntohs(g_servaddr.sin_port));
fflush(stdout);
@ -382,8 +384,8 @@ void HandleClient(void) {
EzFd(g_clifd);
INFOF("EzHandshake");
EzHandshake();
addrstr = gc(DescribeAddress(&addr));
DEBUGF("%s %s %s", gc(DescribeAddress(&g_servaddr)), "accepted", addrstr);
addrstr = _gc(DescribeAddress(&addr));
DEBUGF("%s %s %s", _gc(DescribeAddress(&g_servaddr)), "accepted", addrstr);
Recv(msg, sizeof(msg));
CHECK_EQ(RUNITD_MAGIC, READ32BE(msg));
@ -391,9 +393,9 @@ void HandleClient(void) {
namesize = READ32BE(msg + 5);
filesize = READ32BE(msg + 9);
crc = READ32BE(msg + 13);
exename = gc(calloc(1, namesize + 1));
exename = _gc(calloc(1, namesize + 1));
Recv(exename, namesize);
g_exepath = gc(xasprintf("o/%d.%s", getpid(), basename(exename)));
g_exepath = _gc(xasprintf("o/%d.%s", getpid(), basename(exename)));
INFOF("%s asked we run %`'s (%,u bytes @ %`'s)", addrstr, exename, filesize,
g_exepath);
@ -567,7 +569,6 @@ int main(int argc, char *argv[]) {
} else {
CHECK_EQ(3, (g_bogusfd = open("/dev/zero", O_RDONLY | O_CLOEXEC)));
}
defer(close_s, &g_bogusfd);
if (!isdirectory("o")) CHECK_NE(-1, mkdir("o", 0700));
if (g_daemonize) Daemonize();
return Serve();

View file

@ -35,8 +35,7 @@
#include "libc/log/log.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/append.internal.h"
#include "libc/str/errfun.h"
#include "libc/stdio/append.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/nr.h"
#include "libc/sysv/consts/ptrace.h"
@ -660,7 +659,7 @@ static void Flush(void) {
static const char *GetErrnoName(int x) {
const char *s;
static char buf[16];
if ((s = strerrno(x))) return s;
if ((s = _strerrno(x))) return s;
FormatInt64(buf, x);
return buf;
}

View file

@ -20,7 +20,6 @@
#include "libc/errno.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
/**
@ -33,7 +32,7 @@ int main(int argc, char *argv[]) {
prog = argc > 0 ? argv[0] : "touch.com";
for (i = 1; i < argc; ++i) {
if (touch(argv[i], 0666) == -1) {
s = strerdoc(errno);
s = _strerdoc(errno);
fputs(prog, stderr);
fputs(": cannot touch '", stderr);
fputs(argv[i], stderr);

View file

@ -22,9 +22,11 @@
#include "libc/calls/struct/winsize.h"
#include "libc/calls/termios.h"
#include "libc/calls/ttydefaults.h"
#include "libc/errno.h"
#include "libc/intrin/kprintf.h"
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/sig.h"
#include "libc/sysv/consts/termios.h"

View file

@ -23,7 +23,6 @@
#include "libc/fmt/itoa.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/errfun.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/s.h"
#include "libc/x/x.h"
@ -59,12 +58,12 @@ void Execute(char *argv[]) {
int Visit(const char *fpath, const struct stat *sb, int tflag,
struct FTW *ftwbuf) {
if (tflag == FTW_F && endswith(fpath, ".gz")) {
if (tflag == FTW_F && _endswith(fpath, ".gz")) {
Execute((char *[]){"build/bootstrap/gzip.com", "-d", fpath, 0});
strcpy(binpath, fpath);
binpath[strlen(binpath) - 3] = 0;
chmod(binpath, 0755);
} else if (tflag == FTW_F && endswith(fpath, ".sym")) {
} else if (tflag == FTW_F && _endswith(fpath, ".sym")) {
strcpy(binpath, fpath);
binpath[strlen(binpath) - 4] = 0;
symlink(xslurp(fpath, 0), binpath);
@ -83,7 +82,7 @@ int main(int argc, char *argv[]) {
if (nftw(tmpdir, Visit, 20, 0) == -1) {
fputs(prog, stderr);
fputs(": nftw failed: ", stderr);
fputs(strerdoc(errno), stderr);
fputs(_strerdoc(errno), stderr);
fputs("\n", stderr);
exit(1);
}

View file

@ -22,11 +22,11 @@
#include "libc/log/check.h"
#include "libc/math.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/x/x.h"
#include "libc/x/xasprintf.h"
/**
* @fileoverview Tool for generating rldecode'd character sets, e.g.
@ -216,7 +216,7 @@ int main(int argc, char *argv[]) {
for (i = 0; i < argc; ++i) {
if (i) printf(" ");
printf("%s", !ArgNeedsShellQuotes(argv[i]) ? argv[i]
: gc(AddShellQuotes(argv[i])));
: _gc(AddShellQuotes(argv[i])));
}
printf("\n");
@ -276,7 +276,7 @@ int main(int argc, char *argv[]) {
} else {
if (runcount) {
printf("\t.byte\t%-24s# %02x-%02x %hc-%hc\n",
gc(xasprintf("%3d,%d", runcount, runchar)), runstart,
_gc(xasprintf("%3d,%d", runcount, runchar)), runstart,
runstart + runcount - 1, Bing(runstart),
Bing(runstart + runcount - 1));
thetally += 2;

View file

@ -24,7 +24,7 @@
#include "libc/limits.h"
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/clock.h"
@ -138,7 +138,7 @@ void ProcessFile(struct ElfWriter *elf, const char *path) {
}
if (S_ISDIR(st.st_mode)) {
st.st_size = 0;
if (!endswith(name, "/")) {
if (!_endswith(name, "/")) {
name = gc(xstrcat(name, '/'));
}
}
@ -160,7 +160,7 @@ void PullEndOfCentralDirectoryIntoLinkage(struct ElfWriter *elf) {
void CheckFilenameKosher(const char *path) {
CHECK_LE(kZipCfileHdrMinSize + strlen(path),
kZipCdirHdrLinkableSizeBootstrap);
CHECK(!startswith(path, "/"));
CHECK(!_startswith(path, "/"));
CHECK(!strstr(path, ".."));
}