From 7642710155310cd22f03856b85caf8304f18f25a Mon Sep 17 00:00:00 2001 From: Alexander Nicholi Date: Tue, 2 Feb 2021 11:14:45 -0500 Subject: [PATCH] wip on intellisense (again) --- .vscode/c_cpp_properties.json | 57 +++++------ .vscode/vscode.h | 159 +++++++++++++++++++++++++++++++ dsp/tty/quant.h | 2 + libc/alg/arraylist.internal.h | 2 + libc/alg/arraylist2.internal.h | 2 + libc/alg/reverse.h | 2 + libc/alg/shuffle.h | 2 + libc/bits/bits.h | 14 +++ libc/bits/initializer.internal.h | 2 + libc/calls/calls.h | 2 + libc/calls/internal.h | 35 +++---- libc/calls/sigaction.c | 2 + libc/calls/stat2linux.c | 2 + libc/integral/c.inc | 2 + libc/runtime/symbolic.h | 3 - libc/str/tinystrstr.internal.h | 2 + libc/str/tpdecodecb.internal.h | 2 +- libc/testlib/bench.h | 2 + 18 files changed, 242 insertions(+), 52 deletions(-) create mode 100644 .vscode/vscode.h diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index bee9294f7..ea6e5d408 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -8,19 +8,9 @@ "cStandard": "c11", "cppStandard": "c++11", "compilerPath": "${workspaceFolder}/o/third_party/gcc/bin/x86_64-linux-musl-gcc", + "forcedInclude": ["${workspaceFolder}/.vscode/vscode.h"], "defines": [ - "__VSCODE_INTELLISENSE__", - "__BIGGEST_ALIGNMENT__", - "__SHRT_MAX__", - "__DBL_MIN__", - "__UINT32_MAX__", - "NULL=(void*)0", - "true", - "false=(!(true))", - "COSMOPOLITAN_C_START_=", - "COSMOPOLITAN_C_END_=", "libcesque=", - "mallocesque=", "pureconst=", "paramsnonnull(x)=", "alignas(x)", @@ -28,12 +18,34 @@ "artificial=", "nodiscard=", "mayalias=", - "_Vector_size(x)=", "forceinline=", "forcealign(x)=", + "scanfesque(x)=", + "strftimeesque(x)=", "wontreturn=", "textreal=", + "mallocesque=", + "callocesque=", "vallocesque=", + "reallocesque=", + "strlenesque=", + "memcpyesque=", + "hasatleast=", + "noinline=", + "textexit=", + "returnstwice=", + "textwindows=", + "privileged=", + "compatfn=", + "noinstrument=", + "nodebuginfo=", + "interruptfn=", + "optimizespeed=", + "forcealignargpointer=", + "noasan=", + "noubsan=", + "testonly=", + "donothing=", "nosideeffect=", "unreachable=", "thatispacked=", @@ -47,28 +59,9 @@ "returnspointerwithnoaliases=", "printfesque(x)=", "attributeallocsize(x)=", - "va_list=void*", "returnsaligned(x)=", "attributeallocalign(x)=", - "nullterminated(x)=", - "PAGESIZE", - "g_loglevel", - "int8_t=signed char", - "int16_t=signed short int", - "int32_t=signed int", - "int64_t=signed long long", - "uint8_t=unsigned char", - "uint16_t=unsigned short int", - "uint32_t=unsigned int", - "uint64_t=unsigned long long", - "errno_t=int", - "size_t=uint64_t", - "ssize_t=int64_t", - "uintptr_t=uint64_t", - "intptr_t=int64_t", - "bool=uint8_t", - "char16_t=uint16_t", - "char32_t=uint32_t" + "nullterminated(x)=" ] } ], diff --git a/.vscode/vscode.h b/.vscode/vscode.h new file mode 100644 index 000000000..90af26afc --- /dev/null +++ b/.vscode/vscode.h @@ -0,0 +1,159 @@ + +#define __VSCODE_INTELLISENSE__ 1 +#define __BIGGEST_ALIGNMENT__ 1 +#define __CHAR_MAX__ 0x7F +#define __SCHAR_MAX__ __CHAR_MAX__ +#define __SHRT_MAX__ 0x7FFF +#define __INT_MAX__ 0x7FFFFFFF +#define __LONG_MAX__ 0x7FFFFFFFFFFFFFFF +#define __LONG_LONG_MAX__ __LONG_MAX__ +#define __CHAR_MIN__ -((__CHAR_MAX__)+1) +#define __SHRT_MIN__ -((__SHRT_MAX__)+1) +#define __INT_MIN__ -((__INT_MAX__)+1) +#define __LONG_MIN__ -((__LONG_MAX__)+1) +#define __LONG_LONG_MIN__ -((__LONG_LONG_MAX__)+1) +#define __UCHAR_MAX__ 0xFF +#define __USHRT_MAX__ 0xFFFF +#define __UINT_MAX__ 0xFFFFFFFF +#define __ULONG_MAX__ 0xFFFFFFFFFFFFFFFF +#define __SIZE_MAX__ __ULONG_MAX__ +#define __SSIZE_MAX__ __LONG_MAX__ +#define __UINTPTR_MAX__ __SIZE_MAX__ +#define __INTPTR_MAX__ __SSIZE_MAX__ +#define __WCHAR_MAX__ __UINT_MAX__ +#define __PTRDIFF_MAX__ __UINTPTR_MAX__ +#define __INTMAX_MAX__ __ULONG_MAX__ +#define __SIZEOF_POINTER__ 8 +#define __SIZEOF_SHORT__ 2 +#define __SIZEOF_INT__ 4 +#define __SIZEOF_LONG__ 8 +#define __SIZEOF_LONG_LONG__ 8 +#define __SIZEOF_PTRDIFF_T__ 8 +#define __SIZEOF_SIZE_T__ 8 +#define __SIZEOF_WCHAR_T__ 4 +#define __SIZEOF_WINT_T__ 4 +#define __SIZEOF_FLOAT__ 4 +#define __SIZEOF_FLOAT128__ 16 +#define __SIZEOF_DOUBLE__ 8 +#define __SIZEOF_FLOAT80__ 10 +#define __SIZEOF_LONG_DOUBLE__ 16 +#define __FLT_MAX__ 1 +#define __DBL_MAX__ 1 + +#define __INT_LEAST8_TYPE__ signed char; +#define __INT_LEAST16_TYPE__ signed short; +#define __INT_LEAST32_TYPE__ signed int; +#define __INT_LEAST64_TYPE__ signed long long; +#define __UINT_LEAST8_TYPE__ unsigned char; +#define __UINT_LEAST16_TYPE__ unsigned short; +#define __UINT_LEAST32_TYPE__ unsigned int; +#define __UINT_LEAST64_TYPE__ unsigned long long; + +#define __UINT8_MAX__ __UCHAR_MAX__ +#define __UINT16_MAX__ __USHRT_MAX__ +#define __UINT32_MAX__ __UINT_MAX__ +#define __UINT64_MAX__ __ULONG_MAX__ + +#define __INT8_MAX__ __CHAR_MAX__ +#define __INT16_MAX__ __SHRT_MAX__ +#define __INT32_MAX__ __INT_MAX__ +#define __INT64_MAX__ __LONG_MAX__ + +#define ATEXIT_MAX 1 +#define STACKSIZE 0x10000 +#define ARG_MAX 255 +#define OPEN_MAX 0x7FFF +#define CHAR_BIT 7 +#define NSIG 1 +#define NULL (0) +#define false 0 +#define true (!(false)) +#define COSMOPOLITAN_C_START_ +#define COSMOPOLITAN_C_END_ +#define PAGESIZE 0x1000 +#define BIGPAGESIZE 0x10000 +#define NAME_MAX 255 + +#define SWITCHEROO(...) 0 + +extern unsigned g_loglevel; + +typedef void * va_list; + +#define va_start(...) 0 +#define va_end(...) 0 +#define va_arg(x, y) (y)(0) + +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +#define int64_t long long +#define int128_t int64_t +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +typedef unsigned long long uint128_t; + +typedef int errno_t; +typedef uint64_t size_t; +typedef unsigned long long ssize_t; +typedef uint64_t uintptr_t; +typedef long long intptr_t; + +typedef unsigned long long uintmax_t; +typedef long long intmax_t; + +typedef uint32_t bool32; + +#ifndef __cplusplus +typedef uint8_t bool; +typedef uint16_t char16_t; +typedef uint32_t char32_t; +#endif /* __cplusplus */ + +typedef char32_t wint_t; +typedef char32_t wchar_t; +typedef struct { int ax, dx; } axdx_t; + +/* duplicate and replace xmmintrin.internal.h to fix it for IntelliSense + * SEE: <> */ + +#define _Vector_size(x) __attribute__(( vector_size( x ) )) + +#define __SIGACTION(...) (0) +#define VEIL(x, y) (y) +#define STATIC_YOINK(x) +#define BUFSIZ 1 +#define FRAMESIZE 0x10000 +#define PATH_MAX 252 +#define concat(x, y, z) 0 +#define CONCAT(a, b, c, d, e) 0 +#define shuffle(...) 0 +#define reverse(x, y) 0 +#define atomic_load(...) 0 +#define atomic_store(...) 0 + +#define _Generic_(...) (void*)(0) +#define _Generic(...) _Generic_ + +#define offsetof(x, y) 0 +#define cmpxchg(...) 0 +#define lockxchg(...) 0 +#define lockcmpxchg(...) 0 +#define xgetbv(...) 0 +#define rdmsr(...) 0 +#define INITIALIZER(...) struct _dummy +#define __far +#define tinystrstr(...) 0 +#define BENCHLOOP(...) 0 + +#ifdef __hook +#undef __hook +#endif /* __hook */ + +#ifdef UriKeyval +#undef UriKeyval +#endif /* UriKeyval */ + +#define _Static_assert(...) 0 diff --git a/dsp/tty/quant.h b/dsp/tty/quant.h index d60e5f36a..575c309ba 100644 --- a/dsp/tty/quant.h +++ b/dsp/tty/quant.h @@ -72,6 +72,7 @@ void ttyquantsetup(enum TtyQuantizationAlgorithm, enum TtyQuantizationChannels, extern char *ttyraster(char *, const struct TtyRgb *, size_t, size_t, struct TtyRgb, struct TtyRgb); +#ifndef ttyquant #define ttyquant() (&g_ttyquant_) #define TTYQUANT() VEIL("r", &g_ttyquant_) #define rgb2tty(...) (ttyquant()->rgb2tty(__VA_ARGS__)) @@ -81,6 +82,7 @@ extern char *ttyraster(char *, const struct TtyRgb *, size_t, size_t, #define setbg(...) (ttyquant()->setbg(__VA_ARGS__)) #define setfg(...) (ttyquant()->setfg(__VA_ARGS__)) #define setbgfg(...) (ttyquant()->setbgfg(__VA_ARGS__)) +#endif /* ttyquant */ forceinline bool ttyeq(struct TtyRgb x, struct TtyRgb y) { return x.r == y.r && x.g == y.g && x.b == y.b; diff --git a/libc/alg/arraylist.internal.h b/libc/alg/arraylist.internal.h index 6012fe507..3b7a5c8be 100644 --- a/libc/alg/arraylist.internal.h +++ b/libc/alg/arraylist.internal.h @@ -28,6 +28,7 @@ #define append(ARRAYLIST, ITEM) concat((ARRAYLIST), (ITEM), 1) +#ifndef concat #define concat(ARRAYLIST, ITEM, COUNT) \ ({ \ autotype(ARRAYLIST) List = (ARRAYLIST); \ @@ -43,6 +44,7 @@ } \ (ssize_t)(Idx); \ }) +#endif /* concat */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ALG_ARRAYLIST_H_ */ diff --git a/libc/alg/arraylist2.internal.h b/libc/alg/arraylist2.internal.h index b78008ec7..e86d3a402 100644 --- a/libc/alg/arraylist2.internal.h +++ b/libc/alg/arraylist2.internal.h @@ -10,6 +10,7 @@ COSMOPOLITAN_C_START_ #define APPEND(LIST_P, LIST_I, LIST_N, ITEM) \ CONCAT(LIST_P, LIST_I, LIST_N, ITEM, 1) +#ifndef CONCAT #define CONCAT(LIST_P, LIST_I, LIST_N, ITEM, COUNT) \ ({ \ autotype(LIST_P) ListP = (LIST_P); \ @@ -31,6 +32,7 @@ COSMOPOLITAN_C_START_ } \ Entry; \ }) +#endif /* CONCAT */ COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/alg/reverse.h b/libc/alg/reverse.h index a782ec7ff..598f65826 100644 --- a/libc/alg/reverse.h +++ b/libc/alg/reverse.h @@ -11,6 +11,7 @@ * @return pointer to start of array * @see ARRAYLEN() */ +#ifndef reverse #define reverse(ARRAY, COUNT) \ ({ \ autotype(&(ARRAY)[0]) Array = (ARRAY); \ @@ -26,6 +27,7 @@ } \ Array; \ }) +#endif /* reverse */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ALG_REVERSE_H_ */ diff --git a/libc/alg/shuffle.h b/libc/alg/shuffle.h index 43e55862f..027675a4f 100644 --- a/libc/alg/shuffle.h +++ b/libc/alg/shuffle.h @@ -11,6 +11,7 @@ * @param n is the number of items in A * @see ARRAYLEN() */ +#ifndef shuffle #define shuffle(R, A, n) \ do { \ autotype(A) Array = (A); \ @@ -18,6 +19,7 @@ xchg(&Array[i], &Array[R() % (i + 1)]); \ } \ } while (0) +#endif /* shuffle */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_RAND_SHUFFLE_H_ */ diff --git a/libc/bits/bits.h b/libc/bits/bits.h index 02874e7f3..44f9cd33e 100644 --- a/libc/bits/bits.h +++ b/libc/bits/bits.h @@ -205,6 +205,7 @@ unsigned long hamming(unsigned long, unsigned long) pureconst; * @see Intel's Six-Thousand Page Manual V.3A §8.2.3.1 * @see atomic_store() */ +#ifndef atomic_load #define atomic_load(MEM) \ ({ \ autotype(MEM) Mem = (MEM); \ @@ -212,6 +213,7 @@ unsigned long hamming(unsigned long, unsigned long) pureconst; asm("mov\t%1,%0" : "=r"(Reg) : "m"(*Mem)); \ Reg; \ }) +#endif /* atomic_load */ /** * Saves scalar to memory w/ one operation. @@ -229,6 +231,7 @@ unsigned long hamming(unsigned long, unsigned long) pureconst; * @see Intel Six-Thousand Page Manual Manual V.3A §8.2.3.1 * @see atomic_load() */ +#ifndef atomic_store #define atomic_store(MEM, VAL) \ ({ \ autotype(VAL) Val = (VAL); \ @@ -236,6 +239,7 @@ unsigned long hamming(unsigned long, unsigned long) pureconst; asm("mov%z1\t%1,%0" : "=m"(*Mem) : "r"(Val)); \ Val; \ }) +#endif /* atomic_store */ #define bts(MEM, BIT) __BitOp("bts", BIT, MEM) /** bit test and set */ #define btr(MEM, BIT) __BitOp("btr", BIT, MEM) /** bit test and reset */ @@ -263,6 +267,7 @@ unsigned long hamming(unsigned long, unsigned long) pureconst; * @return LOCALVAR[0] * @see xchg() */ +#ifndef lockxchg #define lockxchg(MEMORY, LOCALVAR) \ ({ \ _Static_assert( \ @@ -270,6 +275,7 @@ unsigned long hamming(unsigned long, unsigned long) pureconst; asm("xchg\t%0,%1" : "+%m"(*(MEMORY)), "+r"(*(LOCALVAR))); \ *(LOCALVAR); \ }) +#endif /* lockxchg */ /** * Compares and exchanges. @@ -278,6 +284,7 @@ unsigned long hamming(unsigned long, unsigned long) pureconst; * @return true if value was exchanged, otherwise false * @see lockcmpxchg() */ +#ifndef cmpxchg #define cmpxchg(IFTHING, ISEQUALTOME, REPLACEITWITHME) \ ({ \ bool DidIt; \ @@ -290,6 +297,7 @@ unsigned long hamming(unsigned long, unsigned long) pureconst; : "cc"); \ DidIt; \ }) +#endif /* cmpxchg */ /** * Compares and exchanges w/ one operation. @@ -298,6 +306,7 @@ unsigned long hamming(unsigned long, unsigned long) pureconst; * @return true if value was exchanged, otherwise false * @see lockcmpxchg() */ +#ifndef lockcmpxchg #define lockcmpxchg(IFTHING, ISEQUALTOME, REPLACEITWITHME) \ ({ \ bool DidIt; \ @@ -310,27 +319,32 @@ unsigned long hamming(unsigned long, unsigned long) pureconst; : "cc"); \ DidIt; \ }) +#endif /* lockcmpxchg */ /** * Gets value of extended control register. */ +#ifndef xgetbv #define xgetbv(xcr_register_num) \ ({ \ unsigned hi, lo; \ asm("xgetbv" : "=d"(hi), "=a"(lo) : "c"(cr_register_num)); \ (uint64_t) hi << 32 | lo; \ }) +#endif /* xgetbv */ /** * Reads model-specific register. * @note programs running as guests won't have authorization */ +#ifndef rdmsr #define rdmsr(msr) \ ({ \ uint32_t lo, hi; \ asm volatile("rdmsr" : "=a"(lo), "=d"(hi) : "c"(msr)); \ (uint64_t) hi << 32 | lo; \ }) +#endif rdmsr /** * Writes model-specific register. diff --git a/libc/bits/initializer.internal.h b/libc/bits/initializer.internal.h index a6b90a842..6aa1708de 100644 --- a/libc/bits/initializer.internal.h +++ b/libc/bits/initializer.internal.h @@ -7,6 +7,7 @@ /** * Teleports code fragment inside _init(). */ +#ifndef INITIALIZER #define INITIALIZER(PRI, NAME, CODE) \ asm(".section .init." #PRI "." #NAME ",\"ax\",@progbits\n\t" \ "call\t" #NAME "\n\t" \ @@ -15,6 +16,7 @@ CODE; \ asm volatile("" : /* no outputs */ : "D"(rdi), "S"(rsi)); \ } +#endif /* INITIALIZER */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_BITS_INITIALIZER_H_ */ diff --git a/libc/calls/calls.h b/libc/calls/calls.h index c57a840c1..0198a637b 100644 --- a/libc/calls/calls.h +++ b/libc/calls/calls.h @@ -251,6 +251,7 @@ int vdprintf(int, const char *, va_list) paramsnonnull(); void _init_onntconsoleevent(void); void _init_wincrash(void); +#ifndef __SIGACTION #define __SIGACTION(FN, SIG, ...) \ ({ \ if (SupportsWindows()) { \ @@ -279,6 +280,7 @@ void _init_wincrash(void); } \ (FN)(SIG, __VA_ARGS__); \ }) +#endif #define dprintf(FD, FMT, ...) (dprintf)(FD, PFLINK(FMT), ##__VA_ARGS__) #define sigaction(SIG, ACT, OLD) __SIGACTION(sigaction, SIG, ACT, OLD) diff --git a/libc/calls/internal.h b/libc/calls/internal.h index 195d5acf9..b9148264a 100644 --- a/libc/calls/internal.h +++ b/libc/calls/internal.h @@ -36,25 +36,28 @@ struct IoctlPtmGet { char theduxname[16]; char workername[16]; }; +enum FdKind { + kFdEmpty, + kFdFile, + kFdSocket, + kFdProcess, + kFdConsole, + kFdSerial, + kFdZip, + kFdEpoll, +}; + +struct Fd { + int64_t handle; + int64_t extra; + int kind; + unsigned flags; +}; struct Fds { size_t f; // lowest free slot size_t n; // monotonic capacity - struct Fd { - int64_t handle; - int64_t extra; - enum FdKind { - kFdEmpty, - kFdFile, - kFdSocket, - kFdProcess, - kFdConsole, - kFdSerial, - kFdZip, - kFdEpoll, - } kind; - unsigned flags; - } * p; + struct Fd * p; struct Fd __init_p[OPEN_MAX]; }; @@ -76,7 +79,7 @@ forceinline bool __isfdopen(int fd) { return 0 <= fd && fd < g_fds.n && g_fds.p[fd].kind != kFdEmpty; } -forceinline bool __isfdkind(int fd, enum FdKind kind) { +forceinline bool __isfdkind(int fd, int kind) { return 0 <= fd && fd < g_fds.n && g_fds.p[fd].kind == kind; } diff --git a/libc/calls/sigaction.c b/libc/calls/sigaction.c index 5a6b94f1b..2548aa791 100644 --- a/libc/calls/sigaction.c +++ b/libc/calls/sigaction.c @@ -45,6 +45,7 @@ union metasigaction { struct sigaction$xnu_out xnu_out; }; +#ifndef SWITCHEROO #define SWITCHEROO(S1, S2, A, B, C, D) \ do { \ autotype((S2).A) a = (typeof((S2).A))(S1).A; \ @@ -59,6 +60,7 @@ union metasigaction { memset(&((S2).D), 0, sizeof((S2).D)); \ memcpy(&((S2).D), &d, MIN(sizeof(d), sizeof((S2).D))); \ } while (0); +#endif static void sigaction$cosmo2native(union metasigaction *sa) { if (!sa) return; diff --git a/libc/calls/stat2linux.c b/libc/calls/stat2linux.c index 76f20eb94..d815c51be 100644 --- a/libc/calls/stat2linux.c +++ b/libc/calls/stat2linux.c @@ -20,6 +20,7 @@ #include "libc/calls/struct/metastat.internal.h" #include "libc/dce.h" +#ifndef SWITCHEROO #define SWITCHEROO(S1, S2, A, B, C, D, E, F, G, H, I, J, K, L, M) \ do { \ autotype((S2).A) a = (typeof((S2).A))(S1).A; \ @@ -49,6 +50,7 @@ (S2).L = l; \ (S2).M = m; \ } while (0); +#endif forceinline void stat2linux_xnu(union metastat *ms) { SWITCHEROO(ms->xnu, ms->linux, st_dev, st_ino, st_nlink, st_mode, st_uid, diff --git a/libc/integral/c.inc b/libc/integral/c.inc index 56aa255f2..04974506c 100644 --- a/libc/integral/c.inc +++ b/libc/integral/c.inc @@ -759,12 +759,14 @@ typedef uint64_t uintmax_t; #define DebugBreak() asm("int3") +#ifndef VEIL #define VEIL(CONSTRAINT, EXPRESSION) \ ({ \ autotype(EXPRESSION) VeiledValue = (EXPRESSION); \ asm("" : "=" CONSTRAINT ""(VeiledValue) : "0"(VeiledValue)); \ VeiledValue; \ }) +#endif /* VEIL */ #define CONCEAL(CONSTRAINT, EXPRESSION) \ ({ \ diff --git a/libc/runtime/symbolic.h b/libc/runtime/symbolic.h index 8edbb8251..8a6280a84 100644 --- a/libc/runtime/symbolic.h +++ b/libc/runtime/symbolic.h @@ -6,9 +6,6 @@ #define SYMBOLIC(NAME) NAME(%rip) #define LITERALLY(NAME) $NAME /* clang-format on */ -#elif defined(__VSCODE_INTELLISENSE__) -#define SYMBOLIC(NAME) 1 -#define LITERALLY(NAME) 1 #else #define SYMBOLIC(NAME) NAME #define LITERALLY(NAME) NAME diff --git a/libc/str/tinystrstr.internal.h b/libc/str/tinystrstr.internal.h index 3c050339e..eb82b3142 100644 --- a/libc/str/tinystrstr.internal.h +++ b/libc/str/tinystrstr.internal.h @@ -3,6 +3,7 @@ #include "libc/str/str.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) +#ifndef tinystrstr #define tinystrstr(HAYSTACK, NEEDLE) \ ({ \ autotype(HAYSTACK) Haystack = (HAYSTACK); \ @@ -21,6 +22,7 @@ Found: \ Haystack; \ }) +#endif /* tinystrstr */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_STR_TINYSTRSTR_H_ */ diff --git a/libc/str/tpdecodecb.internal.h b/libc/str/tpdecodecb.internal.h index 6ec04a388..0bb8f1915 100644 --- a/libc/str/tpdecodecb.internal.h +++ b/libc/str/tpdecodecb.internal.h @@ -27,7 +27,7 @@ forceinline int tpdecodecb(wint_t *out, int first, if ((cb & 0b11000000) == 0b10000000) { wc = wc << 6 | (cb & 0b00111111); } else { - if (out) *out = u'�'; + if (out) *out = u'\xFFFD'; return -1; } } diff --git a/libc/testlib/bench.h b/libc/testlib/bench.h index eea7c6e30..c64f8c9f8 100644 --- a/libc/testlib/bench.h +++ b/libc/testlib/bench.h @@ -8,6 +8,7 @@ COSMOPOLITAN_C_START_ * @fileoverview Microbenchmarking tools. */ +#ifndef BENCHLOOP #define BENCHLOOP(START, STOP, N, INIT, EXPR) \ ({ \ unsigned long Iter, Count; \ @@ -22,6 +23,7 @@ COSMOPOLITAN_C_START_ } \ Average; \ }) +#endif /* BENCHLOOP */ COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */