mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-31 15:00:28 +00:00
Fix warnings
This change fixes Cosmopolitan so it has fewer opinions about compiler warnings. The whole repository had to be cleaned up to be buildable in -Werror -Wall mode. This lets us benefit from things like strict const checking. Some actual bugs might have been caught too.
This commit is contained in:
parent
e2b3c3618e
commit
0d748ad58e
571 changed files with 1306 additions and 1888 deletions
1
third_party/bzip2/bzip2.mk
vendored
1
third_party/bzip2/bzip2.mk
vendored
|
@ -63,6 +63,7 @@ o/$(MODE)/third_party/bzip2/bzip2recover.com.dbg: \
|
|||
|
||||
$(THIRD_PARTY_BZIP2_A_OBJS): private \
|
||||
CFLAGS += \
|
||||
-w \
|
||||
-ffunction-sections \
|
||||
-fdata-sections
|
||||
|
||||
|
|
34
third_party/chibicc/as.c
vendored
34
third_party/chibicc/as.c
vendored
|
@ -775,7 +775,7 @@ static void Tokenize(struct As *a, int path) {
|
|||
|
||||
static int GetSymbol(struct As *a, int name) {
|
||||
struct HashEntry *p;
|
||||
unsigned i, j, k, n, m, h, n2;
|
||||
unsigned i, j, k, n, m, h;
|
||||
if (!(h = crc32c(0, a->slices.p[name].p, a->slices.p[name].n))) h = 1;
|
||||
n = a->symbolindex.n;
|
||||
i = 0;
|
||||
|
@ -932,7 +932,6 @@ static int NewBinary(struct As *a, enum ExprKind k, int lhs, int rhs) {
|
|||
// | symbol
|
||||
// | reference
|
||||
static int ParsePrimary(struct As *a, int *rest, int i) {
|
||||
int e;
|
||||
if (IsInt(a, i)) {
|
||||
*rest = i + 1;
|
||||
return NewPrimary(a, EX_INT, a->ints.p[a->things.p[i].i]);
|
||||
|
@ -1765,7 +1764,7 @@ static void OnSize(struct As *a, struct Slice s) {
|
|||
}
|
||||
|
||||
static void OnEqu(struct As *a, struct Slice s) {
|
||||
int i, j;
|
||||
int i;
|
||||
i = GetSymbol(a, a->things.p[a->i++].i);
|
||||
ConsumeComma(a);
|
||||
a->symbols.p[i].offset = GetInt(a);
|
||||
|
@ -1967,15 +1966,17 @@ static int RemoveRexw(int x) {
|
|||
|
||||
static int GetRegisterReg(struct As *a) {
|
||||
int reg;
|
||||
struct Slice wut;
|
||||
if ((reg = FindRegReg(GetSlice(a))) == -1) InvalidRegister(a);
|
||||
if ((reg = FindRegReg(GetSlice(a))) == -1) {
|
||||
InvalidRegister(a);
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
|
||||
static int GetRegisterRm(struct As *a) {
|
||||
int reg;
|
||||
struct Slice wut;
|
||||
if ((reg = FindRegRm(GetSlice(a))) == -1) InvalidRegister(a);
|
||||
if ((reg = FindRegRm(GetSlice(a))) == -1) {
|
||||
InvalidRegister(a);
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
|
||||
|
@ -1992,7 +1993,7 @@ static int ParseModrm(struct As *a, int *disp) {
|
|||
│││││├──────┐├┐├─┐├─┐
|
||||
0b00000000000000000000000000000000*/
|
||||
struct Slice str;
|
||||
int reg, scale, modrm = 0;
|
||||
int reg, modrm = 0;
|
||||
if (!ConsumeSegment(a) && IsRegister(a, a->i)) {
|
||||
*disp = 0;
|
||||
modrm = GetRegisterRm(a) | ISREG;
|
||||
|
@ -2057,12 +2058,12 @@ static void EmitImm(struct As *a, int reg, int imm) {
|
|||
}
|
||||
|
||||
static void EmitModrm(struct As *a, int reg, int modrm, int disp) {
|
||||
int relo, mod, rm;
|
||||
int relo, mod;
|
||||
void (*emitter)(struct As *, uint128_t);
|
||||
reg &= 7;
|
||||
reg <<= 3;
|
||||
if (modrm & ISREG) {
|
||||
EmitByte(a, 0300 | reg | modrm & 7);
|
||||
EmitByte(a, 0300 | reg | (modrm & 7));
|
||||
} else {
|
||||
if (modrm & ISRIP) {
|
||||
EmitByte(a, 005 | reg);
|
||||
|
@ -2348,7 +2349,7 @@ static dontinline void OpXadd(struct As *a) {
|
|||
}
|
||||
|
||||
static dontinline int OpF6Impl(struct As *a, struct Slice s, int reg) {
|
||||
int modrm, imm, disp;
|
||||
int modrm, disp;
|
||||
modrm = ParseModrm(a, &disp);
|
||||
reg |= GetOpSize(a, s, modrm, 1) << 3;
|
||||
EmitRexOpModrm(a, 0xF6, reg, modrm, disp, 1);
|
||||
|
@ -2642,7 +2643,6 @@ static void OnPush(struct As *a, struct Slice s) {
|
|||
}
|
||||
|
||||
static void OnRdpid(struct As *a, struct Slice s) {
|
||||
int modrm, disp;
|
||||
EmitVarword(a, 0xf30fc7);
|
||||
EmitByte(a, 0370 | GetRegisterReg(a));
|
||||
}
|
||||
|
@ -2700,6 +2700,8 @@ static void OnFile(struct As *a, struct Slice s) {
|
|||
struct Slice path;
|
||||
fileno = GetInt(a);
|
||||
path = GetSlice(a);
|
||||
(void)fileno;
|
||||
(void)path;
|
||||
// TODO: DWARF
|
||||
}
|
||||
|
||||
|
@ -2707,6 +2709,8 @@ static void OnLoc(struct As *a, struct Slice s) {
|
|||
int fileno, lineno;
|
||||
fileno = GetInt(a);
|
||||
lineno = GetInt(a);
|
||||
(void)fileno;
|
||||
(void)lineno;
|
||||
// TODO: DWARF
|
||||
}
|
||||
|
||||
|
@ -2762,7 +2766,7 @@ static void OnFxch(struct As *a, struct Slice s) {
|
|||
int rm;
|
||||
rm = !IsSemicolon(a) ? GetRegisterRm(a) : 1;
|
||||
EmitByte(a, 0xD9);
|
||||
EmitByte(a, 0310 | rm & 7);
|
||||
EmitByte(a, 0310 | (rm & 7));
|
||||
}
|
||||
|
||||
static void OnBswap(struct As *a, struct Slice s) {
|
||||
|
@ -2770,7 +2774,7 @@ static void OnBswap(struct As *a, struct Slice s) {
|
|||
srm = GetRegisterRm(a);
|
||||
EmitRex(a, srm);
|
||||
EmitByte(a, 0x0F);
|
||||
EmitByte(a, 0310 | srm & 7);
|
||||
EmitByte(a, 0310 | (srm & 7));
|
||||
}
|
||||
|
||||
static dontinline void OpFcomImpl(struct As *a, int op) {
|
||||
|
@ -2786,7 +2790,7 @@ static dontinline void OpFcomImpl(struct As *a, int op) {
|
|||
}
|
||||
}
|
||||
}
|
||||
EmitVarword(a, op | rm & 7);
|
||||
EmitVarword(a, op | (rm & 7));
|
||||
}
|
||||
|
||||
static dontinline void OpFcom(struct As *a, int op) {
|
||||
|
|
2
third_party/chibicc/asm.c
vendored
2
third_party/chibicc/asm.c
vendored
|
@ -670,7 +670,7 @@ static void PopAsmInputs(Asm *a) {
|
|||
}
|
||||
|
||||
static void StoreAsmOutputs(Asm *a) {
|
||||
int i, z, x0, x1;
|
||||
int i, z;
|
||||
for (i = 0; i < a->n; ++i) {
|
||||
if (a->ops[i].flow == '=' || a->ops[i].flow == '+') {
|
||||
switch (a->ops[i].type) {
|
||||
|
|
2
third_party/chibicc/chibicc.c
vendored
2
third_party/chibicc/chibicc.c
vendored
|
@ -424,7 +424,7 @@ static bool NeedsShellQuotes(const char *s) {
|
|||
|
||||
static bool run_subprocess(char **argv) {
|
||||
int rc, ws;
|
||||
size_t i, j, n;
|
||||
size_t i, j;
|
||||
if (opt_verbose) {
|
||||
for (i = 0; argv[i]; i++) {
|
||||
fputc(' ', stderr);
|
||||
|
|
6
third_party/chibicc/chibicc.h
vendored
6
third_party/chibicc/chibicc.h
vendored
|
@ -180,7 +180,7 @@ struct AsmOperand {
|
|||
uint8_t reg;
|
||||
uint8_t type;
|
||||
char flow;
|
||||
char x87mask;
|
||||
unsigned char x87mask;
|
||||
bool isused;
|
||||
int regmask;
|
||||
int predicate;
|
||||
|
@ -216,10 +216,10 @@ void gen_addr(Node *);
|
|||
void gen_asm(Asm *);
|
||||
void gen_expr(Node *);
|
||||
void pop(char *);
|
||||
void popreg(char *);
|
||||
void popreg(const char *);
|
||||
void print_loc(int64_t, int64_t);
|
||||
void push(void);
|
||||
void pushreg(char *);
|
||||
void pushreg(const char *);
|
||||
|
||||
//
|
||||
// fpclassify.c
|
||||
|
|
9
third_party/chibicc/codegen.c
vendored
9
third_party/chibicc/codegen.c
vendored
|
@ -67,7 +67,6 @@ static void emitlin(char *nextline) {
|
|||
|
||||
void println(char *fmt, ...) {
|
||||
va_list ap;
|
||||
char *nextline;
|
||||
va_start(ap, fmt);
|
||||
emitlin(xvasprintf(fmt, ap));
|
||||
va_end(ap);
|
||||
|
@ -105,12 +104,12 @@ void pop2(char *a, char *b) {
|
|||
DCHECK_GE(depth, 0);
|
||||
}
|
||||
|
||||
void pushreg(char *arg) {
|
||||
void pushreg(const char *arg) {
|
||||
println("\tpush\t%%%s", arg);
|
||||
depth++;
|
||||
}
|
||||
|
||||
void popreg(char *arg) {
|
||||
void popreg(const char *arg) {
|
||||
println("\tpop\t%%%s", arg);
|
||||
depth--;
|
||||
DCHECK_GE(depth, 0);
|
||||
|
@ -1777,15 +1776,13 @@ void gen_expr(Node *node) {
|
|||
gen_expr(node->lhs);
|
||||
pop("%rdi");
|
||||
}
|
||||
char *ax, *di, *dx;
|
||||
char *ax, *di;
|
||||
if (node->lhs->ty->kind == TY_LONG || node->lhs->ty->base) {
|
||||
ax = "%rax";
|
||||
di = "%rdi";
|
||||
dx = "%rdx";
|
||||
} else {
|
||||
ax = "%eax";
|
||||
di = "%edi";
|
||||
dx = "%edx";
|
||||
}
|
||||
switch (node->kind) {
|
||||
case ND_PMOVMSKB:
|
||||
|
|
1
third_party/chibicc/dox1.c
vendored
1
third_party/chibicc/dox1.c
vendored
|
@ -42,7 +42,6 @@ struct DoxWriter {
|
|||
};
|
||||
|
||||
static void SerializeData(struct Buffer *buf, const void *p, unsigned long n) {
|
||||
struct Slice *s;
|
||||
buf->p = realloc(buf->p, buf->n + n);
|
||||
memcpy(buf->p + buf->n, p, n);
|
||||
buf->n += n;
|
||||
|
|
3
third_party/chibicc/dox2.c
vendored
3
third_party/chibicc/dox2.c
vendored
|
@ -153,7 +153,6 @@ static char *DeserializeStr(struct Dox *dox) {
|
|||
|
||||
static struct Javadown *DeserializeJavadown(struct Dox *dox) {
|
||||
int i;
|
||||
bool present;
|
||||
struct Javadown *jd;
|
||||
if (DeserializeInt(dox)) {
|
||||
jd = FreeLater(dox, calloc(1, sizeof(struct Javadown)));
|
||||
|
@ -273,7 +272,7 @@ static bool AddSet(struct Set *set, char *s) {
|
|||
static int CompareDoxIndexEntry(const void *p1, const void *p2, void *arg) {
|
||||
struct Dox *dox;
|
||||
const char *s1, *s2;
|
||||
struct DoxIndexEntry *a, *b;
|
||||
const struct DoxIndexEntry *a, *b;
|
||||
dox = arg, a = p1, b = p2;
|
||||
s1 = a->t == kObject ? dox->objects.p[a->i].name : dox->macros.p[a->i].name;
|
||||
s2 = b->t == kObject ? dox->objects.p[b->i].name : dox->macros.p[b->i].name;
|
||||
|
|
1
third_party/chibicc/parse.c
vendored
1
third_party/chibicc/parse.c
vendored
|
@ -2436,7 +2436,6 @@ static Node *logor(Token **rest, Token *tok) {
|
|||
|
||||
// logand = binor ("&&" binor)*
|
||||
static Node *logand(Token **rest, Token *tok) {
|
||||
Token *start = tok;
|
||||
Node *node = binor(&tok, tok);
|
||||
while (EQUAL(tok, "&&")) {
|
||||
Token *start = tok;
|
||||
|
|
3
third_party/compiler_rt/divtc3.c
vendored
3
third_party/compiler_rt/divtc3.c
vendored
|
@ -15,6 +15,9 @@
|
|||
#include "libc/math.h"
|
||||
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
|
||||
|
||||
// todo: what m=opt
|
||||
#pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
|
||||
|
||||
__static_yoink("huge_compiler_rt_license");
|
||||
|
||||
#define QUAD_PRECISION
|
||||
|
|
3
third_party/compiler_rt/multc3.c
vendored
3
third_party/compiler_rt/multc3.c
vendored
|
@ -20,6 +20,9 @@ __static_yoink("huge_compiler_rt_license");
|
|||
|
||||
/* Returns: the product of a + ib and c + id */
|
||||
|
||||
// todo: what m=opt
|
||||
#pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
|
||||
|
||||
COMPILER_RT_ABI long double _Complex __multc3(long double a, long double b,
|
||||
long double c, long double d) {
|
||||
long double ac = a * c;
|
||||
|
|
1
third_party/ctags/flex.c
vendored
1
third_party/ctags/flex.c
vendored
|
@ -1475,6 +1475,7 @@ static boolean parseStatement (tokenInfo *const token)
|
|||
boolean is_global = FALSE;
|
||||
boolean is_prototype = FALSE;
|
||||
vString * fulltag;
|
||||
(void)is_prototype;
|
||||
|
||||
vStringClear(saveScope);
|
||||
vStringCopy (saveScope, token->scope);
|
||||
|
|
2
third_party/ctags/jscript.c
vendored
2
third_party/ctags/jscript.c
vendored
|
@ -1106,6 +1106,8 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
|
|||
boolean has_methods = FALSE;
|
||||
vString * fulltag;
|
||||
|
||||
(void)is_prototype;
|
||||
|
||||
vStringClear(saveScope);
|
||||
/*
|
||||
* Functions can be named or unnamed.
|
||||
|
|
1
third_party/ctags/sql.c
vendored
1
third_party/ctags/sql.c
vendored
|
@ -1242,6 +1242,7 @@ static void parseStatements (tokenInfo *const token, const boolean exit_on_endif
|
|||
{
|
||||
boolean isAnsi = TRUE;
|
||||
boolean stmtTerm = FALSE;
|
||||
(void)isAnsi;
|
||||
do
|
||||
{
|
||||
|
||||
|
|
2
third_party/dlmalloc/init.inc
vendored
2
third_party/dlmalloc/init.inc
vendored
|
@ -5,7 +5,7 @@
|
|||
#if LOCK_AT_FORK
|
||||
static void dlmalloc_pre_fork(void) { ACQUIRE_LOCK(&(gm)->mutex); }
|
||||
static void dlmalloc_post_fork_parent(void) { RELEASE_LOCK(&(gm)->mutex); }
|
||||
static void dlmalloc_post_fork_child(void) { INITIAL_LOCK(&(gm)->mutex); }
|
||||
static void dlmalloc_post_fork_child(void) { (void)INITIAL_LOCK(&(gm)->mutex); }
|
||||
#endif /* LOCK_AT_FORK */
|
||||
|
||||
/* Initialize mparams */
|
||||
|
|
4
third_party/double-conversion/wrapper.cc
vendored
4
third_party/double-conversion/wrapper.cc
vendored
|
@ -16,11 +16,11 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/double-conversion/wrapper.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/double-conversion/double-conversion.h"
|
||||
#include "third_party/double-conversion/double-to-string.h"
|
||||
#include "third_party/double-conversion/wrapper.h"
|
||||
|
||||
namespace double_conversion {
|
||||
extern "C" {
|
||||
|
@ -59,7 +59,7 @@ char* DoubleToLua(char buf[128], double x) {
|
|||
}
|
||||
|
||||
double StringToDouble(const char* s, size_t n, int* out_processed) {
|
||||
if (n == -1) n = strlen(s);
|
||||
if (n == -1ull) n = strlen(s);
|
||||
int flags = StringToDoubleConverter::ALLOW_CASE_INSENSITIVITY |
|
||||
StringToDoubleConverter::ALLOW_LEADING_SPACES |
|
||||
StringToDoubleConverter::ALLOW_TRAILING_JUNK |
|
||||
|
|
3
third_party/gdtoa/gdtoa_fltrnds.inc
vendored
3
third_party/gdtoa/gdtoa_fltrnds.inc
vendored
|
@ -1,7 +1,8 @@
|
|||
/* clang-format off */
|
||||
|
||||
FPI *fpi, fpi1;
|
||||
FPI fpi1;
|
||||
int Rounding;
|
||||
const FPI *fpi;
|
||||
Rounding = FLT_ROUNDS;
|
||||
fpi = &fpi0;
|
||||
if (Rounding != FPI_Round_near) {
|
||||
|
|
1
third_party/gdtoa/misc.c
vendored
1
third_party/gdtoa/misc.c
vendored
|
@ -128,7 +128,6 @@ __gdtoa_Balloc(int k, ThInfo **PTI)
|
|||
{
|
||||
int x;
|
||||
Bigint *rv;
|
||||
unsigned int len;
|
||||
ThInfo *TI;
|
||||
if (!(TI = *PTI))
|
||||
*PTI = TI = __gdtoa_get_TI();
|
||||
|
|
3
third_party/gdtoa/strtord.c
vendored
3
third_party/gdtoa/strtord.c
vendored
|
@ -67,7 +67,8 @@ int
|
|||
strtord(const char *s, char **sp, int rounding, double *d)
|
||||
{
|
||||
static const FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI, 0 /*unused*/ };
|
||||
FPI *fpi, fpi1;
|
||||
FPI fpi1;
|
||||
const FPI *fpi;
|
||||
ULong bits[2];
|
||||
Long exp;
|
||||
int k;
|
||||
|
|
3
third_party/gdtoa/strtordd.c
vendored
3
third_party/gdtoa/strtordd.c
vendored
|
@ -165,7 +165,8 @@ int
|
|||
strtordd(const char *s, char **sp, int rounding, double *dd)
|
||||
{
|
||||
static const FPI fpi0 = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0, 0 /*unused*/ };
|
||||
FPI *fpi, fpi1;
|
||||
FPI fpi1;
|
||||
const FPI *fpi;
|
||||
ULong bits[4];
|
||||
Long exp;
|
||||
int k;
|
||||
|
|
3
third_party/gdtoa/strtorf.c
vendored
3
third_party/gdtoa/strtorf.c
vendored
|
@ -63,7 +63,8 @@ int
|
|||
strtorf(const char *s, char **sp, int rounding, float *f)
|
||||
{
|
||||
static const FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI, 0 /*unused*/ };
|
||||
FPI *fpi, fpi1;
|
||||
FPI fpi1;
|
||||
const FPI *fpi;
|
||||
ULong bits[1];
|
||||
Long exp;
|
||||
int k;
|
||||
|
|
3
third_party/gdtoa/strtorx.c
vendored
3
third_party/gdtoa/strtorx.c
vendored
|
@ -74,7 +74,8 @@ int
|
|||
strtorx(const char *s, char **sp, int rounding, void *L)
|
||||
{
|
||||
static const FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI, 0 /*unused*/ };
|
||||
FPI *fpi, fpi1;
|
||||
FPI fpi1;
|
||||
const FPI *fpi;
|
||||
ULong bits[2];
|
||||
Long exp;
|
||||
int k;
|
||||
|
|
12
third_party/ggml/ggml.c
vendored
12
third_party/ggml/ggml.c
vendored
|
@ -4198,7 +4198,7 @@ const char * ggml_get_name(const struct ggml_tensor * tensor) {
|
|||
}
|
||||
|
||||
void ggml_set_name(struct ggml_tensor * tensor, const char * name) {
|
||||
strncpy(tensor->name, name, sizeof(tensor->name));
|
||||
strlcpy(tensor->name, name, sizeof(tensor->name));
|
||||
tensor->name[sizeof(tensor->name) - 1] = '\0';
|
||||
}
|
||||
|
||||
|
@ -15755,11 +15755,11 @@ size_t ggml_quantize_q8_0(const float * src, void * dst, int n, int k, int64_t *
|
|||
}
|
||||
|
||||
static const quantize_chunk_f *const ggjt_v3_quantize_chunk[GGML_TYPE_COUNT] = {
|
||||
[GGML_TYPE_Q4_0] = ggml_quantize_q4_0,
|
||||
[GGML_TYPE_Q4_1] = ggml_quantize_q4_1,
|
||||
[GGML_TYPE_Q5_0] = ggml_quantize_q5_0,
|
||||
[GGML_TYPE_Q5_1] = ggml_quantize_q5_1,
|
||||
[GGML_TYPE_Q8_0] = ggml_quantize_q8_0,
|
||||
[GGML_TYPE_Q4_0] = (void *)ggml_quantize_q4_0,
|
||||
[GGML_TYPE_Q4_1] = (void *)ggml_quantize_q4_1,
|
||||
[GGML_TYPE_Q5_0] = (void *)ggml_quantize_q5_0,
|
||||
[GGML_TYPE_Q5_1] = (void *)ggml_quantize_q5_1,
|
||||
[GGML_TYPE_Q8_0] = (void *)ggml_quantize_q8_0,
|
||||
};
|
||||
const quantize_chunk_f *const *GGML_QUANTIZE_CHUNK;
|
||||
static_assert(GGML_TYPE_COUNT == 13, "GGML_QUANTIZE_CHUNK is outdated");
|
||||
|
|
2
third_party/ggml/llama.cc
vendored
2
third_party/ggml/llama.cc
vendored
|
@ -510,7 +510,7 @@ struct llama_file_loader {
|
|||
}
|
||||
|
||||
vocab.token_to_id[word] = i;
|
||||
vocab.longest_token = MAX(vocab.longest_token, word.size());
|
||||
vocab.longest_token = std::max(vocab.longest_token, (int)word.size());
|
||||
|
||||
auto & tok_score = vocab.id_to_token[i];
|
||||
tok_score.tok = std::move(word);
|
||||
|
|
3
third_party/ggml/main.cc
vendored
3
third_party/ggml/main.cc
vendored
|
@ -389,7 +389,7 @@ int main(int argc, char ** argv) {
|
|||
}
|
||||
fprintf(stderr, "\"\n");
|
||||
fprintf(stderr, "%s: second part of prompt: \"", __func__);
|
||||
for (int i = n_keep; i < embd_inp.size(); i++) {
|
||||
for (int i = n_keep; i < (int)embd_inp.size(); i++) {
|
||||
fprintf(stderr, "%'s", llama_token_to_str(ctx, embd_inp[i]));
|
||||
}
|
||||
fprintf(stderr, "\"\n");
|
||||
|
@ -607,7 +607,6 @@ int main(int argc, char ** argv) {
|
|||
if (just_finished_initializing_prompt && !params.prompt_path.empty()) {
|
||||
int fd = -1;
|
||||
int close_rc;
|
||||
uint8_t buf[8];
|
||||
size_t file_size;
|
||||
size_t state_size;
|
||||
std::string tmppath;
|
||||
|
|
5
third_party/libcxx/__config
vendored
5
third_party/libcxx/__config
vendored
|
@ -14,8 +14,9 @@
|
|||
#define _LIBCPP_ABI_UNSTABLE
|
||||
#define _LIBCPP_NO_EXCEPTIONS
|
||||
#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
#define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
|
||||
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
#define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
|
||||
#define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
|
||||
#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
|
||||
#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
|
||||
|
||||
|
@ -889,7 +890,7 @@ typedef unsigned int char32_t;
|
|||
// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
|
||||
#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
|
||||
# if __has_attribute(deprecated)
|
||||
# define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
|
||||
# define _LIBCPP_DEPRECATED __attribute__ ((__deprecated__))
|
||||
# elif _LIBCPP_STD_VER > 11
|
||||
# define _LIBCPP_DEPRECATED [[deprecated]]
|
||||
# else
|
||||
|
|
53
third_party/linenoise/linenoise.c
vendored
53
third_party/linenoise/linenoise.c
vendored
|
@ -231,30 +231,30 @@ struct linenoiseRing {
|
|||
};
|
||||
|
||||
struct linenoiseState {
|
||||
int state; /* state machine */
|
||||
int ifd; /* terminal stdin file descriptor */
|
||||
int ofd; /* terminal stdout file descriptor */
|
||||
struct winsize ws; /* rows and columns in terminal */
|
||||
char *buf; /* edited line buffer */
|
||||
const char *prompt; /* prompt to display */
|
||||
int hindex; /* history index */
|
||||
int rows; /* rows being used */
|
||||
int oldpos; /* previous refresh cursor position */
|
||||
unsigned debugrow; /* row for debug display */
|
||||
unsigned buflen; /* edited line buffer size */
|
||||
unsigned pos; /* current buffer index */
|
||||
unsigned len; /* current edited line length */
|
||||
unsigned mark; /* saved cursor position */
|
||||
unsigned yi, yj; /* boundaries of last yank */
|
||||
char seq[2][16]; /* keystroke history for yanking code */
|
||||
char final; /* set to true on last update */
|
||||
char dirty; /* if an update was squashed */
|
||||
int state; /* state machine */
|
||||
int ifd; /* terminal stdin file descriptor */
|
||||
int ofd; /* terminal stdout file descriptor */
|
||||
struct winsize ws; /* rows and columns in terminal */
|
||||
char *buf; /* edited line buffer */
|
||||
char *prompt; /* prompt to display */
|
||||
int hindex; /* history index */
|
||||
int rows; /* rows being used */
|
||||
int oldpos; /* previous refresh cursor position */
|
||||
unsigned debugrow; /* row for debug display */
|
||||
unsigned buflen; /* edited line buffer size */
|
||||
unsigned pos; /* current buffer index */
|
||||
unsigned len; /* current edited line length */
|
||||
unsigned mark; /* saved cursor position */
|
||||
unsigned yi, yj; /* boundaries of last yank */
|
||||
char seq[2][16]; /* keystroke history for yanking code */
|
||||
char final; /* set to true on last update */
|
||||
char dirty; /* if an update was squashed */
|
||||
linenoiseCompletions lc;
|
||||
struct abuf ab;
|
||||
int i, j, perline, itemlen;
|
||||
// for reverse search
|
||||
int fail, matlen, oldindex, olderpos;
|
||||
const char *oldprompt;
|
||||
char *oldprompt;
|
||||
};
|
||||
|
||||
static const unsigned short kMirrorLeft[][2] = {
|
||||
|
@ -296,8 +296,6 @@ static char iscapital;
|
|||
static int historylen;
|
||||
static signed char rawmode = -1;
|
||||
static struct linenoiseRing ring;
|
||||
static struct sigaction orig_int;
|
||||
static struct sigaction orig_quit;
|
||||
static struct sigaction orig_cont;
|
||||
static struct sigaction orig_winch;
|
||||
static struct termios orig_termios;
|
||||
|
@ -386,7 +384,7 @@ static struct rune GetUtf8(const char *p, size_t n) {
|
|||
if ((r.n = r.c = 0) < n && (r.c = p[r.n++] & 255) >= 0300) {
|
||||
r.c = DecodeUtf8(r.c).c;
|
||||
while (r.n < n && (p[r.n] & 0300) == 0200) {
|
||||
r.c = r.c << 6 | p[r.n++] & 077;
|
||||
r.c = r.c << 6 | (p[r.n++] & 077);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
|
@ -738,7 +736,7 @@ static void linenoiseDebug(struct linenoiseState *l, const char *fmt, ...) {
|
|||
va_list va;
|
||||
char *msg = 0;
|
||||
char *ansi = 0;
|
||||
int x, y, n, dy, xn;
|
||||
int x, y, n, xn;
|
||||
va_start(va, fmt);
|
||||
(vappendf)(&msg, fmt, va);
|
||||
va_end(va);
|
||||
|
@ -1105,9 +1103,9 @@ static void linenoiseRefreshLineImpl(struct linenoiseState *l, int force,
|
|||
struct abuf ab;
|
||||
struct rune rune;
|
||||
unsigned flip[2];
|
||||
const char *p, *buf;
|
||||
const char *buf;
|
||||
struct winsize oldsize;
|
||||
int i, x, y, t, xn, yn, cx, cy, tn, resized;
|
||||
int i, x, t, xn, yn, cx, cy, tn, resized;
|
||||
int fd, plen, width, pwidth, rows, len, pos;
|
||||
|
||||
/*
|
||||
|
@ -1464,9 +1462,9 @@ static void linenoiseEditRuboutWord(struct linenoiseState *l) {
|
|||
static void linenoiseEditXlatWord(struct linenoiseState *l,
|
||||
wint_t xlat(wint_t)) {
|
||||
int c;
|
||||
size_t i, j;
|
||||
struct rune r;
|
||||
struct abuf ab;
|
||||
size_t i, j, p;
|
||||
abInit(&ab);
|
||||
i = Forwards(l, l->pos, iswseparator);
|
||||
for (j = i; j < l->len; j += r.n) {
|
||||
|
@ -1569,7 +1567,6 @@ static void linenoiseEditTranspose(struct linenoiseState *l) {
|
|||
|
||||
static void linenoiseEditTransposeWords(struct linenoiseState *l) {
|
||||
char *q, *p;
|
||||
struct rune r;
|
||||
size_t pi, xi, xj, yi, yj;
|
||||
pi = EscapeWord(l);
|
||||
xj = Backwards(l, pi, iswseparator);
|
||||
|
@ -1897,7 +1894,7 @@ ssize_t linenoiseEdit(struct linenoiseState *l, const char *prompt, char **obuf,
|
|||
|
||||
// handle reverse history search
|
||||
if (seq[0] == CTRL('R')) {
|
||||
int fail, added, oldpos;
|
||||
int fail, added;
|
||||
if (historylen <= 1) continue;
|
||||
l->ab.len = 0;
|
||||
l->olderpos = l->pos;
|
||||
|
|
2
third_party/lua/cosmo.h
vendored
2
third_party/lua/cosmo.h
vendored
|
@ -29,7 +29,7 @@ int LuaEncodeJsonData(lua_State *, char **, int, struct EncoderConfig);
|
|||
int LuaEncodeLuaData(lua_State *, char **, int, struct EncoderConfig);
|
||||
int LuaEncodeUrl(lua_State *);
|
||||
int LuaParseUrl(lua_State *);
|
||||
int LuaPushHeader(lua_State *, struct HttpMessage *, char *, int);
|
||||
int LuaPushHeader(lua_State *, struct HttpMessage *, const char *, int);
|
||||
int LuaPushHeaders(lua_State *, struct HttpMessage *, const char *);
|
||||
void LuaPrintStack(lua_State *);
|
||||
void LuaPushLatin1(lua_State *, const char *, size_t);
|
||||
|
|
6
third_party/lua/lrepl.c
vendored
6
third_party/lua/lrepl.c
vendored
|
@ -73,7 +73,7 @@ linenoiseCompletionCallback *lua_repl_completions_callback;
|
|||
struct linenoiseState *lua_repl_linenoise;
|
||||
const char *lua_progname;
|
||||
static lua_State *globalL;
|
||||
static const char *g_historypath;
|
||||
static char *g_historypath;
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
|
@ -105,8 +105,9 @@ void lua_readline_completions (const char *p, linenoiseCompletions *c) {
|
|||
size_t n;
|
||||
bool found;
|
||||
lua_State *L;
|
||||
const char *a;
|
||||
const char *name;
|
||||
char *a, *b, *s, *component;
|
||||
char *b, *s, *component;
|
||||
|
||||
// start searching globals
|
||||
L = globalL;
|
||||
|
@ -318,7 +319,6 @@ static void lstop (lua_State *L, lua_Debug *ar) {
|
|||
static int multiline (lua_State *L) {
|
||||
for (;;) { /* repeat until gets a complete statement */
|
||||
size_t len;
|
||||
ssize_t rc;
|
||||
const char *line = lua_tolstring(L, 1, &len); /* get what it has */
|
||||
int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */
|
||||
if (!incomplete(L, status) || pushline(L, 0) != 1)
|
||||
|
|
3
third_party/lua/lua.main.c
vendored
3
third_party/lua/lua.main.c
vendored
|
@ -70,9 +70,6 @@ STATIC_STACK_SIZE(0x80000);
|
|||
#define LUA_INITVARVERSION LUA_INIT_VAR LUA_VERSUFFIX
|
||||
|
||||
|
||||
static lua_State *globalL = NULL;
|
||||
|
||||
|
||||
static bool lua_stdin_is_tty(void) {
|
||||
return isatty(0);
|
||||
}
|
||||
|
|
2
third_party/lua/luaencodejsondata.c
vendored
2
third_party/lua/luaencodejsondata.c
vendored
|
@ -69,8 +69,8 @@ OnError:
|
|||
|
||||
static int SerializeString(lua_State *L, char **buf, int idx,
|
||||
struct Serializer *z) {
|
||||
char *s;
|
||||
size_t m;
|
||||
const char *s;
|
||||
s = lua_tolstring(L, idx, &m);
|
||||
if (!(s = EscapeJsStringLiteral(&z->strbuf, &z->strbuflen, s, m, &m))) {
|
||||
goto OnError;
|
||||
|
|
7
third_party/lua/luaencodeluadata.c
vendored
7
third_party/lua/luaencodeluadata.c
vendored
|
@ -113,7 +113,7 @@ OnError:
|
|||
|
||||
static int SerializeNumber(lua_State *L, char **buf, int idx) {
|
||||
int64_t x;
|
||||
char ibuf[24];
|
||||
char ibuf[128];
|
||||
if (lua_isinteger(L, idx)) {
|
||||
x = luaL_checkinteger(L, idx);
|
||||
if (x == -9223372036854775807 - 1) {
|
||||
|
@ -252,7 +252,6 @@ OnError:
|
|||
static int SerializeArray(lua_State *L, char **buf, struct Serializer *z,
|
||||
int depth) {
|
||||
size_t i, n;
|
||||
const char *s;
|
||||
RETURN_ON_ERROR(appendw(buf, '{'));
|
||||
n = lua_rawlen(L, -1);
|
||||
for (i = 1; i <= n; i++) {
|
||||
|
@ -269,7 +268,6 @@ OnError:
|
|||
|
||||
static int SerializeObject(lua_State *L, char **buf, struct Serializer *z,
|
||||
int depth, bool multi) {
|
||||
int rc;
|
||||
size_t n;
|
||||
const char *s;
|
||||
bool comma = false;
|
||||
|
@ -308,8 +306,8 @@ OnError:
|
|||
|
||||
static int SerializeSorted(lua_State *L, char **buf, struct Serializer *z,
|
||||
int depth, bool multi) {
|
||||
int i;
|
||||
size_t n;
|
||||
int i, rc;
|
||||
const char *s;
|
||||
struct StrList sl = {0};
|
||||
lua_pushnil(L);
|
||||
|
@ -354,7 +352,6 @@ static int SerializeTable(lua_State *L, char **buf, int idx,
|
|||
struct Serializer *z, int depth) {
|
||||
int rc;
|
||||
bool multi;
|
||||
intptr_t rsp, bot;
|
||||
if (UNLIKELY(!HaveStackMemory(getauxval(AT_PAGESZ)))) {
|
||||
z->reason = "out of stack";
|
||||
return -1;
|
||||
|
|
29
third_party/lua/luaencodeurl.c
vendored
29
third_party/lua/luaencodeurl.c
vendored
|
@ -25,23 +25,28 @@
|
|||
#include "third_party/lua/lua.h"
|
||||
|
||||
int LuaEncodeUrl(lua_State *L) {
|
||||
char *data;
|
||||
size_t size;
|
||||
struct Url h;
|
||||
int i, j, n;
|
||||
const char *data;
|
||||
struct Url h;
|
||||
if (!lua_isnil(L, 1)) {
|
||||
i = lua_gettop(L);
|
||||
bzero(&h, sizeof(h));
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
if (lua_getfield(L, 1, "scheme"))
|
||||
h.scheme.p = lua_tolstring(L, -1, &h.scheme.n);
|
||||
h.scheme.p = (char *)lua_tolstring(L, -1, &h.scheme.n);
|
||||
if (lua_getfield(L, 1, "fragment"))
|
||||
h.fragment.p = lua_tolstring(L, -1, &h.fragment.n);
|
||||
if (lua_getfield(L, 1, "user")) h.user.p = lua_tolstring(L, -1, &h.user.n);
|
||||
if (lua_getfield(L, 1, "pass")) h.pass.p = lua_tolstring(L, -1, &h.pass.n);
|
||||
if (lua_getfield(L, 1, "host")) h.host.p = lua_tolstring(L, -1, &h.host.n);
|
||||
if (lua_getfield(L, 1, "port")) h.port.p = lua_tolstring(L, -1, &h.port.n);
|
||||
if (lua_getfield(L, 1, "path")) h.path.p = lua_tolstring(L, -1, &h.path.n);
|
||||
h.fragment.p = (char *)lua_tolstring(L, -1, &h.fragment.n);
|
||||
if (lua_getfield(L, 1, "user"))
|
||||
h.user.p = (char *)lua_tolstring(L, -1, &h.user.n);
|
||||
if (lua_getfield(L, 1, "pass"))
|
||||
h.pass.p = (char *)lua_tolstring(L, -1, &h.pass.n);
|
||||
if (lua_getfield(L, 1, "host"))
|
||||
h.host.p = (char *)lua_tolstring(L, -1, &h.host.n);
|
||||
if (lua_getfield(L, 1, "port"))
|
||||
h.port.p = (char *)lua_tolstring(L, -1, &h.port.n);
|
||||
if (lua_getfield(L, 1, "path"))
|
||||
h.path.p = (char *)lua_tolstring(L, -1, &h.path.n);
|
||||
lua_settop(L, i); // restore stack position
|
||||
if (lua_getfield(L, 1, "params")) {
|
||||
luaL_checktype(L, -1, LUA_TTABLE);
|
||||
|
@ -55,10 +60,10 @@ int LuaEncodeUrl(lua_State *L) {
|
|||
h.params.p =
|
||||
xrealloc(h.params.p, ++h.params.n * sizeof(*h.params.p));
|
||||
h.params.p[h.params.n - 1].key.p =
|
||||
lua_tolstring(L, -1, &h.params.p[h.params.n - 1].key.n);
|
||||
(char *)lua_tolstring(L, -1, &h.params.p[h.params.n - 1].key.n);
|
||||
if (lua_geti(L, -2, 2)) {
|
||||
h.params.p[h.params.n - 1].val.p =
|
||||
lua_tolstring(L, -1, &h.params.p[h.params.n - 1].val.n);
|
||||
h.params.p[h.params.n - 1].val.p = (char *)lua_tolstring(
|
||||
L, -1, &h.params.p[h.params.n - 1].val.n);
|
||||
} else {
|
||||
h.params.p[h.params.n - 1].val.p = 0;
|
||||
h.params.p[h.params.n - 1].val.n = 0;
|
||||
|
|
2
third_party/lua/luapushheader.c
vendored
2
third_party/lua/luapushheader.c
vendored
|
@ -22,7 +22,7 @@
|
|||
#include "third_party/lua/lauxlib.h"
|
||||
#include "third_party/lua/lua.h"
|
||||
|
||||
int LuaPushHeader(lua_State *L, struct HttpMessage *m, char *b, int h) {
|
||||
int LuaPushHeader(lua_State *L, struct HttpMessage *m, const char *b, int h) {
|
||||
char *val;
|
||||
size_t vallen;
|
||||
if (!kHttpRepeatable[h]) {
|
||||
|
|
41
third_party/lua/lunix.c
vendored
41
third_party/lua/lunix.c
vendored
|
@ -203,8 +203,8 @@ static dontinline int ReturnString(lua_State *L, const char *x) {
|
|||
}
|
||||
|
||||
int LuaUnixSysretErrno(lua_State *L, const char *call, int olderr) {
|
||||
int unixerr, winerr;
|
||||
struct UnixErrno *ep;
|
||||
int i, unixerr, winerr;
|
||||
unixerr = errno;
|
||||
winerr = IsWindows() ? GetLastError() : 0;
|
||||
if (!IsTiny() && !(0 < unixerr && unixerr < (!IsWindows() ? 4096 : 65536))) {
|
||||
|
@ -591,7 +591,7 @@ static int LuaUnixExecve(lua_State *L) {
|
|||
return LuaUnixSysretErrno(L, "execve", olderr);
|
||||
}
|
||||
} else {
|
||||
ezargs[0] = prog;
|
||||
ezargs[0] = (char *)prog;
|
||||
ezargs[1] = 0;
|
||||
argv = ezargs;
|
||||
envp = environ;
|
||||
|
@ -736,7 +736,7 @@ static int LuaUnixWait(lua_State *L) {
|
|||
// └─→ nil, unix.Errno
|
||||
static int LuaUnixFcntl(lua_State *L) {
|
||||
struct flock lock;
|
||||
int rc, fd, cmd, olderr = errno;
|
||||
int fd, cmd, olderr = errno;
|
||||
fd = luaL_checkinteger(L, 1);
|
||||
cmd = luaL_checkinteger(L, 2);
|
||||
if (cmd == F_SETLK || cmd == F_SETLKW || cmd == F_GETLK) {
|
||||
|
@ -920,7 +920,6 @@ static int LuaUnixSetresgid(lua_State *L) {
|
|||
// ├─→ 0
|
||||
// └─→ nil, unix.Errno
|
||||
static int LuaUnixUtimensat(lua_State *L) {
|
||||
struct timespec ts;
|
||||
int olderr = errno;
|
||||
return SysretInteger(
|
||||
L, "utimensat", olderr,
|
||||
|
@ -937,7 +936,6 @@ static int LuaUnixUtimensat(lua_State *L) {
|
|||
// ├─→ 0
|
||||
// └─→ nil, unix.Errno
|
||||
static int LuaUnixFutimens(lua_State *L) {
|
||||
struct timespec ts;
|
||||
int olderr = errno;
|
||||
return SysretInteger(
|
||||
L, "futimens", olderr,
|
||||
|
@ -953,7 +951,7 @@ static int LuaUnixFutimens(lua_State *L) {
|
|||
// └─→ nil, unix.Errno
|
||||
static int LuaUnixGettime(lua_State *L) {
|
||||
struct timespec ts;
|
||||
int rc, olderr = errno;
|
||||
int olderr = errno;
|
||||
if (!clock_gettime(luaL_optinteger(L, 1, CLOCK_REALTIME), &ts)) {
|
||||
lua_pushinteger(L, ts.tv_sec);
|
||||
lua_pushinteger(L, ts.tv_nsec);
|
||||
|
@ -1178,14 +1176,14 @@ static bool IsSockoptBool(int l, int x) {
|
|||
x == SO_KEEPALIVE || //
|
||||
x == SO_ACCEPTCONN || //
|
||||
x == SO_DONTROUTE; //
|
||||
} else if (l = SOL_TCP) {
|
||||
} else if (l == SOL_TCP) {
|
||||
return x == TCP_NODELAY || //
|
||||
x == TCP_CORK || //
|
||||
x == TCP_QUICKACK || //
|
||||
x == TCP_SAVE_SYN || //
|
||||
x == TCP_FASTOPEN_CONNECT || //
|
||||
x == TCP_DEFER_ACCEPT; //
|
||||
} else if (l = SOL_IP) {
|
||||
} else if (l == SOL_IP) {
|
||||
return x == IP_HDRINCL; //
|
||||
} else {
|
||||
return false;
|
||||
|
@ -1198,7 +1196,7 @@ static bool IsSockoptInt(int l, int x) {
|
|||
x == SO_RCVBUF || //
|
||||
x == SO_RCVLOWAT || //
|
||||
x == SO_SNDLOWAT; //
|
||||
} else if (l = SOL_TCP) {
|
||||
} else if (l == SOL_TCP) {
|
||||
return x == TCP_FASTOPEN || //
|
||||
x == TCP_KEEPCNT || //
|
||||
x == TCP_MAXSEG || //
|
||||
|
@ -1207,7 +1205,7 @@ static bool IsSockoptInt(int l, int x) {
|
|||
x == TCP_WINDOW_CLAMP || //
|
||||
x == TCP_KEEPIDLE || //
|
||||
x == TCP_KEEPINTVL; //
|
||||
} else if (l = SOL_IP) {
|
||||
} else if (l == SOL_IP) {
|
||||
return x == IP_TOS || //
|
||||
x == IP_MTU || //
|
||||
x == IP_TTL; //
|
||||
|
@ -1230,7 +1228,7 @@ static int LuaUnixSetsockopt(lua_State *L) {
|
|||
struct linger l;
|
||||
uint32_t optsize;
|
||||
struct timeval tv;
|
||||
int rc, fd, level, optname, optint, olderr = errno;
|
||||
int fd, level, optname, optint, olderr = errno;
|
||||
fd = luaL_checkinteger(L, 1);
|
||||
level = luaL_checkinteger(L, 2);
|
||||
optname = luaL_checkinteger(L, 3);
|
||||
|
@ -1281,7 +1279,7 @@ static int LuaUnixGetsockopt(lua_State *L) {
|
|||
uint32_t size;
|
||||
struct linger l;
|
||||
struct timeval tv;
|
||||
int rc, fd, level, optname, optval, olderr = errno;
|
||||
int fd, level, optname, optval, olderr = errno;
|
||||
fd = luaL_checkinteger(L, 1);
|
||||
level = luaL_checkinteger(L, 2);
|
||||
optname = luaL_checkinteger(L, 3);
|
||||
|
@ -1547,7 +1545,7 @@ static int LuaUnixPoll(lua_State *L) {
|
|||
struct sigset *mask;
|
||||
struct timespec ts, *tsp;
|
||||
struct pollfd *fds, *fds2;
|
||||
int i, fd, events, olderr = errno;
|
||||
int i, events, olderr = errno;
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
if (!lua_isnoneornil(L, 2)) {
|
||||
ts = timespec_frommillis(luaL_checkinteger(L, 2));
|
||||
|
@ -1633,7 +1631,7 @@ static int LuaUnixRecv(lua_State *L) {
|
|||
size_t got;
|
||||
ssize_t rc;
|
||||
lua_Integer bufsiz;
|
||||
int fd, flags, pushed, olderr = errno;
|
||||
int fd, flags, olderr = errno;
|
||||
fd = luaL_checkinteger(L, 1);
|
||||
bufsiz = luaL_optinteger(L, 2, 1500);
|
||||
bufsiz = MIN(bufsiz, 0x7ffff000);
|
||||
|
@ -1655,9 +1653,8 @@ static int LuaUnixRecv(lua_State *L) {
|
|||
// ├─→ sent:int
|
||||
// └─→ nil, unix.Errno
|
||||
static int LuaUnixSend(lua_State *L) {
|
||||
char *data;
|
||||
ssize_t rc;
|
||||
size_t sent, size;
|
||||
size_t size;
|
||||
const char *data;
|
||||
int fd, flags, olderr = errno;
|
||||
fd = luaL_checkinteger(L, 1);
|
||||
data = luaL_checklstring(L, 2, &size);
|
||||
|
@ -1670,9 +1667,9 @@ static int LuaUnixSend(lua_State *L) {
|
|||
// ├─→ sent:int
|
||||
// └─→ nil, unix.Errno
|
||||
static int LuaUnixSendto(lua_State *L) {
|
||||
char *data;
|
||||
size_t size;
|
||||
uint32_t salen;
|
||||
const char *data;
|
||||
struct sockaddr_storage ss;
|
||||
int i, fd, flags, olderr = errno;
|
||||
fd = luaL_checkinteger(L, 1);
|
||||
|
@ -1697,7 +1694,6 @@ static int LuaUnixShutdown(lua_State *L) {
|
|||
// ├─→ oldmask:unix.Sigset
|
||||
// └─→ nil, unix.Errno
|
||||
static int LuaUnixSigprocmask(lua_State *L) {
|
||||
uint64_t imask;
|
||||
int olderr = errno;
|
||||
struct sigset oldmask;
|
||||
if (!sigprocmask(luaL_checkinteger(L, 1),
|
||||
|
@ -2734,7 +2730,7 @@ static int LuaUnixMemoryWrite(lua_State *L) {
|
|||
if (lua_isnoneornil(L, b)) {
|
||||
// unix.Memory:write(data:str[, offset:int])
|
||||
// writes binary data, plus a nul terminator
|
||||
if (i < n < m->size) {
|
||||
if (i < n && n < m->size) {
|
||||
// include lua string's implicit nul so this round trips with
|
||||
// unix.Memory:read(offset:int) even when we're overwriting a
|
||||
// larger string that was previously inserted
|
||||
|
@ -2842,7 +2838,7 @@ static int LuaUnixMemoryXor(lua_State *L) {
|
|||
static int LuaUnixMemoryWait(lua_State *L) {
|
||||
lua_Integer expect;
|
||||
int rc, olderr = errno;
|
||||
struct timespec ts, now, *deadline;
|
||||
struct timespec ts, *deadline;
|
||||
expect = luaL_checkinteger(L, 3);
|
||||
if (!(INT32_MIN <= expect && expect <= INT32_MAX)) {
|
||||
luaL_argerror(L, 3, "must be an int32_t");
|
||||
|
@ -3351,7 +3347,8 @@ static const luaL_Reg kLuaUnix[] = {
|
|||
{0}, //
|
||||
};
|
||||
|
||||
static void LoadMagnums(lua_State *L, struct MagnumStr *ms, const char *pfx) {
|
||||
static void LoadMagnums(lua_State *L, const struct MagnumStr *ms,
|
||||
const char *pfx) {
|
||||
int i;
|
||||
char b[64], *p;
|
||||
p = stpcpy(b, pfx);
|
||||
|
|
4
third_party/make/getopt.c
vendored
4
third_party/make/getopt.c
vendored
|
@ -646,7 +646,7 @@ _getopt_internal (int argc, char *const *argv, const char *optstring,
|
|||
optarg = nameend + 1;
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
if (opterr) {
|
||||
if (argv[optind - 1][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr,
|
||||
|
@ -657,7 +657,7 @@ _getopt_internal (int argc, char *const *argv, const char *optstring,
|
|||
fprintf (stderr,
|
||||
_("%s: option '%c%s' doesn't allow an argument\n"),
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
|
||||
optopt = pfound->val;
|
||||
|
|
26
third_party/make/job.c
vendored
26
third_party/make/job.c
vendored
|
@ -410,18 +410,18 @@ get_target_variable (const char *name,
|
|||
return dflt;
|
||||
}
|
||||
|
||||
const char *
|
||||
char *
|
||||
get_tmpdir (struct file *file)
|
||||
{
|
||||
return get_target_variable (STRING_SIZE_TUPLE ("TMPDIR"), file, 0);
|
||||
return strdup (get_target_variable (STRING_SIZE_TUPLE ("TMPDIR"), file, 0));
|
||||
}
|
||||
|
||||
char *
|
||||
new_tmpdir (const char *tmp, struct file *file)
|
||||
{
|
||||
char *tmpdir;
|
||||
const char *s;
|
||||
int c, e, i, j;
|
||||
char *dir, *tmpdir;
|
||||
char cwd[PATH_MAX];
|
||||
char path[PATH_MAX];
|
||||
|
||||
|
@ -1875,9 +1875,9 @@ child_execute_job (struct childbase *child,
|
|||
char outpathbuf[PATH_MAX];
|
||||
int fdout = FD_STDOUT;
|
||||
int fderr = FD_STDERR;
|
||||
const char *s;
|
||||
pid_t pid;
|
||||
int e, r;
|
||||
char *s;
|
||||
|
||||
/* Divert child output if we want to capture it. */
|
||||
if (child->output.syncout)
|
||||
|
@ -1931,11 +1931,11 @@ child_execute_job (struct childbase *child,
|
|||
|
||||
if (sandboxed)
|
||||
{
|
||||
promises = emptytonull (get_target_variable
|
||||
(STRING_SIZE_TUPLE (".PLEDGE"),
|
||||
c ? c->file : 0, 0));
|
||||
if (promises)
|
||||
promises = xstrdup (promises);
|
||||
const char *ps;
|
||||
ps = emptytonull (get_target_variable
|
||||
(STRING_SIZE_TUPLE (".PLEDGE"),
|
||||
c ? c->file : 0, 0));
|
||||
promises = ps ? xstrdup (promises) : 0;
|
||||
if (ParsePromises (promises, &ipromises))
|
||||
{
|
||||
OSS (error, NILF, "%s: invalid .PLEDGE string: %s",
|
||||
|
@ -2128,7 +2128,7 @@ child_execute_job (struct childbase *child,
|
|||
DB (DB_JOBS, (_("Blocked Internet access with seccomp ptrace\n")));
|
||||
else
|
||||
{
|
||||
if (errno = EPERM)
|
||||
if (errno == EPERM)
|
||||
{
|
||||
errno = e;
|
||||
DB (DB_JOBS, (_("Can't block Internet if already traced\n")));
|
||||
|
@ -2152,7 +2152,7 @@ child_execute_job (struct childbase *child,
|
|||
if (!strict || !sandboxed)
|
||||
{
|
||||
if ((s = commandv (argv[0], pathbuf, sizeof (pathbuf))))
|
||||
argv[0] = s;
|
||||
argv[0] = (char *)s;
|
||||
else
|
||||
{
|
||||
OSS (error, NILF, "%s: command not found on $PATH: %s",
|
||||
|
@ -2255,7 +2255,7 @@ child_execute_job (struct childbase *child,
|
|||
if (!c->file->phony &&
|
||||
strlen(c->file->name) < PATH_MAX)
|
||||
{
|
||||
int fd, rc, err;
|
||||
int fd, err;
|
||||
if (c->file->last_mtime == NONEXISTENT_MTIME)
|
||||
{
|
||||
strcpy (outpathbuf, c->file->name);
|
||||
|
@ -2306,7 +2306,7 @@ child_execute_job (struct childbase *child,
|
|||
RETURN_ON_ERROR (Unveil (d->file->name, "rx"));
|
||||
if (n > 4 && READ32LE(d->file->name + n - 4) == READ32LE(".com"))
|
||||
{
|
||||
s = xstrcat (d->file->name, ".dbg");
|
||||
char *s = xstrcat (d->file->name, ".dbg");
|
||||
RETURN_ON_ERROR (Unveil (s, "rx"));
|
||||
free (s);
|
||||
}
|
||||
|
|
3
third_party/make/main.c
vendored
3
third_party/make/main.c
vendored
|
@ -1662,7 +1662,10 @@ main (int argc, char **argv, char **envp)
|
|||
p = quote_for_env (p, eval_strings->list[i]);
|
||||
*(p++) = ' ';
|
||||
}
|
||||
#pragma GCC push_options
|
||||
#pragma GCC diagnostic ignored "-Wstringop-overflow" /* wut */
|
||||
p[-1] = '\0';
|
||||
#pragma GCC pop_options
|
||||
|
||||
define_variable_cname ("-*-eval-flags-*-", value, o_automatic, 0);
|
||||
}
|
||||
|
|
4
third_party/make/read.c
vendored
4
third_party/make/read.c
vendored
|
@ -431,6 +431,7 @@ eval_makefile (const char *filename, unsigned short flags)
|
|||
|
||||
/* [jart] breaks gcc11 (also wat) */
|
||||
void *volatile wat = alloca (0);
|
||||
(void)wat;
|
||||
|
||||
errno = 0;
|
||||
return deps;
|
||||
|
@ -474,6 +475,7 @@ eval_buffer (char *buffer, const floc *flocp)
|
|||
|
||||
/* [jart] breaks gcc11 (also wat) */
|
||||
void *volatile wat = alloca (0);
|
||||
(void)wat;
|
||||
}
|
||||
|
||||
/* Check LINE to see if it's a variable assignment or undefine.
|
||||
|
@ -1181,7 +1183,7 @@ eval (struct ebuffer *ebuf, int set_default)
|
|||
if (semip)
|
||||
{
|
||||
size_t l = p2 - variable_buffer;
|
||||
*(--semip) = ';';
|
||||
*__veil("r", (--semip)) = ';';
|
||||
collapse_continuations (semip);
|
||||
variable_buffer_output (p2 + strlen (p2),
|
||||
semip, strlen (semip)+1);
|
||||
|
|
1
third_party/make/remake.c
vendored
1
third_party/make/remake.c
vendored
|
@ -324,6 +324,7 @@ update_file (struct file *file, unsigned int depth)
|
|||
|
||||
/* Clean up any alloca() used during the update. */
|
||||
void *volatile wat = alloca (0);
|
||||
(void)wat;
|
||||
|
||||
/* If we got an error, don't bother with double_colon etc. */
|
||||
if (new && !keep_going_flag)
|
||||
|
|
1
third_party/mbedtls/aesni.c
vendored
1
third_party/mbedtls/aesni.c
vendored
|
@ -130,7 +130,6 @@ int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx,
|
|||
*/
|
||||
void mbedtls_aesni_gcm_mult( unsigned char a[16], const uint64_t b[2] )
|
||||
{
|
||||
size_t i;
|
||||
uint64_t aa _Vector_size(16) forcealign(16);
|
||||
uint64_t bb _Vector_size(16) forcealign(16);
|
||||
|
||||
|
|
4
third_party/mbedtls/base64.c
vendored
4
third_party/mbedtls/base64.c
vendored
|
@ -15,8 +15,8 @@
|
|||
│ See the License for the specific language governing permissions and │
|
||||
│ limitations under the License. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/mbedtls/base64.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/mbedtls/common.h"
|
||||
#include "third_party/mbedtls/platform.h"
|
||||
|
||||
|
@ -127,8 +127,8 @@ static inline unsigned char mbedtls_base64_table_lookup( const unsigned char * c
|
|||
int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen,
|
||||
const unsigned char *src, size_t slen )
|
||||
{
|
||||
size_t n;
|
||||
unsigned w;
|
||||
size_t i, n;
|
||||
unsigned char *q;
|
||||
const unsigned char *p, *pe;
|
||||
if( !slen ) {
|
||||
|
|
11
third_party/mbedtls/bigmul.c
vendored
11
third_party/mbedtls/bigmul.c
vendored
|
@ -26,7 +26,7 @@
|
|||
#include "third_party/mbedtls/profile.h"
|
||||
/* clang-format off */
|
||||
|
||||
void Mul(uint64_t *c, uint64_t *A, unsigned n, uint64_t *B, unsigned m)
|
||||
void Mul(uint64_t *c, const uint64_t *A, unsigned n, const uint64_t *B, unsigned m)
|
||||
{
|
||||
if (!m--) return;
|
||||
mbedtls_platform_zeroize(c, m * ciL);
|
||||
|
@ -41,8 +41,8 @@ void Mul(uint64_t *c, uint64_t *A, unsigned n, uint64_t *B, unsigned m)
|
|||
void mbedtls_mpi_mul_hlp1(size_t n, const uint64_t *s, uint64_t *d, uint64_t b)
|
||||
{
|
||||
size_t i;
|
||||
uint64_t c;
|
||||
uint128_t x;
|
||||
uint64_t c, t, t1, t2;
|
||||
i = c = 0;
|
||||
#if defined(__x86_64__) && !defined(__STRICT_ANSI__)
|
||||
if( X86_HAVE(BMI2) )
|
||||
|
@ -113,7 +113,7 @@ void mbedtls_mpi_mul_hlp1(size_t n, const uint64_t *s, uint64_t *d, uint64_t b)
|
|||
/**
|
||||
* Computes inner loop of multiplication algorithm.
|
||||
*/
|
||||
void mbedtls_mpi_mul_hlp(size_t n, uint64_t *s, uint64_t *d, uint64_t b)
|
||||
void mbedtls_mpi_mul_hlp(size_t n, const uint64_t *s, uint64_t *d, uint64_t b)
|
||||
{
|
||||
size_t i;
|
||||
uint128_t x;
|
||||
|
@ -241,9 +241,10 @@ int mbedtls_mpi_mul_int(mbedtls_mpi *X, const mbedtls_mpi *A,
|
|||
int mbedtls_mpi_mul_mpi(mbedtls_mpi *X, const mbedtls_mpi *A,
|
||||
const mbedtls_mpi *B)
|
||||
{
|
||||
int i, j, t, k, ret;
|
||||
int i, j, t, ret;
|
||||
mbedtls_mpi TA, TB;
|
||||
mbedtls_mpi_uint *K;
|
||||
mbedtls_mpi TA, TB, *T;
|
||||
const mbedtls_mpi *T;
|
||||
MPI_VALIDATE_RET(X);
|
||||
MPI_VALIDATE_RET(A);
|
||||
MPI_VALIDATE_RET(B);
|
||||
|
|
6
third_party/mbedtls/bignum.c
vendored
6
third_party/mbedtls/bignum.c
vendored
|
@ -438,7 +438,7 @@ cleanup:
|
|||
*/
|
||||
size_t mbedtls_mpi_lsb( const mbedtls_mpi *X )
|
||||
{
|
||||
size_t i, j, count = 0;
|
||||
size_t i, count = 0;
|
||||
MBEDTLS_INTERNAL_VALIDATE_RET(X, 0);
|
||||
for( i = 0; i < X->n; i++ )
|
||||
{
|
||||
|
@ -1279,6 +1279,8 @@ forceinline mbedtls_mpi_uint mpi_sub_hlp(mbedtls_mpi_uint *d,
|
|||
size_t i;
|
||||
unsigned char cf;
|
||||
mbedtls_mpi_uint c, x;
|
||||
(void)x;
|
||||
(void)cf;
|
||||
cf = c = i = 0;
|
||||
#if defined(__x86_64__) && !defined(__STRICT_ANSI__)
|
||||
if (!n) return 0;
|
||||
|
@ -1679,7 +1681,7 @@ int mbedtls_mpi_div_mpi(mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A,
|
|||
const mbedtls_mpi *B)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_THIS_CORRUPTION;
|
||||
size_t i, n, t, k, Xn, Yn;
|
||||
size_t i, n, t, k;
|
||||
mbedtls_mpi X, Y, Z, T1, T2;
|
||||
mbedtls_mpi_uint TP2[3];
|
||||
MPI_VALIDATE_RET(A);
|
||||
|
|
8
third_party/mbedtls/bignum_internal.h
vendored
8
third_party/mbedtls/bignum_internal.h
vendored
|
@ -9,8 +9,8 @@ COSMOPOLITAN_C_START_
|
|||
#define MPI_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE(cond)
|
||||
|
||||
#define ciL (sizeof(mbedtls_mpi_uint)) /* chars in limb */
|
||||
#define biL (ciL << 3) /* bits in limb */
|
||||
#define biH (ciL << 2) /* half limb size */
|
||||
#define biL (ciL << 3) /* bits in limb */
|
||||
#define biH (ciL << 2) /* half limb size */
|
||||
|
||||
#define MPI_SIZE_T_MAX ((size_t)-1) /* SIZE_T_MAX is not standard */
|
||||
|
||||
|
@ -30,9 +30,9 @@ void Mul4x4Adx(uint64_t[8], const uint64_t[4], const uint64_t[4]);
|
|||
void Mul6x6Adx(uint64_t[12], const uint64_t[6], const uint64_t[6]);
|
||||
void Mul8x8Adx(uint64_t[16], const uint64_t[8], const uint64_t[8]);
|
||||
void Mul4x4Pure(uint64_t[16], const uint64_t[8], const uint64_t[8]);
|
||||
void Mul(uint64_t *, uint64_t *, unsigned, uint64_t *, unsigned);
|
||||
void Mul(uint64_t *, const uint64_t *, unsigned, const uint64_t *, unsigned);
|
||||
void Karatsuba(uint64_t *, uint64_t *, uint64_t *, size_t, uint64_t *);
|
||||
void mbedtls_mpi_mul_hlp(size_t, uint64_t *, uint64_t *, uint64_t);
|
||||
void mbedtls_mpi_mul_hlp(size_t, const uint64_t *, uint64_t *, uint64_t);
|
||||
void mbedtls_mpi_mul_hlp1(size_t, const uint64_t *, uint64_t *, uint64_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
4
third_party/mbedtls/bigshift.c
vendored
4
third_party/mbedtls/bigshift.c
vendored
|
@ -70,14 +70,13 @@ static inline void shld(mbedtls_mpi_uint *p, size_t n, size_t m, char k)
|
|||
int mbedtls_mpi_shift_l(mbedtls_mpi *X, size_t k)
|
||||
{
|
||||
int r;
|
||||
size_t b, n, m, l, z;
|
||||
size_t b, n, m, l;
|
||||
MPI_VALIDATE_RET(X);
|
||||
l = mbedtls_mpi_bitlen(X);
|
||||
b = l + k;
|
||||
n = BITS_TO_LIMBS(b);
|
||||
m = k / biL;
|
||||
k = k % biL;
|
||||
z = X->n;
|
||||
if (n > X->n && (r = mbedtls_mpi_grow(X, n)))
|
||||
return r;
|
||||
if (k)
|
||||
|
@ -102,7 +101,6 @@ void ShiftRightPure(mbedtls_mpi_uint *p, size_t n, unsigned char k) {
|
|||
int mbedtls_mpi_shift_r(mbedtls_mpi *X, size_t k)
|
||||
{
|
||||
size_t n;
|
||||
mbedtls_mpi_uint x, y;
|
||||
MPI_VALIDATE_RET(X);
|
||||
k = MIN(k, X->n * biL);
|
||||
n = k / biL;
|
||||
|
|
3
third_party/mbedtls/ecdh_everest.c
vendored
3
third_party/mbedtls/ecdh_everest.c
vendored
|
@ -15,8 +15,8 @@
|
|||
│ See the License for the specific language governing permissions and │
|
||||
│ limitations under the License. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/mbedtls/ecdh_everest.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/mbedtls/everest.h"
|
||||
#if defined(MBEDTLS_ECDH_C) && defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED)
|
||||
#define KEYSIZE 32
|
||||
|
@ -156,7 +156,6 @@ int mbedtls_everest_get_params(mbedtls_ecdh_context_everest *ctx,
|
|||
mbedtls_everest_ecdh_side side)
|
||||
{
|
||||
size_t olen = 0;
|
||||
mbedtls_everest_ecdh_side s;
|
||||
switch (side)
|
||||
{
|
||||
case MBEDTLS_EVEREST_ECDH_THEIRS:
|
||||
|
|
6
third_party/mbedtls/ecp.c
vendored
6
third_party/mbedtls/ecp.c
vendored
|
@ -15,6 +15,7 @@
|
|||
│ See the License for the specific language governing permissions and │
|
||||
│ limitations under the License. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/mbedtls/ecp.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
|
@ -26,7 +27,6 @@
|
|||
#include "third_party/mbedtls/common.h"
|
||||
#include "third_party/mbedtls/config.h"
|
||||
#include "third_party/mbedtls/ctr_drbg.h"
|
||||
#include "third_party/mbedtls/ecp.h"
|
||||
#include "third_party/mbedtls/ecp_internal.h"
|
||||
#include "third_party/mbedtls/error.h"
|
||||
#include "third_party/mbedtls/hmac_drbg.h"
|
||||
|
@ -1737,9 +1737,9 @@ static int ecp_add_mixed( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
|||
/*
|
||||
* Trivial cases: P == 0 or Q == 0 (case 1)
|
||||
*/
|
||||
if( mbedtls_ecp_is_zero( P ) )
|
||||
if( mbedtls_ecp_is_zero( (void *)P ) )
|
||||
return( mbedtls_ecp_copy( R, Q ) );
|
||||
if( Q->Z.p && mbedtls_ecp_is_zero( Q ) )
|
||||
if( Q->Z.p && mbedtls_ecp_is_zero( (void *)Q ) )
|
||||
return( mbedtls_ecp_copy( R, P ) );
|
||||
/*
|
||||
* Make sure Q coordinates are normalized
|
||||
|
|
2
third_party/mbedtls/ecp256.c
vendored
2
third_party/mbedtls/ecp256.c
vendored
|
@ -38,7 +38,7 @@ static bool
|
|||
mbedtls_p256_gte( uint64_t p[5] )
|
||||
{
|
||||
return( (((int64_t)p[4] > 0) |
|
||||
(!p[4] &
|
||||
((!p[4]) &
|
||||
((p[3] > 0xffffffff00000001) |
|
||||
((p[3] == 0xffffffff00000001) &
|
||||
((p[2] > 0x0000000000000000) |
|
||||
|
|
10
third_party/mbedtls/ecp384.c
vendored
10
third_party/mbedtls/ecp384.c
vendored
|
@ -39,7 +39,7 @@ static bool
|
|||
mbedtls_p384_gte( uint64_t p[7] )
|
||||
{
|
||||
return( (((int64_t)p[6] > 0) |
|
||||
(!p[6] &
|
||||
((!p[6]) &
|
||||
((p[5] > 0xffffffffffffffff) |
|
||||
((p[5] == 0xffffffffffffffff) &
|
||||
((p[4] > 0xffffffffffffffff) |
|
||||
|
@ -189,13 +189,11 @@ mbedtls_p384_mul( uint64_t X[12],
|
|||
void *f = 0;
|
||||
if( A == X )
|
||||
{
|
||||
A = memcpy( malloc( 6 * 8 ), A, 6 * 8 );
|
||||
f = A;
|
||||
A = f = memcpy( malloc( 6 * 8 ), A, 6 * 8 );
|
||||
}
|
||||
else if( B == X )
|
||||
{
|
||||
B = memcpy( malloc( 6 * 8 ), B, 6 * 8 );
|
||||
f = B;
|
||||
B = f = memcpy( malloc( 6 * 8 ), B, 6 * 8 );
|
||||
}
|
||||
Mul( X, A, n, B, m );
|
||||
mbedtls_platform_zeroize( X + n + m, (12 - n - m) * 8 );
|
||||
|
@ -417,7 +415,7 @@ int mbedtls_p384_double_jac( const mbedtls_ecp_group *G,
|
|||
if( IsAsan() ) __asan_verify( P, sizeof( *P ) );
|
||||
if( IsAsan() ) __asan_verify( R, sizeof( *R ) );
|
||||
if( ( ret = mbedtls_p384_dim( R ) ) ) return( ret );
|
||||
if( ( ret = mbedtls_p384_dim( P ) ) ) return( ret );
|
||||
if( ( ret = mbedtls_p384_dim( (void *)P ) ) ) return( ret );
|
||||
mbedtls_platform_zeroize( T, sizeof( T ) );
|
||||
mbedtls_p384_mul( T[1], P->Z.p, 6, P->Z.p, 6 );
|
||||
mbedtls_p384_add( T[2], P->X.p, T[1] );
|
||||
|
|
24
third_party/mbedtls/ecpshl.c
vendored
24
third_party/mbedtls/ecpshl.c
vendored
|
@ -33,10 +33,10 @@ static void mbedtls_mpi_shift_l_mod_p256( const mbedtls_ecp_group *G,
|
|||
X->p[0] = X->p[0] << 1;
|
||||
if( (X->p[4] ||
|
||||
X->p[3] > G->P.p[3] ||
|
||||
(X->p[3] == G->P.p[3] &&
|
||||
X->p[2] > G->P.p[2] ||
|
||||
(X->p[2] == G->P.p[2] &&
|
||||
X->p[0] > G->P.p[0] ||
|
||||
((X->p[3] == G->P.p[3] &&
|
||||
X->p[2] > G->P.p[2]) ||
|
||||
((X->p[2] == G->P.p[2] &&
|
||||
X->p[0] > G->P.p[0]) ||
|
||||
(X->p[0] == G->P.p[0])))) )
|
||||
{
|
||||
SBB(X->p[0], X->p[0], G->P.p[0], 0, c);
|
||||
|
@ -63,14 +63,14 @@ static void mbedtls_mpi_shift_l_mod_p384( const mbedtls_ecp_group *G,
|
|||
X->p[0] = X->p[0] << 1;
|
||||
if( (X->p[6] ||
|
||||
X->p[5] > G->P.p[5] ||
|
||||
(X->p[5] == G->P.p[5] &&
|
||||
X->p[4] > G->P.p[4] ||
|
||||
(X->p[4] == G->P.p[4] &&
|
||||
X->p[3] > G->P.p[3] ||
|
||||
(X->p[3] == G->P.p[3] &&
|
||||
X->p[2] > G->P.p[2] ||
|
||||
(X->p[2] == G->P.p[2] &&
|
||||
X->p[0] > G->P.p[0] ||
|
||||
((X->p[5] == G->P.p[5] &&
|
||||
X->p[4] > G->P.p[4]) ||
|
||||
((X->p[4] == G->P.p[4] &&
|
||||
X->p[3] > G->P.p[3]) ||
|
||||
((X->p[3] == G->P.p[3] &&
|
||||
X->p[2] > G->P.p[2]) ||
|
||||
((X->p[2] == G->P.p[2] &&
|
||||
X->p[0] > G->P.p[0]) ||
|
||||
(X->p[0] == G->P.p[0])))))) )
|
||||
{
|
||||
SBB(X->p[0], X->p[0], G->P.p[0], 0, c);
|
||||
|
|
2
third_party/mbedtls/everest.c
vendored
2
third_party/mbedtls/everest.c
vendored
|
@ -171,7 +171,7 @@ static void HaclEcPointSwap(uint64_t a[2][5], uint64_t b[2][5], uint64_t m) {
|
|||
}
|
||||
}
|
||||
|
||||
static void HaclEcFormatFexpand(uint64_t o[5], uint8_t p[32]) {
|
||||
static void HaclEcFormatFexpand(uint64_t o[5], const uint8_t p[32]) {
|
||||
o[0] = READ64LE(p + 000) >> 00 & 0x7ffffffffffff;
|
||||
o[1] = READ64LE(p + 006) >> 03 & 0x7ffffffffffff;
|
||||
o[2] = READ64LE(p + 014) >> 06 & 0x7ffffffffffff;
|
||||
|
|
3
third_party/mbedtls/gcm.c
vendored
3
third_party/mbedtls/gcm.c
vendored
|
@ -15,6 +15,7 @@
|
|||
│ See the License for the specific language governing permissions and │
|
||||
│ limitations under the License. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/mbedtls/gcm.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "libc/log/log.h"
|
||||
|
@ -27,7 +28,6 @@
|
|||
#include "third_party/mbedtls/common.h"
|
||||
#include "third_party/mbedtls/endian.h"
|
||||
#include "third_party/mbedtls/error.h"
|
||||
#include "third_party/mbedtls/gcm.h"
|
||||
#include "third_party/mbedtls/platform.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
|
@ -102,7 +102,6 @@ void mbedtls_gcm_init( mbedtls_gcm_context *ctx )
|
|||
static int gcm_gen_table( mbedtls_gcm_context *ctx )
|
||||
{
|
||||
int ret, i, j;
|
||||
uint64_t hi, lo;
|
||||
uint64_t vl, vh;
|
||||
unsigned char h[16];
|
||||
size_t olen = 0;
|
||||
|
|
13
third_party/mbedtls/karatsuba.c
vendored
13
third_party/mbedtls/karatsuba.c
vendored
|
@ -24,7 +24,6 @@
|
|||
#include "third_party/mbedtls/platform.h"
|
||||
|
||||
forceinline int Cmp(uint64_t *a, uint64_t *b, size_t n) {
|
||||
size_t i;
|
||||
uint64_t x, y;
|
||||
while (n--) {
|
||||
x = a[n];
|
||||
|
@ -38,8 +37,9 @@ forceinline int Cmp(uint64_t *a, uint64_t *b, size_t n) {
|
|||
|
||||
forceinline bool Sub(uint64_t *C, uint64_t *A, uint64_t *B, size_t n) {
|
||||
bool cf;
|
||||
uint64_t c, i;
|
||||
uint64_t i;
|
||||
#ifdef __x86_64__
|
||||
uint64_t c;
|
||||
asm volatile("xor\t%1,%1\n\t"
|
||||
".align\t16\n1:\t"
|
||||
"mov\t(%5,%3,8),%1\n\t"
|
||||
|
@ -52,7 +52,7 @@ forceinline bool Sub(uint64_t *C, uint64_t *A, uint64_t *B, size_t n) {
|
|||
: "r"(C), "r"(A), "r"(B), "3"(0)
|
||||
: "cc", "memory");
|
||||
#else
|
||||
for (cf = false, c = i = 0; i < n; ++i) {
|
||||
for (cf = false, i = 0; i < n; ++i) {
|
||||
SBB(C[i], A[i], B[i], cf, cf);
|
||||
}
|
||||
#endif
|
||||
|
@ -61,8 +61,9 @@ forceinline bool Sub(uint64_t *C, uint64_t *A, uint64_t *B, size_t n) {
|
|||
|
||||
forceinline bool Add(uint64_t *C, uint64_t *A, uint64_t *B, size_t n) {
|
||||
bool cf;
|
||||
uint64_t c, i;
|
||||
uint64_t i;
|
||||
#ifdef __x86_64__
|
||||
uint64_t c;
|
||||
asm volatile("xor\t%1,%1\n\t"
|
||||
".align\t16\n1:\t"
|
||||
"mov\t(%5,%3,8),%1\n\t"
|
||||
|
@ -75,7 +76,7 @@ forceinline bool Add(uint64_t *C, uint64_t *A, uint64_t *B, size_t n) {
|
|||
: "r"(C), "r"(A), "r"(B), "3"(0)
|
||||
: "cc", "memory");
|
||||
#else
|
||||
for (cf = false, c = i = 0; i < n; ++i) {
|
||||
for (cf = false, i = 0; i < n; ++i) {
|
||||
ADC(C[i], A[i], B[i], cf, cf);
|
||||
}
|
||||
#endif
|
||||
|
@ -89,10 +90,8 @@ forceinline bool Add(uint64_t *C, uint64_t *A, uint64_t *B, size_t n) {
|
|||
* For 16384 bit numbers it's thrice as fast.
|
||||
*/
|
||||
void Karatsuba(uint64_t *C, uint64_t *A, uint64_t *B, size_t n, uint64_t *K) {
|
||||
int q, r;
|
||||
size_t i;
|
||||
uint64_t c, t;
|
||||
uint64_t *x, *y;
|
||||
if (n == 8) {
|
||||
#ifdef __x86_64__
|
||||
if (X86_HAVE(BMI2) && X86_HAVE(ADX)) {
|
||||
|
|
7
third_party/mbedtls/san.c
vendored
7
third_party/mbedtls/san.c
vendored
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/mbedtls/san.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
|
@ -23,7 +24,6 @@
|
|||
#include "third_party/mbedtls/asn1write.h"
|
||||
#include "third_party/mbedtls/oid.h"
|
||||
#include "third_party/mbedtls/platform.h"
|
||||
#include "third_party/mbedtls/san.h"
|
||||
#include "third_party/mbedtls/x509_crt.h"
|
||||
|
||||
/**
|
||||
|
@ -33,9 +33,10 @@
|
|||
*/
|
||||
int mbedtls_x509write_crt_set_subject_alternative_name(
|
||||
mbedtls_x509write_cert *ctx, const struct mbedtls_san *san, size_t sanlen) {
|
||||
int ret, a, b, c;
|
||||
int ret;
|
||||
const unsigned char *item;
|
||||
size_t i, len, cap, itemlen;
|
||||
unsigned char *pc, *buf, *item, ip4[4];
|
||||
unsigned char *pc, *buf, ip4[4];
|
||||
if (!sanlen) return 0;
|
||||
cap = sanlen * (253 + 5 + 1) + 5 + 1;
|
||||
if (!(buf = mbedtls_calloc(1, cap))) return MBEDTLS_ERR_ASN1_ALLOC_FAILED;
|
||||
|
|
7
third_party/mbedtls/secp256r1.c
vendored
7
third_party/mbedtls/secp256r1.c
vendored
|
@ -43,16 +43,18 @@
|
|||
* @see FIPS 186-3 §D.2.3
|
||||
*/
|
||||
void secp256r1(uint64_t p[8]) {
|
||||
int r;
|
||||
char o;
|
||||
signed char E;
|
||||
uint64_t A, B, C, D, a, b, c, d, e;
|
||||
uint64_t A, B, C, D, b, c, d;
|
||||
A = Q(0);
|
||||
B = Q(2);
|
||||
C = Q(4);
|
||||
D = Q(6);
|
||||
E = 0;
|
||||
#if !defined(__x86_64__) || defined(__STRICT_ANSI__)
|
||||
(void)b;
|
||||
(void)c;
|
||||
(void)d;
|
||||
ADC(B, B, H(Q(10)) << 1, 0, o);
|
||||
ADC(C, C, Q(12) << 1 | Q(10) >> 63, o, o);
|
||||
ADC(D, D, Q(14) << 1 | Q(12) >> 63, o, o);
|
||||
|
@ -92,6 +94,7 @@ void secp256r1(uint64_t p[8]) {
|
|||
SBB(D, D, H(Q(12)), o, o);
|
||||
E -= o;
|
||||
#else
|
||||
(void)o;
|
||||
asm volatile(/* x += 2 × ( A₁₅ ‖ A₁₄ ‖ A₁₃ ‖ A₁₂ ‖ A₁₁ ‖ 0 ‖ 0 ‖ 0 ) */
|
||||
"mov\t11*4(%8),%k5\n\t"
|
||||
"mov\t12*4(%8),%6\n\t"
|
||||
|
|
1
third_party/mbedtls/secp384r1.c
vendored
1
third_party/mbedtls/secp384r1.c
vendored
|
@ -112,6 +112,7 @@ void secp384r1(uint64_t p[12]) {
|
|||
SBB(F, F, 0, o, o);
|
||||
G -= o;
|
||||
#else
|
||||
(void)o;
|
||||
asm volatile(/* S₁ = (0 ‖0 ‖0 ‖0 ‖0 ‖A₂₃‖A₂₂‖A₂₁‖0 ‖0 ‖0 ‖0 ) */
|
||||
"mov\t21*4(%9),%7\n\t"
|
||||
"mov\t23*4(%9),%k8\n\t"
|
||||
|
|
2
third_party/mbedtls/sha1.c
vendored
2
third_party/mbedtls/sha1.c
vendored
|
@ -380,8 +380,8 @@ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
|
|||
size_t ilen )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_THIS_CORRUPTION;
|
||||
size_t fill;
|
||||
uint32_t left;
|
||||
size_t n, fill;
|
||||
|
||||
SHA1_VALIDATE_RET( ctx != NULL );
|
||||
SHA1_VALIDATE_RET( ilen == 0 || input != NULL );
|
||||
|
|
4
third_party/mbedtls/shiftright-avx.c
vendored
4
third_party/mbedtls/shiftright-avx.c
vendored
|
@ -25,9 +25,9 @@ typedef uint64_t xmm_t __attribute__((__vector_size__(16), __aligned__(1)));
|
|||
|
||||
void ShiftRightAvx(uint64_t *p, size_t n, unsigned char k) {
|
||||
uint64_t p1;
|
||||
xmm_t o0, o1;
|
||||
xmm_t i0, i1;
|
||||
xmm_t cv = {0};
|
||||
xmm_t i0, i1, i2, i3;
|
||||
xmm_t o0, o1, o2, o3;
|
||||
MBEDTLS_ASSERT(!(k & ~63));
|
||||
p1 = n > 1 ? p[1] : 0;
|
||||
while (n >= 4) {
|
||||
|
|
2
third_party/mbedtls/ssl_msg.c
vendored
2
third_party/mbedtls/ssl_msg.c
vendored
|
@ -1253,8 +1253,6 @@ MBEDTLS_STATIC_TESTABLE int mbedtls_ssl_cf_hmac(
|
|||
const unsigned char * const okey = ikey + block_size;
|
||||
const size_t hash_size = mbedtls_md_get_size( ctx->md_info );
|
||||
|
||||
unsigned char aux_out[MBEDTLS_MD_MAX_SIZE];
|
||||
size_t offset;
|
||||
int ret = MBEDTLS_ERR_THIS_CORRUPTION;
|
||||
|
||||
#define MD_CHK( func_call ) \
|
||||
|
|
2
third_party/mbedtls/ssl_tls.c
vendored
2
third_party/mbedtls/ssl_tls.c
vendored
|
@ -2808,7 +2808,7 @@ static void ssl_calc_finished_tls_sha384(
|
|||
{
|
||||
int len = 12;
|
||||
const char *sender;
|
||||
unsigned char padbuf[48];
|
||||
unsigned char padbuf[64];
|
||||
mbedtls_sha512_context sha512;
|
||||
mbedtls_ssl_session *session = ssl->session_negotiate;
|
||||
if( !session )
|
||||
|
|
4
third_party/mbedtls/test/lib.c
vendored
4
third_party/mbedtls/test/lib.c
vendored
|
@ -78,7 +78,6 @@ int option_verbose = 1;
|
|||
mbedtls_test_info_t mbedtls_test_info;
|
||||
|
||||
int mbedtls_test_platform_setup(void) {
|
||||
char *p;
|
||||
int ret = 0;
|
||||
static char mybuf[2][BUFSIZ];
|
||||
ShowCrashReports();
|
||||
|
@ -132,8 +131,7 @@ int mbedtls_hardware_poll(void *wut, unsigned char *p, size_t n, size_t *olen) {
|
|||
}
|
||||
|
||||
int mbedtls_test_write(const char *fmt, ...) {
|
||||
int i, n;
|
||||
char *p;
|
||||
int n;
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
if (option_verbose) {
|
||||
|
|
8
third_party/mbedtls/test/secp384r1_test.c
vendored
8
third_party/mbedtls/test/secp384r1_test.c
vendored
|
@ -59,14 +59,6 @@ TEST(secp384r1, testIsTheSame) {
|
|||
|
||||
TEST(secp384r1, needsDownwardCorrection) {
|
||||
int i;
|
||||
uint64_t P[6] = {
|
||||
0x00000000ffffffff, //
|
||||
0xffffffff00000000, //
|
||||
0xfffffffffffffffe, //
|
||||
0xffffffffffffffff, //
|
||||
0xffffffffffffffff, //
|
||||
0xffffffffffffffff, //
|
||||
};
|
||||
uint64_t X[12] = {
|
||||
0xffffffffffffffff, //
|
||||
0xffffffffffffffff, //
|
||||
|
|
|
@ -512,6 +512,8 @@ void test_aes_check_params( )
|
|||
const int valid_mode = MBEDTLS_AES_ENCRYPT;
|
||||
const int invalid_mode = 42;
|
||||
|
||||
(void)size;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_aes_init( NULL ) );
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
TEST_INVALID_PARAM( mbedtls_aes_xts_init( NULL ) );
|
||||
|
|
|
@ -502,6 +502,8 @@ void test_aes_check_params( )
|
|||
const int valid_mode = MBEDTLS_AES_ENCRYPT;
|
||||
const int invalid_mode = 42;
|
||||
|
||||
(void)size;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_aes_init( NULL ) );
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
TEST_INVALID_PARAM( mbedtls_aes_xts_init( NULL ) );
|
||||
|
|
|
@ -501,6 +501,8 @@ void test_aes_check_params( )
|
|||
size_t size;
|
||||
const int valid_mode = MBEDTLS_AES_ENCRYPT;
|
||||
const int invalid_mode = 42;
|
||||
|
||||
(void)size;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_aes_init( NULL ) );
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
|
|
|
@ -502,6 +502,8 @@ void test_aes_check_params( )
|
|||
const int valid_mode = MBEDTLS_AES_ENCRYPT;
|
||||
const int invalid_mode = 42;
|
||||
|
||||
(void)size;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_aes_init( NULL ) );
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
TEST_INVALID_PARAM( mbedtls_aes_xts_init( NULL ) );
|
||||
|
|
|
@ -502,6 +502,8 @@ void test_aes_check_params( )
|
|||
const int valid_mode = MBEDTLS_AES_ENCRYPT;
|
||||
const int invalid_mode = 42;
|
||||
|
||||
(void)size;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_aes_init( NULL ) );
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
TEST_INVALID_PARAM( mbedtls_aes_xts_init( NULL ) );
|
||||
|
|
|
@ -502,6 +502,8 @@ void test_aes_check_params( )
|
|||
const int valid_mode = MBEDTLS_AES_ENCRYPT;
|
||||
const int invalid_mode = 42;
|
||||
|
||||
(void)size;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_aes_init( NULL ) );
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
TEST_INVALID_PARAM( mbedtls_aes_xts_init( NULL ) );
|
||||
|
|
8
third_party/musl/glob.c
vendored
8
third_party/musl/glob.c
vendored
|
@ -25,17 +25,17 @@
|
|||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/alg.h"
|
||||
#include "third_party/musl/glob.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/dt.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "third_party/musl/fnmatch.h"
|
||||
#include "third_party/musl/glob.h"
|
||||
|
||||
#define MAXPATH 1024
|
||||
|
||||
|
@ -186,7 +186,7 @@ static int PerformGlob(char *buf, size_t pos, int type, char *pat, int flags,
|
|||
/* With GLOB_PERIOD don't allow matching . or .. unless fnmatch()
|
||||
* would match them with FNM_PERIOD rules in effect. */
|
||||
if (p2 && (flags & GLOB_PERIOD) && de->d_name[0] == '.' &&
|
||||
(!de->d_name[1] || de->d_name[1] == '.' && !de->d_name[2]) &&
|
||||
(!de->d_name[1] || (de->d_name[1] == '.' && !de->d_name[2])) &&
|
||||
fnmatch(pat, de->d_name, fnm_flags | FNM_PERIOD)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ int glob(const char *pat, int flags, int errfunc(const char *path, int err),
|
|||
glob_t *g) {
|
||||
int error = 0;
|
||||
size_t cnt, i;
|
||||
char *p, **pathv, buf[MAXPATH];
|
||||
char **pathv, buf[MAXPATH];
|
||||
struct GlobList head = {.next = NULL}, *tail = &head;
|
||||
size_t offs = (flags & GLOB_DOOFFS) ? g->gl_offs : 0;
|
||||
if (!errfunc) errfunc = IgnoreGlobError;
|
||||
|
|
4
third_party/musl/rand48.c
vendored
4
third_party/musl/rand48.c
vendored
|
@ -39,8 +39,8 @@ static unsigned short __seed48[7] = { 0, 0, 0, 0xe66d, 0xdeec, 0x5, 0xb };
|
|||
static uint64_t __rand48_step(unsigned short *xi, unsigned short *lc)
|
||||
{
|
||||
uint64_t a, x;
|
||||
x = xi[0] | xi[1]+0U<<16 | xi[2]+0ULL<<32;
|
||||
a = lc[0] | lc[1]+0U<<16 | lc[2]+0ULL<<32;
|
||||
x = xi[0] | (xi[1]+0U)<<16 | (xi[2]+0ULL)<<32;
|
||||
a = lc[0] | (lc[1]+0U)<<16 | (lc[2]+0ULL)<<32;
|
||||
x = a*x + lc[3];
|
||||
xi[0] = x;
|
||||
xi[1] = x>>16;
|
||||
|
|
4
third_party/musl/tempnam.c
vendored
4
third_party/musl/tempnam.c
vendored
|
@ -25,6 +25,7 @@
|
|||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/musl/tempnam.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
|
@ -35,7 +36,6 @@
|
|||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "third_party/musl/tempnam.h"
|
||||
|
||||
#define MAXTRIES 100
|
||||
|
||||
|
@ -52,7 +52,7 @@ __randname(char *template)
|
|||
struct timespec ts;
|
||||
unsigned long r;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
r = ts.tv_nsec * 65537 ^ (uintptr_t)&ts / 16 + (uintptr_t) template;
|
||||
r = ts.tv_nsec * 65537 ^ ((uintptr_t)&ts / 16 + (uintptr_t) template);
|
||||
for (i = 0; i < 6; i++, r >>= 5) template[i] = 'A' + (r & 15) + (r & 16) * 2;
|
||||
return template;
|
||||
}
|
||||
|
|
9
third_party/nsync/futex.c
vendored
9
third_party/nsync/futex.c
vendored
|
@ -163,9 +163,8 @@ static int nsync_futex_polyfill_ (atomic_int *w, int expect, struct timespec *ab
|
|||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static int nsync_futex_wait_win32_ (atomic_int *w, int expect, char pshare, struct timespec *timeout) {
|
||||
static int nsync_futex_wait_win32_ (atomic_int *w, int expect, char pshare, const struct timespec *timeout) {
|
||||
int rc;
|
||||
uint32_t ms;
|
||||
struct timespec deadline, interval, remain, wait, now;
|
||||
|
||||
if (timeout) {
|
||||
|
@ -211,8 +210,8 @@ static struct timespec *nsync_futex_timeout_ (struct timespec *memory,
|
|||
}
|
||||
}
|
||||
|
||||
int nsync_futex_wait_ (atomic_int *w, int expect, char pshare, struct timespec *abstime) {
|
||||
int e, rc, op, fop;
|
||||
int nsync_futex_wait_ (atomic_int *w, int expect, char pshare, const struct timespec *abstime) {
|
||||
int e, rc, op;
|
||||
struct PosixThread *pt = 0;
|
||||
struct timespec tsmem, *timeout;
|
||||
|
||||
|
@ -298,7 +297,7 @@ Finished:
|
|||
}
|
||||
|
||||
int nsync_futex_wake_ (atomic_int *w, int count, char pshare) {
|
||||
int e, rc, op, fop;
|
||||
int rc, op, fop;
|
||||
|
||||
ASSERT (count == 1 || count == INT_MAX);
|
||||
|
||||
|
|
2
third_party/nsync/futex.internal.h
vendored
2
third_party/nsync/futex.internal.h
vendored
|
@ -6,7 +6,7 @@
|
|||
COSMOPOLITAN_C_START_
|
||||
|
||||
int nsync_futex_wake_(_Atomic(int) *, int, char);
|
||||
int nsync_futex_wait_(_Atomic(int) *, int, char, struct timespec *);
|
||||
int nsync_futex_wait_(_Atomic(int) *, int, char, const struct timespec *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
4
third_party/nsync/mu_semaphore_futex.c
vendored
4
third_party/nsync/mu_semaphore_futex.c
vendored
|
@ -52,7 +52,7 @@ void nsync_mu_semaphore_init_futex (nsync_semaphore *s) {
|
|||
/* Wait until the count of *s exceeds 0, and decrement it. */
|
||||
errno_t nsync_mu_semaphore_p_futex (nsync_semaphore *s) {
|
||||
struct futex *f = (struct futex *) s;
|
||||
int e, i;
|
||||
int i;
|
||||
errno_t result = 0;
|
||||
do {
|
||||
i = ATM_LOAD ((nsync_atomic_uint32_ *) &f->i);
|
||||
|
@ -79,7 +79,7 @@ errno_t nsync_mu_semaphore_p_futex (nsync_semaphore *s) {
|
|||
or abs_deadline expires, in which case return ETIMEDOUT. */
|
||||
errno_t nsync_mu_semaphore_p_with_deadline_futex (nsync_semaphore *s, nsync_time abs_deadline) {
|
||||
struct futex *f = (struct futex *)s;
|
||||
int e, i;
|
||||
int i;
|
||||
int result = 0;
|
||||
do {
|
||||
i = ATM_LOAD ((nsync_atomic_uint32_ *) &f->i);
|
||||
|
|
1
third_party/nsync/mu_semaphore_gcd.c
vendored
1
third_party/nsync/mu_semaphore_gcd.c
vendored
|
@ -50,6 +50,7 @@ static long dispatch_semaphore_wait (dispatch_semaphore_t ds,
|
|||
|
||||
static long dispatch_semaphore_signal (dispatch_semaphore_t ds) {
|
||||
long rc = __syslib->dispatch_semaphore_signal (ds);
|
||||
(void)rc;
|
||||
STRACE ("dispatch_semaphore_signal(%#lx) → %ld", ds, rc);
|
||||
return (ds);
|
||||
}
|
||||
|
|
1
third_party/python/Include/datetime.h
vendored
1
third_party/python/Include/datetime.h
vendored
|
@ -4,6 +4,7 @@
|
|||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
|
||||
/* Fields are packed into successive bytes, each viewed as unsigned and
|
||||
* big-endian, unless otherwise noted:
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "third_party/python/Include/pymacro.h"
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
|
||||
/******************************************************************************/
|
||||
/* Module */
|
||||
|
@ -871,6 +873,7 @@ PyDoc_STRVAR(doc_ctx_to_sci_string,
|
|||
Convert a number to a string using scientific notation.\n\
|
||||
\n");
|
||||
|
||||
#pragma GCC pop_options
|
||||
|
||||
#endif /* DOCSTRINGS_H */
|
||||
|
||||
|
|
10
third_party/python/Modules/_hashmbedtls.c
vendored
10
third_party/python/Modules/_hashmbedtls.c
vendored
|
@ -54,10 +54,10 @@ PYTHON_PROVIDE("_hashlib.mbedtls_sha512");
|
|||
|
||||
struct Hasher {
|
||||
PyObject_HEAD
|
||||
PyObject *name;
|
||||
const PyObject *name;
|
||||
mbedtls_md_context_t ctx;
|
||||
#ifdef WITH_THREAD
|
||||
PyThread_type_lock lock;
|
||||
PyThread_type_lock lock;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -81,7 +81,7 @@ SetMbedtlsError(PyObject *exc, int rc)
|
|||
}
|
||||
|
||||
static struct Hasher *
|
||||
hasher_new(PyObject *name)
|
||||
hasher_new(const PyObject *name)
|
||||
{
|
||||
struct Hasher *self;
|
||||
if ((self = PyObject_New(struct Hasher, &hasher_type))) {
|
||||
|
@ -304,7 +304,7 @@ static PyTypeObject hasher_type = {
|
|||
};
|
||||
|
||||
static PyObject *
|
||||
NewHasher(PyObject *name_obj,
|
||||
NewHasher(const PyObject *name_obj,
|
||||
const mbedtls_md_info_t *digest,
|
||||
void *p, Py_ssize_t n)
|
||||
{
|
||||
|
@ -482,7 +482,7 @@ GenerateHashNameList(void)
|
|||
{
|
||||
int i;
|
||||
char *s;
|
||||
uint8_t *p;
|
||||
const uint8_t *p;
|
||||
PyObject *set, *name;
|
||||
if ((set = PyFrozenSet_New(0))) {
|
||||
for (p = mbedtls_md_list(); *p != MBEDTLS_MD_NONE; ++p) {
|
||||
|
|
3
third_party/python/Modules/_testcapimodule.c
vendored
3
third_party/python/Modules/_testcapimodule.c
vendored
|
@ -4305,6 +4305,7 @@ tracemalloc_track(PyObject *self, PyObject *args)
|
|||
Py_ssize_t size;
|
||||
int release_gil = 0;
|
||||
int res;
|
||||
(void)ptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "IOn|i", &domain, &ptr_obj, &size, &release_gil))
|
||||
return NULL;
|
||||
|
@ -4336,6 +4337,7 @@ tracemalloc_untrack(PyObject *self, PyObject *args)
|
|||
PyObject *ptr_obj;
|
||||
void *ptr;
|
||||
int res;
|
||||
(void)ptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "IO", &domain, &ptr_obj))
|
||||
return NULL;
|
||||
|
@ -4358,6 +4360,7 @@ tracemalloc_get_traceback(PyObject *self, PyObject *args)
|
|||
unsigned int domain;
|
||||
PyObject *ptr_obj;
|
||||
void *ptr;
|
||||
(void)ptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "IO", &domain, &ptr_obj))
|
||||
return NULL;
|
||||
|
|
|
@ -244,10 +244,13 @@ getcodec(PyObject *self, PyObject *encoding)
|
|||
return r;
|
||||
}
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
static struct PyMethodDef __methods[] = {
|
||||
{"getcodec", (PyCFunction)getcodec, METH_O, ""},
|
||||
{0},
|
||||
};
|
||||
#pragma GCC pop_options
|
||||
|
||||
#ifdef USING_BINARY_PAIR_SEARCH
|
||||
static DBCHAR
|
||||
|
|
2
third_party/python/Modules/main.c
vendored
2
third_party/python/Modules/main.c
vendored
|
@ -405,6 +405,8 @@ Py_Main(int argc, wchar_t **argv)
|
|||
PyObject *warning_option = NULL;
|
||||
PyObject *warning_options = NULL;
|
||||
|
||||
(void)opt;
|
||||
|
||||
cf.cf_flags = 0;
|
||||
|
||||
orig_argc = argc; /* For Py_GetArgcArgv() */
|
||||
|
|
3
third_party/python/Modules/socketmodule.c
vendored
3
third_party/python/Modules/socketmodule.c
vendored
|
@ -687,7 +687,6 @@ internal_setblocking(PySocketSockObject *s, int block)
|
|||
#endif
|
||||
#if !defined(MS_WINDOWS) \
|
||||
&& !((defined(HAVE_SYS_IOCTL_H) && defined(FIONBIO)))
|
||||
int delay_flag, new_delay_flag;
|
||||
#endif
|
||||
#ifdef SOCK_NONBLOCK
|
||||
if (block)
|
||||
|
@ -5655,7 +5654,7 @@ socket_inet_aton(PyObject *self, PyObject *args)
|
|||
#ifdef HAVE_INET_ATON
|
||||
|
||||
#ifdef USE_INET_ATON_WEAKLINK
|
||||
if (inet_aton != NULL) {
|
||||
if (__veil("r", inet_aton) != NULL) {
|
||||
#endif
|
||||
if (inet_aton(ip_addr, &buf))
|
||||
return PyBytes_FromStringAndSize((char *)(&buf),
|
||||
|
|
1
third_party/python/Modules/timemodule.c
vendored
1
third_party/python/Modules/timemodule.c
vendored
|
@ -1520,7 +1520,6 @@ pysleep(_PyTime_t secs)
|
|||
{
|
||||
_PyTime_t deadline, monotonic;
|
||||
#ifndef MS_WINDOWS
|
||||
struct timeval timeout;
|
||||
struct timespec timeout2;
|
||||
int err = 0;
|
||||
#else
|
||||
|
|
5
third_party/python/Modules/tlsmodule.c
vendored
5
third_party/python/Modules/tlsmodule.c
vendored
|
@ -285,7 +285,6 @@ tls_recv_into(struct Tls *self, PyObject *args)
|
|||
{
|
||||
LOG("TLS.recv_into\n");
|
||||
int rc;
|
||||
Py_ssize_t n;
|
||||
PyObject *res;
|
||||
Py_buffer buf;
|
||||
if (!PyArg_ParseTuple(args, "w*:recv_into", &buf)) return 0;
|
||||
|
@ -458,7 +457,7 @@ Creates TLS client.");
|
|||
static PyObject *
|
||||
newclient(PyObject *self, PyObject *args)
|
||||
{
|
||||
int rc, fd;
|
||||
int fd;
|
||||
PyObject *todo;
|
||||
struct Tls *tls;
|
||||
const char *host;
|
||||
|
@ -483,7 +482,7 @@ static struct PyModuleDef mbedtls_module = {
|
|||
PyMODINIT_FUNC
|
||||
PyInit_tls(void)
|
||||
{
|
||||
PyObject *m, *mbedtls_md_meth_names;
|
||||
PyObject *m;
|
||||
Py_TYPE(&tls_type) = &PyType_Type;
|
||||
if (PyType_Ready(&tls_type) < 0) return 0;
|
||||
if (!(m = PyModule_Create(&mbedtls_module))) return 0;
|
||||
|
|
|
@ -270,7 +270,7 @@ _PyUnicode_GetUcName(PyObject *self, Py_UCS4 code, char *buffer, int buflen,
|
|||
/* copy word string from lexicon. the last character in the
|
||||
word has bit 7 set. the last word in a string ends with
|
||||
0x80 */
|
||||
w = (_PyUnicode_Lexicon +
|
||||
w = (void *)(_PyUnicode_Lexicon +
|
||||
BitFieldExtract(_PyUnicode_LexiconOffset, word,
|
||||
_PyUnicode_LexiconOffsetBits));
|
||||
while (*w < 128) {
|
||||
|
|
5
third_party/python/Objects/descrobject.c
vendored
5
third_party/python/Objects/descrobject.c
vendored
|
@ -4,10 +4,10 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Include/descrobject.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
#include "third_party/python/Include/ceval.h"
|
||||
#include "third_party/python/Include/descrobject.h"
|
||||
#include "third_party/python/Include/dictobject.h"
|
||||
#include "third_party/python/Include/modsupport.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
|
@ -297,7 +297,8 @@ _PyMethodDescr_FastCallKeywords(PyObject *descrobj,
|
|||
}
|
||||
|
||||
result = _PyMethodDef_RawFastCallKeywords(descr->d_method, self,
|
||||
args+1, nargs-1, kwnames);
|
||||
(void *)(args+1), nargs-1,
|
||||
kwnames);
|
||||
result = _Py_CheckFunctionResult((PyObject *)descr, result, NULL);
|
||||
return result;
|
||||
}
|
||||
|
|
1
third_party/python/Objects/object.c
vendored
1
third_party/python/Objects/object.c
vendored
|
@ -464,6 +464,7 @@ int
|
|||
_PyObject_IsFreed(PyObject *op)
|
||||
{
|
||||
uintptr_t ptr = (uintptr_t)op;
|
||||
(void)ptr;
|
||||
if (_PyMem_IsFreed(&ptr, sizeof(ptr))) {
|
||||
return 1;
|
||||
}
|
||||
|
|
3
third_party/python/Objects/structseq.c
vendored
3
third_party/python/Objects/structseq.c
vendored
|
@ -4,13 +4,13 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Include/structseq.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/dictobject.h"
|
||||
#include "third_party/python/Include/longobject.h"
|
||||
#include "third_party/python/Include/modsupport.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
#include "third_party/python/Include/structmember.h"
|
||||
#include "third_party/python/Include/structseq.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Implementation helper: a struct that looks like a tuple. See timemodule
|
||||
|
@ -188,6 +188,7 @@ structseq_repr(PyStructSequence *obj)
|
|||
/* "typename(", limited to TYPE_MAXSIZE */
|
||||
len = strlen(typ->tp_name) > TYPE_MAXSIZE ? TYPE_MAXSIZE :
|
||||
strlen(typ->tp_name);
|
||||
#pragma GCC diagnostic ignored "-Wstringop-truncation"
|
||||
strncpy(pbuf, typ->tp_name, len);
|
||||
pbuf += len;
|
||||
*pbuf++ = '(';
|
||||
|
|
6
third_party/python/Python/ceval.c
vendored
6
third_party/python/Python/ceval.c
vendored
|
@ -5353,6 +5353,9 @@ dtrace_function_entry(PyFrameObject *f)
|
|||
char* filename;
|
||||
char* funcname;
|
||||
int lineno;
|
||||
(void)filename;
|
||||
(void)funcname;
|
||||
(void)lineno;
|
||||
filename = PyUnicode_AsUTF8(f->f_code->co_filename);
|
||||
funcname = PyUnicode_AsUTF8(f->f_code->co_name);
|
||||
lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
|
||||
|
@ -5365,6 +5368,9 @@ dtrace_function_return(PyFrameObject *f)
|
|||
char* filename;
|
||||
char* funcname;
|
||||
int lineno;
|
||||
(void)filename;
|
||||
(void)funcname;
|
||||
(void)lineno;
|
||||
filename = PyUnicode_AsUTF8(f->f_code->co_filename);
|
||||
funcname = PyUnicode_AsUTF8(f->f_code->co_name);
|
||||
lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
|
||||
|
|
9
third_party/python/Python/cosmomodule.c
vendored
9
third_party/python/Python/cosmomodule.c
vendored
|
@ -100,13 +100,13 @@ cosmo_rdtsc(PyObject *self, PyObject *noargs)
|
|||
return PyLong_FromUnsignedLong(rdtsc());
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
PyDoc_STRVAR(getcpucore_doc,
|
||||
"getcpucore($module)\n\
|
||||
--\n\n\
|
||||
Returns 0-indexed CPU core on which process is currently scheduled.");
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
static PyObject *
|
||||
cosmo_getcpucore(PyObject *self, PyObject *noargs)
|
||||
{
|
||||
|
@ -137,7 +137,6 @@ Similar to zlib.crc32().");
|
|||
static PyObject *
|
||||
cosmo_crc32c(PyObject *self, PyObject *args)
|
||||
{
|
||||
Py_ssize_t n;
|
||||
Py_buffer data;
|
||||
unsigned crc, init = 0;
|
||||
if (!PyArg_ParseTuple(args, "y*|I:crc32c", &data, &init)) return 0;
|
||||
|
@ -283,8 +282,6 @@ cosmo_exit1(PyObject *self, PyObject *args)
|
|||
_Exit(1);
|
||||
}
|
||||
|
||||
static bool ftrace_installed = 0;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
} FtracerObject;
|
||||
|
@ -327,6 +324,7 @@ static PyTypeObject FtracerType = {
|
|||
.tp_methods = FtracerObject_methods,
|
||||
};
|
||||
|
||||
#ifdef FTRACE
|
||||
PyDoc_STRVAR(ftrace_doc,
|
||||
"ftrace($module)\n\
|
||||
--\n\n\
|
||||
|
@ -337,6 +335,7 @@ Enables logging of C function calls to stderr, e.g.\n\
|
|||
\n\
|
||||
Please be warned this prints massive amount of text. In order for it\n\
|
||||
to work, the concomitant .com.dbg binary needs to be present.");
|
||||
#endif
|
||||
|
||||
static PyObject *
|
||||
cosmo_ftrace(PyObject *self, PyObject *noargs)
|
||||
|
|
1
third_party/python/Python/fatality.c
vendored
1
third_party/python/Python/fatality.c
vendored
|
@ -17,7 +17,6 @@
|
|||
/* clang-format off */
|
||||
|
||||
_Py_IDENTIFIER(flush);
|
||||
_Py_IDENTIFIER(stdout);
|
||||
_Py_IDENTIFIER(stderr);
|
||||
|
||||
/* Import the site module (not into __main__ though) */
|
||||
|
|
5
third_party/python/Python/import.c
vendored
5
third_party/python/Python/import.c
vendored
|
@ -865,7 +865,7 @@ PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co,
|
|||
{
|
||||
struct stat stinfo;
|
||||
PyObject *m = NULL;
|
||||
PyObject *nameobj, *pathobj = NULL, *cpathobj = NULL, *external= NULL;
|
||||
PyObject *nameobj, *pathobj = NULL, *cpathobj = NULL;
|
||||
|
||||
nameobj = PyUnicode_FromString(name);
|
||||
if (nameobj == NULL)
|
||||
|
@ -1183,7 +1183,7 @@ _imp_create_builtin(PyObject *module, PyObject *spec)
|
|||
res = bsearch(&key, Builtins_Lookup.entries, Builtins_Lookup.n, sizeof(initentry), cmp_initentry);
|
||||
|
||||
if (res != NULL) {
|
||||
p = res->tab;
|
||||
p = (void *)res->tab;
|
||||
PyModuleDef *def;
|
||||
if (p->initfunc == NULL) {
|
||||
/* Cannot re-init internal module ("sys" or "builtins") */
|
||||
|
@ -2491,7 +2491,6 @@ static PyObject *SFLObject_get_code(SourcelessFileLoader *self, PyObject *arg) {
|
|||
FILE *fp = NULL;
|
||||
PyObject *res = NULL;
|
||||
char *rawbuf = NULL;
|
||||
size_t rawlen = 0;
|
||||
|
||||
if (!PyArg_Parse(arg, "z:get_code", &name)) return 0;
|
||||
if (!name) name = self->name;
|
||||
|
|
1
third_party/python/Python/initimport.c
vendored
1
third_party/python/Python/initimport.c
vendored
|
@ -30,7 +30,6 @@ _Py_InitImport(PyInterpreterState *interp, PyObject *sysmod)
|
|||
{
|
||||
PyObject *importlib;
|
||||
PyObject *impmod;
|
||||
PyObject *cosmomod;
|
||||
PyObject *sys_modules;
|
||||
PyObject *value;
|
||||
|
||||
|
|
7
third_party/python/Python/pylifecycle.c
vendored
7
third_party/python/Python/pylifecycle.c
vendored
|
@ -4,6 +4,7 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Include/pylifecycle.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
|
@ -13,8 +14,8 @@
|
|||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/str/locale.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/ast.h"
|
||||
|
@ -37,7 +38,6 @@
|
|||
#include "third_party/python/Include/parsetok.h"
|
||||
#include "third_party/python/Include/pydebug.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/pylifecycle.h"
|
||||
#include "third_party/python/Include/pymem.h"
|
||||
#include "third_party/python/Include/pystrcmp.h"
|
||||
#include "third_party/python/Include/pytime.h"
|
||||
|
@ -53,9 +53,6 @@
|
|||
|
||||
/* Python interpreter top-level routines, including init/exit */
|
||||
|
||||
_Py_IDENTIFIER(name);
|
||||
_Py_IDENTIFIER(flush);
|
||||
_Py_IDENTIFIER(stdout);
|
||||
_Py_IDENTIFIER(stderr);
|
||||
|
||||
/* Forward */
|
||||
|
|
5
third_party/python/Python/random.c
vendored
5
third_party/python/Python/random.c
vendored
|
@ -11,8 +11,8 @@
|
|||
#include "libc/fmt/conv.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
#include "libc/sysv/consts/grnd.h"
|
||||
|
@ -392,7 +392,6 @@ void
|
|||
_PyRandom_Init(void)
|
||||
{
|
||||
char *env;
|
||||
const unsigned char *auxrng;
|
||||
unsigned char *secret = (unsigned char *)&_Py_HashSecret.uc;
|
||||
Py_ssize_t secret_size = sizeof(_Py_HashSecret_t);
|
||||
Py_BUILD_ASSERT(sizeof(_Py_HashSecret_t) == sizeof(_Py_HashSecret.uc));
|
||||
|
@ -431,7 +430,7 @@ _PyRandom_Init(void)
|
|||
}
|
||||
else {
|
||||
uint64_t x;
|
||||
int res, i, j;
|
||||
int i, j;
|
||||
/* _PyRandom_Init() is called very early in the Python initialization
|
||||
and so exceptions cannot be used (use raise=0).
|
||||
_PyRandom_Init() must not block Python initialization: call
|
||||
|
|
35
third_party/python/Python/sysmodule.c
vendored
35
third_party/python/Python/sysmodule.c
vendored
|
@ -1026,11 +1026,6 @@ sys_getwindowsversion(PyObject *self)
|
|||
int pos = 0;
|
||||
PyObject *version;
|
||||
struct NtOsVersionInfo ver;
|
||||
uint32_t realMajor, realMinor, realBuild;
|
||||
int64_t hKernel32;
|
||||
wchar_t kernel32_path[PATH_MAX];
|
||||
void *verblock;
|
||||
uint32_t verblock_size;
|
||||
|
||||
if (!IsWindows()) {
|
||||
PyErr_SetString(PyExc_SystemError, "this is not windows");
|
||||
|
@ -1055,36 +1050,6 @@ sys_getwindowsversion(PyObject *self)
|
|||
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wSuiteMask));
|
||||
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wProductType));
|
||||
|
||||
realMajor = ver.dwMajorVersion;
|
||||
realMinor = ver.dwMinorVersion;
|
||||
realBuild = ver.dwBuildNumber;
|
||||
|
||||
#if 0 // todo(jart): port me
|
||||
// GetVersion will lie if we are running in a compatibility mode.
|
||||
// We need to read the version info from a system file resource
|
||||
// to accurately identify the OS version. If we fail for any reason,
|
||||
// just return whatever GetVersion said.
|
||||
hKernel32 = GetModuleHandle("kernel32.dll");
|
||||
if (hKernel32 && GetModuleFileNameW(hKernel32, kernel32_path, MAX_PATH) &&
|
||||
(verblock_size = GetFileVersionInfoSizeW(kernel32_path, NULL)) &&
|
||||
(verblock = PyMem_RawMalloc(verblock_size))) {
|
||||
VS_FIXEDFILEINFO *ffi;
|
||||
UINT ffi_len;
|
||||
if (GetFileVersionInfoW(kernel32_path, 0, verblock_size, verblock) &&
|
||||
VerQueryValueW(verblock, L"", (LPVOID)&ffi, &ffi_len)) {
|
||||
realMajor = HIWORD(ffi->dwProductVersionMS);
|
||||
realMinor = LOWORD(ffi->dwProductVersionMS);
|
||||
realBuild = HIWORD(ffi->dwProductVersionLS);
|
||||
}
|
||||
PyMem_RawFree(verblock);
|
||||
}
|
||||
PyStructSequence_SET_ITEM(version, pos++, Py_BuildValue("(kkk)",
|
||||
realMajor,
|
||||
realMinor,
|
||||
realBuild
|
||||
));
|
||||
#endif
|
||||
|
||||
if (PyErr_Occurred()) {
|
||||
Py_DECREF(version);
|
||||
return NULL;
|
||||
|
|
2
third_party/python/launch.c
vendored
2
third_party/python/launch.c
vendored
|
@ -51,7 +51,7 @@ PYTHON_YOINK("launchpy");
|
|||
|
||||
extern char kLaunchPythonModuleName[]; /* generated by pyobj.com */
|
||||
const struct _frozen *PyImport_FrozenModules = _PyImport_FrozenModules;
|
||||
struct _inittab *PyImport_Inittab = _PyImport_Inittab;
|
||||
struct _inittab *PyImport_Inittab = (void *)_PyImport_Inittab;
|
||||
|
||||
int
|
||||
LaunchPythonModule(const char *name)
|
||||
|
|
3
third_party/python/pycomp.c
vendored
3
third_party/python/pycomp.c
vendored
|
@ -77,7 +77,6 @@ void
|
|||
GetOpts(int argc, char *argv[])
|
||||
{
|
||||
int opt;
|
||||
char *outdir;
|
||||
while ((opt = getopt(argc, argv, "hnO:o:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'O':
|
||||
|
@ -114,7 +113,7 @@ main(int argc, char *argv[])
|
|||
ssize_t rc;
|
||||
size_t i, n;
|
||||
struct stat st;
|
||||
char *s, *p, m[12];
|
||||
char *p, m[12];
|
||||
PyObject *code, *marshalled;
|
||||
ShowCrashReports();
|
||||
GetOpts(argc, argv);
|
||||
|
|
7
third_party/python/pyobj.c
vendored
7
third_party/python/pyobj.c
vendored
|
@ -215,9 +215,6 @@ const char *const kIgnoredModules[] = /* sorted */ {
|
|||
/* "xml.dom", */
|
||||
};
|
||||
|
||||
_Py_IDENTIFIER(stdout);
|
||||
_Py_IDENTIFIER(stderr);
|
||||
|
||||
struct Yoinks {
|
||||
size_t n;
|
||||
char **p;
|
||||
|
@ -469,13 +466,13 @@ Analyze(const char *modname, PyObject *code, struct Interner *globals)
|
|||
int rc;
|
||||
bool istry;
|
||||
unsigned a;
|
||||
size_t i, j, n;
|
||||
size_t i, n;
|
||||
char *p, *mod, *imp;
|
||||
int x, y, op, arg, rel;
|
||||
PyObject *co_code, *co_names, *co_consts, *name, *iter, *item;
|
||||
rc = 0;
|
||||
mod = 0;
|
||||
istry = rel = 0;
|
||||
istry = (rel = 0);
|
||||
assert(PyCode_Check(code));
|
||||
co_code = ((PyCodeObject *)code)->co_code;
|
||||
co_names = ((PyCodeObject *)code)->co_names;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue