Reduce header complexity

- Remove most __ASSEMBLER__ __LINKER__ ifdefs
- Rename libc/intrin/bits.h to libc/serialize.h
- Block pthread cancelation in fchmodat() polyfill
- Remove `clang-format off` statements in third_party
This commit is contained in:
Justine Tunney 2023-11-28 14:24:28 -08:00
parent 96f979dfc5
commit fa20edc44d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
3057 changed files with 410 additions and 4398 deletions

View file

@ -20,7 +20,8 @@
#include "libc/assert.h"
#include "libc/calls/calls.h"
#include "libc/fmt/conv.h"
#include "libc/intrin/bits.h"
#include "libc/serialize.h"
#include "libc/intrin/bswap.h"
#include "libc/limits.h"
#include "libc/log/gdb.h"
#include "libc/log/log.h"
@ -2937,11 +2938,23 @@ typedef struct {
uint16_t value[288];
} stbi__zhuffman;
static uint32_t ReverseBits32(uint32_t x) {
x = bswap_32(x);
x = (x & 0xaaaaaaaa) >> 1 | (x & 0x55555555) << 1;
x = (x & 0xcccccccc) >> 2 | (x & 0x33333333) << 2;
x = (x & 0xf0f0f0f0) >> 4 | (x & 0x0f0f0f0f) << 4;
return x;
}
static int ReverseBits16(int x) {
return ReverseBits32(x) >> 16;
}
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 _bitreverse16(v) >> (16 - bits);
return ReverseBits16(v) >> (16 - bits);
}
static int stbi__zbuild_huffman(stbi__zhuffman *z,