mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 11:48:30 +00:00
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:
parent
b69f3d2488
commit
6f7d0cb1c3
960 changed files with 4072 additions and 4873 deletions
|
@ -20,11 +20,13 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/ioctl.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/winsize.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/locale.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
|
@ -32,7 +34,6 @@
|
|||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/sysv/consts/termios.h"
|
||||
#include "libc/str/locale.h"
|
||||
#include "third_party/stb/stb_image.h"
|
||||
|
||||
#define SQR(X) ((X) * (X))
|
||||
|
|
|
@ -16,15 +16,15 @@
|
|||
│ 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/stat.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/intrin/tpenc.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
|
||||
|
@ -44,7 +44,7 @@ void bf(int fd) {
|
|||
char ibuf[W], obuf[12 + 1 + W * 6 + 1 + W * (2 + 11) + 11 + 1];
|
||||
o = 0;
|
||||
if (fstat(fd, &st) != -1 && S_ISREG(st.st_mode) && st.st_size) {
|
||||
bits = bsr(roundup2pow(st.st_size));
|
||||
bits = _bsr(_roundup2pow(st.st_size));
|
||||
bits = ROUNDUP(bits, 4);
|
||||
} else {
|
||||
bits = 48;
|
||||
|
@ -58,7 +58,7 @@ void bf(int fd) {
|
|||
obuf[n++] = ' ';
|
||||
for (i = 0; i < rc; ++i) {
|
||||
c = ibuf[i] & 0xff;
|
||||
w = tpenc(kCp437[c]);
|
||||
w = _tpenc(kCp437[c]);
|
||||
do {
|
||||
obuf[n++] = w;
|
||||
} while ((w >>= 8));
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
#include "libc/nexgen32e/rdtscp.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/nexgen32e/x86info.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#include "tool/decode/lib/x86idnames.h"
|
||||
|
||||
|
@ -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);
|
||||
|
|
|
@ -1,29 +1,21 @@
|
|||
#include "dsp/tty/tty.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/termios.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/libcxx/math.h"
|
||||
|
||||
/**
|
||||
* @fileoverview demo code borrowed from Rosetta Code.
|
||||
*/
|
||||
|
||||
#define FRAMERATE 23.976
|
||||
#define WRITE(s) write(STDOUT_FILENO, s, strlen(s))
|
||||
#define WRITE(s) write(1, s, strlen(s))
|
||||
|
||||
struct Sphere {
|
||||
long double cx, cy, cz, r;
|
||||
double cx, cy, cz, r;
|
||||
};
|
||||
|
||||
static const char *kShades[] = {
|
||||
|
@ -36,7 +28,7 @@ static const char *kShades[] = {
|
|||
};
|
||||
|
||||
static jmp_buf jb_;
|
||||
static long double light_[3] = {-50, 0, 50};
|
||||
static double light_[3] = {-50, 0, 50};
|
||||
static struct Sphere pos_ = {11, 11, 11, 11};
|
||||
static struct Sphere neg_ = {1, 1, -4, 11};
|
||||
|
||||
|
@ -44,42 +36,41 @@ static void OnCtrlC(int sig) {
|
|||
longjmp(jb_, 1);
|
||||
}
|
||||
|
||||
static void Normalize(long double v[3]) {
|
||||
long double len;
|
||||
len = 1 / sqrtl(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
||||
static void Normalize(double v[3]) {
|
||||
double len;
|
||||
len = 1 / sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
||||
v[0] *= len;
|
||||
v[1] *= len;
|
||||
v[2] *= len;
|
||||
}
|
||||
|
||||
static long double Dot(const long double x[3], const long double y[3]) {
|
||||
return fabsl(x[0] * y[0] + x[1] * y[1] + x[2] * y[2]);
|
||||
static double Dot(const double x[3], const double y[3]) {
|
||||
return fabs(x[0] * y[0] + x[1] * y[1] + x[2] * y[2]);
|
||||
}
|
||||
|
||||
/* check if a ray (x,y, -inf)->(x, y, inf) hits a sphere; if so, return
|
||||
the intersecting z values. z1 is closer to the eye */
|
||||
static int HitSphere(struct Sphere *s, long double x, long double y,
|
||||
long double z[2]) {
|
||||
long double zsq;
|
||||
static int HitSphere(struct Sphere *s, double x, double y, double z[2]) {
|
||||
double zsq;
|
||||
x -= s->cx;
|
||||
y -= s->cy;
|
||||
zsq = s->r * s->r - (x * x + y * y);
|
||||
if (zsq < 0) {
|
||||
return 0;
|
||||
} else {
|
||||
zsq = sqrtl(zsq);
|
||||
zsq = sqrt(zsq);
|
||||
z[0] = s->cz - zsq;
|
||||
z[1] = s->cz + zsq;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawSphere(long double k, long double ambient) {
|
||||
static void DrawSphere(double k, double ambient) {
|
||||
int i, j, hit_result;
|
||||
long double x, y, vec[3], zb[2], zs[2];
|
||||
for (i = floorl(pos_.cy - pos_.r); i <= ceill(pos_.cy + pos_.r); i++) {
|
||||
double x, y, vec[3], zb[2], zs[2];
|
||||
for (i = floor(pos_.cy - pos_.r); i <= ceil(pos_.cy + pos_.r); i++) {
|
||||
y = i + .5L;
|
||||
for (j = floorl(pos_.cx - 2 * pos_.r); j <= ceill(pos_.cx + 2 * pos_.r);
|
||||
for (j = floor(pos_.cx - 2 * pos_.r); j <= ceil(pos_.cx + 2 * pos_.r);
|
||||
j++) {
|
||||
x = .5L * (j - pos_.cx) + .5L + pos_.cx;
|
||||
if (!HitSphere(&pos_, x, y, zb)) {
|
||||
|
@ -117,10 +108,10 @@ static void DrawSphere(long double k, long double ambient) {
|
|||
break;
|
||||
}
|
||||
Normalize(vec);
|
||||
WRITE(kShades[min(
|
||||
ARRAYLEN(kShades) - 1,
|
||||
max(0, lroundl((1 - (powl(Dot(light_, vec), k) + ambient)) *
|
||||
(ARRAYLEN(kShades) - 1))))]);
|
||||
WRITE(
|
||||
kShades[min(ARRAYLEN(kShades) - 1,
|
||||
max(0, lround((1 - (pow(Dot(light_, vec), k) + ambient)) *
|
||||
(ARRAYLEN(kShades) - 1))))]);
|
||||
}
|
||||
WRITE("\e[0m\n");
|
||||
}
|
||||
|
@ -128,16 +119,16 @@ static void DrawSphere(long double k, long double ambient) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
long double ang;
|
||||
double ang;
|
||||
struct termios old;
|
||||
WRITE("\e[?25l");
|
||||
if (!setjmp(jb_)) {
|
||||
xsigaction(SIGINT, OnCtrlC, 0, 0, NULL);
|
||||
signal(SIGINT, OnCtrlC);
|
||||
ang = 0;
|
||||
for (;;) {
|
||||
WRITE("\e[H");
|
||||
light_[1] = cosl(ang * 2);
|
||||
sincosl(ang, &light_[0], &light_[2]);
|
||||
sincos(ang, &light_[0], &light_[2]);
|
||||
Normalize(light_);
|
||||
ang += .05L;
|
||||
DrawSphere(1.5L, .01L);
|
||||
|
|
|
@ -24,18 +24,18 @@
|
|||
#include "libc/calls/termios.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/tpenc.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
|
@ -104,7 +104,7 @@ int y_; /* -y HEIGHT [in flexidecimal] */
|
|||
#define Mode BEST
|
||||
|
||||
#if Mode == BEST
|
||||
#define MC 9u /* log2(#) of color combos to consider */
|
||||
#define MC 9u /* log2(#) of color combos to consider */
|
||||
#define GN 35u /* # of glyphs to consider */
|
||||
#elif Mode == FAST
|
||||
#define MC 6u
|
||||
|
@ -114,10 +114,10 @@ int y_; /* -y HEIGHT [in flexidecimal] */
|
|||
#define GN 25u
|
||||
#endif
|
||||
|
||||
#define CN 3u /* # channels (rgb) */
|
||||
#define YS 8u /* row stride -or- block height */
|
||||
#define XS 4u /* column stride -or- block width */
|
||||
#define GT 44u /* total glyphs */
|
||||
#define CN 3u /* # channels (rgb) */
|
||||
#define YS 8u /* row stride -or- block height */
|
||||
#define XS 4u /* column stride -or- block width */
|
||||
#define GT 44u /* total glyphs */
|
||||
#define BN (YS * XS) /* # scalars in block/glyph plane */
|
||||
|
||||
#define PHIPRIME 0x9E3779B1u
|
||||
|
@ -138,7 +138,7 @@ extern const char16_t kRunes[];
|
|||
*/
|
||||
static char *tptoa(char *p, wchar_t x) {
|
||||
unsigned long w;
|
||||
for (w = tpenc(x); w; w >>= 010) *p++ = w & 0xff;
|
||||
for (w = _tpenc(x); w; w >>= 010) *p++ = w & 0xff;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "libc/fmt/conv.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/x/x.h"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/stdio/hex.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
#include "libc/calls/ioctl.h"
|
||||
#include "libc/calls/struct/winsize.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -50,7 +50,7 @@ void PrintBar(unsigned char *p, size_t n) {
|
|||
}
|
||||
for (i = 0; i < j; ++i) {
|
||||
if (p[i]) {
|
||||
fputwc(u"░░▒▒▓▓██"[bsr(p[i])], stdout);
|
||||
fputwc(u"░░▒▒▓▓██"[_bsr(p[i])], stdout);
|
||||
} else {
|
||||
fputc(' ', stdout);
|
||||
}
|
||||
|
@ -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);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/lcg.internal.h"
|
||||
#include "libc/stdio/rand.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"
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "third_party/stb/stb_image_write.h"
|
||||
|
||||
#define YN (1080 / YM)
|
||||
|
@ -53,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;
|
||||
}
|
||||
|
|
|
@ -16,16 +16,17 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/tpenc.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
|
@ -84,7 +85,7 @@ static char *Raster(int yn, int xn, unsigned char Y[yn][xn], int *dw) {
|
|||
bs = s;
|
||||
}
|
||||
}
|
||||
appendw(&r, tpenc(kBlocks[bi].c));
|
||||
appendw(&r, _tpenc(kBlocks[bi].c));
|
||||
++w;
|
||||
}
|
||||
if (w > *dw) *dw = w;
|
||||
|
@ -109,9 +110,8 @@ int main(int argc, char *argv[]) {
|
|||
unsigned char **ttf;
|
||||
stbtt_fontinfo *font;
|
||||
int c, i, j, m, o, dw, maxw, *w, *h, s = 40 * 4;
|
||||
struct sigaction sa = {.sa_handler = OnSig};
|
||||
ShowCrashReports();
|
||||
sigaction(SIGPIPE, &sa, 0);
|
||||
signal(SIGPIPE, OnSig);
|
||||
start = 0;
|
||||
end = 0x10FFFD;
|
||||
while ((o = getopt(argc, argv, "vdc:s:e:S:")) != -1) {
|
||||
|
@ -139,14 +139,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);
|
||||
|
|
|
@ -19,10 +19,11 @@
|
|||
#include "libc/fmt/conv.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
|
||||
float b32;
|
||||
double b64;
|
||||
|
@ -33,41 +34,41 @@ int128_t x;
|
|||
|
||||
void int2float(const char *s) {
|
||||
x = strtoi128(s, NULL, 0);
|
||||
if ((0 <= x && x <= UINT32_MAX) && !startswith(s, "-") &&
|
||||
(!endswith(s, "l") && !endswith(s, "L"))) {
|
||||
if ((0 <= x && x <= UINT32_MAX) && !_startswith(s, "-") &&
|
||||
(!_endswith(s, "l") && !_endswith(s, "L"))) {
|
||||
u32 = x;
|
||||
memcpy(&b32, &u32, 4);
|
||||
s = gc(xdtoa(b32));
|
||||
if (!strchr(s, '.')) s = gc(xasprintf("%s.", s));
|
||||
s = gc(xasprintf("%sf", s));
|
||||
s = _gc(xdtoa(b32));
|
||||
if (!strchr(s, '.')) s = _gc(xasprintf("%s.", s));
|
||||
s = _gc(xasprintf("%sf", s));
|
||||
puts(s);
|
||||
} else if ((0 <= x && x <= UINT64_MAX) && !startswith(s, "-")) {
|
||||
} else if ((0 <= x && x <= UINT64_MAX) && !_startswith(s, "-")) {
|
||||
u64 = x;
|
||||
memcpy(&b64, &u64, 8);
|
||||
s = gc(xdtoa(b64));
|
||||
if (!strchr(s, '.')) s = gc(xasprintf("%s.", s));
|
||||
s = _gc(xdtoa(b64));
|
||||
if (!strchr(s, '.')) s = _gc(xasprintf("%s.", s));
|
||||
puts(s);
|
||||
} else if ((INT32_MIN <= x && x <= 0) &&
|
||||
(!endswith(s, "l") && !endswith(s, "L"))) {
|
||||
(!_endswith(s, "l") && !_endswith(s, "L"))) {
|
||||
u32 = ABS(x);
|
||||
memcpy(&b32, &u32, 4);
|
||||
b32 = -b32;
|
||||
s = gc(xdtoa(b32));
|
||||
if (!strchr(s, '.')) s = gc(xasprintf("%s.", s));
|
||||
s = gc(xasprintf("%sf", s));
|
||||
s = _gc(xdtoa(b32));
|
||||
if (!strchr(s, '.')) s = _gc(xasprintf("%s.", s));
|
||||
s = _gc(xasprintf("%sf", s));
|
||||
puts(s);
|
||||
} else if (INT64_MIN <= x && x <= 0) {
|
||||
u64 = ABS(x);
|
||||
memcpy(&b64, &u64, 8);
|
||||
b64 = -b64;
|
||||
s = gc(xdtoa(b64));
|
||||
if (!strchr(s, '.')) s = gc(xasprintf("%s.", s));
|
||||
s = _gc(xdtoa(b64));
|
||||
if (!strchr(s, '.')) s = _gc(xasprintf("%s.", s));
|
||||
puts(s);
|
||||
} else {
|
||||
memcpy(&b80, &x, 16);
|
||||
s = gc(xdtoa(b80));
|
||||
if (!strchr(s, '.')) s = gc(xasprintf("%s.", s));
|
||||
s = gc(xasprintf("%sL", s));
|
||||
s = _gc(xdtoa(b80));
|
||||
if (!strchr(s, '.')) s = _gc(xasprintf("%s.", s));
|
||||
s = _gc(xasprintf("%sL", s));
|
||||
puts(s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/twixt8.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
@ -82,16 +82,16 @@ void *BilinearScale(long dcw, long dyw, long dxw,
|
|||
DCHECK_LE(sxn, sxw);
|
||||
DCHECK_LE(dyn, dyw);
|
||||
DCHECK_LE(dxn, dxw);
|
||||
DCHECK_LT(bsrl(cn) + bsrl(syn) + bsrl(sxn), 32);
|
||||
DCHECK_LT(bsrl(cn) + bsrl(dyn) + bsrl(dxn), 32);
|
||||
DCHECK_LT(_bsrl(cn) + _bsrl(syn) + _bsrl(sxn), 32);
|
||||
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]);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.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/viz/lib/graphic.h"
|
||||
#include "tool/viz/lib/knobs.h"
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/mem/gc.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));
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "libc/log/check.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "tool/viz/lib/formatstringtable.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "tool/viz/lib/formatstringtable.h"
|
||||
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "tool/viz/lib/formatstringtable.h"
|
||||
#include "tool/viz/lib/stringbuilder.h"
|
||||
|
||||
|
@ -44,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));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/strwidth.h"
|
||||
#include "libc/x/x.h"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_VIZ_LIB_GRAPHIC_H_
|
||||
#define COSMOPOLITAN_TOOL_VIZ_LIB_GRAPHIC_H_
|
||||
#include "dsp/tty/quant.h"
|
||||
#include "libc/runtime/buffer.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/runtime/buffer.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/intrin/xmmintrin.internal.h"
|
||||
#include "libc/runtime/buffer.h"
|
||||
#include "libc/runtime/buffer.internal.h"
|
||||
#include "tool/viz/lib/graphic.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,19 +25,19 @@
|
|||
#include "dsp/core/illumination.h"
|
||||
#include "dsp/core/q.h"
|
||||
#include "dsp/scale/scale.h"
|
||||
#include "libc/intrin/xmmintrin.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/intrin/pmulhrsw.h"
|
||||
#include "libc/intrin/xmmintrin.internal.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.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/nexgen32e/x86feature.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
@ -96,8 +96,8 @@ void YCbCrComputeCoefficients(int swing, double gamma,
|
|||
double x;
|
||||
double f1[6][3];
|
||||
long longs[6][6];
|
||||
long bitlimit = roundup2pow(swing);
|
||||
long wordoffset = rounddown2pow((bitlimit - swing) / 2);
|
||||
long bitlimit = _roundup2pow(swing);
|
||||
long wordoffset = _rounddown2pow((bitlimit - swing) / 2);
|
||||
long chromaswing = swing + 2 * (bitlimit / 2. - swing / 2. - wordoffset);
|
||||
long lumamin = wordoffset;
|
||||
long lumamax = wordoffset + swing;
|
||||
|
|
|
@ -16,19 +16,16 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/gamma.h"
|
||||
#include "dsp/scale/scale.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/ioctl.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/termios.h"
|
||||
#include "libc/calls/struct/winsize.h"
|
||||
#include "libc/calls/termios.internal.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/popcnt.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/intrin/xchg.internal.h"
|
||||
|
@ -41,9 +38,7 @@
|
|||
#include "libc/nt/dll.h"
|
||||
#include "libc/nt/enum/bitblt.h"
|
||||
#include "libc/nt/enum/color.h"
|
||||
#include "libc/nt/enum/cs.h"
|
||||
#include "libc/nt/enum/cw.h"
|
||||
#include "libc/nt/enum/ht.h"
|
||||
#include "libc/nt/enum/idc.h"
|
||||
#include "libc/nt/enum/mb.h"
|
||||
#include "libc/nt/enum/mf.h"
|
||||
|
@ -51,38 +46,26 @@
|
|||
#include "libc/nt/enum/ofn.h"
|
||||
#include "libc/nt/enum/rdw.h"
|
||||
#include "libc/nt/enum/sc.h"
|
||||
#include "libc/nt/enum/size.h"
|
||||
#include "libc/nt/enum/sw.h"
|
||||
#include "libc/nt/enum/tpm.h"
|
||||
#include "libc/nt/enum/vk.h"
|
||||
#include "libc/nt/enum/wm.h"
|
||||
#include "libc/nt/enum/ws.h"
|
||||
#include "libc/nt/events.h"
|
||||
#include "libc/nt/messagebox.h"
|
||||
#include "libc/nt/paint.h"
|
||||
#include "libc/nt/struct/msg.h"
|
||||
#include "libc/nt/struct/openfilename.h"
|
||||
#include "libc/nt/struct/paintstruct.h"
|
||||
#include "libc/nt/struct/windowplacement.h"
|
||||
#include "libc/nt/struct/wndclass.h"
|
||||
#include "libc/nt/windows.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/pollfd.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/strwidth.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
#include "libc/str/unicode.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/poll.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/consts/termios.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
|
||||
/**
|
||||
|
@ -310,12 +293,7 @@ static void Unset(long y, long x) {
|
|||
}
|
||||
|
||||
static long Population(void) {
|
||||
long i, n, p;
|
||||
n = (byn * bxn) >> 6;
|
||||
for (p = i = 0; i < n; ++i) {
|
||||
p += popcnt(board[i]);
|
||||
}
|
||||
return p;
|
||||
return _countbits(board, byn * bxn / 64 * 8);
|
||||
}
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
|
@ -505,9 +483,9 @@ static void *NewBoard(size_t *out_size) {
|
|||
s = (byn * bxn) >> 3;
|
||||
k = PAGESIZE + ROUNDUP(s, PAGESIZE);
|
||||
n = ROUNDUP(k + PAGESIZE, FRAMESIZE);
|
||||
p = mmap(NULL, n, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
mprotect(p, PAGESIZE, PROT_NONE);
|
||||
mprotect(p + k, n - k, PROT_NONE);
|
||||
p = _mapanon(n);
|
||||
mprotect(p, PAGESIZE, 0);
|
||||
mprotect(p + k, n - k, 0);
|
||||
if (out_size) *out_size = n;
|
||||
return p + PAGESIZE;
|
||||
}
|
||||
|
@ -734,7 +712,7 @@ static void GetTtySize(void) {
|
|||
struct winsize wsize;
|
||||
wsize.ws_row = tyn + 1;
|
||||
wsize.ws_col = txn;
|
||||
getttysize(out, &wsize);
|
||||
_getttysize(out, &wsize);
|
||||
tyn = wsize.ws_row - 1;
|
||||
txn = wsize.ws_col;
|
||||
right = left + txn;
|
||||
|
@ -761,11 +739,11 @@ static void OnExit(void) {
|
|||
ioctl(out, TCSETS, &oldterm);
|
||||
}
|
||||
|
||||
static void OnSigInt(int sig, struct siginfo *sa, void *uc) {
|
||||
static void OnSigInt(int sig) {
|
||||
action |= INTERRUPTED;
|
||||
}
|
||||
|
||||
static void OnSigWinch(int sig, struct siginfo *sa, void *uc) {
|
||||
static void OnSigWinch(int sig) {
|
||||
action |= RESIZED;
|
||||
}
|
||||
|
||||
|
@ -1128,8 +1106,8 @@ static void Tui(void) {
|
|||
EnableRaw();
|
||||
EnableMouse();
|
||||
atexit(OnExit);
|
||||
sigaction(SIGINT, &(struct sigaction){.sa_sigaction = OnSigInt}, NULL);
|
||||
sigaction(SIGWINCH, &(struct sigaction){.sa_sigaction = OnSigWinch}, NULL);
|
||||
sigaction(SIGINT, &(struct sigaction){.sa_handler = OnSigInt}, 0);
|
||||
sigaction(SIGWINCH, &(struct sigaction){.sa_handler = OnSigWinch}, 0);
|
||||
do {
|
||||
if (action & RESIZED) {
|
||||
GetTtySize();
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/madv.h"
|
||||
|
@ -241,7 +241,7 @@ static void ProcessImageVerbatim(LONG yn, LONG xn,
|
|||
unsigned char img[yn][xn][4]) {
|
||||
CHAR w;
|
||||
void *R, *G, *B, *A;
|
||||
w = roundup2log(MAX(yn, xn));
|
||||
w = _roundup2log(MAX(yn, xn));
|
||||
R = xvalloc((1u << w) * (1u << w));
|
||||
G = xvalloc((1u << w) * (1u << w));
|
||||
B = xvalloc((1u << w) * (1u << w));
|
||||
|
@ -256,7 +256,7 @@ static void ProcessImageVerbatim(LONG yn, LONG xn,
|
|||
static void ProcessImageDouble(LONG yn, LONG xn, unsigned char img[yn][xn][4]) {
|
||||
CHAR w;
|
||||
void *t, *R, *G, *B, *A;
|
||||
w = roundup2log(MAX(yn, xn)) + 1;
|
||||
w = _roundup2log(MAX(yn, xn)) + 1;
|
||||
t = xvalloc((1u << w) * (1u << w));
|
||||
R = xvalloc((1u << w) * (1u << w));
|
||||
G = xvalloc((1u << w) * (1u << w));
|
||||
|
@ -277,7 +277,7 @@ static void ProcessImageDouble(LONG yn, LONG xn, unsigned char img[yn][xn][4]) {
|
|||
static void ProcessImageHalf(LONG yn, LONG xn, unsigned char img[yn][xn][4]) {
|
||||
CHAR w;
|
||||
void *R, *G, *B, *A;
|
||||
w = roundup2log(MAX(yn, xn));
|
||||
w = _roundup2log(MAX(yn, xn));
|
||||
R = xvalloc((1u << w) * (1u << w));
|
||||
G = xvalloc((1u << w) * (1u << w));
|
||||
B = xvalloc((1u << w) * (1u << w));
|
||||
|
@ -300,7 +300,7 @@ static void ProcessImageHalf(LONG yn, LONG xn, unsigned char img[yn][xn][4]) {
|
|||
static void ProcessImageHalfY(LONG yn, LONG xn, unsigned char img[yn][xn][4]) {
|
||||
CHAR w;
|
||||
void *R, *G, *B, *A;
|
||||
w = roundup2log(MAX(yn, xn));
|
||||
w = _roundup2log(MAX(yn, xn));
|
||||
R = xvalloc((1u << w) * (1u << w));
|
||||
G = xvalloc((1u << w) * (1u << w));
|
||||
B = xvalloc((1u << w) * (1u << w));
|
||||
|
@ -322,7 +322,7 @@ static void ProcessImageHalfLanczos(LONG yn, LONG xn,
|
|||
void *t, *R, *G, *B, *A;
|
||||
t = xvalloc((yn >> 1) * (xn >> 1) * 4);
|
||||
lanczos1b(yn >> 1, xn >> 1, t, yn, xn, &img[0][0][0]);
|
||||
w = roundup2log(MAX(yn >> 1, xn >> 1));
|
||||
w = _roundup2log(MAX(yn >> 1, xn >> 1));
|
||||
R = xvalloc((1u << w) * (1u << w));
|
||||
G = xvalloc((1u << w) * (1u << w));
|
||||
B = xvalloc((1u << w) * (1u << w));
|
||||
|
@ -338,7 +338,7 @@ static void ProcessImageHalfLanczos(LONG yn, LONG xn,
|
|||
static void ProcessImageWash(LONG yn, LONG xn, unsigned char img[yn][xn][4]) {
|
||||
long w;
|
||||
void *R, *G, *B, *A, *t;
|
||||
w = roundup2log(MAX(yn, xn)) + 1;
|
||||
w = _roundup2log(MAX(yn, xn)) + 1;
|
||||
t = xvalloc((1u << w) * (1u << w));
|
||||
R = xvalloc((1u << w) * (1u << w));
|
||||
G = xvalloc((1u << w) * (1u << w));
|
||||
|
@ -443,7 +443,7 @@ static void ProcessImageMagikarp(LONG syn, LONG sxn,
|
|||
LONG dyn, dxn;
|
||||
dyn = syn >> 1;
|
||||
dxn = sxn >> 1;
|
||||
sw = roundup2log(MAX(syn, sxn));
|
||||
sw = _roundup2log(MAX(syn, sxn));
|
||||
ProcessImageMagikarpImpl(sw, gc(xvalloc((1u << sw) * (1u << sw) * 5)), syn,
|
||||
sxn, img, dyn, dxn);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "net/http/http.h"
|
||||
#include "net/http/ip.h"
|
||||
|
|
|
@ -24,7 +24,7 @@ struct WinArgs {
|
|||
char envblock[ARG_MAX / 2];
|
||||
};
|
||||
|
||||
//#define INCREMENT roundup2pow(kAutomapSize/16)
|
||||
//#define INCREMENT _roundup2pow(kAutomapSize/16)
|
||||
#define INCREMENT (64L*1024*1024*1024)
|
||||
|
||||
uint64_t last;
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/scale/cdecimate2xuint8x8.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/hilbert.h"
|
||||
#include "libc/intrin/morton.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/ioctl.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
|
@ -32,15 +28,20 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/bsf.h"
|
||||
#include "libc/intrin/hilbert.h"
|
||||
#include "libc/intrin/morton.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/intrin/tpenc.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/bsf.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/pollfd.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
#include "libc/str/unicode.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
|
@ -50,7 +51,6 @@
|
|||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/consts/termios.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/str/unicode.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
|
||||
#define USAGE \
|
||||
|
@ -191,11 +191,11 @@ static void GetTtySize(void) {
|
|||
struct winsize wsize;
|
||||
wsize.ws_row = tyn + 1;
|
||||
wsize.ws_col = txn;
|
||||
getttysize(out, &wsize);
|
||||
_getttysize(out, &wsize);
|
||||
tyn = MAX(2, wsize.ws_row) - 1;
|
||||
txn = MAX(17, wsize.ws_col) - 16;
|
||||
tyn = rounddown2pow(tyn);
|
||||
txn = rounddown2pow(txn);
|
||||
tyn = _rounddown2pow(tyn);
|
||||
txn = _rounddown2pow(txn);
|
||||
tyn = MIN(tyn, txn);
|
||||
}
|
||||
|
||||
|
@ -747,7 +747,7 @@ static void Render(void) {
|
|||
p = FormatInt64(p, fg);
|
||||
*p++ = 'm';
|
||||
}
|
||||
w = tpenc(kCp437[c]);
|
||||
w = _tpenc(kCp437[c]);
|
||||
do {
|
||||
*p++ = w & 0xff;
|
||||
w >>= 8;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xgetline.h"
|
||||
|
||||
#define DLL "iphlpapi"
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/dos2errno.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/str/errfun.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
// note: these are supplementary errno magnum mappings
|
||||
|
@ -28,11 +27,11 @@
|
|||
int main(int argc, char *argv[]) {
|
||||
int i;
|
||||
for (i = 0; kDos2Errno[i].doscode; ++i) {
|
||||
kprintf(
|
||||
"dos error %10hu maps to rva %10d errno %10d which is %s%n",
|
||||
kDos2Errno[i].doscode, kDos2Errno[i].systemv,
|
||||
*(const int *)((intptr_t)kDos2Errno + kDos2Errno[i].systemv),
|
||||
strerrno(*(const int *)((intptr_t)kDos2Errno + kDos2Errno[i].systemv)));
|
||||
kprintf("dos error %10hu maps to rva %10d errno %10d which is %s%n",
|
||||
kDos2Errno[i].doscode, kDos2Errno[i].systemv,
|
||||
*(const int *)((intptr_t)kDos2Errno + kDos2Errno[i].systemv),
|
||||
_strerrno(
|
||||
*(const int *)((intptr_t)kDos2Errno + kDos2Errno[i].systemv)));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/mem.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/ex.h"
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/struct/winsize.h"
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/calls/ucontext.h"
|
||||
#include "libc/dns/dns.h"
|
||||
|
@ -55,8 +56,7 @@
|
|||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/nt/console.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/runtime/buffer.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/runtime/buffer.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/pollfd.h"
|
||||
|
@ -91,7 +91,7 @@
|
|||
#include "libc/sysv/consts/w.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xsigaction.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "third_party/stb/stb_image_resize.h"
|
||||
#include "tool/viz/lib/graphic.h"
|
||||
|
@ -428,7 +428,7 @@ static void DimensionDisplay(void) {
|
|||
wsize_.ws_row = 25;
|
||||
wsize_.ws_col = 80;
|
||||
wsize_ = (struct winsize){.ws_row = 40, .ws_col = 80};
|
||||
if (getttysize(outfd_, &wsize_) == -1) getttysize(0, &wsize_);
|
||||
if (_getttysize(outfd_, &wsize_) == -1) _getttysize(0, &wsize_);
|
||||
dh_ = wsize_.ws_row * 2;
|
||||
dw_ = wsize_.ws_col * 2;
|
||||
}
|
||||
|
@ -1397,8 +1397,8 @@ static void OnExit(void) {
|
|||
YCbCrFree(&ycbcr_);
|
||||
RestoreTty();
|
||||
ttyidentclear(&ti_);
|
||||
close_s(&infd_);
|
||||
close_s(&outfd_);
|
||||
close(infd_), infd_ = -1;
|
||||
close(outfd_), outfd_ = -1;
|
||||
bfree(&graphic_[0].b);
|
||||
bfree(&graphic_[1].b);
|
||||
bfree(&vtframe_[0].b);
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
@ -26,7 +26,7 @@
|
|||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xsigaction.h"
|
||||
|
||||
/**
|
||||
* @fileoverview tail -f with lower poll rate
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/unicode.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
|
||||
int a, b, w, i;
|
||||
char name[512];
|
||||
|
@ -65,7 +65,7 @@ void DisplayUnicodeBlock(void) {
|
|||
printf("\n\n%-60s%20s\n"
|
||||
"──────────────────────────────────────────────"
|
||||
"──────────────────────────────────\n",
|
||||
name, gc(xasprintf("%04x .. %04x", a, b)));
|
||||
name, _gc(xasprintf("%04x .. %04x", a, b)));
|
||||
w = 0;
|
||||
for (i = a; i <= b; ++i) {
|
||||
DisplayUnicodeCharacter();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/elf/scalar.h"
|
||||
#include "libc/elf/struct/ehdr.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue