mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-03 09:48:29 +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.
Compared to 6f7d0cb1c3
, some tiny corrections were made in libc/intrin/g_fds.c and libc/zipos/open.c including double semi colons and incorrect indentation for existing vista changes that were manually pulled from this commit previously.
This commit is contained in:
parent
555260d2e5
commit
7b26b42769
959 changed files with 4065 additions and 4868 deletions
|
@ -20,7 +20,7 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#define W sizeof(size_t)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
|
||||
/**
|
||||
* Appends formatted string to buffer, e.g.
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#define W sizeof(size_t)
|
||||
|
@ -55,7 +55,7 @@ ssize_t appendr(char **b, size_t i) {
|
|||
z = appendz((p = *b));
|
||||
if (i != z.i || !p) {
|
||||
n = ROUNDUP(i + 1, 8) + W;
|
||||
if (n > z.n || bsrl(n) < bsrl(z.n)) {
|
||||
if (n > z.n || _bsrl(n) < _bsrl(z.n)) {
|
||||
if ((p = realloc(p, n))) {
|
||||
z.n = malloc_usable_size(p);
|
||||
assert(!(z.n & (W - 1)));
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/stdio/strlist.internal.h"
|
||||
|
||||
int AppendStrList(struct StrList *sl) {
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
|
||||
#define W sizeof(size_t)
|
||||
|
||||
|
@ -59,7 +59,7 @@ ssize_t appendw(char **b, uint64_t w) {
|
|||
char *p, *q;
|
||||
struct appendz z;
|
||||
z = appendz((p = *b));
|
||||
l = w ? (bsrl(w) >> 3) + 1 : 1;
|
||||
l = w ? (_bsrl(w) >> 3) + 1 : 1;
|
||||
n = ROUNDUP(z.i + 8 + 1, 8) + W;
|
||||
if (n > z.n) {
|
||||
if (!z.n) z.n = W * 2;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
|
||||
#define W sizeof(size_t)
|
||||
|
||||
|
|
|
@ -19,14 +19,13 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/nopl.internal.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
|
@ -38,6 +37,7 @@
|
|||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/zip.h"
|
||||
#include "libc/zipos/zipos.internal.h"
|
||||
|
||||
|
@ -264,11 +264,11 @@ DIR *opendir(const char *name) {
|
|||
if (!name || (IsAsan() && !__asan_is_valid(name, 1))) {
|
||||
efault();
|
||||
res = 0;
|
||||
} else if (weaken(__zipos_get) &&
|
||||
weaken(__zipos_parseuri)(name, &zipname) != -1) {
|
||||
if (weaken(__zipos_stat)(&zipname, &st) != -1) {
|
||||
} else if (_weaken(__zipos_get) &&
|
||||
_weaken(__zipos_parseuri)(name, &zipname) != -1) {
|
||||
if (_weaken(__zipos_stat)(&zipname, &st) != -1) {
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
zip = weaken(__zipos_get)();
|
||||
zip = _weaken(__zipos_get)();
|
||||
res = calloc(1, sizeof(DIR));
|
||||
res->iszip = true;
|
||||
res->fd = -1;
|
||||
|
@ -334,7 +334,7 @@ static struct dirent *readdir_impl(DIR *dir) {
|
|||
struct dirent_openbsd *obsd;
|
||||
if (dir->iszip) {
|
||||
ent = 0;
|
||||
zip = weaken(__zipos_get)();
|
||||
zip = _weaken(__zipos_get)();
|
||||
while (!ent && dir->tell < dir->zip.records) {
|
||||
assert(ZIP_CFILE_MAGIC(zip->map + dir->zip.offset) == kZipCfileHdrMagic);
|
||||
s = ZIP_CFILE_NAME(zip->map + dir->zip.offset);
|
||||
|
@ -496,7 +496,7 @@ void rewinddir(DIR *dir) {
|
|||
_lockdir(dir);
|
||||
if (dir->iszip) {
|
||||
dir->tell = 0;
|
||||
dir->zip.offset = GetZipCdirOffset(weaken(__zipos_get)()->cdir);
|
||||
dir->zip.offset = GetZipCdirOffset(_weaken(__zipos_get)()->cdir);
|
||||
} else if (!IsWindows()) {
|
||||
if (!lseek(dir->fd, 0, SEEK_SET)) {
|
||||
dir->buf_pos = dir->buf_end = 0;
|
||||
|
@ -521,9 +521,9 @@ void seekdir(DIR *dir, long off) {
|
|||
long i;
|
||||
struct Zipos *zip;
|
||||
_lockdir(dir);
|
||||
zip = weaken(__zipos_get)();
|
||||
zip = _weaken(__zipos_get)();
|
||||
if (dir->iszip) {
|
||||
dir->zip.offset = GetZipCdirOffset(weaken(__zipos_get)()->cdir);
|
||||
dir->zip.offset = GetZipCdirOffset(_weaken(__zipos_get)()->cdir);
|
||||
for (i = 0; i < off && i < dir->zip.records; ++i) {
|
||||
dir->zip.offset += ZIP_CFILE_HDRSIZE(zip->map + dir->zip.offset);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "libc/fmt/fmt.internal.h"
|
||||
#include "libc/fmt/internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#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/str/str.h"
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ int fclose(FILE *f) {
|
|||
f->state = EOF;
|
||||
if (f->noclose) {
|
||||
f->fd = -1;
|
||||
} else if (close_s(&f->fd) == -1) {
|
||||
} else if (close(f->fd) == -1) {
|
||||
f->state = errno;
|
||||
}
|
||||
if (f->state == EOF) {
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/tpenc.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
|
||||
/**
|
||||
* Writes wide character to stream.
|
||||
|
@ -29,7 +29,7 @@
|
|||
wint_t fputwc_unlocked(wchar_t wc, FILE *f) {
|
||||
uint64_t w;
|
||||
if (wc != -1) {
|
||||
w = tpenc(wc);
|
||||
w = _tpenc(wc);
|
||||
do {
|
||||
if (fputc_unlocked(w, f) == -1) {
|
||||
return -1;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/stdio/strlist.internal.h"
|
||||
|
||||
void FreeStrList(struct StrList *sl) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/stdio/strlist.internal.h"
|
||||
|
||||
int JoinStrList(struct StrList *sl, char **buf, uint64_t sep) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
|
||||
/**
|
||||
* Appends formatted string to buffer w/ kprintf, e.g.
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/append.h"
|
||||
|
||||
#define W sizeof(size_t)
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/stdio/lcg.internal.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
|
|
|
@ -34,6 +34,6 @@
|
|||
ezlea __stderr_buf,cx
|
||||
mov %rcx,0x18(%rax) #→ f.buf
|
||||
movl $BUFSIZ,0x20(%rax) #→ f.size
|
||||
movb $PTHREAD_MUTEX_RECURSIVE,0x38+16(%rax) #→ f.lock.attr
|
||||
movb $PTHREAD_MUTEX_RECURSIVE,0x38+4(%rax) #→ f.lock._type
|
||||
mov %rax,stderr(%rip)
|
||||
.init.end 400,_init_stderr,globl,hidden
|
||||
|
|
|
@ -30,6 +30,6 @@
|
|||
ezlea __stdin_buf,cx
|
||||
mov %rcx,0x18(%rax) #→ f.buf
|
||||
movl $BUFSIZ,0x20(%rax) #→ f.size
|
||||
movb $PTHREAD_MUTEX_RECURSIVE,0x38+16(%rax) #→ f.lock.attr
|
||||
movb $PTHREAD_MUTEX_RECURSIVE,0x38+4(%rax) #→ f.lock._type
|
||||
mov %rax,stdin(%rip)
|
||||
.init.end 400,_init_stdin,globl,hidden
|
||||
|
|
|
@ -32,6 +32,6 @@
|
|||
ezlea __stdout_buf,cx
|
||||
mov %rcx,0x18(%rax) #→ f.buf
|
||||
movl $BUFSIZ,0x20(%rax) #→ f.size
|
||||
movb $PTHREAD_MUTEX_RECURSIVE,0x38+16(%rax) #→ f.lock.attr
|
||||
movb $PTHREAD_MUTEX_RECURSIVE,0x38+4(%rax) #→ f.lock._type
|
||||
mov %rax,stdout(%rip)
|
||||
.init.end 400,_init_stdout,globl,hidden
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/rusage.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/tpenc.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
|
||||
/**
|
||||
* Pushes wide character back to stream.
|
||||
|
@ -29,7 +29,7 @@ wint_t ungetwc_unlocked(wint_t c, FILE *f) {
|
|||
uint64_t w;
|
||||
if (c == -1) return -1;
|
||||
n = 0;
|
||||
w = tpenc(c);
|
||||
w = _tpenc(c);
|
||||
do {
|
||||
b[n++] = w;
|
||||
} while ((w >>= 8));
|
||||
|
|
|
@ -21,7 +21,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"
|
||||
|
||||
#define W sizeof(size_t)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue