Improve documentation

The Cosmo API documentation page is pretty good now
https://justine.lol/cosmopolitan/documentation.html
This commit is contained in:
Justine Tunney 2020-12-27 07:02:35 -08:00
parent 13437dd19b
commit 1bc3a25505
367 changed files with 2542 additions and 26178 deletions

View file

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/bits/safemacros.h"
#include "libc/bits/weaken.h"
#include "libc/calls/calls.h"
#include "libc/fmt/itoa.h"
@ -44,13 +44,13 @@ STATIC_YOINK("_init_asan");
* so it can emit fast code, that checks the validity of each memory op
* with byte granularity, by probing shadow memory.
*
* AddressSanitizer dedicates one-eighth of the virtual address space
* - AddressSanitizer dedicates one-eighth of the virtual address space
* to its shadow memory and uses a direct mapping with a scale and
* offset to translate an application address to its corresponding
* shadow address. Given the application memory address Addr, the
* address of the shadow byte is computed as (Addr>>3)+Offset."
*
* We use the following encoding for each shadow byte: 0 means that
* - We use the following encoding for each shadow byte: 0 means that
* all 8 bytes of the corresponding application memory region are
* addressable; k (1 k 7) means that the first k bytes are
* addressible; any negative value indicates that the entire 8-byte
@ -60,11 +60,11 @@ STATIC_YOINK("_init_asan");
*
* Here's what the generated code looks like for 64-bit reads:
*
* movq %addr,%tmp
* shrq $3,%tmp
* cmpb $0,0x7fff8000(%tmp)
* jnz abort
* movq (%addr),%dst
* movq %addr,%tmp
* shrq $3,%tmp
* cmpb $0,0x7fff8000(%tmp)
* jnz abort
* movq (%addr),%dst
*/
#define HOOK(HOOK, IMPL) \
@ -142,7 +142,6 @@ static const char *__asan_describe_access_poison(int c) {
case kAsanUnscoped:
return "unscoped";
default:
DebugBreak();
return "poisoned";
}
}
@ -399,9 +398,8 @@ void __asan_map_shadow(void *p, size_t n) {
b = ROUNDUP(SHADOW(ROUNDUP((uintptr_t)p + n, 8)), 1 << 16) >> 16;
for (; a < b; ++a) {
if (!__asan_is_mapped(a)) {
sm = DirectMap((void *)((uintptr_t)a << 16), 1 << 16,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
sm = __mmap((void *)((uintptr_t)a << 16), 1 << 16, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
if (sm.addr == MAP_FAILED ||
TrackMemoryInterval(&_mmi, a, a, sm.maphandle, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED) == -1) {
@ -412,7 +410,8 @@ void __asan_map_shadow(void *p, size_t n) {
}
static char *__asan_get_stack_base(void) {
register uintptr_t rsp asm("rsp");
uintptr_t rsp;
asm("mov\t%%rsp,%0" : "=r"(rsp));
return (char *)ROUNDDOWN(ROUNDDOWN(rsp, STACKSIZE), FRAMESIZE);
}

View file

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/bits/safemacros.h"
#include "libc/calls/calls.h"
#include "libc/calls/hefty/spawn.h"
#include "libc/fmt/fmt.h"

View file

@ -19,7 +19,7 @@
*/
#include "libc/alg/alg.h"
#include "libc/alg/bisectcarleft.internal.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/bits/safemacros.h"
#include "libc/bits/weaken.h"
#include "libc/calls/calls.h"
#include "libc/calls/hefty/spawn.h"

View file

@ -41,15 +41,15 @@
* It's a common antipattern to check isatty(STDERR_FILENO), since that
* usually makes colors harder to get than they are to remove:
*
* sed 's/\x1b\[[;[:digit:]]*m//g' <color.txt >uncolor.txt
* sed 's/\x1b\[[;[:digit:]]*m//g' <color.txt >uncolor.txt
*
* Ideally, all software should be updated to understand color, since
* it's been formally standardized nearly as long as ASCII. Even old
* MS-DOS supports it (but Windows didn't until Windows 10) yet even
* tools like less may need wrapper scripts, e.g.:
*
* #!/bin/sh
* LESSCHARSET=UTF-8 exec /usr/bin/less -RS "$@"
* #!/bin/sh
* LESSCHARSET=UTF-8 exec /usr/bin/less -RS "$@"
*
* It's that easy fam.
*/

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/bits/bits.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/bits/safemacros.h"
#include "libc/calls/calls.h"
#include "libc/dce.h"
#include "libc/errno.h"

View file

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/bits/safemacros.h"
#include "libc/calls/calls.h"
#include "libc/log/log.h"
#include "libc/mem/mem.h"

View file

@ -26,7 +26,9 @@
#include "libc/sysv/consts/fileno.h"
/**
* Aborts process after printing details on its current state.
* Aborts process after printing a backtrace.
*
* If a debugger is present then this will trigger a breakpoint.
*/
relegated wontreturn void __die(void) {
static bool once;

View file

@ -44,12 +44,12 @@ int attachdebugger(intptr_t);
({ \
int64_t WaAx; \
if (!IsWindows()) { \
register void *Reg10 asm("r10") = (OPT_OUT_RUSAGE); \
asm volatile("syscall" \
asm volatile("mov\t%5,%%r10\n\t" \
"syscall" \
: "=a"(WaAx) \
: "0"(__NR_wait4), "D"(PID), "S"(OPT_OUT_WSTATUS), \
"d"(OPTIONS), "r"(Reg10) \
: "rcx", "r11", "cc", "memory"); \
"d"(OPTIONS), "g"(OPT_OUT_RUSAGE) \
: "rcx", "r10", "r11", "cc", "memory"); \
} else { \
WaAx = wait4$nt(PID, OPT_OUT_WSTATUS, OPTIONS, OPT_OUT_RUSAGE); \
} \

View file

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/bits/safemacros.h"
#include "libc/calls/calls.h"
#include "libc/calls/hefty/spawn.h"
#include "libc/fmt/fmt.h"

View file

@ -19,4 +19,4 @@
*/
#include "libc/log/gdb.h"
volatile int g_gdbsync;
volatile int g_gdbsync hidden;

View file

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/bits/safemacros.h"
#include "libc/calls/calls.h"
#include "libc/calls/termios.h"
#include "libc/fmt/conv.h"

View file

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/bits/safemacros.h"
#include "libc/log/log.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"

View file

@ -64,8 +64,8 @@ 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];
struct sigaction g_oldcrashacts[8];
hidden int kCrashSigs[8];
hidden struct sigaction g_oldcrashacts[8];
relegated static const char *TinyStrSignal(int sig) {
size_t i;