mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-27 04:50:28 +00:00
Add chibicc
This program popped up on Hacker News recently. It's the only modern compiler I've ever seen that doesn't have dependencies and is easily modified. So I added all of the missing GNU extensions I like to use which means it might be possible soon to build on non-Linux and have third party not vendor gcc binaries.
This commit is contained in:
parent
e44a0cf6f8
commit
8da931a7f6
298 changed files with 19493 additions and 11950 deletions
|
@ -35,7 +35,7 @@
|
|||
int ispipe_;
|
||||
int newlines_;
|
||||
|
||||
noreturn void ShowUsage(FILE *f, int rc) {
|
||||
wontreturn void ShowUsage(FILE *f, int rc) {
|
||||
fputs(program_invocation_name, f);
|
||||
fputs(": [-p] [-n] [FILE...]\n", f);
|
||||
exit(rc);
|
||||
|
|
|
@ -398,8 +398,8 @@ static struct Cell derasterize(unsigned char block[CN][YS * XS]) {
|
|||
static char *RenderImage(char *v, unsigned yn, unsigned xn,
|
||||
const unsigned char srgb[yn][YS][xn][XS][CN]) {
|
||||
unsigned y, x, i, j, k;
|
||||
unsigned char copy[YS][XS][CN] aligned(32);
|
||||
unsigned char block[CN][YS * XS] aligned(32);
|
||||
unsigned char copy[YS][XS][CN] forcealign(32);
|
||||
unsigned char block[CN][YS * XS] forcealign(32);
|
||||
DCHECK_ALIGNED(32, v);
|
||||
DCHECK_ALIGNED(32, srgb);
|
||||
for (y = 0; y < yn; ++y) {
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
|
||||
void double2int(const char *s) {
|
||||
double b64;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
int column_;
|
||||
|
||||
noreturn void usage(int rc, FILE *f) {
|
||||
wontreturn void usage(int rc, FILE *f) {
|
||||
fputs("Usage: ", f);
|
||||
fputs(program_invocation_name, f);
|
||||
fputs(" [-w COLS] [FILE...]\n", f);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "libc/sysv/consts/ex.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "tool/viz/lib/formatstringtable.h"
|
||||
|
||||
|
@ -59,7 +59,7 @@ struct Range r1_ = {LONG_MIN, LONG_MAX};
|
|||
struct Range r2_ = {0, 1};
|
||||
StringTableFormatter *formatter_ = FormatStringTableAsCode;
|
||||
|
||||
static noreturn void PrintUsage(int rc, FILE *f) {
|
||||
static wontreturn void PrintUsage(int rc, FILE *f) {
|
||||
fprintf(f, "Usage: %s%s", program_invocation_name, "\
|
||||
[FLAGS] [FILE]\n\
|
||||
\n\
|
||||
|
@ -95,8 +95,8 @@ static bool StringEquals(const char *a, const char *b) {
|
|||
return strcasecmp(a, b) == 0;
|
||||
}
|
||||
|
||||
static noreturn void ShowInvalidArg(const char *name, const char *s,
|
||||
const char *type) {
|
||||
static wontreturn void ShowInvalidArg(const char *name, const char *s,
|
||||
const char *type) {
|
||||
fprintf(stderr, "error: invalid %s %s: %s\n", type, name, s);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
static FILE *fi_, *fo_;
|
||||
static char *inpath_, *outpath_;
|
||||
|
||||
noreturn void usage(int rc, FILE *f) {
|
||||
wontreturn void usage(int rc, FILE *f) {
|
||||
fprintf(f, "%s%s%s\n", "Usage: ", program_invocation_name,
|
||||
" [-o FILE] [FILE...]\n");
|
||||
exit(rc);
|
||||
|
|
|
@ -19,10 +19,12 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/conv/conv.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "tool/viz/lib/formatstringtable.h"
|
||||
#include "tool/viz/lib/stringbuilder.h"
|
||||
|
||||
|
@ -34,7 +36,9 @@ void *ConvertMatrixToStringTable(long yn, long xn, char *T[yn][xn],
|
|||
assert(yn && xn && !T[0][0]);
|
||||
for (y = 0; y < yn; ++y) {
|
||||
for (x = 0; x < xn; ++x) {
|
||||
T[y][x] = xdtoa(RoundDecimalPlaces(M[y][x], digs, rounder));
|
||||
T[y][x] = xmalloc(40);
|
||||
T[y][x][0] = '\0';
|
||||
g_dfmt_p(T[y][x], &M[y][x], digs, 40, 0);
|
||||
}
|
||||
}
|
||||
return T;
|
||||
|
|
|
@ -48,7 +48,7 @@ TOOL_VIZ_LIB_A_DIRECTDEPS = \
|
|||
LIBC_STR \
|
||||
LIBC_X \
|
||||
THIRD_PARTY_AVIR \
|
||||
THIRD_PARTY_DTOA \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_DLMALLOC
|
||||
|
||||
TOOL_VIZ_LIB_A_DEPS := \
|
||||
|
|
|
@ -668,7 +668,7 @@ static int Write(const char *s) {
|
|||
return write(out, s, strlen(s));
|
||||
}
|
||||
|
||||
static noreturn void PrintUsage(int rc) {
|
||||
static wontreturn void PrintUsage(int rc) {
|
||||
Write("SYNOPSIS\n\n ");
|
||||
Write(program_invocation_name);
|
||||
Write(USAGE);
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "libc/x/x.h"
|
||||
#include "third_party/avir/lanczos1b.h"
|
||||
#include "third_party/avir/lanczos1f.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "third_party/stb/stb_image.h"
|
||||
#include "tool/viz/lib/bilinearscale.h"
|
||||
|
|
|
@ -241,7 +241,7 @@ static void Setup(void) {
|
|||
sigaction(SIGWINCH, &(struct sigaction){.sa_sigaction = OnSigWinch}, NULL);
|
||||
}
|
||||
|
||||
static noreturn void FailPath(const char *s, int rc) {
|
||||
static wontreturn void FailPath(const char *s, int rc) {
|
||||
Write("error: ");
|
||||
Write(s);
|
||||
Write(": ");
|
||||
|
@ -861,7 +861,7 @@ static void MemZoom(void) {
|
|||
} while (!(action & INTERRUPTED));
|
||||
}
|
||||
|
||||
static noreturn void PrintUsage(int rc) {
|
||||
static wontreturn void PrintUsage(int rc) {
|
||||
Write("SYNOPSIS\n\n ");
|
||||
Write(program_invocation_name);
|
||||
Write(USAGE);
|
||||
|
|
|
@ -69,7 +69,7 @@ static struct Flags {
|
|||
enum TtyQuantizationAlgorithm quant;
|
||||
} g_flags;
|
||||
|
||||
static noreturn void PrintUsage(int rc, FILE *f) {
|
||||
static wontreturn void PrintUsage(int rc, FILE *f) {
|
||||
fprintf(f, "Usage: %s%s", program_invocation_name, "\
|
||||
[FLAGS] [PATH]\n\
|
||||
\n\
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
#include "third_party/dtoa/dtoa.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i;
|
||||
|
|
|
@ -298,9 +298,9 @@ static struct Graphic graphic_[2], *g1_, *g2_;
|
|||
static bool yes_, stats_, dither_, ttymode_, istango_;
|
||||
static long double deadline_, dura_, skip_, starttime_;
|
||||
static long double decode_start_, f1_start_, f2_start_;
|
||||
static bool fullclear_, historyclear_, tuned_, yonly_, gotvideo_;
|
||||
static int16_t pcm_[PLM_AUDIO_SAMPLES_PER_FRAME * 2 / 8][8];
|
||||
static int16_t pcmscale_[PLM_AUDIO_SAMPLES_PER_FRAME * 2 / 8][8];
|
||||
static int16_t pcm_[PLM_AUDIO_SAMPLES_PER_FRAME * 2 / 8][8] aligned(PAGESIZE);
|
||||
static bool fullclear_, historyclear_, tuned_, yonly_, gotvideo_;
|
||||
static int homerow_, lastrow_, playfd_, infd_, outfd_, nullfd_, speakerfails_;
|
||||
static char host_[DNS_NAME_MAX + 1], port_[8], path_[PATH_MAX], status_[7][200],
|
||||
logpath_[PATH_MAX], fifopath_[PATH_MAX], chansstr_[16], sratestr_[16];
|
||||
|
|
|
@ -54,7 +54,7 @@ static size_t linecap_;
|
|||
static char *outpath_, *line_;
|
||||
static bool rawmode_, background_, emphasis_, cleanup_;
|
||||
|
||||
noreturn void usage(int rc, FILE *f) {
|
||||
wontreturn void usage(int rc, FILE *f) {
|
||||
fprintf(f, kUsage, program_invocation_name);
|
||||
exit(rc);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ static struct Lines lines_;
|
|||
static size_t mincol_, col_, maxcol_, linecap_;
|
||||
static char *inpath_, *outpath_, *delim_, *line_;
|
||||
|
||||
noreturn void usage(int rc, FILE *f) {
|
||||
wontreturn void usage(int rc, FILE *f) {
|
||||
fprintf(f, "%s%s%s\n", "Usage: ", program_invocation_name,
|
||||
" [-c] [-m MINCOL] [-M MAXCOL] [-F DELIM] [-o FILE] [FILE...]\n"
|
||||
"\n"
|
||||
|
|
|
@ -54,7 +54,7 @@ TOOL_VIZ_DIRECTDEPS = \
|
|||
THIRD_PARTY_GETOPT \
|
||||
THIRD_PARTY_AVIR \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
THIRD_PARTY_DTOA \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_STB \
|
||||
THIRD_PARTY_XED \
|
||||
THIRD_PARTY_ZLIB
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue