mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Enhance chibicc
This commit is contained in:
parent
8da931a7f6
commit
9df2cef4c4
52 changed files with 2606 additions and 2004 deletions
|
@ -229,12 +229,12 @@ unsigned long hamming(unsigned long, unsigned long) pureconst;
|
|||
* @see Intel Six-Thousand Page Manual Manual V.3A §8.2.3.1
|
||||
* @see atomic_load()
|
||||
*/
|
||||
#define atomic_store(MEM, VAL) \
|
||||
({ \
|
||||
autotype(VAL) Val = (VAL); \
|
||||
typeof(&Val) Mem = (MEM); \
|
||||
asm("mov%z1\t%1,%0" : "=m,m"(*Mem) : "i,r"(Val)); \
|
||||
Val; \
|
||||
#define atomic_store(MEM, VAL) \
|
||||
({ \
|
||||
autotype(VAL) Val = (VAL); \
|
||||
typeof(&Val) Mem = (MEM); \
|
||||
asm("mov%z1\t%1,%0" : "=m"(*Mem) : "r"(Val)); \
|
||||
Val; \
|
||||
})
|
||||
|
||||
#define bts(MEM, BIT) __BitOp("bts", BIT, MEM) /** bit test and set */
|
||||
|
|
|
@ -39,9 +39,6 @@ $(LIBC_BITS_A).pkg: \
|
|||
$(LIBC_BITS_A_OBJS) \
|
||||
$(foreach x,$(LIBC_BITS_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
#o/$(MODE)/libc/bits/bsf.o: CC = clang-10
|
||||
#o/$(MODE)/libc/bits/bsf.o: CC = /opt/cross9cc/bin/x86_64-linux-musl-cc
|
||||
|
||||
LIBC_BITS_LIBS = $(foreach x,$(LIBC_BITS_ARTIFACTS),$($(x)))
|
||||
LIBC_BITS_SRCS = $(foreach x,$(LIBC_BITS_ARTIFACTS),$($(x)_SRCS))
|
||||
LIBC_BITS_HDRS = $(foreach x,$(LIBC_BITS_ARTIFACTS),$($(x)_HDRS))
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_FMT_BING_H_
|
||||
#define COSMOPOLITAN_LIBC_FMT_BING_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
#ifndef __cplusplus
|
||||
|
||||
int bing(int, int) nosideeffect;
|
||||
int unbing(int) nosideeffect;
|
||||
|
@ -9,8 +8,6 @@ void *unbingbuf(void *, size_t, const char16_t *, int);
|
|||
void *unbingstr(const char16_t *) paramsnonnull() mallocesque;
|
||||
void *unhexbuf(void *, size_t, const char *);
|
||||
void *unhexstr(const char *) mallocesque;
|
||||
short *bingblit(int ys, int xs, unsigned char[ys][xs], int, int);
|
||||
|
||||
#endif /* __cplusplus */
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_FMT_BING_H_ */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define COSMOPOLITAN_LIBC_FMT_PFLINK_H_
|
||||
#include "libc/dce.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
#if !defined(__STRICT_ANSI__) && !defined(__chibicc__)
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
/**
|
||||
* @fileoverview builtin+preprocessor+linker tricks for printf/scanf.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#define COSMOPOLITAN_CXX_USING_
|
||||
#endif
|
||||
|
||||
#if defined(__STRICT_ANSI__) && __STDC_VERSION__ + 0 < 201112
|
||||
#ifdef __STRICT_ANSI__
|
||||
#define asm __asm__
|
||||
#endif
|
||||
|
||||
|
@ -773,8 +773,9 @@ typedef uint64_t uintmax_t;
|
|||
*/
|
||||
#if __cplusplus + 0 >= 201103L
|
||||
#define autotype(x) auto
|
||||
#elif (__has_builtin(auto_type) || defined(__llvm__) || \
|
||||
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 409)
|
||||
#elif ((__has_builtin(auto_type) || defined(__llvm__) || \
|
||||
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 409) && \
|
||||
!defined(__chibicc__))
|
||||
#define autotype(x) __auto_type
|
||||
#else
|
||||
#define autotype(x) typeof(x)
|
||||
|
|
|
@ -7,7 +7,7 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
void palignr(void *, const void *, const void *, unsigned long);
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#if !defined(__STRICT_ANSI__) && !defined(__chibicc__)
|
||||
__intrin_xmm_t __palignrs(__intrin_xmm_t, __intrin_xmm_t);
|
||||
#define palignr(C, B, A, I) \
|
||||
do { \
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "libc/intrin/pand.h"
|
||||
|
||||
/**
|
||||
* Nands 128-bit integers.
|
||||
* Ands 128-bit integers.
|
||||
*
|
||||
* @param 𝑎 [w/o] receives result
|
||||
* @param 𝑏 [r/o] supplies first input vector
|
||||
|
|
|
@ -59,10 +59,7 @@ cescapec:
|
|||
#ifdef __STRICT_ANSI__
|
||||
.LQM: mov $'?',%ah
|
||||
ret
|
||||
.LESC:
|
||||
#elif defined(__GNUC__)
|
||||
.LESC: mov $'e',%ah
|
||||
ret
|
||||
#else
|
||||
.LQM:
|
||||
#endif
|
||||
1: mov %edi,%eax
|
||||
|
@ -91,9 +88,7 @@ cescapectab.ro:
|
|||
.byte 1,.LVT-.Lanchorpoint
|
||||
.byte 1,.LFF-.Lanchorpoint
|
||||
.byte 1,.LCR-.Lanchorpoint
|
||||
.byte 0x1b-'\r-1,1b-.Lanchorpoint
|
||||
.byte 1,.LESC-.Lanchorpoint
|
||||
.byte '\"-0x1b-1,1b-.Lanchorpoint
|
||||
.byte '\"-'\r-1,1b-.Lanchorpoint
|
||||
.byte 1,.LDQ-.Lanchorpoint
|
||||
.byte '\'-'\"-1,1b-.Lanchorpoint
|
||||
.byte 1,.LSQ-.Lanchorpoint
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_STR_STRCMP8TO16I_H_
|
||||
#define COSMOPOLITAN_LIBC_STR_STRCMP8TO16I_H_
|
||||
#include "libc/conv/conv.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/str/oldutf16.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpdecode.internal.h"
|
||||
|
@ -12,9 +13,12 @@ forceinline int strcmp8to16i(const char *s1, const char16_t *s2, size_t n,
|
|||
int res = 0;
|
||||
if (n) {
|
||||
do {
|
||||
unsigned i, j;
|
||||
wint_t wc1, wc2;
|
||||
s1 += abs(tpdecode(s1, &wc1));
|
||||
s2 += abs(getutf16(s2, &wc2));
|
||||
i = tpdecode(s1, &wc1);
|
||||
j = getutf16(s2, &wc2);
|
||||
s1 += ABS(i);
|
||||
s2 += ABS(j);
|
||||
if ((res = xlat(wc1) - xlat(wc2)) || !wc1) break;
|
||||
} while (n == -1ul || --n);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue