mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +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.
This commit is contained in:
parent
b69f3d2488
commit
6f7d0cb1c3
960 changed files with 4072 additions and 4873 deletions
|
@ -28,7 +28,6 @@
|
|||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
@ -125,7 +124,7 @@ hidden int __fmt(void *fn, void *arg, const char *format, va_list va) {
|
|||
int d, w, n, sign, prec, flags, width, lasterr;
|
||||
|
||||
lasterr = errno;
|
||||
out = fn ? fn : (void *)missingno;
|
||||
out = fn ? fn : (void *)_missingno;
|
||||
|
||||
while (*format) {
|
||||
if (*format != '%') {
|
||||
|
@ -347,7 +346,7 @@ hidden int __fmt(void *fn, void *arg, const char *format, va_list va) {
|
|||
break;
|
||||
}
|
||||
case 'm':
|
||||
p = weaken(strerror) ? weaken(strerror)(lasterr) : "?";
|
||||
p = _weaken(strerror) ? _weaken(strerror)(lasterr) : "?";
|
||||
signbit = 0;
|
||||
goto FormatString;
|
||||
case 'r':
|
||||
|
@ -381,15 +380,15 @@ hidden int __fmt(void *fn, void *arg, const char *format, va_list va) {
|
|||
case 'E':
|
||||
case 'a':
|
||||
case 'A':
|
||||
if (!weaken(__fmt_dtoa)) {
|
||||
if (!_weaken(__fmt_dtoa)) {
|
||||
p = "?";
|
||||
prec = 0;
|
||||
flags &= ~(FLAGS_PRECISION | FLAGS_PLUS | FLAGS_SPACE);
|
||||
goto FormatString;
|
||||
}
|
||||
if (weaken(__fmt_dtoa)(out, arg, d, flags, prec, sign, width,
|
||||
longdouble, qchar, signbit, alphabet,
|
||||
va) == -1) {
|
||||
if (_weaken(__fmt_dtoa)(out, arg, d, flags, prec, sign, width,
|
||||
longdouble, qchar, signbit, alphabet,
|
||||
va) == -1) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
|
||||
static inline int PickGoodWidth(unsigned x) {
|
||||
if (x < 16) {
|
||||
|
@ -45,7 +45,7 @@ char *FormatBinary64(char p[hasatleast 67], uint64_t x, char z) {
|
|||
*p++ = '0';
|
||||
*p++ = 'b';
|
||||
}
|
||||
i = PickGoodWidth(bsrl(x));
|
||||
i = PickGoodWidth(_bsrl(x));
|
||||
do {
|
||||
b = 1;
|
||||
b <<= i;
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
|
||||
static inline int PickGoodWidth(unsigned x, char z) {
|
||||
if (z) {
|
||||
|
@ -48,7 +48,7 @@ char *FormatHex64(char p[hasatleast 19], uint64_t x, char z) {
|
|||
*p++ = '0';
|
||||
*p++ = 'x';
|
||||
}
|
||||
i = PickGoodWidth(bsrl(x), z);
|
||||
i = PickGoodWidth(_bsrl(x), z);
|
||||
do {
|
||||
*p++ = "0123456789abcdef"[(x >> (i -= 4)) & 15];
|
||||
} while (i);
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
|
||||
size_t uint64toarray_radix16(uint64_t x, char b[hasatleast 17]) {
|
||||
return uint64toarray_fixed16(x, b, ROUNDUP(x ? bsrl(x) + 1 : 1, 4));
|
||||
return uint64toarray_fixed16(x, b, ROUNDUP(x ? _bsrl(x) + 1 : 1, 4));
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/log.h"
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
#include "libc/fmt/fmt.internal.h"
|
||||
#include "libc/fmt/internal.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/intrin/tpenc.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/strwidth.h"
|
||||
#include "libc/str/thompike.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
#include "libc/str/unicode.h"
|
||||
#include "libc/str/utf16.h"
|
||||
|
||||
|
@ -40,27 +40,27 @@ static int __fmt_stoa_byte(out_f out, void *a, uint64_t c) {
|
|||
|
||||
static int __fmt_stoa_wide(out_f out, void *a, uint64_t w) {
|
||||
char buf[8];
|
||||
if (!isascii(w)) w = tpenc(w);
|
||||
if (!isascii(w)) w = _tpenc(w);
|
||||
WRITE64LE(buf, w);
|
||||
return out(buf, a, w ? (bsr(w) >> 3) + 1 : 1);
|
||||
return out(buf, a, w ? (_bsr(w) >> 3) + 1 : 1);
|
||||
}
|
||||
|
||||
static int __fmt_stoa_bing(out_f out, void *a, uint64_t w) {
|
||||
char buf[8];
|
||||
w = tpenc(kCp437[w & 0xFF]);
|
||||
w = _tpenc(kCp437[w & 0xFF]);
|
||||
WRITE64LE(buf, w);
|
||||
return out(buf, a, w ? (bsr(w) >> 3) + 1 : 1);
|
||||
return out(buf, a, w ? (_bsr(w) >> 3) + 1 : 1);
|
||||
}
|
||||
|
||||
static int __fmt_stoa_quoted(out_f out, void *a, uint64_t w) {
|
||||
char buf[8];
|
||||
if (isascii(w)) {
|
||||
w = cescapec(w);
|
||||
w = _cescapec(w);
|
||||
} else {
|
||||
w = tpenc(w);
|
||||
w = _tpenc(w);
|
||||
}
|
||||
WRITE64LE(buf, w);
|
||||
return out(buf, a, w ? (bsr(w) >> 3) + 1 : 1);
|
||||
return out(buf, a, w ? (_bsr(w) >> 3) + 1 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +102,7 @@ int __fmt_stoa(int out(const char *, void *, size_t), void *arg, void *data,
|
|||
} else {
|
||||
emit = __fmt_stoa_wide;
|
||||
}
|
||||
} else if ((flags & FLAGS_HASH) && weaken(kCp437)) {
|
||||
} else if ((flags & FLAGS_HASH) && _weaken(kCp437)) {
|
||||
justdobytes = true;
|
||||
emit = __fmt_stoa_bing;
|
||||
ignorenul = flags & FLAGS_PRECISION;
|
||||
|
@ -129,15 +129,15 @@ int __fmt_stoa(int out(const char *, void *, size_t), void *arg, void *data,
|
|||
if (width) {
|
||||
w = precision;
|
||||
if (signbit == 63) {
|
||||
if (weaken(wcsnwidth)) {
|
||||
w = weaken(wcsnwidth)((const wchar_t *)p, precision, 0);
|
||||
if (_weaken(wcsnwidth)) {
|
||||
w = _weaken(wcsnwidth)((const wchar_t *)p, precision, 0);
|
||||
}
|
||||
} else if (signbit == 15) {
|
||||
if (weaken(strnwidth16)) {
|
||||
w = weaken(strnwidth16)((const char16_t *)p, precision, 0);
|
||||
if (_weaken(strnwidth16)) {
|
||||
w = _weaken(strnwidth16)((const char16_t *)p, precision, 0);
|
||||
}
|
||||
} else if (weaken(strnwidth)) {
|
||||
w = weaken(strnwidth)(p, precision, 0);
|
||||
} else if (_weaken(strnwidth)) {
|
||||
w = _weaken(strnwidth)(p, precision, 0);
|
||||
}
|
||||
if (!(flags & FLAGS_NOQUOTE) && (flags & FLAGS_REPR)) {
|
||||
w += 2 + (signbit == 63) + (signbit == 15);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/str/errfun.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
|
@ -28,7 +27,7 @@
|
|||
*/
|
||||
char *strerror(int err) {
|
||||
if (IsTiny()) {
|
||||
return firstnonnull(strerrno(err), "EUNKNOWN");
|
||||
return firstnonnull(_strerrno(err), "EUNKNOWN");
|
||||
} else {
|
||||
_Alignas(1) static char buf[512];
|
||||
strerror_r(err, buf, sizeof(buf));
|
||||
|
|
|
@ -231,9 +231,9 @@ int vcscanf(int callback(void *), int unget(int, void *), void *arg,
|
|||
if (discard) {
|
||||
buf = NULL;
|
||||
} else if (ismalloc) {
|
||||
buf = weaken(malloc)(bufsize * charbytes);
|
||||
buf = _weaken(malloc)(bufsize * charbytes);
|
||||
struct FreeMe *entry;
|
||||
if (buf && (entry = weaken(calloc)(1, sizeof(struct FreeMe)))) {
|
||||
if (buf && (entry = _weaken(calloc)(1, sizeof(struct FreeMe)))) {
|
||||
entry->ptr = buf;
|
||||
entry->next = freeme;
|
||||
freeme = entry;
|
||||
|
@ -245,7 +245,7 @@ int vcscanf(int callback(void *), int unget(int, void *), void *arg,
|
|||
size_t j = 0;
|
||||
for (;;) {
|
||||
if (ismalloc && !width && j + 2 + 1 >= bufsize &&
|
||||
!weaken(__grow)(&buf, &bufsize, charbytes, 0)) {
|
||||
!_weaken(__grow)(&buf, &bufsize, charbytes, 0)) {
|
||||
width = bufsize - 1;
|
||||
}
|
||||
if (c != -1 && j + !rawmode < bufsize && (rawmode || !isspace(c))) {
|
||||
|
@ -298,11 +298,11 @@ int vcscanf(int callback(void *), int unget(int, void *), void *arg,
|
|||
}
|
||||
}
|
||||
Done:
|
||||
while (freeme && weaken(free)) {
|
||||
while (freeme && _weaken(free)) {
|
||||
struct FreeMe *entry = freeme;
|
||||
freeme = entry->next;
|
||||
if (items == -1) weaken(free)(entry->ptr);
|
||||
weaken(free)(entry);
|
||||
if (items == -1) _weaken(free)(entry->ptr);
|
||||
_weaken(free)(entry);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue