mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-26 22:38:30 +00:00
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:
parent
96f979dfc5
commit
fa20edc44d
3057 changed files with 410 additions and 4398 deletions
17
third_party/stb/stb_image.c
vendored
17
third_party/stb/stb_image.c
vendored
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue