mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 19:58:30 +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
|
@ -147,7 +147,7 @@ static const char *__asan_describe_access_poison(int c) {
|
|||
}
|
||||
}
|
||||
|
||||
static noreturn void __asan_die(const char *msg, size_t size) {
|
||||
static wontreturn void __asan_die(const char *msg, size_t size) {
|
||||
write(STDERR_FILENO, msg, size);
|
||||
__die();
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ static char *__asan_report_start(char *p) {
|
|||
return stpcpy(p, ": ");
|
||||
}
|
||||
|
||||
static noreturn void __asan_report_deallocate_fault(void *addr, int c) {
|
||||
static wontreturn void __asan_report_deallocate_fault(void *addr, int c) {
|
||||
char *p, ibuf[21], buf[256];
|
||||
p = __asan_report_start(buf);
|
||||
p = stpcpy(p, __asan_dscribe_free_poison(c));
|
||||
|
@ -175,8 +175,8 @@ static noreturn void __asan_report_deallocate_fault(void *addr, int c) {
|
|||
__asan_die(buf, p - buf);
|
||||
}
|
||||
|
||||
static noreturn void __asan_report_memory_fault(uint8_t *addr, int size,
|
||||
const char *kind) {
|
||||
static wontreturn void __asan_report_memory_fault(uint8_t *addr, int size,
|
||||
const char *kind) {
|
||||
char *p, ibuf[21], buf[256];
|
||||
p = __asan_report_start(buf);
|
||||
p = stpcpy(p, __asan_describe_access_poison(*(char *)SHADOW((intptr_t)addr)));
|
||||
|
|
|
@ -8,23 +8,23 @@ COSMOPOLITAN_C_START_
|
|||
│ cosmopolitan § logging » berkeley logger ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
void err(int, const char *, ...) printfesque(2) noreturn;
|
||||
void errx(int, const char *, ...) printfesque(2) noreturn;
|
||||
void verr(int, const char *, va_list) paramsnonnull((3)) noreturn;
|
||||
void verrx(int, const char *, va_list) paramsnonnull((3)) noreturn;
|
||||
void err(int, const char *, ...) printfesque(2) wontreturn;
|
||||
void errx(int, const char *, ...) printfesque(2) wontreturn;
|
||||
void verr(int, const char *, va_list) paramsnonnull((3)) wontreturn;
|
||||
void verrx(int, const char *, va_list) paramsnonnull((3)) wontreturn;
|
||||
void vwarn(const char *, va_list) paramsnonnull((2));
|
||||
void vwarnx(const char *, va_list) paramsnonnull((2));
|
||||
void warn(const char *, ...) printfesque(1);
|
||||
void warnx(const char *, ...) printfesque(1);
|
||||
|
||||
#define err(EVAL, FMT, ...) (err)(EVAL, PFLINK(FMT), ##__VA_ARGS__)
|
||||
#define err(EVAL, FMT, ...) (err)(EVAL, PFLINK(FMT), ##__VA_ARGS__)
|
||||
#define errx(EVAL, FMT, ...) (errx)(EVAL, PFLINK(FMT), ##__VA_ARGS__)
|
||||
#define verr(EVAL, FMT, VA) (verr)(EVAL, PFLINK(FMT), VA)
|
||||
#define verr(EVAL, FMT, VA) (verr)(EVAL, PFLINK(FMT), VA)
|
||||
#define verrx(EVAL, FMT, VA) (verrx)(EVAL, PFLINK(FMT), VA)
|
||||
#define vwarn(FMT, VA) (vwarn)(PFLINK(FMT), VA)
|
||||
#define vwarnx(FMT, VA) (vwarnx)(PFLINK(FMT), VA)
|
||||
#define warn(FMT, ...) (warn)(PFLINK(FMT), ##__VA_ARGS__)
|
||||
#define warnx(FMT, ...) (warn)(PFLINK(FMT), ##__VA_ARGS__)
|
||||
#define vwarn(FMT, VA) (vwarn)(PFLINK(FMT), VA)
|
||||
#define vwarnx(FMT, VA) (vwarnx)(PFLINK(FMT), VA)
|
||||
#define warn(FMT, ...) (warn)(PFLINK(FMT), ##__VA_ARGS__)
|
||||
#define warnx(FMT, ...) (warn)(PFLINK(FMT), ##__VA_ARGS__)
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -84,15 +84,15 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
void __check_fail(const char *, const char *, uint64_t, const char *, uint64_t,
|
||||
const char *, const char *, int, const char *,
|
||||
...) relegated noreturn;
|
||||
...) relegated wontreturn;
|
||||
|
||||
void __check_fail_eq(uint64_t, uint64_t) relegated noreturn;
|
||||
void __check_fail_ne(uint64_t, uint64_t) relegated noreturn;
|
||||
void __check_fail_le(uint64_t, uint64_t) relegated noreturn;
|
||||
void __check_fail_lt(uint64_t, uint64_t) relegated noreturn;
|
||||
void __check_fail_ge(uint64_t, uint64_t) relegated noreturn;
|
||||
void __check_fail_gt(uint64_t, uint64_t) relegated noreturn;
|
||||
void __check_fail_aligned(unsigned, uint64_t) relegated noreturn;
|
||||
void __check_fail_eq(uint64_t, uint64_t) relegated wontreturn;
|
||||
void __check_fail_ne(uint64_t, uint64_t) relegated wontreturn;
|
||||
void __check_fail_le(uint64_t, uint64_t) relegated wontreturn;
|
||||
void __check_fail_lt(uint64_t, uint64_t) relegated wontreturn;
|
||||
void __check_fail_ge(uint64_t, uint64_t) relegated wontreturn;
|
||||
void __check_fail_gt(uint64_t, uint64_t) relegated wontreturn;
|
||||
void __check_fail_aligned(unsigned, uint64_t) relegated wontreturn;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/**
|
||||
* Aborts process after printing details on its current state.
|
||||
*/
|
||||
relegated noreturn void __die(void) {
|
||||
relegated wontreturn void __die(void) {
|
||||
static bool once;
|
||||
if (!once) {
|
||||
once = true;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/log/bsd.h"
|
||||
|
||||
noreturn void(err)(int eval, const char *fmt, ...) {
|
||||
wontreturn void(err)(int eval, const char *fmt, ...) {
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
(verr)(eval, fmt, va);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/log/bsd.h"
|
||||
|
||||
noreturn void(errx)(int eval, const char *fmt, ...) {
|
||||
wontreturn void(errx)(int eval, const char *fmt, ...) {
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
(verrx)(eval, fmt, va);
|
||||
|
|
|
@ -33,10 +33,10 @@ typedef struct FILE FILE;
|
|||
|
||||
extern FILE *g_logfile;
|
||||
|
||||
void perror(const char *) relegated; /* print the last system error */
|
||||
void __die(void) relegated noreturn; /* print backtrace and abort() */
|
||||
void meminfo(int); /* shows malloc statistics &c. */
|
||||
void memsummary(int); /* light version of same thing */
|
||||
void perror(const char *) relegated; /* print the last system error */
|
||||
void __die(void) relegated wontreturn; /* print backtrace and abort() */
|
||||
void meminfo(int); /* shows malloc statistics &c. */
|
||||
void memsummary(int); /* light version of same thing */
|
||||
uint16_t getttycols(uint16_t);
|
||||
int getttysize(int, struct winsize *) paramsnonnull();
|
||||
bool isterminalinarticulate(void) nosideeffect;
|
||||
|
@ -218,8 +218,8 @@ void fverbosef(ARGS, ...) asm("flogf") ATTR relegated libcesque;
|
|||
void vfverbosef(ARGS, va_list) asm("vflogf") ATTRV relegated libcesque;
|
||||
void fdebugf(ARGS, ...) asm("flogf") ATTR relegated libcesque;
|
||||
void vfdebugf(ARGS, va_list) asm("vflogf") ATTRV relegated libcesque;
|
||||
void ffatalf(ARGS, ...) asm("flogf") ATTR relegated noreturn libcesque;
|
||||
void vffatalf(ARGS, va_list) asm("vflogf") ATTRV relegated noreturn libcesque;
|
||||
void ffatalf(ARGS, ...) asm("flogf") ATTR relegated wontreturn libcesque;
|
||||
void vffatalf(ARGS, va_list) asm("vflogf") ATTRV relegated wontreturn libcesque;
|
||||
#undef ARGS
|
||||
#undef ATTR
|
||||
#undef ATTRV
|
||||
|
|
|
@ -51,17 +51,17 @@ STATIC_YOINK("stoa");
|
|||
|
||||
struct siginfo;
|
||||
|
||||
static const char kGregOrder[17] aligned(1) = {
|
||||
static const char kGregOrder[17] forcealign(1) = {
|
||||
13, 11, 8, 14, 12, 9, 10, 15, 16, 0, 1, 2, 3, 4, 5, 6, 7,
|
||||
};
|
||||
|
||||
static const char kGregNames[17][4] aligned(1) = {
|
||||
static const char kGregNames[17][4] forcealign(1) = {
|
||||
"R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15", "RDI",
|
||||
"RSI", "RBP", "RBX", "RDX", "RAX", "RCX", "RSP", "RIP",
|
||||
};
|
||||
|
||||
static const char kGodHatesFlags[12] aligned(1) = "CVPRAKZSTIDO";
|
||||
static const char kCrashSigNames[8][5] aligned(1) = {
|
||||
static const char kGodHatesFlags[12] forcealign(1) = "CVPRAKZSTIDO";
|
||||
static const char kCrashSigNames[8][5] forcealign(1) = {
|
||||
"QUIT", "FPE", "ILL", "SEGV", "TRAP", "ABRT", "BUS"};
|
||||
|
||||
int kCrashSigs[8];
|
||||
|
|
|
@ -98,13 +98,13 @@ struct UbsanShiftOutOfBoundsData {
|
|||
};
|
||||
|
||||
void __ubsan_abort(const struct UbsanSourceLocation *,
|
||||
const char *) relegated hidden noreturn;
|
||||
const char *) relegated hidden wontreturn;
|
||||
void __ubsan_handle_type_mismatch(struct UbsanTypeMismatchInfo *,
|
||||
uintptr_t) relegated hidden noreturn;
|
||||
uintptr_t) relegated hidden wontreturn;
|
||||
void ___ubsan_handle_type_mismatch_v1(struct UbsanTypeMismatchInfoClang *,
|
||||
uintptr_t) relegated hidden noreturn;
|
||||
uintptr_t) relegated hidden wontreturn;
|
||||
void __ubsan_handle_float_cast_overflow(void *,
|
||||
void *) relegated hidden noreturn;
|
||||
void *) relegated hidden wontreturn;
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_UBSAN_H_ */
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
noreturn void(verr)(int eval, const char *fmt, va_list va) {
|
||||
wontreturn void(verr)(int eval, const char *fmt, va_list va) {
|
||||
fprintf(stderr, "%s: %s%s%s[%m]: ", program_invocation_name, RED2, "ERROR",
|
||||
RESET);
|
||||
if (fmt) (vfprintf)(stderr, fmt, va);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
noreturn void(verrx)(int eval, const char *fmt, va_list va) {
|
||||
wontreturn void(verrx)(int eval, const char *fmt, va_list va) {
|
||||
fprintf(stderr, "%s: %s%s%s: ", program_invocation_name, RED2, "ERROR",
|
||||
RESET);
|
||||
if (fmt) (vfprintf)(stderr, fmt, va);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue