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=",
|
"textwindows=",
|
||||||
"privileged=",
|
"privileged=",
|
||||||
"compatfn=",
|
"compatfn=",
|
||||||
"noinstrument=",
|
"dontinstrument=",
|
||||||
"nodebuginfo=",
|
"nodebuginfo=",
|
||||||
"interruptfn=",
|
"interruptfn=",
|
||||||
"optimizespeed=",
|
"optimizespeed=",
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
*
|
*
|
||||||
* @define (a + b) / 2
|
* @define (a + b) / 2
|
||||||
*/
|
*/
|
||||||
static inline pureconst artificial unsigned char C11(unsigned char al,
|
__funline unsigned char C11(unsigned char al, unsigned char bl) {
|
||||||
unsigned char bl) {
|
|
||||||
short ax;
|
short ax;
|
||||||
ax = al;
|
ax = al;
|
||||||
ax += bl;
|
ax += bl;
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||||
COSMOPOLITAN_C_START_
|
COSMOPOLITAN_C_START_
|
||||||
|
|
||||||
forceinline pureconst artificial unsigned char C121(unsigned char al,
|
__funline unsigned char C121(unsigned char al, unsigned char bl,
|
||||||
unsigned char bl,
|
|
||||||
unsigned char cl) {
|
unsigned char cl) {
|
||||||
unsigned short ax, bx;
|
unsigned short ax, bx;
|
||||||
ax = al;
|
ax = al;
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
#define COSMOPOLITAN_DSP_CORE_C121S_H_
|
#define COSMOPOLITAN_DSP_CORE_C121S_H_
|
||||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||||
|
|
||||||
forceinline pureconst artificial signed char C121S(signed char al,
|
__funline signed char C121S(signed char al, signed char bl, signed char cl) {
|
||||||
signed char bl,
|
|
||||||
signed char cl) {
|
|
||||||
short ax, bx;
|
short ax, bx;
|
||||||
ax = al;
|
ax = al;
|
||||||
ax += bl;
|
ax += bl;
|
||||||
|
|
|
@ -9,10 +9,8 @@
|
||||||
* @see C161() afterward for superior sin(𝑥)/𝑥
|
* @see C161() afterward for superior sin(𝑥)/𝑥
|
||||||
* @limit [0,255] → [0..2,044] → [0..255]
|
* @limit [0,255] → [0..2,044] → [0..255]
|
||||||
*/
|
*/
|
||||||
forceinline pureconst artificial unsigned char C1331(unsigned char al,
|
__funline unsigned char C1331(unsigned char al, unsigned char bl,
|
||||||
unsigned char bl,
|
unsigned char cl, unsigned char dl) {
|
||||||
unsigned char cl,
|
|
||||||
unsigned char dl) {
|
|
||||||
short ax, bx;
|
short ax, bx;
|
||||||
bx = bl;
|
bx = bl;
|
||||||
bx += cl;
|
bx += cl;
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
* @define (1*(a-128)+3*(a-128)+3*(a-128)+1*(a-128))/(1+3+3+1)+128
|
* @define (1*(a-128)+3*(a-128)+3*(a-128)+1*(a-128))/(1+3+3+1)+128
|
||||||
* @see C1331(), Y420CbCr2RgbScale()
|
* @see C1331(), Y420CbCr2RgbScale()
|
||||||
*/
|
*/
|
||||||
forceinline pureconst artificial signed char C1331S(signed char al,
|
__funline signed char C1331S(signed char al, signed char bl, signed char cl,
|
||||||
signed char bl,
|
|
||||||
signed char cl,
|
|
||||||
signed char dl) {
|
signed char dl) {
|
||||||
short ax, bx;
|
short ax, bx;
|
||||||
bx = bl;
|
bx = bl;
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
* @limit [0..255] → [-510..1,532] → [-127..383] → [0..255]
|
* @limit [0..255] → [-510..1,532] → [-127..383] → [0..255]
|
||||||
* @see C1331()
|
* @see C1331()
|
||||||
*/
|
*/
|
||||||
forceinline pureconst artificial unsigned char C161(unsigned char al,
|
__funline unsigned char C161(unsigned char al, unsigned char bl,
|
||||||
unsigned char bl,
|
|
||||||
unsigned char cl) {
|
unsigned char cl) {
|
||||||
short ax, bx, cx;
|
short ax, bx, cx;
|
||||||
ax = al;
|
ax = al;
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
#include "libc/macros.internal.h"
|
#include "libc/macros.internal.h"
|
||||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||||
|
|
||||||
forceinline pureconst artificial signed char C161S(signed char al,
|
__funline signed char C161S(signed char al, signed char bl, signed char cl) {
|
||||||
signed char bl,
|
|
||||||
signed char cl) {
|
|
||||||
short ax, bx, cx;
|
short ax, bx, cx;
|
||||||
ax = al;
|
ax = al;
|
||||||
bx = bl;
|
bx = bl;
|
||||||
|
|
|
@ -9,8 +9,7 @@ COSMOPOLITAN_C_START_
|
||||||
* @define (3*a + 3*b + 1*c) / 7
|
* @define (3*a + 3*b + 1*c) / 7
|
||||||
* @see C1331()
|
* @see C1331()
|
||||||
*/
|
*/
|
||||||
static inline pureconst artificial unsigned char C331(unsigned char al,
|
__funline unsigned char C331(unsigned char al, unsigned char bl,
|
||||||
unsigned char bl,
|
|
||||||
unsigned char cl) {
|
unsigned char cl) {
|
||||||
unsigned eax, ebx, ecx;
|
unsigned eax, ebx, ecx;
|
||||||
eax = al;
|
eax = al;
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
*
|
*
|
||||||
* @see round(), rint()
|
* @see round(), rint()
|
||||||
*/
|
*/
|
||||||
static inline pureconst artificial long ituround(double x) {
|
__funline long ituround(double x) {
|
||||||
return floor(x + .5);
|
return floor(x + .5);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline pureconst artificial int ituroundf(float x) {
|
__funline int ituroundf(float x) {
|
||||||
return floorf(x + .5f);
|
return floorf(x + .5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,7 @@ COSMOPOLITAN_C_START_
|
||||||
/**
|
/**
|
||||||
* 8-bit linear interpolation kernel.
|
* 8-bit linear interpolation kernel.
|
||||||
*/
|
*/
|
||||||
static inline pureconst artificial unsigned char twixt8(unsigned char al,
|
__funline unsigned char twixt8(unsigned char al, unsigned char bl,
|
||||||
unsigned char bl,
|
|
||||||
unsigned char p) {
|
unsigned char p) {
|
||||||
short bx;
|
short bx;
|
||||||
bx = bl;
|
bx = bl;
|
||||||
|
|
|
@ -7,12 +7,11 @@ COSMOPOLITAN_C_START_
|
||||||
int dprintf(int, const char *, ...) printfesque(2) paramsnonnull((2));
|
int dprintf(int, const char *, ...) printfesque(2) paramsnonnull((2));
|
||||||
int vdprintf(int, const char *, va_list) paramsnonnull();
|
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 dprintf(FD, FMT, ...) (dprintf)(FD, PFLINK(FMT), ##__VA_ARGS__)
|
||||||
#define vdprintf(FD, FMT, VA) (vdprintf)(FD, PFLINK(FMT), VA)
|
#define vdprintf(FD, FMT, VA) (vdprintf)(FD, PFLINK(FMT), VA)
|
||||||
|
|
||||||
#endif /* GNU && !ANSI */
|
#endif /* GNU && !ANSI */
|
||||||
|
|
||||||
COSMOPOLITAN_C_END_
|
COSMOPOLITAN_C_END_
|
||||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||||
#endif /* COSMOPOLITAN_LIBC_CALLS_DPRINTF_H_ */
|
#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(GetExitCodeProcess) *const __imp_GetExitCodeProcess;
|
||||||
__msabi extern typeof(UnmapViewOfFile) *const __imp_UnmapViewOfFile;
|
__msabi extern typeof(UnmapViewOfFile) *const __imp_UnmapViewOfFile;
|
||||||
|
|
||||||
static noinstrument __msabi bool32
|
static dontinstrument __msabi bool32
|
||||||
BlockExecveConsoleEvent(uint32_t dwCtrlType) {
|
BlockExecveConsoleEvent(uint32_t dwCtrlType) {
|
||||||
// block SIGINT and SIGQUIT in execve() parent process
|
// block SIGINT and SIGQUIT in execve() parent process
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -67,7 +67,7 @@ getcontext:
|
||||||
|
|
||||||
.end
|
.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%%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%%xmm1,%0" : /* no outputs */ : "m"(uc->__fpustate.xmm[1]));
|
||||||
asm volatile("movaps\t%%xmm2,%0" : /* no outputs */ : "m"(uc->__fpustate.xmm[2]));
|
asm volatile("movaps\t%%xmm2,%0" : /* no outputs */ : "m"(uc->__fpustate.xmm[2]));
|
||||||
|
|
|
@ -78,10 +78,12 @@ libcesque nosideeffect;
|
||||||
│ cosmopolitan § conversion » manipulation ─╬─│┼
|
│ cosmopolitan § conversion » manipulation ─╬─│┼
|
||||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||||
|
|
||||||
|
#ifdef COSMO
|
||||||
char *dirname(char *);
|
char *dirname(char *);
|
||||||
char *basename(char *);
|
char *basename(char *);
|
||||||
char *stripext(char *);
|
char *stripext(char *);
|
||||||
char *stripexts(char *);
|
char *stripexts(char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||||
│ cosmopolitan § conversion » computation ─╬─│┼
|
│ cosmopolitan § conversion » computation ─╬─│┼
|
||||||
|
|
|
@ -35,7 +35,7 @@ char *gcvt(double, int, char *);
|
||||||
│ cosmopolitan § string formatting » optimizations ─╬─│┼
|
│ 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 sprintf(BUF, FMT, ...) (sprintf)(BUF, PFLINK(FMT), ##__VA_ARGS__)
|
||||||
#define vsprintf(BUF, FMT, VA) (vsprintf)(BUF, PFLINK(FMT), VA)
|
#define vsprintf(BUF, FMT, VA) (vsprintf)(BUF, PFLINK(FMT), VA)
|
||||||
#define snprintf(B, Z, F, ...) (snprintf)(B, Z, PFLINK(F), ##__VA_ARGS__)
|
#define snprintf(B, Z, F, ...) (snprintf)(B, Z, PFLINK(F), ##__VA_ARGS__)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef COSMOPOLITAN_LIBC_FMT_PFLINK_H_
|
#ifndef COSMOPOLITAN_LIBC_FMT_PFLINK_H_
|
||||||
#define COSMOPOLITAN_LIBC_FMT_PFLINK_H_
|
#define COSMOPOLITAN_LIBC_FMT_PFLINK_H_
|
||||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||||
|
#ifdef COSMO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fileoverview builtin+preprocessor+linker tricks for printf/scanf.
|
* @fileoverview builtin+preprocessor+linker tricks for printf/scanf.
|
||||||
|
@ -59,5 +60,12 @@
|
||||||
#pragma GCC diagnostic ignored "-Wformat-security"
|
#pragma GCC diagnostic ignored "-Wformat-security"
|
||||||
#endif /* __GNUC__ + 0 < 6 */
|
#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 /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||||
#endif /* COSMOPOLITAN_LIBC_FMT_PFLINK_H_ */
|
#endif /* COSMOPOLITAN_LIBC_FMT_PFLINK_H_ */
|
||||||
|
|
|
@ -208,13 +208,13 @@ typedef struct {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef noinstrument
|
#ifndef dontinstrument
|
||||||
#if !defined(__STRICT_ANSI__) && \
|
#if !defined(__STRICT_ANSI__) && \
|
||||||
(__has_attribute(__no_instrument_function__) || \
|
(__has_attribute(__no_instrument_function__) || \
|
||||||
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 204)
|
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 204)
|
||||||
#define noinstrument __attribute__((__no_instrument_function__))
|
#define dontinstrument __attribute__((__no_instrument_function__))
|
||||||
#else
|
#else
|
||||||
#define noinstrument
|
#define dontinstrument
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -485,32 +485,13 @@ typedef struct {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef artificial
|
#ifndef _Microarchitecture
|
||||||
#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
|
|
||||||
#if !defined(__STRICT_ANSI__) && \
|
#if !defined(__STRICT_ANSI__) && \
|
||||||
(__has_attribute(__target__) || \
|
(__has_attribute(__target__) || \
|
||||||
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 404)
|
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 404)
|
||||||
#define microarchitecture(march) __attribute__((__target__(march)))
|
#define _Microarchitecture(march) __attribute__((__target__(march)))
|
||||||
#else
|
#else
|
||||||
#define microarchitecture(march)
|
#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)
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -629,8 +610,8 @@ void abort(void) wontreturn;
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#ifndef __STRICT_ANSI__
|
#ifndef __STRICT_ANSI__
|
||||||
#define textstartup _Section(".text.startup") noinstrument
|
#define textstartup _Section(".text.startup") dontinstrument
|
||||||
#define textexit _Section(".text.exit") noinstrument
|
#define textexit _Section(".text.exit") dontinstrument
|
||||||
#define textreal _Section(".text.real")
|
#define textreal _Section(".text.real")
|
||||||
#define texthead _Section(".text.head")
|
#define texthead _Section(".text.head")
|
||||||
#define textwindows _Section(".text.windows")
|
#define textwindows _Section(".text.windows")
|
||||||
|
|
|
@ -44,7 +44,7 @@ static void bzero128(char *p, size_t n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#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};
|
xmm_t v = {0};
|
||||||
if (IsAsan()) __asan_verify(p, n);
|
if (IsAsan()) __asan_verify(p, n);
|
||||||
if (n <= 32) {
|
if (n <= 32) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ static dontinline antiquity int memcmp_sse(const unsigned char *p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
microarchitecture("avx") static int memcmp_avx(const unsigned char *p,
|
_Microarchitecture("avx") static int memcmp_avx(const unsigned char *p,
|
||||||
const unsigned char *q,
|
const unsigned char *q,
|
||||||
size_t n) {
|
size_t n) {
|
||||||
uint64_t w;
|
uint64_t w;
|
||||||
|
|
|
@ -46,7 +46,7 @@ static void *memset_sse(char *p, char c, size_t n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#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;
|
char *t;
|
||||||
xmm_t v = {c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c};
|
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);
|
if (IsAsan()) __asan_verify(p, n);
|
||||||
|
|
|
@ -35,7 +35,7 @@ const unsigned char kConsoleHandles[3] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Puts cmd.exe gui back the way it was.
|
// Puts cmd.exe gui back the way it was.
|
||||||
privileged noinstrument void _restorewintty(void) {
|
privileged dontinstrument void _restorewintty(void) {
|
||||||
if (!IsWindows()) return;
|
if (!IsWindows()) return;
|
||||||
if (__imp_GetCurrentProcessId() != __pid_exec) return;
|
if (__imp_GetCurrentProcessId() != __pid_exec) return;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
|
|
@ -45,9 +45,8 @@
|
||||||
* @param st is open symbol table for current executable
|
* @param st is open symbol table for current executable
|
||||||
* @return -1 w/ errno if error happened
|
* @return -1 w/ errno if error happened
|
||||||
*/
|
*/
|
||||||
noinstrument noasan int PrintBacktraceUsingSymbols(int fd,
|
dontinstrument noasan int PrintBacktraceUsingSymbols(
|
||||||
const struct StackFrame *bp,
|
int fd, const struct StackFrame *bp, struct SymbolTable *st) {
|
||||||
struct SymbolTable *st) {
|
|
||||||
bool ok;
|
bool ok;
|
||||||
size_t gi;
|
size_t gi;
|
||||||
intptr_t addr;
|
intptr_t addr;
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
#include "libc/errno.h"
|
#include "libc/errno.h"
|
||||||
#include "libc/log/log.h"
|
#include "libc/log/log.h"
|
||||||
|
|
||||||
noinstrument int _log_get_errno(void) {
|
dontinstrument int _log_get_errno(void) {
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
#include "libc/log/log.h"
|
#include "libc/log/log.h"
|
||||||
#include "libc/runtime/runtime.h"
|
#include "libc/runtime/runtime.h"
|
||||||
|
|
||||||
noinstrument void _log_retrace(void) {
|
dontinstrument void _log_retrace(void) {
|
||||||
ftrace_enabled(+1);
|
ftrace_enabled(+1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
#include "libc/errno.h"
|
#include "libc/errno.h"
|
||||||
#include "libc/log/log.h"
|
#include "libc/log/log.h"
|
||||||
|
|
||||||
noinstrument void _log_set_errno(int e) {
|
dontinstrument void _log_set_errno(int e) {
|
||||||
errno = e;
|
errno = e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
#include "libc/log/log.h"
|
#include "libc/log/log.h"
|
||||||
#include "libc/runtime/runtime.h"
|
#include "libc/runtime/runtime.h"
|
||||||
|
|
||||||
noinstrument void _log_untrace(void) {
|
dontinstrument void _log_untrace(void) {
|
||||||
ftrace_enabled(-1);
|
ftrace_enabled(-1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,6 @@
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
#include "libc/str/str.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));
|
flogf(kLogWarn, file, line, NULL, PFLINK("%s → %s"), form, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,7 +254,7 @@ relegated void ShowCrashReport(int err, int sig, struct siginfo *si,
|
||||||
kprintf("\n");
|
kprintf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static wontreturn relegated noinstrument void __minicrash(int sig,
|
static wontreturn relegated dontinstrument void __minicrash(int sig,
|
||||||
struct siginfo *si,
|
struct siginfo *si,
|
||||||
ucontext_t *ctx,
|
ucontext_t *ctx,
|
||||||
const char *kind) {
|
const char *kind) {
|
||||||
|
|
|
@ -33,14 +33,14 @@ static char __watch_last[4096];
|
||||||
|
|
||||||
void __watch_hook(void);
|
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;
|
size_t i;
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
p[i] = q[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;
|
int c;
|
||||||
if (n == 8) return READ64LE(p) != READ64LE(q);
|
if (n == 8) return READ64LE(p) != READ64LE(q);
|
||||||
if (n == 4) return READ32LE(p) != READ32LE(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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
noinstrument void __watcher(void) {
|
dontinstrument void __watcher(void) {
|
||||||
if (__watch_busy) return;
|
if (__watch_busy) return;
|
||||||
__watch_busy = true;
|
__watch_busy = true;
|
||||||
if (Cmp(__watch_last, __watch_addr, __watch_size)) {
|
if (Cmp(__watch_last, __watch_addr, __watch_size)) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ int asprintf(char **, const char *, ...) printfesque(2)
|
||||||
paramsnonnull((1, 2)) libcesque;
|
paramsnonnull((1, 2)) libcesque;
|
||||||
int vasprintf(char **, const char *, va_list) paramsnonnull() 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 asprintf(SP, FMT, ...) (asprintf)(SP, PFLINK(FMT), ##__VA_ARGS__)
|
||||||
#define vasprintf(SP, FMT, VA) (vasprintf)(SP, PFLINK(FMT), VA)
|
#define vasprintf(SP, FMT, VA) (vasprintf)(SP, PFLINK(FMT), VA)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -111,7 +111,7 @@ int WinThreadLaunch(void *arg, // rdi
|
||||||
// 2. windows owns the stack memory right now
|
// 2. windows owns the stack memory right now
|
||||||
// we need win32 raw imports because:
|
// we need win32 raw imports because:
|
||||||
// 1. generated thunks are function logged
|
// 1. generated thunks are function logged
|
||||||
noasan noinstrument static textwindows wontreturn void //
|
noasan dontinstrument static textwindows wontreturn void //
|
||||||
WinThreadEntry(int rdi, // rcx
|
WinThreadEntry(int rdi, // rcx
|
||||||
int rsi, // rdx
|
int rsi, // rdx
|
||||||
int rdx, // r8
|
int rdx, // r8
|
||||||
|
|
|
@ -37,9 +37,8 @@ forceinline char *MemChr(const char *s, unsigned char c, unsigned long n) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static textwindows noasan noinstrument axdx_t Recode16to8(char *dst,
|
static textwindows noasan dontinstrument axdx_t
|
||||||
size_t dstsize,
|
Recode16to8(char *dst, size_t dstsize, const char16_t *src) {
|
||||||
const char16_t *src) {
|
|
||||||
bool v;
|
bool v;
|
||||||
axdx_t r;
|
axdx_t r;
|
||||||
uint64_t w;
|
uint64_t w;
|
||||||
|
@ -72,7 +71,7 @@ static textwindows noasan noinstrument axdx_t Recode16to8(char *dst,
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
textwindows noinstrument noasan void FixPath(char *path) {
|
textwindows dontinstrument noasan void FixPath(char *path) {
|
||||||
char *p;
|
char *p;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
@ -112,7 +111,7 @@ textwindows noinstrument noasan void FixPath(char *path) {
|
||||||
// @param envp stores NULL-terminated string pointer list (optional)
|
// @param envp stores NULL-terminated string pointer list (optional)
|
||||||
// @param max is the pointer count capacity of envp
|
// @param max is the pointer count capacity of envp
|
||||||
// @return number of variables decoded, excluding NULL-terminator
|
// @return number of variables decoded, excluding NULL-terminator
|
||||||
textwindows noasan noinstrument int GetDosEnviron(const char16_t *env,
|
textwindows noasan dontinstrument int GetDosEnviron(const char16_t *env,
|
||||||
char *buf, size_t size,
|
char *buf, size_t size,
|
||||||
char **envp, size_t max) {
|
char **envp, size_t max) {
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -27,7 +27,7 @@ extern _Hide struct SymbolTable *__symtab;
|
||||||
* @param t if null will be auto-populated only if already open
|
* @param t if null will be auto-populated only if already open
|
||||||
* @return index or -1 if nothing found
|
* @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:
|
// we need privileged because:
|
||||||
// kprintf is privileged and it depends on this
|
// kprintf is privileged and it depends on this
|
||||||
// we don't want function tracing because:
|
// we don't want function tracing because:
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/runtime/symbols.internal.h"
|
#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) {
|
struct SymbolTable *t, int s) {
|
||||||
/* asan runtime depends on this function */
|
/* asan runtime depends on this function */
|
||||||
if (t && s != -1) {
|
if (t && s != -1) {
|
||||||
|
|
|
@ -106,7 +106,8 @@ static privileged void HookFunction(code_t *func, void *dest) {
|
||||||
* @param st can be obtained using `GetSymbolTable()`
|
* @param st can be obtained using `GetSymbolTable()`
|
||||||
* @see ape/ape.lds
|
* @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;
|
long i;
|
||||||
sigset_t mask;
|
sigset_t mask;
|
||||||
code_t *p, *pe;
|
code_t *p, *pe;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/intrin/kprintf.h"
|
#include "libc/intrin/kprintf.h"
|
||||||
|
|
||||||
privileged noasan noinstrument void __stack_chk_fail(void) {
|
void __stack_chk_fail(void) {
|
||||||
kprintf("stack smashed\n");
|
kprintf("stack smashed\n");
|
||||||
__builtin_trap();
|
__builtin_trap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ int vfprintf_unlocked(FILE *, const char *, va_list)
|
||||||
│ cosmopolitan § standard i/o » optimizations ─╬─│┼
|
│ cosmopolitan § standard i/o » optimizations ─╬─│┼
|
||||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
#if defined(COSMO) && !defined(__cplusplus)
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
#define printf(FMT, ...) (printf)(PFLINK(FMT), ##__VA_ARGS__)
|
#define printf(FMT, ...) (printf)(PFLINK(FMT), ##__VA_ARGS__)
|
||||||
#define vprintf(FMT, VA) (vprintf)(PFLINK(FMT), VA)
|
#define vprintf(FMT, VA) (vprintf)(PFLINK(FMT), VA)
|
||||||
|
|
|
@ -38,7 +38,7 @@ static int bcmp_sse(const char *p, const char *q, size_t n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
microarchitecture("avx") static int bcmp_avx(const char *p, const char *q,
|
_Microarchitecture("avx") static int bcmp_avx(const char *p, const char *q,
|
||||||
size_t n) {
|
size_t n) {
|
||||||
xmm_t a, b, c, d;
|
xmm_t a, b, c, d;
|
||||||
if (n > 32) {
|
if (n > 32) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ noasan static unsigned timingsafe_bcmp_sse(const char *p, const char *q,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
noasan static microarchitecture("avx") int timingsafe_bcmp_avx(const char *p,
|
noasan static _Microarchitecture("avx") int timingsafe_bcmp_avx(const char *p,
|
||||||
const char *q,
|
const char *q,
|
||||||
size_t n) {
|
size_t n) {
|
||||||
uint64_t w;
|
uint64_t w;
|
||||||
|
|
|
@ -60,7 +60,7 @@ C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */
|
||||||
C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */
|
C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */
|
||||||
C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */
|
C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */
|
||||||
|
|
||||||
noinstrument float __cosdf(double x)
|
dontinstrument float __cosdf(double x)
|
||||||
{
|
{
|
||||||
double_t r, w, z;
|
double_t r, w, z;
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ S2 = 0x111110896efbb2.0p-59, /* 0.0083333293858894631756 */
|
||||||
S3 = -0x1a00f9e2cae774.0p-65, /* -0.000198393348360966317347 */
|
S3 = -0x1a00f9e2cae774.0p-65, /* -0.000198393348360966317347 */
|
||||||
S4 = 0x16cd878c3b46a7.0p-71; /* 0.0000027183114939898219064 */
|
S4 = 0x16cd878c3b46a7.0p-71; /* 0.0000027183114939898219064 */
|
||||||
|
|
||||||
noinstrument float __sindf(double x)
|
dontinstrument float __sindf(double x)
|
||||||
{
|
{
|
||||||
double_t r, s, w, z;
|
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()
|
char *xvasprintf(const char *, va_list) paramsnonnull()
|
||||||
returnspointerwithnoaliases dontthrow nocallback dontdiscard returnsnonnull;
|
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 xasprintf(FMT, ...) (xasprintf)(PFLINK(FMT), ##__VA_ARGS__)
|
||||||
#define xvasprintf(FMT, VA) (xvasprintf)(PFLINK(FMT), VA)
|
#define xvasprintf(FMT, VA) (xvasprintf)(PFLINK(FMT), VA)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "libc/runtime/runtime.h"
|
#include "libc/runtime/runtime.h"
|
||||||
#include "libc/sock/sock.h"
|
#include "libc/sock/sock.h"
|
||||||
#include "libc/sock/struct/sockaddr.h"
|
#include "libc/sock/struct/sockaddr.h"
|
||||||
|
#include "libc/sock/struct/sockaddr6.h"
|
||||||
#include "libc/stdio/lock.internal.h"
|
#include "libc/stdio/lock.internal.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
#include "libc/sysv/consts/af.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));
|
ASSERT_SYS(EPERM, -1, setsockopt(3, SOL_SOCKET, SO_TIMESTAMP, &yes, 4));
|
||||||
struct sockaddr_in sin = {AF_INET, 0, {htonl(0x7f000001)}};
|
struct sockaddr_in sin = {AF_INET, 0, {htonl(0x7f000001)}};
|
||||||
ASSERT_SYS(0, 0, bind(4, (struct sockaddr *)&sin, sizeof(sin)));
|
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);
|
uint32_t az = sizeof(sin);
|
||||||
ASSERT_SYS(0, 0, getsockname(4, (struct sockaddr *)&sin, &az));
|
ASSERT_SYS(0, 0, getsockname(4, (struct sockaddr *)&sin, &az));
|
||||||
ASSERT_SYS(0, 5,
|
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_
|
#ifndef COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_
|
||||||
#define COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_
|
#define COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_
|
||||||
|
#ifdef COSMO
|
||||||
|
|
||||||
#define no_argument 0
|
#define no_argument 0
|
||||||
#define required_argument 1
|
#define required_argument 1
|
||||||
|
@ -27,4 +28,5 @@ int getopt_long_only(int, char *const *, const char *, const struct option *,
|
||||||
|
|
||||||
COSMOPOLITAN_C_END_
|
COSMOPOLITAN_C_END_
|
||||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||||
|
#endif /* COSMO */
|
||||||
#endif /* COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_ */
|
#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 │
|
│ See the License for the specific language governing permissions and │
|
||||||
│ limitations under the License. │
|
│ limitations under the License. │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
|
#include "third_party/mbedtls/sha256.h"
|
||||||
#include "libc/dce.h"
|
#include "libc/dce.h"
|
||||||
#include "libc/intrin/asan.internal.h"
|
#include "libc/intrin/asan.internal.h"
|
||||||
#include "libc/macros.internal.h"
|
#include "libc/macros.internal.h"
|
||||||
|
@ -26,7 +27,6 @@
|
||||||
#include "third_party/mbedtls/endian.h"
|
#include "third_party/mbedtls/endian.h"
|
||||||
#include "third_party/mbedtls/error.h"
|
#include "third_party/mbedtls/error.h"
|
||||||
#include "third_party/mbedtls/md.h"
|
#include "third_party/mbedtls/md.h"
|
||||||
#include "third_party/mbedtls/sha256.h"
|
|
||||||
|
|
||||||
asm(".ident\t\"\\n\\n\
|
asm(".ident\t\"\\n\\n\
|
||||||
Mbed TLS (Apache 2.0)\\n\
|
Mbed TLS (Apache 2.0)\\n\
|
||||||
|
@ -476,12 +476,12 @@ exit:
|
||||||
return( ret );
|
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 );
|
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 );
|
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 │
|
│ See the License for the specific language governing permissions and │
|
||||||
│ limitations under the License. │
|
│ limitations under the License. │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
|
#include "third_party/mbedtls/sha512.h"
|
||||||
#include "libc/intrin/asan.internal.h"
|
#include "libc/intrin/asan.internal.h"
|
||||||
#include "libc/literal.h"
|
#include "libc/literal.h"
|
||||||
#include "libc/macros.internal.h"
|
#include "libc/macros.internal.h"
|
||||||
|
@ -27,7 +28,6 @@
|
||||||
#include "third_party/mbedtls/error.h"
|
#include "third_party/mbedtls/error.h"
|
||||||
#include "third_party/mbedtls/md.h"
|
#include "third_party/mbedtls/md.h"
|
||||||
#include "third_party/mbedtls/platform.h"
|
#include "third_party/mbedtls/platform.h"
|
||||||
#include "third_party/mbedtls/sha512.h"
|
|
||||||
|
|
||||||
asm(".ident\t\"\\n\\n\
|
asm(".ident\t\"\\n\\n\
|
||||||
Mbed TLS (Apache 2.0)\\n\
|
Mbed TLS (Apache 2.0)\\n\
|
||||||
|
@ -419,12 +419,12 @@ cleanup:
|
||||||
return( ret );
|
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 );
|
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 );
|
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 │
|
│ Mark Adler madler@alumni.caltech.edu │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/runtime/runtime.h"
|
|
||||||
#include "third_party/puff/puff.h"
|
#include "third_party/puff/puff.h"
|
||||||
|
#include "libc/runtime/runtime.h"
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
asm(".ident\t\"\\n\\n\
|
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
|
* buffer, using shift right, and new bytes are appended to the top of the
|
||||||
* bit buffer, using shift left.
|
* 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) */
|
long val; /* bit accumulator (can use up to 20 bits) */
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,6 @@ Keywords={
|
||||||
"__msabi",
|
"__msabi",
|
||||||
"offsetof",
|
"offsetof",
|
||||||
"microarchitecture",
|
"microarchitecture",
|
||||||
"targetclones",
|
|
||||||
"forcealignargpointer",
|
"forcealignargpointer",
|
||||||
"textexit",
|
"textexit",
|
||||||
"externinline",
|
"externinline",
|
||||||
|
@ -125,7 +124,7 @@ Keywords={
|
||||||
"noreturn",
|
"noreturn",
|
||||||
"initarray",
|
"initarray",
|
||||||
"mayalias",
|
"mayalias",
|
||||||
"noinstrument",
|
"dontinstrument",
|
||||||
"interruptfn",
|
"interruptfn",
|
||||||
"nocallback",
|
"nocallback",
|
||||||
"textstartup",
|
"textstartup",
|
||||||
|
|
|
@ -29,8 +29,7 @@
|
||||||
"__funline"
|
"__funline"
|
||||||
"function"
|
"function"
|
||||||
"offsetof"
|
"offsetof"
|
||||||
"microarchitecture"
|
"_Microarchitecture"
|
||||||
"targetclones"
|
|
||||||
"forcealignargpointer"
|
"forcealignargpointer"
|
||||||
"textexit"
|
"textexit"
|
||||||
"externinline"
|
"externinline"
|
||||||
|
@ -59,7 +58,8 @@
|
||||||
"antiquity"
|
"antiquity"
|
||||||
"memcpyesque"
|
"memcpyesque"
|
||||||
"libcesque"
|
"libcesque"
|
||||||
"artificial"
|
"unrollloops"
|
||||||
|
"__artificial"
|
||||||
"returnstwice"
|
"returnstwice"
|
||||||
"returnsaligned"
|
"returnsaligned"
|
||||||
"noprune"
|
"noprune"
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
"nostackprotector"
|
"nostackprotector"
|
||||||
"initarray"
|
"initarray"
|
||||||
"mayalias"
|
"mayalias"
|
||||||
"noinstrument"
|
"dontinstrument"
|
||||||
"interruptfn"
|
"interruptfn"
|
||||||
"nocallback"
|
"nocallback"
|
||||||
"textstartup"
|
"textstartup"
|
||||||
|
|
|
@ -347,7 +347,7 @@ cosmo_kws = frozenset([
|
||||||
"nodebuginfo",
|
"nodebuginfo",
|
||||||
"dontdiscard",
|
"dontdiscard",
|
||||||
"dontinline",
|
"dontinline",
|
||||||
"noinstrument",
|
"dontinstrument",
|
||||||
"nointerpose",
|
"nointerpose",
|
||||||
"dontoptimize",
|
"dontoptimize",
|
||||||
"noprune",
|
"noprune",
|
||||||
|
|
|
@ -27,7 +27,7 @@ static inline pureconst bool IsControl(int c) {
|
||||||
return (0 <= c && c <= 0x1F) || (0x7F <= c && c <= 0x9F);
|
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;
|
return 'a' <= c && c <= 'z' ? 'A' - 'a' + c : c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
static int Read1(int);
|
static int Read1(int);
|
||||||
static int Read2(int);
|
static int Read2(int);
|
||||||
|
|
||||||
noinstrument int ReadSpaces(int fd) {
|
dontinstrument int ReadSpaces(int fd) {
|
||||||
size_t n;
|
size_t n;
|
||||||
ssize_t rc;
|
ssize_t rc;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -64,13 +64,13 @@ noinstrument int ReadSpaces(int fd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
noinstrument int ReadByte(int fd) {
|
dontinstrument int ReadByte(int fd) {
|
||||||
int c;
|
int c;
|
||||||
if ((c = g_buffer[fd][bp[fd]++] & 255)) return c;
|
if ((c = g_buffer[fd][bp[fd]++] & 255)) return c;
|
||||||
return ReadSpaces(fd);
|
return ReadSpaces(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
noinstrument int ReadChar(int fd) {
|
dontinstrument int ReadChar(int fd) {
|
||||||
int b, a = dx;
|
int b, a = dx;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
dx = ReadByte(fd);
|
dx = ReadByte(fd);
|
||||||
|
|
|
@ -312,8 +312,8 @@ static unsigned combinecolors(unsigned char bf[1u << MC][2],
|
||||||
return r; \
|
return r; \
|
||||||
}
|
}
|
||||||
|
|
||||||
ADJUDICATE(adjudicate_avx2, microarchitecture("avx2,fma"))
|
ADJUDICATE(adjudicate_avx2, _Microarchitecture("avx2,fma"))
|
||||||
ADJUDICATE(adjudicate_avx, microarchitecture("avx"))
|
ADJUDICATE(adjudicate_avx, _Microarchitecture("avx"))
|
||||||
ADJUDICATE(adjudicate_default, )
|
ADJUDICATE(adjudicate_default, )
|
||||||
|
|
||||||
static float (*adjudicate_hook)(unsigned, unsigned, unsigned,
|
static float (*adjudicate_hook)(unsigned, unsigned, unsigned,
|
||||||
|
|
Loading…
Reference in a new issue