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
third_party/stb/stb_image.c
vendored
28
third_party/stb/stb_image.c
vendored
|
@ -17,9 +17,9 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/gdb.h"
|
||||
#include "libc/log/log.h"
|
||||
|
@ -2113,8 +2113,8 @@ static unsigned char *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y,
|
|||
}
|
||||
|
||||
static dontinline void *stbi__jpeg_load(stbi__context *s, int *x, int *y,
|
||||
int *comp, int req_comp,
|
||||
stbi__result_info *ri) {
|
||||
int *comp, int req_comp,
|
||||
stbi__result_info *ri) {
|
||||
unsigned char *result;
|
||||
stbi__jpeg *j = (stbi__jpeg *)malloc(sizeof(stbi__jpeg));
|
||||
j->s = s;
|
||||
|
@ -2178,19 +2178,11 @@ typedef struct {
|
|||
uint16_t value[288];
|
||||
} stbi__zhuffman;
|
||||
|
||||
forceinline int stbi__bitreverse16(int n) {
|
||||
n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1);
|
||||
n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2);
|
||||
n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4);
|
||||
n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8);
|
||||
return n;
|
||||
}
|
||||
|
||||
forceinline int stbi__bit_reverse(int v, int bits) {
|
||||
assert(bits <= 16);
|
||||
// to bit reverse n bits, reverse 16 and shift
|
||||
// e.g. 11 bits, bit reverse and shift away 5
|
||||
return stbi__bitreverse16(v) >> (16 - bits);
|
||||
return _bitreverse16(v) >> (16 - bits);
|
||||
}
|
||||
|
||||
static int stbi__zbuild_huffman(stbi__zhuffman *z,
|
||||
|
@ -3414,8 +3406,8 @@ static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp,
|
|||
}
|
||||
|
||||
static dontinline void *stbi__png_load(stbi__context *s, int *x, int *y,
|
||||
int *comp, int req_comp,
|
||||
stbi__result_info *ri) {
|
||||
int *comp, int req_comp,
|
||||
stbi__result_info *ri) {
|
||||
stbi__png p;
|
||||
p.s = s;
|
||||
return stbi__do_png(&p, x, y, comp, req_comp, ri);
|
||||
|
@ -3917,8 +3909,8 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
|
|||
}
|
||||
|
||||
static dontinline void *stbi__gif_load(stbi__context *s, int *x, int *y,
|
||||
int *comp, int req_comp,
|
||||
stbi__result_info *ri) {
|
||||
int *comp, int req_comp,
|
||||
stbi__result_info *ri) {
|
||||
unsigned char *u = 0;
|
||||
stbi__gif *g;
|
||||
g = calloc(1, sizeof(stbi__gif));
|
||||
|
@ -3970,8 +3962,8 @@ static int stbi__pnm_test(stbi__context *s) {
|
|||
}
|
||||
|
||||
static dontinline void *stbi__pnm_load(stbi__context *s, int *x, int *y,
|
||||
int *comp, int req_comp,
|
||||
stbi__result_info *ri) {
|
||||
int *comp, int req_comp,
|
||||
stbi__result_info *ri) {
|
||||
unsigned char *out;
|
||||
if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y,
|
||||
(int *)&s->img_n)) {
|
||||
|
|
20
third_party/stb/stb_vorbis.c
vendored
20
third_party/stb/stb_vorbis.c
vendored
|
@ -32,13 +32,13 @@
|
|||
// manxorist@github saga musix github:infatum
|
||||
// Timur Gagiev Maxwell Koo
|
||||
//
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/mem/alloca.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -649,7 +649,7 @@ static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) {
|
|||
res = available[z];
|
||||
assert(z >= 0 && z < 32);
|
||||
available[z] = 0;
|
||||
add_entry(c, bitreverse32(res), i, m++, len[i], values);
|
||||
add_entry(c, _bitreverse32(res), i, m++, len[i], values);
|
||||
// propagate availability up the tree
|
||||
if (z != len[i]) {
|
||||
assert(len[i] >= 0 && len[i] < 32);
|
||||
|
@ -675,7 +675,7 @@ static void compute_accelerated_huffman(Codebook *c) {
|
|||
for (i = 0; i < len; ++i) {
|
||||
if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) {
|
||||
uint32 z =
|
||||
c->sparse ? bitreverse32(c->sorted_codewords[i]) : c->codewords[i];
|
||||
c->sparse ? _bitreverse32(c->sorted_codewords[i]) : c->codewords[i];
|
||||
// set table entries for all bit combinations in the higher bits
|
||||
while (z < FAST_HUFFMAN_TABLE_SIZE) {
|
||||
c->fast_huffman[z] = i;
|
||||
|
@ -720,11 +720,11 @@ static void compute_sorted_huffman(Codebook *c, uint8 *lengths,
|
|||
int k = 0;
|
||||
for (i = 0; i < c->entries; ++i)
|
||||
if (include_in_sort(c, lengths[i]))
|
||||
c->sorted_codewords[k++] = bitreverse32(c->codewords[i]);
|
||||
c->sorted_codewords[k++] = _bitreverse32(c->codewords[i]);
|
||||
assert(k == c->sorted_entries);
|
||||
} else {
|
||||
for (i = 0; i < c->sorted_entries; ++i)
|
||||
c->sorted_codewords[i] = bitreverse32(c->codewords[i]);
|
||||
c->sorted_codewords[i] = _bitreverse32(c->codewords[i]);
|
||||
}
|
||||
|
||||
qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]),
|
||||
|
@ -740,7 +740,7 @@ static void compute_sorted_huffman(Codebook *c, uint8 *lengths,
|
|||
for (i = 0; i < len; ++i) {
|
||||
int huff_len = c->sparse ? lengths[values[i]] : lengths[i];
|
||||
if (include_in_sort(c, huff_len)) {
|
||||
uint32 code = bitreverse32(c->codewords[i]);
|
||||
uint32 code = _bitreverse32(c->codewords[i]);
|
||||
int x = 0, n = c->sorted_entries;
|
||||
while (n > 1) {
|
||||
// invariant: sc[x] <= code < sc[x+n]
|
||||
|
@ -808,7 +808,7 @@ static void compute_window(int n, float *window) {
|
|||
static void compute_bitreverse(int n, uint16 *rev) {
|
||||
int ld = ilog(n) - 1; // ilog is off-by-one from normal definitions
|
||||
int i, n8 = n >> 3;
|
||||
for (i = 0; i < n8; ++i) rev[i] = (bitreverse32(i) >> (32 - ld + 3)) << 2;
|
||||
for (i = 0; i < n8; ++i) rev[i] = (_bitreverse32(i) >> (32 - ld + 3)) << 2;
|
||||
}
|
||||
|
||||
static int init_blocksize(vorb *f, int b, int n) {
|
||||
|
@ -1182,7 +1182,7 @@ static int codebook_decode_scalar_raw(vorb *f, Codebook *c) {
|
|||
// sorted_codewords && c->entries > 8
|
||||
if (c->entries > 8 ? c->sorted_codewords != NULL : !c->codewords) {
|
||||
// binary search
|
||||
uint32 code = bitreverse32(f->acc);
|
||||
uint32 code = _bitreverse32(f->acc);
|
||||
int x = 0, n = c->sorted_entries, len;
|
||||
|
||||
while (n > 1) {
|
||||
|
@ -2560,7 +2560,7 @@ void inverse_mdct_naive(float *buffer, int n)
|
|||
|
||||
// step 4
|
||||
for (i=0; i < n8; ++i) {
|
||||
int j = bitreverse32(i) >> (32-ld+3);
|
||||
int j = _bitreverse32(i) >> (32-ld+3);
|
||||
assert(j < n8);
|
||||
if (i == j) {
|
||||
// paper bug: original code probably swapped in place; if copying,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue