Get Cosmopolitan into releasable state

A new rollup tool now exists for flattening out the headers in a way
that works better for our purposes than cpp. A lot of the API clutter
has been removed. APIs that aren't a sure thing in terms of general
recommendation are now marked internal.

There's now a smoke test for the amalgamation archive and gigantic
header file. So we can now guarantee you can use this project on the
easiest difficulty setting without the gigantic repository.

A website is being created, which is currently a work in progress:
https://justine.storage.googleapis.com/cosmopolitan/index.html
This commit is contained in:
Justine Tunney 2020-11-25 08:19:00 -08:00
parent dba7552c1e
commit ea0b5d9d1c
775 changed files with 6864 additions and 3963 deletions

View file

@ -32,13 +32,13 @@
* @see examples and reference material on using the asm() keyword
* - libc/nexgen32e/bsf.h
* - libc/nexgen32e/tzcnt.h
* - libc/nexgen32e/cpuid4.h
* - libc/nexgen32e/tinystrcmp.h
* - libc/nexgen32e/cpuid4.internal.h
* - libc/nexgen32e/tinystrcmp.internal.h
* - https://gist.github.com/jart/fe8d104ef93149b5ba9b72912820282c
*/
int main(int argc, char *argv[]) {
showcrashreports();
asm("int3"); /* cf. die(), perror("msg"), abort(), exit(1), _Exit(1) */
asm("int3"); /* cf. __die(), perror("msg"), abort(), exit(1), _Exit(1) */
return 0;
}

View file

@ -1,63 +0,0 @@
#if 0
/*─────────────────────────────────────────────────────────────────╗
To the extent possible under law, Justine Tunney has waived
all copyright and related or neighboring rights to this file,
as it is written in the following disclaimers:
http://unlicense.org/ │
http://creativecommons.org/publicdomain/zero/1.0/ │
*/
#endif
#include "libc/calls/calls.h"
#include "libc/log/backtrace.h"
#include "libc/log/log.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/symbols.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/fileno.h"
/*
Your executables will try to find the addr2line tool, which is needed
to decrypt gcc debug information, enabling backtraces like this:
0x0000000000403a7a: Hello at examples/backtrace.c:31
0x0000000000403ac3: World at examples/backtrace.c:38
0x0000000000401608: main at examples/backtrace.c:42
0x0000000000401379: _start at libc/crt/crt.S:61
If that doesn't work, then your αcτµαlly pδrταblε εxεcµταblε will use
its own builtin fallback solution:
0000ac2fa7e0 000000403a9b Hello+0x49
0000ac2fa7f0 000000403ac4 World+0x22
0000ac2fa800 000000401609 main+0x7
0000ac2fa810 00000040137a _start+0x63
This is guaranteed to work if the .com.dbg file can be found.
Otherwise it'll print numbers:
0000268a8390 000000403a90 (null)+0x403a8f
0000268a83a0 000000403aef (null)+0x403aee
0000268a83b0 0000004015fe (null)+0x4015fd
0000268a83c0 00000040137a (null)+0x401379
*/
void hello(void) {
gc(malloc(1));
ShowBacktrace(STDOUT_FILENO, NULL);
setenv("ADDR2LINE", "", true);
ShowBacktrace(STDOUT_FILENO, NULL);
}
void world(void) {
gc(malloc(1));
hello();
}
int main(int argc, char *argv[]) {
world();
return 0;
}

View file

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/bits/safemacros.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
@ -31,9 +31,15 @@ class Log {
int *x_;
};
Log::Log() { x_ = new int[64]; }
Log::~Log() { delete x_; }
int *Log::x() { return x_; }
Log::Log() {
x_ = new int[64];
}
Log::~Log() {
delete x_;
}
int *Log::x() {
return x_;
}
class Log g_log;

View file

@ -9,7 +9,7 @@
#endif
#include "libc/calls/calls.h"
#include "libc/log/check.h"
#include "libc/log/color.h"
#include "libc/log/color.internal.h"
#include "libc/log/log.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.h"

View file

@ -12,7 +12,7 @@
#include "dsp/scale/scale.h"
#include "dsp/tty/itoa8.h"
#include "dsp/tty/quant.h"
#include "libc/alg/arraylist2.h"
#include "libc/alg/arraylist2.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/ioctl.h"
#include "libc/calls/struct/stat.h"

View file

@ -13,7 +13,7 @@
#include "libc/conv/conv.h"
#include "libc/limits.h"
#include "libc/log/check.h"
#include "libc/log/color.h"
#include "libc/log/color.internal.h"
#include "libc/log/log.h"
#include "libc/math.h"
#include "libc/runtime/runtime.h"

View file

@ -7,7 +7,7 @@
http://creativecommons.org/publicdomain/zero/1.0/ │
*/
#endif
#include "libc/nt/enum/messageboxtype.h"
#include "libc/nt/enum/mb.h"
#include "libc/nt/messagebox.h"
int main(int argc, char *argv[]) {

View file

@ -8,7 +8,8 @@
*/
#endif
#include "libc/alg/alg.h"
#include "libc/alg/arraylist.h"
#include "libc/alg/arraylist.internal.h"
#include "libc/alg/critbit0.h"
#include "libc/bits/bits.h"
#include "libc/calls/calls.h"
#include "libc/conv/conv.h"
@ -18,7 +19,7 @@
#include "libc/mem/mem.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/str/tpdecode.h"
#include "libc/str/tpdecode.internal.h"
#include "libc/sysv/consts/fileno.h"
#include "libc/x/x.h"

View file

@ -59,7 +59,7 @@ Contact: antirez@gmail.com\"\n\
#define _GNU_SOURCE
#include "libc/alg/alg.h"
#include "libc/alg/arraylist2.h"
#include "libc/alg/arraylist2.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/termios.h"
#include "libc/calls/weirdtypes.h"

View file

@ -8,8 +8,8 @@
*/
#endif
#include "libc/alg/alg.h"
#include "libc/alg/arraylist2.h"
#include "libc/bits/safemacros.h"
#include "libc/alg/arraylist2.internal.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/dirent.h"
#include "libc/calls/struct/stat.h"

View file

@ -10,10 +10,10 @@
#include "dsp/tty/itoa8.h"
#include "dsp/tty/quant.h"
#include "dsp/tty/tty.h"
#include "libc/alg/arraylist2.h"
#include "libc/alg/arraylist2.internal.h"
#include "libc/assert.h"
#include "libc/bits/bits.h"
#include "libc/bits/safemacros.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/hefty/spawn.h"
#include "libc/calls/struct/itimerval.h"

View file

@ -8,7 +8,7 @@
*/
#endif
#include "libc/bits/bits.h"
#include "libc/bits/safemacros.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/dce.h"
#include "libc/stdio/stdio.h"

View file

@ -7,7 +7,7 @@
http://creativecommons.org/publicdomain/zero/1.0/ │
*/
#endif
#include "libc/bits/progn.h"
#include "libc/bits/progn.internal.h"
#include "libc/log/log.h"
#include "libc/macros.h"
#include "libc/runtime/runtime.h"

View file

@ -1,36 +0,0 @@
#if 0
/*─────────────────────────────────────────────────────────────────╗
To the extent possible under law, Justine Tunney has waived
all copyright and related or neighboring rights to this file,
as it is written in the following disclaimers:
http://unlicense.org/ │
http://creativecommons.org/publicdomain/zero/1.0/ │
*/
#endif
#include "libc/calls/calls.h"
#include "libc/elf/elf.h"
#include "libc/log/backtrace.h"
#include "libc/log/log.h"
#include "libc/runtime/symbols.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/fileno.h"
int main(int argc, char *argv[]) {
int rc = 0;
char *filename;
struct SymbolTable *tab = NULL;
if ((filename = FindDebugBinary()) != NULL &&
(tab = OpenSymbolTable(filename))) {
for (unsigned i = 0; i < tab->count; ++i) {
printf("%p %s\n", tab->addr_base + tab->symbols[i].addr_rva,
GetElfString(tab->elf, tab->elfsize, tab->name_base,
tab->symbols[i].name_rva));
}
} else {
perror("printmysymbols");
ShowBacktrace(STDERR_FILENO, NULL);
rc = 1;
}
CloseSymbolTable(&tab);
return rc;
}