mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-08 04:08:32 +00:00
Get Cosmopolitan into releasable state
A new rollup tool now exists for flattening out the headers in a way that works better for our purposes than cpp. A lot of the API clutter has been removed. APIs that aren't a sure thing in terms of general recommendation are now marked internal. There's now a smoke test for the amalgamation archive and gigantic header file. So we can now guarantee you can use this project on the easiest difficulty setting without the gigantic repository. A website is being created, which is currently a work in progress: https://justine.storage.googleapis.com/cosmopolitan/index.html
This commit is contained in:
parent
dba7552c1e
commit
ea0b5d9d1c
775 changed files with 6864 additions and 3963 deletions
|
@ -1,6 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_AVX2INTRIN_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_AVX2INTRIN_H_
|
||||
#include "libc/bits/avxintrin.h"
|
||||
#include "libc/bits/avxintrin.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Converts binary-coded-decimal to integer.
|
||||
/
|
||||
/ @param rdi is the string copied into a word
|
||||
bcd2i: .leafprologue
|
||||
.profilable
|
||||
test %rdi,%rdi
|
||||
je 2f
|
||||
mov $1,%ecx
|
||||
xor %eax,%eax
|
||||
1: mov %edi,%edx
|
||||
and $15,%edx
|
||||
imul %rcx,%rdx
|
||||
add %rdx,%rax
|
||||
add %rcx,%rcx
|
||||
lea (%rcx,%rcx,4),%rcx
|
||||
shr $4,%rdi
|
||||
jne 1b
|
||||
ret
|
||||
2: xor %eax,%eax
|
||||
.leafepilogue
|
||||
.endfn bcd2i,globl
|
|
@ -1,54 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
bcxcpy: push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
push %rbx
|
||||
xor %ebx,%ebx
|
||||
lea -64(%rbp),%rdx
|
||||
sub $24,%rsp
|
||||
3: lea (,%rbx,4),%ecx
|
||||
mov %rsi,%rax
|
||||
shr %cl,%rax
|
||||
and $15,%eax
|
||||
cmp $9,%eax
|
||||
lea 7(%rax),%ecx
|
||||
cmova %ecx,%eax
|
||||
add $48,%eax
|
||||
mov %al,(%rdx,%rbx)
|
||||
add $1,%rbx
|
||||
cmp $16,%rbx
|
||||
jne 3b
|
||||
mov %rdx,%rax
|
||||
lea -48(%rbp),%rcx
|
||||
lea 15(%rdi),%rdx
|
||||
4: movzbl (%rax),%ebx
|
||||
add $1,%rax
|
||||
sub $1,%rdx
|
||||
mov %bl,1(%rdx)
|
||||
cmp %rcx,%rax
|
||||
jne 4b
|
||||
add $24,%rsp
|
||||
pop %rbx
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn bcxcpy,globl
|
|
@ -1,28 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_BIGWORD_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_BIGWORD_H_
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Let BIGWORD be the the number of bytes in the largest cpu register
|
||||
* available within the instruction set architecture requirements chosen
|
||||
* at compile-time.
|
||||
*
|
||||
* In plainer terms, if you tune with flags like -mavx, you're not just
|
||||
* giving the compiler permission to generate code that's incompatible
|
||||
* with older computers; you're also asking Cosmopolitan to systemically
|
||||
* change alignment, vectoring, buffering, ABIs, memory allocation, etc.
|
||||
*/
|
||||
#endif
|
||||
#ifndef BIGWORD
|
||||
#if __AVX512F__ + 0
|
||||
#define BIGWORD 64
|
||||
#elif __AVX2__ + 0
|
||||
#define BIGWORD 32
|
||||
#elif __SSE2__ + 0
|
||||
#define BIGWORD 16
|
||||
#else
|
||||
#define BIGWORD __BIGGEST_ALIGNMENT__
|
||||
#endif
|
||||
#endif /*BIGWORD*/
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_BITS_BIGWORD_H_ */
|
16
libc/bits/bigword.internal.h
Normal file
16
libc/bits/bigword.internal.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_BIGWORD_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_BIGWORD_H_
|
||||
|
||||
#ifndef BIGWORD
|
||||
#if __AVX512F__ + 0
|
||||
#define BIGWORD 64
|
||||
#elif __AVX2__ + 0
|
||||
#define BIGWORD 32
|
||||
#elif __SSE2__ + 0
|
||||
#define BIGWORD 16
|
||||
#else
|
||||
#define BIGWORD __BIGGEST_ALIGNMENT__
|
||||
#endif
|
||||
#endif /*BIGWORD*/
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_BITS_BIGWORD_H_ */
|
|
@ -1,5 +1,5 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
|
@ -17,15 +17,8 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
#include "libc/bits/bits.h"
|
||||
|
||||
bitreverse16:
|
||||
push %rbx
|
||||
mov %edi,%eax
|
||||
mov $kReverseBits,%ebx
|
||||
xlat
|
||||
xchg %al,%ah
|
||||
xlat
|
||||
pop %rbx
|
||||
ret
|
||||
.endfn bitreverse16,globl
|
||||
uint16_t(bitreverse16)(uint16_t x) {
|
||||
return kReverseBits[x & 0x00FF] << 8 | kReverseBits[(x & 0xFF00) >> 8];
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
|
@ -17,15 +17,8 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
#include "libc/bits/bits.h"
|
||||
|
||||
bitreverse8:
|
||||
.leafprologue
|
||||
.profilable
|
||||
push %rbx
|
||||
mov %edi,%eax
|
||||
mov $kReverseBits,%ebx
|
||||
xlat
|
||||
pop %rbx
|
||||
.leafepilogue
|
||||
.endfn bitreverse8,globl
|
||||
uint8_t(bitreverse8)(uint8_t x) {
|
||||
return kReverseBits[x];
|
||||
}
|
|
@ -9,42 +9,26 @@ COSMOPOLITAN_C_START_
|
|||
│ cosmopolitan § bits ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
extern const bool kTrue;
|
||||
extern const bool kFalse;
|
||||
extern const uint8_t kReverseBits[256];
|
||||
|
||||
uint32_t gray(uint32_t) pureconst;
|
||||
uint32_t ungray(uint32_t) pureconst;
|
||||
unsigned bcdadd(unsigned, unsigned) pureconst;
|
||||
unsigned long bcd2i(unsigned long) pureconst;
|
||||
unsigned long i2bcd(unsigned long) pureconst;
|
||||
void bcxcpy(unsigned char (*)[16], unsigned long);
|
||||
int ffs(int) pureconst;
|
||||
int ffsl(long int) pureconst;
|
||||
int ffsll(long long int) pureconst;
|
||||
int fls(int) pureconst;
|
||||
int flsl(long int) pureconst;
|
||||
int flsll(long long int) pureconst;
|
||||
|
||||
uint8_t bitreverse8(uint8_t) libcesque pureconst;
|
||||
uint16_t bitreverse16(uint16_t) libcesque pureconst;
|
||||
uint32_t bitreverse32(uint32_t) libcesque pureconst;
|
||||
uint64_t bitreverse64(uint64_t) libcesque pureconst;
|
||||
|
||||
unsigned long roundup2pow(unsigned long) libcesque pureconst;
|
||||
unsigned long roundup2log(unsigned long) libcesque pureconst;
|
||||
unsigned long rounddown2pow(unsigned long) libcesque pureconst;
|
||||
|
||||
unsigned long hamming(unsigned long, unsigned long) pureconst;
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § bits » no assembly required ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
/**
|
||||
* Undocumented incantations for ROR, ROL, and SAR.
|
||||
*/
|
||||
#define ROR(w, k) (CheckUnsigned(w) >> (k) | (w) << (sizeof(w) * 8 - (k)))
|
||||
#define ROL(w, k) ((w) << (k) | CheckUnsigned(w) >> (sizeof(w) * 8 - (k)))
|
||||
#define SAR(w, k) (((w) & ~(~0u >> (k))) | ((w) >> ((k) & (sizeof(w) * 8 - 1))))
|
||||
|
||||
#define bitreverse8(X) (kReverseBits[(uint8_t)(X)])
|
||||
#define bitreverse16(X) \
|
||||
((uint16_t)kReverseBits[(uint8_t)(X)] << 010 | \
|
||||
|
@ -253,49 +237,6 @@ unsigned long hamming(unsigned long, unsigned long) pureconst;
|
|||
Val; \
|
||||
})
|
||||
|
||||
/**
|
||||
* Returns true if bit is set in memory.
|
||||
*
|
||||
* This is a generically-typed Bitset<T> ∀ RAM. This macro is intended
|
||||
* to be container-like with optimal machine instruction encoding, cf.
|
||||
* machine-agnostic container abstractions. Memory accesses are words.
|
||||
* Register allocation can be avoided if BIT is known. Be careful when
|
||||
* casting character arrays since that should cause a page fault.
|
||||
*
|
||||
* @param MEM is uint𝑘_t[] where 𝑘 ∈ {16,32,64} base address
|
||||
* @param BIT ∈ [-(2**(𝑘-1)),2**(𝑘-1)) is zero-based index
|
||||
* @return true if bit is set, otherwise false
|
||||
* @see Intel's Six Thousand Page Manual V.2A 3-113
|
||||
* @see bts(), btr(), btc()
|
||||
*/
|
||||
#define bt(MEM, BIT) \
|
||||
({ \
|
||||
bool OldBit; \
|
||||
if (isconstant(BIT)) { \
|
||||
asm(CFLAG_ASM("bt%z1\t%2,%1") \
|
||||
: CFLAG_CONSTRAINT(OldBit) \
|
||||
: "m"((MEM)[(BIT) / (sizeof((MEM)[0]) * CHAR_BIT)]), \
|
||||
"J"((BIT) % (sizeof((MEM)[0]) * CHAR_BIT)) \
|
||||
: "cc"); \
|
||||
} else if (sizeof((MEM)[0]) == 2) { \
|
||||
asm(CFLAG_ASM("bt\t%w2,%1") \
|
||||
: CFLAG_CONSTRAINT(OldBit) \
|
||||
: "m"((MEM)[0]), "r"(BIT) \
|
||||
: "cc"); \
|
||||
} else if (sizeof((MEM)[0]) == 4) { \
|
||||
asm(CFLAG_ASM("bt\t%k2,%1") \
|
||||
: CFLAG_CONSTRAINT(OldBit) \
|
||||
: "m"((MEM)[0]), "r"(BIT) \
|
||||
: "cc"); \
|
||||
} else if (sizeof((MEM)[0]) == 8) { \
|
||||
asm(CFLAG_ASM("bt\t%q2,%1") \
|
||||
: CFLAG_CONSTRAINT(OldBit) \
|
||||
: "m"((MEM)[0]), "r"(BIT) \
|
||||
: "cc"); \
|
||||
} \
|
||||
OldBit; \
|
||||
})
|
||||
|
||||
#define bts(MEM, BIT) __BitOp("bts", BIT, MEM) /** bit test and set */
|
||||
#define btr(MEM, BIT) __BitOp("btr", BIT, MEM) /** bit test and reset */
|
||||
#define btc(MEM, BIT) __BitOp("btc", BIT, MEM) /** bit test and complement */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_EMMINTRIN_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_EMMINTRIN_H_
|
||||
#include "libc/bits/progn.h"
|
||||
#include "libc/bits/xmmintrin.h"
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/bits/xmmintrin.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
@ -17,14 +17,8 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
|
||||
uint32_t gray(uint32_t x) { return x ^ (x >> 1); }
|
||||
|
||||
uint32_t ungray(uint32_t x) {
|
||||
x ^= x >> 16;
|
||||
x ^= x >> 8;
|
||||
x ^= x >> 4;
|
||||
x ^= x >> 2;
|
||||
x ^= x >> 1;
|
||||
return x;
|
||||
uint32_t gray(uint32_t x) {
|
||||
return x ^ (x >> 1);
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Converts integer to binary-coded decimal.
|
||||
i2bcd: .leafprologue
|
||||
.profilable
|
||||
test %rdi,%rdi
|
||||
je 2f
|
||||
mov %rdi,%rsi
|
||||
xor %r9d,%r9d
|
||||
mov $0xcccccccccccccccd,%r8
|
||||
xor %ecx,%ecx
|
||||
1: mov %rsi,%rax
|
||||
mul %r8
|
||||
shr $3,%rdx
|
||||
lea (%rdx,%rdx),%rax
|
||||
lea (%rax,%rax,4),%rax
|
||||
mov %rsi,%rdi
|
||||
sub %rax,%rdi
|
||||
shl %cl,%rdi
|
||||
add %rdi,%r9
|
||||
add $4,%rcx
|
||||
cmp $9,%rsi
|
||||
mov %rdx,%rsi
|
||||
ja 1b
|
||||
jmp 3f
|
||||
2: xor %r9d,%r9d
|
||||
3: mov %r9,%rax
|
||||
.leafepilogue
|
||||
.endfn i2bcd,globl
|
|
@ -2,6 +2,8 @@
|
|||
#define COSMOPOLITAN_LIBC_BITS_INITIALIZER_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
/* TODO: DELETE */
|
||||
|
||||
/**
|
||||
* Teleports code fragment inside _init().
|
||||
*/
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_SHAINTRIN_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_SHAINTRIN_H_
|
||||
#include "libc/bits/emmintrin.h"
|
||||
#include "libc/bits/xmmintrin.h"
|
||||
#include "libc/bits/emmintrin.internal.h"
|
||||
#include "libc/bits/xmmintrin.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
#define _mm_sha1rnds4_epu32(M128I_0, M128I_1, MEM) \
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_TMMINTRIN_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_TMMINTRIN_H_
|
||||
#include "libc/bits/emmintrin.h"
|
||||
#include "libc/bits/emmintrin.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_TYPECHECK_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_TYPECHECK_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
#define TYPECHECK(T, X) \
|
||||
({ \
|
||||
T Lol1; \
|
||||
typeof(X) Lol2; \
|
||||
(void)(&Lol1 == &Lol2); \
|
||||
X; \
|
||||
})
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_BITS_TYPECHECK_H_ */
|
|
@ -1,5 +1,5 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
|
@ -17,22 +17,13 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
#include "libc/bits/bits.h"
|
||||
|
||||
/ Performs addition on binary-coded decimals.
|
||||
bcdadd: .leafprologue
|
||||
.profilable
|
||||
lea 0x6666666(%rdi),%ecx
|
||||
xor %esi,%ecx
|
||||
lea (%rdi,%rsi),%eax
|
||||
add $0x6666666,%eax
|
||||
xor %eax,%ecx
|
||||
not %ecx
|
||||
and $0x11111110,%ecx
|
||||
mov %ecx,%edx
|
||||
shr $2,%edx
|
||||
shr $3,%ecx
|
||||
orl %edx,%ecx
|
||||
sub %ecx,%eax
|
||||
.leafepilogue
|
||||
.endfn bcdadd,globl
|
||||
uint32_t ungray(uint32_t x) {
|
||||
x ^= x >> 16;
|
||||
x ^= x >> 8;
|
||||
x ^= x >> 4;
|
||||
x ^= x >> 2;
|
||||
x ^= x >> 1;
|
||||
return x;
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
|
||||
/**
|
||||
* Subtracts unsigned integers w/ wraparound.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_WMMINTRIN_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_WMMINTRIN_H_
|
||||
#include "libc/bits/emmintrin.h"
|
||||
#include "libc/bits/emmintrin.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
#define _mm_clmulepi64_si128(X, Y, IMM) \
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_XMMINTRIN_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_XMMINTRIN_H_
|
||||
#include "libc/bits/emmintrin.h"
|
||||
#include "libc/bits/mmintrin.h"
|
||||
#include "libc/bits/progn.h"
|
||||
#include "libc/bits/emmintrin.internal.h"
|
||||
#include "libc/bits/mmintrin.internal.h"
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/dce.h"
|
||||
|
||||
#define _MM_EXCEPT_MASK 0x003f
|
Loading…
Add table
Add a link
Reference in a new issue