diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 0fcce52ae..4cc2ec610 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -36,7 +36,7 @@ "textwindows=", "privileged=", "compatfn=", - "noinstrument=", + "dontinstrument=", "nodebuginfo=", "interruptfn=", "optimizespeed=", diff --git a/dsp/core/c11.h b/dsp/core/c11.h index ee83867f2..c46d8d2ee 100644 --- a/dsp/core/c11.h +++ b/dsp/core/c11.h @@ -7,8 +7,7 @@ * * @define (a + b) / 2 */ -static inline pureconst artificial unsigned char C11(unsigned char al, - unsigned char bl) { +__funline unsigned char C11(unsigned char al, unsigned char bl) { short ax; ax = al; ax += bl; diff --git a/dsp/core/c121.h b/dsp/core/c121.h index 71ef3cd43..c03f9e038 100644 --- a/dsp/core/c121.h +++ b/dsp/core/c121.h @@ -3,9 +3,8 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -forceinline pureconst artificial unsigned char C121(unsigned char al, - unsigned char bl, - unsigned char cl) { +__funline unsigned char C121(unsigned char al, unsigned char bl, + unsigned char cl) { unsigned short ax, bx; ax = al; ax += bl; diff --git a/dsp/core/c121s.h b/dsp/core/c121s.h index d7f036e6f..0af3cbc7a 100644 --- a/dsp/core/c121s.h +++ b/dsp/core/c121s.h @@ -2,9 +2,7 @@ #define COSMOPOLITAN_DSP_CORE_C121S_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) -forceinline pureconst artificial signed char C121S(signed char al, - signed char bl, - signed char cl) { +__funline signed char C121S(signed char al, signed char bl, signed char cl) { short ax, bx; ax = al; ax += bl; diff --git a/dsp/core/c1331.h b/dsp/core/c1331.h index f1f8d1153..2a3e27c51 100644 --- a/dsp/core/c1331.h +++ b/dsp/core/c1331.h @@ -9,10 +9,8 @@ * @see C161() afterward for superior sin(๐‘ฅ)/๐‘ฅ * @limit [0,255] โ†’ [0..2,044] โ†’ [0..255] */ -forceinline pureconst artificial unsigned char C1331(unsigned char al, - unsigned char bl, - unsigned char cl, - unsigned char dl) { +__funline unsigned char C1331(unsigned char al, unsigned char bl, + unsigned char cl, unsigned char dl) { short ax, bx; bx = bl; bx += cl; diff --git a/dsp/core/c1331s.h b/dsp/core/c1331s.h index ef5a37f13..66388e080 100644 --- a/dsp/core/c1331s.h +++ b/dsp/core/c1331s.h @@ -8,10 +8,8 @@ * @define (1*(a-128)+3*(a-128)+3*(a-128)+1*(a-128))/(1+3+3+1)+128 * @see C1331(), Y420CbCr2RgbScale() */ -forceinline pureconst artificial signed char C1331S(signed char al, - signed char bl, - signed char cl, - signed char dl) { +__funline signed char C1331S(signed char al, signed char bl, signed char cl, + signed char dl) { short ax, bx; bx = bl; bx += cl; diff --git a/dsp/core/c161.h b/dsp/core/c161.h index d42b890f8..c9b22de12 100644 --- a/dsp/core/c161.h +++ b/dsp/core/c161.h @@ -12,9 +12,8 @@ * @limit [0..255] โ†’ [-510..1,532] โ†’ [-127..383] โ†’ [0..255] * @see C1331() */ -forceinline pureconst artificial unsigned char C161(unsigned char al, - unsigned char bl, - unsigned char cl) { +__funline unsigned char C161(unsigned char al, unsigned char bl, + unsigned char cl) { short ax, bx, cx; ax = al; bx = bl; diff --git a/dsp/core/c161s.h b/dsp/core/c161s.h index bccdb80f9..b67f08a2c 100644 --- a/dsp/core/c161s.h +++ b/dsp/core/c161s.h @@ -4,9 +4,7 @@ #include "libc/macros.internal.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) -forceinline pureconst artificial signed char C161S(signed char al, - signed char bl, - signed char cl) { +__funline signed char C161S(signed char al, signed char bl, signed char cl) { short ax, bx, cx; ax = al; bx = bl; diff --git a/dsp/core/c331.h b/dsp/core/c331.h index 5b537d21a..382bea626 100644 --- a/dsp/core/c331.h +++ b/dsp/core/c331.h @@ -9,9 +9,8 @@ COSMOPOLITAN_C_START_ * @define (3*a + 3*b + 1*c) / 7 * @see C1331() */ -static inline pureconst artificial unsigned char C331(unsigned char al, - unsigned char bl, - unsigned char cl) { +__funline unsigned char C331(unsigned char al, unsigned char bl, + unsigned char cl) { unsigned eax, ebx, ecx; eax = al; ebx = bl; diff --git a/dsp/core/ituround.h b/dsp/core/ituround.h index 791657940..9c05aeaac 100644 --- a/dsp/core/ituround.h +++ b/dsp/core/ituround.h @@ -11,11 +11,11 @@ * * @see round(), rint() */ -static inline pureconst artificial long ituround(double x) { +__funline long ituround(double x) { return floor(x + .5); } -static inline pureconst artificial int ituroundf(float x) { +__funline int ituroundf(float x) { return floorf(x + .5f); } diff --git a/dsp/core/twixt8.h b/dsp/core/twixt8.h index 2f0156358..e8f4a31fb 100644 --- a/dsp/core/twixt8.h +++ b/dsp/core/twixt8.h @@ -6,9 +6,8 @@ COSMOPOLITAN_C_START_ /** * 8-bit linear interpolation kernel. */ -static inline pureconst artificial unsigned char twixt8(unsigned char al, - unsigned char bl, - unsigned char p) { +__funline unsigned char twixt8(unsigned char al, unsigned char bl, + unsigned char p) { short bx; bx = bl; bx -= al; diff --git a/libc/calls/dprintf.h b/libc/calls/dprintf.h index a327e0481..29a87a350 100644 --- a/libc/calls/dprintf.h +++ b/libc/calls/dprintf.h @@ -7,12 +7,11 @@ COSMOPOLITAN_C_START_ int dprintf(int, const char *, ...) printfesque(2) paramsnonnull((2)); int vdprintf(int, const char *, va_list) paramsnonnull(); -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) - +#if defined(COSMO) && !defined(__cplusplus) #define dprintf(FD, FMT, ...) (dprintf)(FD, PFLINK(FMT), ##__VA_ARGS__) #define vdprintf(FD, FMT, VA) (vdprintf)(FD, PFLINK(FMT), VA) - #endif /* GNU && !ANSI */ + COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_DPRINTF_H_ */ diff --git a/libc/calls/execve-nt.greg.c b/libc/calls/execve-nt.greg.c index 61553a921..1277c4891 100644 --- a/libc/calls/execve-nt.greg.c +++ b/libc/calls/execve-nt.greg.c @@ -47,7 +47,7 @@ __msabi extern typeof(WaitForSingleObject) *const __imp_WaitForSingleObject; __msabi extern typeof(GetExitCodeProcess) *const __imp_GetExitCodeProcess; __msabi extern typeof(UnmapViewOfFile) *const __imp_UnmapViewOfFile; -static noinstrument __msabi bool32 +static dontinstrument __msabi bool32 BlockExecveConsoleEvent(uint32_t dwCtrlType) { // block SIGINT and SIGQUIT in execve() parent process return true; diff --git a/libc/calls/getcontext.S b/libc/calls/getcontext.S index 0bef8e9a8..6e246399d 100644 --- a/libc/calls/getcontext.S +++ b/libc/calls/getcontext.S @@ -67,7 +67,7 @@ getcontext: .end //////////////////////////////////////////////////////////////////////////////// -noasan noubsan noinstrument int getcontext(ucontext_t *uc) { +noasan noubsan dontinstrument int getcontext(ucontext_t *uc) { asm volatile("movaps\t%%xmm0,%0" : /* no outputs */ : "m"(uc->__fpustate.xmm[0])); asm volatile("movaps\t%%xmm1,%0" : /* no outputs */ : "m"(uc->__fpustate.xmm[1])); asm volatile("movaps\t%%xmm2,%0" : /* no outputs */ : "m"(uc->__fpustate.xmm[2])); diff --git a/libc/fmt/conv.h b/libc/fmt/conv.h index b08e6c164..4b47e05b9 100644 --- a/libc/fmt/conv.h +++ b/libc/fmt/conv.h @@ -78,10 +78,12 @@ libcesque nosideeffect; โ”‚ cosmopolitan ยง conversion ยป manipulation โ”€โ•ฌโ”€โ”‚โ”ผ โ•šโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚*/ +#ifdef COSMO char *dirname(char *); char *basename(char *); char *stripext(char *); char *stripexts(char *); +#endif /*โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ•— โ”‚ cosmopolitan ยง conversion ยป computation โ”€โ•ฌโ”€โ”‚โ”ผ diff --git a/libc/fmt/fmt.h b/libc/fmt/fmt.h index ba620bf56..9835ef278 100644 --- a/libc/fmt/fmt.h +++ b/libc/fmt/fmt.h @@ -35,7 +35,7 @@ char *gcvt(double, int, char *); โ”‚ cosmopolitan ยง string formatting ยป optimizations โ”€โ•ฌโ”€โ”‚โ”ผ โ•šโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚*/ -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(__cplusplus) +#if defined(COSMO) && !defined(__cplusplus) #define sprintf(BUF, FMT, ...) (sprintf)(BUF, PFLINK(FMT), ##__VA_ARGS__) #define vsprintf(BUF, FMT, VA) (vsprintf)(BUF, PFLINK(FMT), VA) #define snprintf(B, Z, F, ...) (snprintf)(B, Z, PFLINK(F), ##__VA_ARGS__) diff --git a/libc/fmt/pflink.h b/libc/fmt/pflink.h index 7af6cc357..1f654d3ef 100644 --- a/libc/fmt/pflink.h +++ b/libc/fmt/pflink.h @@ -1,6 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_FMT_PFLINK_H_ #define COSMOPOLITAN_LIBC_FMT_PFLINK_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +#ifdef COSMO /** * @fileoverview builtin+preprocessor+linker tricks for printf/scanf. @@ -59,5 +60,12 @@ #pragma GCC diagnostic ignored "-Wformat-security" #endif /* __GNUC__ + 0 < 6 */ +#else +STATIC_YOINK("strerror"); +STATIC_YOINK("strnwidth"); +STATIC_YOINK("__fmt_dtoa"); +STATIC_YOINK("strnwidth16"); +STATIC_YOINK("wcsnwidth"); +#endif /* COSMO */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_FMT_PFLINK_H_ */ diff --git a/libc/integral/c.inc b/libc/integral/c.inc index 452f1ddf5..ec2e1ee24 100644 --- a/libc/integral/c.inc +++ b/libc/integral/c.inc @@ -208,13 +208,13 @@ typedef struct { #endif #endif -#ifndef noinstrument +#ifndef dontinstrument #if !defined(__STRICT_ANSI__) && \ (__has_attribute(__no_instrument_function__) || \ (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 204) -#define noinstrument __attribute__((__no_instrument_function__)) +#define dontinstrument __attribute__((__no_instrument_function__)) #else -#define noinstrument +#define dontinstrument #endif #endif @@ -485,32 +485,13 @@ typedef struct { #endif #endif -#ifndef artificial -#if !defined(__STRICT_ANSI__) && \ - (__has_attribute(__artificial__) || \ - (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 403) -#define artificial __attribute__((__artificial__)) -#else -#define artificial -#endif -#endif - -#ifndef microarchitecture +#ifndef _Microarchitecture #if !defined(__STRICT_ANSI__) && \ (__has_attribute(__target__) || \ (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 404) -#define microarchitecture(march) __attribute__((__target__(march))) +#define _Microarchitecture(march) __attribute__((__target__(march))) #else -#define microarchitecture(march) -#endif -#endif - -#ifndef targetclones -#if !defined(__STRICT_ANSI__) && \ - (__has_attribute(__target_clones__) || __GNUC__ >= 6) -#define targetclones(archs) __attribute__((__target_clones__(archs))) -#else -#define targetclones(archs) +#define _Microarchitecture(march) #endif #endif @@ -629,8 +610,8 @@ void abort(void) wontreturn; } while (0) #ifndef __STRICT_ANSI__ -#define textstartup _Section(".text.startup") noinstrument -#define textexit _Section(".text.exit") noinstrument +#define textstartup _Section(".text.startup") dontinstrument +#define textexit _Section(".text.exit") dontinstrument #define textreal _Section(".text.real") #define texthead _Section(".text.head") #define textwindows _Section(".text.windows") diff --git a/libc/intrin/bzero.c b/libc/intrin/bzero.c index a751b7122..3daf166f4 100644 --- a/libc/intrin/bzero.c +++ b/libc/intrin/bzero.c @@ -44,7 +44,7 @@ static void bzero128(char *p, size_t n) { } #ifdef __x86_64__ -microarchitecture("avx") static void bzero_avx(char *p, size_t n) { +_Microarchitecture("avx") static void bzero_avx(char *p, size_t n) { xmm_t v = {0}; if (IsAsan()) __asan_verify(p, n); if (n <= 32) { diff --git a/libc/intrin/memcmp.c b/libc/intrin/memcmp.c index ff5e23e8d..7ef00b4d1 100644 --- a/libc/intrin/memcmp.c +++ b/libc/intrin/memcmp.c @@ -57,9 +57,9 @@ static dontinline antiquity int memcmp_sse(const unsigned char *p, } } -microarchitecture("avx") static int memcmp_avx(const unsigned char *p, - const unsigned char *q, - size_t n) { +_Microarchitecture("avx") static int memcmp_avx(const unsigned char *p, + const unsigned char *q, + size_t n) { uint64_t w; unsigned u; if (n > 32) { diff --git a/libc/intrin/memset.c b/libc/intrin/memset.c index fb369614c..c83141edd 100644 --- a/libc/intrin/memset.c +++ b/libc/intrin/memset.c @@ -46,7 +46,7 @@ static void *memset_sse(char *p, char c, size_t n) { } #ifdef __x86_64__ -microarchitecture("avx") static void *memset_avx(char *p, char c, size_t n) { +_Microarchitecture("avx") static void *memset_avx(char *p, char c, size_t n) { char *t; xmm_t v = {c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c}; if (IsAsan()) __asan_verify(p, n); diff --git a/libc/intrin/restorewintty.c b/libc/intrin/restorewintty.c index de37f8510..08f924968 100644 --- a/libc/intrin/restorewintty.c +++ b/libc/intrin/restorewintty.c @@ -35,7 +35,7 @@ const unsigned char kConsoleHandles[3] = { }; // Puts cmd.exe gui back the way it was. -privileged noinstrument void _restorewintty(void) { +privileged dontinstrument void _restorewintty(void) { if (!IsWindows()) return; if (__imp_GetCurrentProcessId() != __pid_exec) return; for (int i = 0; i < 3; ++i) { diff --git a/libc/log/backtrace3.c b/libc/log/backtrace3.c index 5bc9096c1..2ca2270ae 100644 --- a/libc/log/backtrace3.c +++ b/libc/log/backtrace3.c @@ -45,9 +45,8 @@ * @param st is open symbol table for current executable * @return -1 w/ errno if error happened */ -noinstrument noasan int PrintBacktraceUsingSymbols(int fd, - const struct StackFrame *bp, - struct SymbolTable *st) { +dontinstrument noasan int PrintBacktraceUsingSymbols( + int fd, const struct StackFrame *bp, struct SymbolTable *st) { bool ok; size_t gi; intptr_t addr; diff --git a/libc/log/log_get_errno.c b/libc/log/log_get_errno.c index 54b8dd5c7..70b4d1ced 100644 --- a/libc/log/log_get_errno.c +++ b/libc/log/log_get_errno.c @@ -19,6 +19,6 @@ #include "libc/errno.h" #include "libc/log/log.h" -noinstrument int _log_get_errno(void) { +dontinstrument int _log_get_errno(void) { return errno; } diff --git a/libc/log/log_retrace.c b/libc/log/log_retrace.c index ad863d896..d113f2314 100644 --- a/libc/log/log_retrace.c +++ b/libc/log/log_retrace.c @@ -19,6 +19,6 @@ #include "libc/log/log.h" #include "libc/runtime/runtime.h" -noinstrument void _log_retrace(void) { +dontinstrument void _log_retrace(void) { ftrace_enabled(+1); } diff --git a/libc/log/log_set_errno.c b/libc/log/log_set_errno.c index b8d985d85..7b7458f45 100644 --- a/libc/log/log_set_errno.c +++ b/libc/log/log_set_errno.c @@ -19,6 +19,6 @@ #include "libc/errno.h" #include "libc/log/log.h" -noinstrument void _log_set_errno(int e) { +dontinstrument void _log_set_errno(int e) { errno = e; } diff --git a/libc/log/log_untrace.c b/libc/log/log_untrace.c index 089e315d6..71290ebe9 100644 --- a/libc/log/log_untrace.c +++ b/libc/log/log_untrace.c @@ -19,6 +19,6 @@ #include "libc/log/log.h" #include "libc/runtime/runtime.h" -noinstrument void _log_untrace(void) { +dontinstrument void _log_untrace(void) { ftrace_enabled(-1); } diff --git a/libc/log/logerrno.c b/libc/log/logerrno.c index cb029a9f7..1ea8b5ffe 100644 --- a/libc/log/logerrno.c +++ b/libc/log/logerrno.c @@ -22,6 +22,6 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" -noinstrument void _log_errno(const char *file, int line, const char *form) { +dontinstrument void _log_errno(const char *file, int line, const char *form) { flogf(kLogWarn, file, line, NULL, PFLINK("%s โ†’ %s"), form, strerror(errno)); } diff --git a/libc/log/oncrash_amd64.c b/libc/log/oncrash_amd64.c index ffab0921b..a2690bbf2 100644 --- a/libc/log/oncrash_amd64.c +++ b/libc/log/oncrash_amd64.c @@ -254,10 +254,10 @@ relegated void ShowCrashReport(int err, int sig, struct siginfo *si, kprintf("\n"); } -static wontreturn relegated noinstrument void __minicrash(int sig, - struct siginfo *si, - ucontext_t *ctx, - const char *kind) { +static wontreturn relegated dontinstrument void __minicrash(int sig, + struct siginfo *si, + ucontext_t *ctx, + const char *kind) { kprintf("\n" "\n" "CRASHED %s WITH %G\n" diff --git a/libc/log/watch.c b/libc/log/watch.c index f506c223f..1ad71baf7 100644 --- a/libc/log/watch.c +++ b/libc/log/watch.c @@ -33,14 +33,14 @@ static char __watch_last[4096]; void __watch_hook(void); -static noinstrument inline void Copy(char *p, char *q, size_t n) { +static dontinstrument inline void Copy(char *p, char *q, size_t n) { size_t i; for (i = 0; i < n; ++i) { p[i] = q[i]; } } -static noinstrument inline int Cmp(char *p, char *q, size_t n) { +static dontinstrument inline int Cmp(char *p, char *q, size_t n) { int c; if (n == 8) return READ64LE(p) != READ64LE(q); if (n == 4) return READ32LE(p) != READ32LE(q); @@ -52,7 +52,7 @@ static noinstrument inline int Cmp(char *p, char *q, size_t n) { return 0; } -noinstrument void __watcher(void) { +dontinstrument void __watcher(void) { if (__watch_busy) return; __watch_busy = true; if (Cmp(__watch_last, __watch_addr, __watch_size)) { diff --git a/libc/mem/fmt.h b/libc/mem/fmt.h index 1351d4885..5691f040e 100644 --- a/libc/mem/fmt.h +++ b/libc/mem/fmt.h @@ -8,7 +8,7 @@ int asprintf(char **, const char *, ...) printfesque(2) paramsnonnull((1, 2)) libcesque; int vasprintf(char **, const char *, va_list) paramsnonnull() libcesque; -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +#if defined(COSMO) && !defined(__cplusplus) #define asprintf(SP, FMT, ...) (asprintf)(SP, PFLINK(FMT), ##__VA_ARGS__) #define vasprintf(SP, FMT, VA) (vasprintf)(SP, PFLINK(FMT), VA) #endif diff --git a/libc/runtime/clone.c b/libc/runtime/clone.c index 716dcb983..3983d3790 100644 --- a/libc/runtime/clone.c +++ b/libc/runtime/clone.c @@ -111,11 +111,11 @@ int WinThreadLaunch(void *arg, // rdi // 2. windows owns the stack memory right now // we need win32 raw imports because: // 1. generated thunks are function logged -noasan noinstrument static textwindows wontreturn void // -WinThreadEntry(int rdi, // rcx - int rsi, // rdx - int rdx, // r8 - struct CloneArgs *wt) { // r9 +noasan dontinstrument static textwindows wontreturn void // +WinThreadEntry(int rdi, // rcx + int rsi, // rdx + int rdx, // r8 + struct CloneArgs *wt) { // r9 int rc; if (wt->tls) __set_tls_win32(wt->tls); *wt->ctid = wt->tid; diff --git a/libc/runtime/getdosenviron.c b/libc/runtime/getdosenviron.c index 27339a31a..9652260f9 100644 --- a/libc/runtime/getdosenviron.c +++ b/libc/runtime/getdosenviron.c @@ -37,9 +37,8 @@ forceinline char *MemChr(const char *s, unsigned char c, unsigned long n) { return 0; } -static textwindows noasan noinstrument axdx_t Recode16to8(char *dst, - size_t dstsize, - const char16_t *src) { +static textwindows noasan dontinstrument axdx_t +Recode16to8(char *dst, size_t dstsize, const char16_t *src) { bool v; axdx_t r; uint64_t w; @@ -72,7 +71,7 @@ static textwindows noasan noinstrument axdx_t Recode16to8(char *dst, return r; } -textwindows noinstrument noasan void FixPath(char *path) { +textwindows dontinstrument noasan void FixPath(char *path) { char *p; size_t i; @@ -112,9 +111,9 @@ textwindows noinstrument noasan void FixPath(char *path) { // @param envp stores NULL-terminated string pointer list (optional) // @param max is the pointer count capacity of envp // @return number of variables decoded, excluding NULL-terminator -textwindows noasan noinstrument int GetDosEnviron(const char16_t *env, - char *buf, size_t size, - char **envp, size_t max) { +textwindows noasan dontinstrument int GetDosEnviron(const char16_t *env, + char *buf, size_t size, + char **envp, size_t max) { int i; char *p; axdx_t r; diff --git a/libc/runtime/getsymbol.c b/libc/runtime/getsymbol.c index d9aab399d..98e0d8f92 100644 --- a/libc/runtime/getsymbol.c +++ b/libc/runtime/getsymbol.c @@ -27,7 +27,7 @@ extern _Hide struct SymbolTable *__symtab; * @param t if null will be auto-populated only if already open * @return index or -1 if nothing found */ -noinstrument privileged int __get_symbol(struct SymbolTable *t, intptr_t a) { +dontinstrument privileged int __get_symbol(struct SymbolTable *t, intptr_t a) { // we need privileged because: // kprintf is privileged and it depends on this // we don't want function tracing because: diff --git a/libc/runtime/getsymbolname.c b/libc/runtime/getsymbolname.c index 4da3690d1..b9ba568e9 100644 --- a/libc/runtime/getsymbolname.c +++ b/libc/runtime/getsymbolname.c @@ -18,7 +18,7 @@ โ•šโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*/ #include "libc/runtime/symbols.internal.h" -privileged noinstrument noasan noubsan char *__get_symbol_name( +privileged dontinstrument noasan noubsan char *__get_symbol_name( struct SymbolTable *t, int s) { /* asan runtime depends on this function */ if (t && s != -1) { diff --git a/libc/runtime/hook.greg.c b/libc/runtime/hook.greg.c index 3ea3d87b5..6c828e9df 100644 --- a/libc/runtime/hook.greg.c +++ b/libc/runtime/hook.greg.c @@ -106,7 +106,8 @@ static privileged void HookFunction(code_t *func, void *dest) { * @param st can be obtained using `GetSymbolTable()` * @see ape/ape.lds */ -privileged noinstrument noasan int __hook(void *dest, struct SymbolTable *st) { +privileged dontinstrument noasan int __hook(void *dest, + struct SymbolTable *st) { long i; sigset_t mask; code_t *p, *pe; diff --git a/libc/runtime/stackchkfail.c b/libc/runtime/stackchkfail.c index 4f5a045db..b5152e6ad 100644 --- a/libc/runtime/stackchkfail.c +++ b/libc/runtime/stackchkfail.c @@ -18,7 +18,7 @@ โ•šโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*/ #include "libc/intrin/kprintf.h" -privileged noasan noinstrument void __stack_chk_fail(void) { +void __stack_chk_fail(void) { kprintf("stack smashed\n"); __builtin_trap(); } diff --git a/libc/stdio/stdio.h b/libc/stdio/stdio.h index ce68ec7b6..2064caca9 100644 --- a/libc/stdio/stdio.h +++ b/libc/stdio/stdio.h @@ -166,7 +166,7 @@ int vfprintf_unlocked(FILE *, const char *, va_list) โ”‚ cosmopolitan ยง standard i/o ยป optimizations โ”€โ•ฌโ”€โ”‚โ”ผ โ•šโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚*/ -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +#if defined(COSMO) && !defined(__cplusplus) /* clang-format off */ #define printf(FMT, ...) (printf)(PFLINK(FMT), ##__VA_ARGS__) #define vprintf(FMT, VA) (vprintf)(PFLINK(FMT), VA) diff --git a/libc/str/bcmp.c b/libc/str/bcmp.c index 7ccd8239b..0f29a1eb9 100644 --- a/libc/str/bcmp.c +++ b/libc/str/bcmp.c @@ -38,8 +38,8 @@ static int bcmp_sse(const char *p, const char *q, size_t n) { } #ifdef __x86_64__ -microarchitecture("avx") static int bcmp_avx(const char *p, const char *q, - size_t n) { +_Microarchitecture("avx") static int bcmp_avx(const char *p, const char *q, + size_t n) { xmm_t a, b, c, d; if (n > 32) { if (n >= 16 + 64) { diff --git a/libc/str/timingsafe_bcmp.c b/libc/str/timingsafe_bcmp.c index 426ae80da..f64fda30d 100644 --- a/libc/str/timingsafe_bcmp.c +++ b/libc/str/timingsafe_bcmp.c @@ -41,9 +41,9 @@ noasan static unsigned timingsafe_bcmp_sse(const char *p, const char *q, } #ifdef __x86_64__ -noasan static microarchitecture("avx") int timingsafe_bcmp_avx(const char *p, - const char *q, - size_t n) { +noasan static _Microarchitecture("avx") int timingsafe_bcmp_avx(const char *p, + const char *q, + size_t n) { uint64_t w; xmm_t a = {0}; if (n > 32) { diff --git a/libc/tinymath/cosdf.c b/libc/tinymath/cosdf.c index c519dba57..f3a7afc9c 100644 --- a/libc/tinymath/cosdf.c +++ b/libc/tinymath/cosdf.c @@ -60,7 +60,7 @@ C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */ C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */ C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */ -noinstrument float __cosdf(double x) +dontinstrument float __cosdf(double x) { double_t r, w, z; diff --git a/libc/tinymath/sindf.c b/libc/tinymath/sindf.c index 06f38699f..aa259ea1a 100644 --- a/libc/tinymath/sindf.c +++ b/libc/tinymath/sindf.c @@ -60,7 +60,7 @@ S2 = 0x111110896efbb2.0p-59, /* 0.0083333293858894631756 */ S3 = -0x1a00f9e2cae774.0p-65, /* -0.000198393348360966317347 */ S4 = 0x16cd878c3b46a7.0p-71; /* 0.0000027183114939898219064 */ -noinstrument float __sindf(double x) +dontinstrument float __sindf(double x) { double_t r, s, w, z; diff --git a/libc/x/xasprintf.h b/libc/x/xasprintf.h index 193839a74..a689a39d3 100644 --- a/libc/x/xasprintf.h +++ b/libc/x/xasprintf.h @@ -9,7 +9,7 @@ char *xasprintf(const char *, ...) printfesque(1) paramsnonnull((1)) char *xvasprintf(const char *, va_list) paramsnonnull() returnspointerwithnoaliases dontthrow nocallback dontdiscard returnsnonnull; -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +#if defined(COSMO) && !defined(__cplusplus) #define xasprintf(FMT, ...) (xasprintf)(PFLINK(FMT), ##__VA_ARGS__) #define xvasprintf(FMT, VA) (xvasprintf)(PFLINK(FMT), VA) #endif diff --git a/test/libc/calls/pledge_test.c b/test/libc/calls/pledge_test.c index 92ad8b1b3..0f93f872f 100644 --- a/test/libc/calls/pledge_test.c +++ b/test/libc/calls/pledge_test.c @@ -38,6 +38,7 @@ #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" #include "libc/sock/struct/sockaddr.h" +#include "libc/sock/struct/sockaddr6.h" #include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/af.h" @@ -352,6 +353,9 @@ TEST(pledge, inet_forbidsOtherSockets) { ASSERT_SYS(EPERM, -1, setsockopt(3, SOL_SOCKET, SO_TIMESTAMP, &yes, 4)); struct sockaddr_in sin = {AF_INET, 0, {htonl(0x7f000001)}}; ASSERT_SYS(0, 0, bind(4, (struct sockaddr *)&sin, sizeof(sin))); + struct sockaddr_in6 sin6 = {.sin6_family = AF_INET6, + .sin6_addr.s6_addr[15] = 1}; + ASSERT_SYS(0, 0, bind(6, (struct sockaddr *)&sin6, sizeof(sin6))); uint32_t az = sizeof(sin); ASSERT_SYS(0, 0, getsockname(4, (struct sockaddr *)&sin, &az)); ASSERT_SYS(0, 5, diff --git a/third_party/getopt/getopt.h b/third_party/getopt/getopt.h index 22ecf6ded..90572bc23 100644 --- a/third_party/getopt/getopt.h +++ b/third_party/getopt/getopt.h @@ -1,5 +1,6 @@ #ifndef COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_ #define COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_ +#ifdef COSMO #define no_argument 0 #define required_argument 1 @@ -27,4 +28,5 @@ int getopt_long_only(int, char *const *, const char *, const struct option *, COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMO */ #endif /* COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_ */ diff --git a/third_party/mbedtls/sha256.c b/third_party/mbedtls/sha256.c index dd1f6674e..3666dfd8b 100644 --- a/third_party/mbedtls/sha256.c +++ b/third_party/mbedtls/sha256.c @@ -15,6 +15,7 @@ โ”‚ See the License for the specific language governing permissions and โ”‚ โ”‚ limitations under the License. โ”‚ โ•šโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*/ +#include "third_party/mbedtls/sha256.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/macros.internal.h" @@ -26,7 +27,6 @@ #include "third_party/mbedtls/endian.h" #include "third_party/mbedtls/error.h" #include "third_party/mbedtls/md.h" -#include "third_party/mbedtls/sha256.h" asm(".ident\t\"\\n\\n\ Mbed TLS (Apache 2.0)\\n\ @@ -476,12 +476,12 @@ exit: return( ret ); } -noinstrument int mbedtls_sha256_ret_224( const void *input, size_t ilen, unsigned char *output ) +dontinstrument int mbedtls_sha256_ret_224( const void *input, size_t ilen, unsigned char *output ) { return mbedtls_sha256_ret( input, ilen, output, true ); } -noinstrument int mbedtls_sha256_ret_256( const void *input, size_t ilen, unsigned char *output ) +dontinstrument int mbedtls_sha256_ret_256( const void *input, size_t ilen, unsigned char *output ) { return mbedtls_sha256_ret( input, ilen, output, false ); } diff --git a/third_party/mbedtls/sha512.c b/third_party/mbedtls/sha512.c index 7561e3e51..c47dd8d5a 100644 --- a/third_party/mbedtls/sha512.c +++ b/third_party/mbedtls/sha512.c @@ -15,6 +15,7 @@ โ”‚ See the License for the specific language governing permissions and โ”‚ โ”‚ limitations under the License. โ”‚ โ•šโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*/ +#include "third_party/mbedtls/sha512.h" #include "libc/intrin/asan.internal.h" #include "libc/literal.h" #include "libc/macros.internal.h" @@ -27,7 +28,6 @@ #include "third_party/mbedtls/error.h" #include "third_party/mbedtls/md.h" #include "third_party/mbedtls/platform.h" -#include "third_party/mbedtls/sha512.h" asm(".ident\t\"\\n\\n\ Mbed TLS (Apache 2.0)\\n\ @@ -419,12 +419,12 @@ cleanup: return( ret ); } -noinstrument int mbedtls_sha512_ret_384( const void *input, size_t ilen, unsigned char *output ) +dontinstrument int mbedtls_sha512_ret_384( const void *input, size_t ilen, unsigned char *output ) { return mbedtls_sha512_ret( input, ilen, output, true ); } -noinstrument int mbedtls_sha512_ret_512( const void *input, size_t ilen, unsigned char *output ) +dontinstrument int mbedtls_sha512_ret_512( const void *input, size_t ilen, unsigned char *output ) { return mbedtls_sha512_ret( input, ilen, output, false ); } diff --git a/third_party/puff/puff.c b/third_party/puff/puff.c index d79a48086..2aac09ad7 100644 --- a/third_party/puff/puff.c +++ b/third_party/puff/puff.c @@ -22,8 +22,8 @@ โ”‚ โ”‚ โ”‚ Mark Adler madler@alumni.caltech.edu โ”‚ โ•šโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*/ -#include "libc/runtime/runtime.h" #include "third_party/puff/puff.h" +#include "libc/runtime/runtime.h" // clang-format off asm(".ident\t\"\\n\\n\ @@ -158,7 +158,7 @@ struct state { * buffer, using shift right, and new bytes are appended to the top of the * bit buffer, using shift left. */ -local noinstrument int bits(struct state *s, int need) +local dontinstrument int bits(struct state *s, int need) { long val; /* bit accumulator (can use up to 20 bits) */ diff --git a/tool/emacs/c.lang b/tool/emacs/c.lang index ceae3bb10..0177782db 100644 --- a/tool/emacs/c.lang +++ b/tool/emacs/c.lang @@ -83,7 +83,6 @@ Keywords={ "__msabi", "offsetof", "microarchitecture", -"targetclones", "forcealignargpointer", "textexit", "externinline", @@ -125,7 +124,7 @@ Keywords={ "noreturn", "initarray", "mayalias", -"noinstrument", +"dontinstrument", "interruptfn", "nocallback", "textstartup", diff --git a/tool/emacs/cosmo-c-keywords.el b/tool/emacs/cosmo-c-keywords.el index 3c864dbad..269108d8b 100644 --- a/tool/emacs/cosmo-c-keywords.el +++ b/tool/emacs/cosmo-c-keywords.el @@ -29,8 +29,7 @@ "__funline" "function" "offsetof" - "microarchitecture" - "targetclones" + "_Microarchitecture" "forcealignargpointer" "textexit" "externinline" @@ -59,7 +58,8 @@ "antiquity" "memcpyesque" "libcesque" - "artificial" + "unrollloops" + "__artificial" "returnstwice" "returnsaligned" "noprune" @@ -78,7 +78,7 @@ "nostackprotector" "initarray" "mayalias" - "noinstrument" + "dontinstrument" "interruptfn" "nocallback" "textstartup" diff --git a/tool/emacs/key.py b/tool/emacs/key.py index 5ba8c66f0..18ca0e31a 100644 --- a/tool/emacs/key.py +++ b/tool/emacs/key.py @@ -347,7 +347,7 @@ cosmo_kws = frozenset([ "nodebuginfo", "dontdiscard", "dontinline", - "noinstrument", + "dontinstrument", "nointerpose", "dontoptimize", "noprune", diff --git a/tool/plinko/lib/char.h b/tool/plinko/lib/char.h index e1cb4d93c..d287ee4a9 100644 --- a/tool/plinko/lib/char.h +++ b/tool/plinko/lib/char.h @@ -27,7 +27,7 @@ static inline pureconst bool IsControl(int c) { return (0 <= c && c <= 0x1F) || (0x7F <= c && c <= 0x9F); } -static noinstrument pureconst inline int ToUpper(int c) { +static dontinstrument pureconst inline int ToUpper(int c) { return 'a' <= c && c <= 'z' ? 'A' - 'a' + c : c; } diff --git a/tool/plinko/lib/read.c b/tool/plinko/lib/read.c index 0537a08d9..468989a89 100644 --- a/tool/plinko/lib/read.c +++ b/tool/plinko/lib/read.c @@ -32,7 +32,7 @@ static int Read1(int); static int Read2(int); -noinstrument int ReadSpaces(int fd) { +dontinstrument int ReadSpaces(int fd) { size_t n; ssize_t rc; for (;;) { @@ -64,13 +64,13 @@ noinstrument int ReadSpaces(int fd) { } } -noinstrument int ReadByte(int fd) { +dontinstrument int ReadByte(int fd) { int c; if ((c = g_buffer[fd][bp[fd]++] & 255)) return c; return ReadSpaces(fd); } -noinstrument int ReadChar(int fd) { +dontinstrument int ReadChar(int fd) { int b, a = dx; for (;;) { dx = ReadByte(fd); diff --git a/tool/viz/derasterize.c b/tool/viz/derasterize.c index d7f32eebf..5f1e0391a 100644 --- a/tool/viz/derasterize.c +++ b/tool/viz/derasterize.c @@ -312,8 +312,8 @@ static unsigned combinecolors(unsigned char bf[1u << MC][2], return r; \ } -ADJUDICATE(adjudicate_avx2, microarchitecture("avx2,fma")) -ADJUDICATE(adjudicate_avx, microarchitecture("avx")) +ADJUDICATE(adjudicate_avx2, _Microarchitecture("avx2,fma")) +ADJUDICATE(adjudicate_avx, _Microarchitecture("avx")) ADJUDICATE(adjudicate_default, ) static float (*adjudicate_hook)(unsigned, unsigned, unsigned,