mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Get GCC to mostly build with Cosmo
This commit is contained in:
parent
2eb7148474
commit
9b55dbe417
54 changed files with 113 additions and 132 deletions
2
.vscode/c_cpp_properties.json
vendored
2
.vscode/c_cpp_properties.json
vendored
|
@ -36,7 +36,7 @@
|
|||
"textwindows=",
|
||||
"privileged=",
|
||||
"compatfn=",
|
||||
"noinstrument=",
|
||||
"dontinstrument=",
|
||||
"nodebuginfo=",
|
||||
"interruptfn=",
|
||||
"optimizespeed=",
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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]));
|
||||
|
|
|
@ -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 ─╬─│┼
|
||||
|
|
|
@ -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__)
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
2
third_party/getopt/getopt.h
vendored
2
third_party/getopt/getopt.h
vendored
|
@ -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_ */
|
||||
|
|
6
third_party/mbedtls/sha256.c
vendored
6
third_party/mbedtls/sha256.c
vendored
|
@ -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 );
|
||||
}
|
||||
|
|
6
third_party/mbedtls/sha512.c
vendored
6
third_party/mbedtls/sha512.c
vendored
|
@ -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 );
|
||||
}
|
||||
|
|
4
third_party/puff/puff.c
vendored
4
third_party/puff/puff.c
vendored
|
@ -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) */
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -347,7 +347,7 @@ cosmo_kws = frozenset([
|
|||
"nodebuginfo",
|
||||
"dontdiscard",
|
||||
"dontinline",
|
||||
"noinstrument",
|
||||
"dontinstrument",
|
||||
"nointerpose",
|
||||
"dontoptimize",
|
||||
"noprune",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue