mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Give Emacs another performance boost
This commit is contained in:
parent
5b42c810a5
commit
9c7b81ee0f
30 changed files with 253 additions and 102 deletions
2
Makefile
2
Makefile
|
@ -324,6 +324,7 @@ COSMOPOLITAN_OBJECTS = \
|
|||
LIBC_LOG \
|
||||
LIBC_TIME \
|
||||
THIRD_PARTY_MUSL \
|
||||
THIRD_PARTY_ZLIB_GZ \
|
||||
LIBC_STDIO \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_REGEX \
|
||||
|
@ -347,6 +348,7 @@ COSMOPOLITAN_OBJECTS = \
|
|||
LIBC_NT_ADVAPI32 \
|
||||
LIBC_NT_SYNCHRONIZATION \
|
||||
LIBC_FMT \
|
||||
THIRD_PARTY_ZLIB \
|
||||
THIRD_PARTY_PUFF \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
LIBC_TINYMATH \
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/_getauxval.internal.h"
|
||||
#include "libc/intrin/getauxval.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
|||
int issetugid(void) {
|
||||
int rc;
|
||||
if (IsLinux()) {
|
||||
rc = !!_getauxval(AT_SECURE).value;
|
||||
rc = !!__getauxval(AT_SECURE).value;
|
||||
} else if (IsMetal()) {
|
||||
rc = 0;
|
||||
} else {
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/ntspawn.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/_getenv.internal.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/getenv.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/alloca.h"
|
||||
#include "libc/mem/arraylist2.internal.h"
|
||||
|
@ -154,7 +154,7 @@ textwindows int mkntenvblock(char16_t envvars[ARG_MAX / 2], char *const envp[],
|
|||
if (!have_systemroot && environ) {
|
||||
// https://jpassing.com/2009/12/28/the-hidden-danger-of-forgetting-to-specify-systemroot-in-a-custom-environment-block/
|
||||
struct Env systemroot;
|
||||
systemroot = _getenv(environ, "SYSTEMROOT");
|
||||
systemroot = __getenv(environ, "SYSTEMROOT");
|
||||
if (systemroot.s) {
|
||||
InsertString(vars, n++, environ[systemroot.i], buf, &bufi,
|
||||
&have_systemroot);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/_getauxval.internal.h"
|
||||
#include "libc/intrin/getauxval.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@
|
|||
* @see System Five Application Binary Interface § 3.4.3
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
dontasan struct AuxiliaryValue _getauxval(unsigned long at) {
|
||||
dontasan struct AuxiliaryValue __getauxval(unsigned long at) {
|
||||
unsigned long *ap;
|
||||
for (ap = __auxv; ap[0]; ap += 2) {
|
||||
if (at == ap[0]) {
|
|
@ -17,12 +17,12 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/_getenv.internal.h"
|
||||
#include "libc/intrin/getenv.internal.h"
|
||||
|
||||
#define ToUpper(c) \
|
||||
(IsWindows() && (c) >= 'a' && (c) <= 'z' ? (c) - 'a' + 'A' : (c))
|
||||
|
||||
struct Env _getenv(char **p, const char *k) {
|
||||
dontasan struct Env __getenv(char **p, const char *k) {
|
||||
char *t;
|
||||
int i, j;
|
||||
for (i = 0; (t = p[i]); ++i) {
|
|
@ -1,15 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN_GETAUXVAL_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN_GETAUXVAL_INTERNAL_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct AuxiliaryValue {
|
||||
unsigned long value;
|
||||
bool isfound;
|
||||
};
|
||||
|
||||
struct AuxiliaryValue _getauxval(unsigned long);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_GETAUXVAL_INTERNAL_H_ */
|
|
@ -1,15 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN__GETENV_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN__GETENV_INTERNAL_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct Env {
|
||||
char *s;
|
||||
int i;
|
||||
};
|
||||
|
||||
struct Env _getenv(char **, const char *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN__GETENV_INTERNAL_H_ */
|
|
@ -19,9 +19,9 @@
|
|||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/ttydefaults.h"
|
||||
#include "libc/intrin/_getenv.internal.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/extend.internal.h"
|
||||
#include "libc/intrin/getenv.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/nomultics.internal.h"
|
||||
#include "libc/intrin/pushpop.internal.h"
|
||||
|
@ -95,7 +95,7 @@ textstartup void __init_fds(int argc, char **argv, char **envp) {
|
|||
} else if (IsWindows()) {
|
||||
int sockset = 0;
|
||||
struct Env var;
|
||||
var = _getenv(envp, "__STDIO_SOCKETS");
|
||||
var = __getenv(envp, "__STDIO_SOCKETS");
|
||||
if (var.s) {
|
||||
int i = var.i + 1;
|
||||
do {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/_getauxval.internal.h"
|
||||
#include "libc/intrin/getauxval.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
unsigned long getauxval(unsigned long key) {
|
||||
struct AuxiliaryValue x;
|
||||
x = _getauxval(key);
|
||||
x = __getauxval(key);
|
||||
if (key == AT_PAGESZ) {
|
||||
if (!x.isfound) {
|
||||
#ifdef __aarch64__
|
||||
|
|
15
libc/intrin/getauxval.internal.h
Normal file
15
libc/intrin/getauxval.internal.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN_GETAUXVAL_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN_GETAUXVAL_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct AuxiliaryValue {
|
||||
unsigned long value;
|
||||
bool isfound;
|
||||
};
|
||||
|
||||
struct AuxiliaryValue __getauxval(unsigned long);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_GETAUXVAL_H_ */
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/_getenv.internal.h"
|
||||
#include "libc/intrin/getenv.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
|
@ -33,7 +33,7 @@ char *getenv(const char *s) {
|
|||
struct Env e;
|
||||
if (!s) return 0;
|
||||
if (!(p = environ)) return 0;
|
||||
e = _getenv(p, s);
|
||||
e = __getenv(p, s);
|
||||
#if SYSDEBUG
|
||||
// if (!(s[0] == 'T' && s[1] == 'Z' && !s[2])) {
|
||||
// TODO(jart): memoize TZ or something
|
||||
|
|
15
libc/intrin/getenv.internal.h
Normal file
15
libc/intrin/getenv.internal.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN_GETENV_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN_GETENV_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct Env {
|
||||
char *s;
|
||||
int i;
|
||||
};
|
||||
|
||||
struct Env __getenv(char **, const char *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_GETENV_H_ */
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/getenv.internal.h"
|
||||
#include "libc/intrin/promises.internal.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
|
@ -45,7 +46,7 @@ int IsDebuggerPresent(bool force) {
|
|||
int e, fd, res;
|
||||
char *p, buf[1024];
|
||||
if (!force && IsGenuineBlink()) return 0;
|
||||
if (!force && __getenv(environ, "HEISENDEBUG")) return 0;
|
||||
if (!force && __getenv(environ, "HEISENDEBUG").s) return 0;
|
||||
if (IsWindows()) return IsBeingDebugged();
|
||||
if (__isworker) return false;
|
||||
if (!PLEDGED(RPATH)) return false;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/_getenv.internal.h"
|
||||
#include "libc/intrin/getenv.internal.h"
|
||||
#include "libc/intrin/kmalloc.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -63,7 +63,7 @@ int PutEnvImpl(char *s, bool overwrite) {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
e = _getenv(p, s);
|
||||
e = __getenv(p, s);
|
||||
if (e.s && !overwrite) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/_getauxval.internal.h"
|
||||
#include "libc/intrin/getauxval.internal.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
@ -54,7 +54,7 @@ uint64_t _rand64(void) {
|
|||
s = g_rand64.thepool; // normal path
|
||||
} else {
|
||||
if (!g_rand64.thepid) {
|
||||
if (AT_RANDOM && (p = (void *)_getauxval(AT_RANDOM).value)) {
|
||||
if (AT_RANDOM && (p = (void *)__getauxval(AT_RANDOM).value)) {
|
||||
// linux / freebsd kernel supplied entropy
|
||||
memcpy(&s, p, 16);
|
||||
} else {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/_getenv.internal.h"
|
||||
#include "libc/intrin/getenv.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
|
@ -36,7 +36,7 @@ int unsetenv(const char *s) {
|
|||
if (*t == '=') return einval();
|
||||
}
|
||||
if ((p = environ)) {
|
||||
e = _getenv(p, s);
|
||||
e = __getenv(p, s);
|
||||
while (p[e.i]) {
|
||||
p[e.i] = p[e.i + 1];
|
||||
++e.i;
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define __ToUpper(c) ((c) >= 'a' && (c) <= 'z' ? (c) - 'a' + 'A' : (c))
|
||||
|
||||
__funline int __strcmp(const char *l, const char *r) {
|
||||
size_t i = 0;
|
||||
while (l[i] == r[i] && r[i]) ++i;
|
||||
|
@ -132,26 +130,6 @@ __funline char16_t *__strstr16(const char16_t *haystack,
|
|||
return 0;
|
||||
}
|
||||
|
||||
__funline char *__getenv(char **p, const char *s) {
|
||||
size_t i, j;
|
||||
if (p) {
|
||||
for (i = 0; p[i]; ++i) {
|
||||
for (j = 0;; ++j) {
|
||||
if (!s[j]) {
|
||||
if (p[i][j] == '=') {
|
||||
return p[i] + j + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ((s[j] & 255) != __ToUpper(p[i][j] & 255)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
__funline const char *__strchr(const char *s, unsigned char c) {
|
||||
char *r;
|
||||
for (;; ++s) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/_getauxval.internal.h"
|
||||
#include "libc/intrin/getauxval.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
|
||||
|
@ -55,7 +55,7 @@ static dontinline int __clk_tck_init(void) {
|
|||
x = -1;
|
||||
}
|
||||
} else {
|
||||
x = _getauxval(AT_CLKTCK).value;
|
||||
x = __getauxval(AT_CLKTCK).value;
|
||||
}
|
||||
if (x < 1) x = 100;
|
||||
clk_tck = x;
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/_getenv.internal.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/getenv.internal.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
@ -120,7 +120,7 @@ static int GetSignalByName(const char *s) {
|
|||
|
||||
static void PutEnv(char **p, const char *kv) {
|
||||
struct Env e;
|
||||
e = _getenv(p, kv);
|
||||
e = __getenv(p, kv);
|
||||
p[e.i] = kv;
|
||||
if (!e.s) p[e.i + 1] = 0;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ static void PutEnv(char **p, const char *kv) {
|
|||
static void UnsetEnv(char **p, const char *k) {
|
||||
int i;
|
||||
struct Env e;
|
||||
if ((e = _getenv(p, k)).s) {
|
||||
if ((e = __getenv(p, k)).s) {
|
||||
p[e.i] = 0;
|
||||
for (i = e.i + 1; p[i]; ++i) {
|
||||
p[i - 1] = p[i];
|
||||
|
@ -399,7 +399,7 @@ static int Read(void) {
|
|||
|
||||
static int Cd(void) {
|
||||
const char *s;
|
||||
if ((s = n > 1 ? args[1] : _getenv(envs, "HOME").s)) {
|
||||
if ((s = n > 1 ? args[1] : __getenv(envs, "HOME").s)) {
|
||||
if (!chdir(s)) {
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -776,7 +776,7 @@ static const char *GetVar(const char *key) {
|
|||
FormatInt32(vbuf, geteuid());
|
||||
return vbuf;
|
||||
} else {
|
||||
return _getenv(envs, key).s;
|
||||
return __getenv(envs, key).s;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/getenv.internal.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
@ -30,7 +28,7 @@
|
|||
textstartup int __strace_init(int argc, char **argv, char **envp, long *auxv) {
|
||||
/* asan isn't initialized yet at runlevel 300 */
|
||||
if (__intercept_flag(&argc, argv, "--strace") ||
|
||||
__atoul(nulltoempty(__getenv(envp, "STRACE")))) {
|
||||
__atoul(nulltoempty(__getenv(envp, "STRACE").s))) {
|
||||
strace_enabled(+1);
|
||||
}
|
||||
return (__argc = argc);
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
|
||||
__static_yoink("zipos");
|
||||
__static_yoink("libc/testlib/hyperion.txt");
|
||||
__static_yoink("inflate");
|
||||
__static_yoink("inflateInit2");
|
||||
__static_yoink("inflateEnd");
|
||||
__static_yoink("_Cz_inflate");
|
||||
__static_yoink("_Cz_inflateInit2");
|
||||
__static_yoink("_Cz_inflateEnd");
|
||||
|
||||
int Worker(void *arg, int tid) {
|
||||
int i, fd;
|
||||
|
|
3
third_party/musl/musl.mk
vendored
3
third_party/musl/musl.mk
vendored
|
@ -25,7 +25,8 @@ THIRD_PARTY_MUSL_A_DIRECTDEPS = \
|
|||
LIBC_RUNTIME \
|
||||
LIBC_STDIO \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV
|
||||
LIBC_SYSV \
|
||||
THIRD_PARTY_ZLIB
|
||||
|
||||
THIRD_PARTY_MUSL_A_DEPS := \
|
||||
$(call uniq,$(foreach x,$(THIRD_PARTY_MUSL_A_DIRECTDEPS),$($(x))))
|
||||
|
|
10
third_party/musl/pwd.c
vendored
10
third_party/musl/pwd.c
vendored
|
@ -44,6 +44,16 @@ Copyright 2005-2014 Rich Felker, et. al.\"");
|
|||
asm(".include \"libc/disclaimer.inc\"");
|
||||
/* clang-format off */
|
||||
|
||||
#ifdef FTRACE
|
||||
// if the default mode debugging tools are enabled, and we're linking
|
||||
// something as substantive as this library, then we shall assume the
|
||||
// application is meaty enough to benefit from the performance of the
|
||||
// chromium zlib library (costs ~40kb binary) versus just having puff
|
||||
__static_yoink("_Cz_inflateInit2");
|
||||
__static_yoink("_Cz_inflate");
|
||||
__static_yoink("_Cz_inflateEnd");
|
||||
#endif
|
||||
|
||||
static char *
|
||||
__create_synthetic_passwd_file(void)
|
||||
{
|
||||
|
|
11
third_party/zip/zipfile.c
vendored
11
third_party/zip/zipfile.c
vendored
|
@ -20,6 +20,7 @@
|
|||
#include "libc/assert.h"
|
||||
#include "third_party/zip/crc32.h"
|
||||
#endif
|
||||
#include "third_party/zip/crc32.h"
|
||||
|
||||
/* for realloc 2/6/2005 EG */
|
||||
#include "libc/calls/calls.h"
|
||||
|
@ -72,6 +73,8 @@
|
|||
#include "libc/nt/winsock.h"
|
||||
#endif
|
||||
|
||||
unsigned _Cz_crc32(unsigned crc, const unsigned char *buf, unsigned len);
|
||||
|
||||
/*
|
||||
* XXX start of zipfile.h
|
||||
*/
|
||||
|
@ -865,7 +868,7 @@ local void read_Unicode_Path_entry(pZipListEntry)
|
|||
}
|
||||
strcpy(iname, pZipListEntry->iname);
|
||||
|
||||
chksum = crc32(chksum, (uch *)(iname), strlen(iname));
|
||||
chksum = _Cz_crc32(chksum, (uch *)(iname), strlen(iname));
|
||||
|
||||
free(iname);
|
||||
|
||||
|
@ -970,7 +973,7 @@ local void read_Unicode_Path_local_entry(pZipListEntry)
|
|||
}
|
||||
strcpy(iname, pZipListEntry->iname);
|
||||
|
||||
chksum = crc32(chksum, (uch *)(iname), strlen(iname));
|
||||
chksum = _Cz_crc32(chksum, (uch *)(iname), strlen(iname));
|
||||
|
||||
free(iname);
|
||||
|
||||
|
@ -1556,7 +1559,7 @@ local int add_Unicode_Path_local_extra_field(pZEntry)
|
|||
# define inameLocal (pZEntry->iname)
|
||||
#endif
|
||||
|
||||
chksum = crc32(chksum, (uch *)(inameLocal), strlen(inameLocal));
|
||||
chksum = _Cz_crc32(chksum, (uch *)(inameLocal), strlen(inameLocal));
|
||||
|
||||
#ifdef WIN32_OEM
|
||||
free(inameLocal);
|
||||
|
@ -1683,7 +1686,7 @@ local int add_Unicode_Path_cen_extra_field(pZEntry)
|
|||
# define inameLocal (pZEntry->iname)
|
||||
#endif
|
||||
|
||||
chksum = crc32(chksum, (uch *)(inameLocal), strlen(inameLocal));
|
||||
chksum = _Cz_crc32(chksum, (uch *)(inameLocal), strlen(inameLocal));
|
||||
|
||||
#ifdef WIN32_OEM
|
||||
free(inameLocal);
|
||||
|
|
1
third_party/zip/zipup.c
vendored
1
third_party/zip/zipup.c
vendored
|
@ -24,7 +24,6 @@
|
|||
#include "third_party/zip/zipup.h"
|
||||
#include "third_party/bzip2/bzlib.h"
|
||||
#include "libc/calls/typedef/u.h"
|
||||
#include "third_party/zlib/zconf.h"
|
||||
#include "libc/runtime/sysconf.h"
|
||||
#include "libc/errno.h"
|
||||
|
||||
|
|
8
third_party/zlib/cpu_features.c
vendored
8
third_party/zlib/cpu_features.c
vendored
|
@ -23,15 +23,17 @@
|
|||
#include "third_party/zlib/cpu_features.internal.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
|
||||
#if defined(__aarch64__) && defined(__ARM_NEON)
|
||||
|
||||
int arm_cpu_enable_crc32;
|
||||
int arm_cpu_enable_pmull;
|
||||
|
||||
void(cpu_check_features)(void) {
|
||||
#if defined(__aarch64__) && defined(__ARM_NEON)
|
||||
void cpu_check_features(void) {
|
||||
if (IsLinux()) {
|
||||
unsigned long features = getauxval(AT_HWCAP);
|
||||
arm_cpu_enable_crc32 = !!(features & HWCAP_CRC32);
|
||||
arm_cpu_enable_pmull = !!(features & HWCAP_PMULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
12
third_party/zlib/cpu_features.internal.h
vendored
12
third_party/zlib/cpu_features.internal.h
vendored
|
@ -1,19 +1,27 @@
|
|||
#ifndef COSMOPOLITAN_THIRD_PARTY_ZLIB_CPU_FEATURES_H_
|
||||
#define COSMOPOLITAN_THIRD_PARTY_ZLIB_CPU_FEATURES_H_
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "third_party/zlib/zconf.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
#ifdef __x86_64__
|
||||
|
||||
#ifdef Z_COSMO_PREFIX_SET
|
||||
#undef x86_cpu_enable_sse2
|
||||
#undef x86_cpu_enable_ssse3
|
||||
#undef x86_cpu_enable_simd
|
||||
#undef x86_cpu_enable_avx512
|
||||
#undef cpu_check_features
|
||||
#endif
|
||||
|
||||
#define x86_cpu_enable_sse2 X86_HAVE(SSE2)
|
||||
#define x86_cpu_enable_ssse3 X86_HAVE(SSSE3)
|
||||
#define x86_cpu_enable_simd (X86_HAVE(SSE4_2) && X86_HAVE(PCLMUL))
|
||||
#define x86_cpu_enable_avx512 X86_HAVE(AVX512F)
|
||||
#define cpu_check_features() (void)0
|
||||
#define cpu_check_features() ((void)0)
|
||||
|
||||
#elif defined(__aarch64__)
|
||||
|
||||
#define cpu_check_features zlib_cpu_check_features
|
||||
extern int arm_cpu_enable_crc32;
|
||||
extern int arm_cpu_enable_pmull;
|
||||
void cpu_check_features(void);
|
||||
|
|
4
third_party/zlib/gz/gzread.c
vendored
4
third_party/zlib/gz/gzread.c
vendored
|
@ -452,8 +452,8 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file)
|
|||
# undef z_gzgetc
|
||||
#else
|
||||
# undef gzgetc
|
||||
# ifdef Z_CR_PREFIX_SET
|
||||
# define gzgetc Cr_z_gzgetc
|
||||
# ifdef Z_COSMO_PREFIX_SET
|
||||
# define gzgetc __gzgetc
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
149
third_party/zlib/zconf.h
vendored
149
third_party/zlib/zconf.h
vendored
|
@ -13,6 +13,155 @@
|
|||
|
||||
#define z_const const
|
||||
|
||||
#define Z_COSMO_PREFIX_SET
|
||||
|
||||
#define Bytef _Cz_Bytef
|
||||
#define _dist_code _Cz__dist_code
|
||||
#define _length_code _Cz__length_code
|
||||
#define _tr_align _Cz__tr_align
|
||||
#define _tr_flush_bits _Cz__tr_flush_bits
|
||||
#define _tr_flush_block _Cz__tr_flush_block
|
||||
#define _tr_init _Cz__tr_init
|
||||
#define _tr_stored_block _Cz__tr_stored_block
|
||||
#define _tr_tally _Cz__tr_tally
|
||||
#define adler32 _Cz_adler32
|
||||
#define adler32_combine _Cz_adler32_combine
|
||||
#define adler32_combine64 _Cz_adler32_combine64
|
||||
#define adler32_simd_ _Cz_adler32_simd_
|
||||
#define adler32_z _Cz_adler32_z
|
||||
#define alloc_func _Cz_alloc_func
|
||||
#define arm_check_features _Cz_arm_check_features
|
||||
#define arm_cpu_enable_crc32 _Cz_arm_cpu_enable_crc32
|
||||
#define arm_cpu_enable_pmull _Cz_arm_cpu_enable_pmull
|
||||
#define armv8_crc32_little _Cz_armv8_crc32_little
|
||||
#define armv8_crc32_pmull_little _Cz_armv8_crc32_pmull_little
|
||||
#define charf _Cz_charf
|
||||
#define compress _Cz_compress
|
||||
#define compress2 _Cz_compress2
|
||||
#define compressBound _Cz_compressBound
|
||||
#define copy_with_crc _Cz_copy_with_crc
|
||||
#define cpu_check_features _Cz_cpu_check_features
|
||||
#define crc32 _Cz_crc32
|
||||
#define crc32_combine _Cz_crc32_combine
|
||||
#define crc32_combine64 _Cz_crc32_combine64
|
||||
#define crc32_combine_gen _Cz_crc32_combine_gen
|
||||
#define crc32_combine_gen64 _Cz_crc32_combine_gen64
|
||||
#define crc32_combine_op _Cz_crc32_combine_op
|
||||
#define crc32_sse42_simd_ _Cz_crc32_sse42_simd_
|
||||
#define crc32_z _Cz_crc32_z
|
||||
#define crc_finalize _Cz_crc_finalize
|
||||
#define crc_fold_512to32 _Cz_crc_fold_512to32
|
||||
#define crc_fold_copy _Cz_crc_fold_copy
|
||||
#define crc_fold_init _Cz_crc_fold_init
|
||||
#define crc_reset _Cz_crc_reset
|
||||
#define deflate _Cz_deflate
|
||||
#define deflateBound _Cz_deflateBound
|
||||
#define deflateCopy _Cz_deflateCopy
|
||||
#define deflateEnd _Cz_deflateEnd
|
||||
#define deflateGetDictionary _Cz_deflateGetDictionary
|
||||
#define deflateInit _Cz_deflateInit
|
||||
#define deflateInit2 _Cz_deflateInit2
|
||||
#define deflateParams _Cz_deflateParams
|
||||
#define deflatePending _Cz_deflatePending
|
||||
#define deflatePrime _Cz_deflatePrime
|
||||
#define deflateReset _Cz_deflateReset
|
||||
#define deflateResetKeep _Cz_deflateResetKeep
|
||||
#define deflateSetDictionary _Cz_deflateSetDictionary
|
||||
#define deflateSetHeader _Cz_deflateSetHeader
|
||||
#define deflateTune _Cz_deflateTune
|
||||
#define deflate_copyright _Cz_deflate_copyright
|
||||
#define deflate_read_buf _Cz_deflate_read_buf
|
||||
#define fill_window_sse _Cz_fill_window_sse
|
||||
#define free_func _Cz_free_func
|
||||
#define get_crc_table _Cz_get_crc_table
|
||||
#define gzFile _Cz_gzFile
|
||||
#define gz_error _Cz_gz_error
|
||||
#define gz_header _Cz_gz_header
|
||||
#define gz_header_s _Cz_gz_header_s
|
||||
#define gz_headerp _Cz_gz_headerp
|
||||
#define gz_intmax _Cz_gz_intmax
|
||||
#define gz_strwinerror _Cz_gz_strwinerror
|
||||
#define gzbuffer _Cz_gzbuffer
|
||||
#define gzclearerr _Cz_gzclearerr
|
||||
#define gzclose _Cz_gzclose
|
||||
#define gzclose_r _Cz_gzclose_r
|
||||
#define gzclose_w _Cz_gzclose_w
|
||||
#define gzdirect _Cz_gzdirect
|
||||
#define gzdopen _Cz_gzdopen
|
||||
#define gzeof _Cz_gzeof
|
||||
#define gzerror _Cz_gzerror
|
||||
#define gzflush _Cz_gzflush
|
||||
#define gzfread _Cz_gzfread
|
||||
#define gzfwrite _Cz_gzfwrite
|
||||
#define gzgetc _Cz_gzgetc
|
||||
#define gzgetc_ _Cz_gzgetc_
|
||||
#define gzgets _Cz_gzgets
|
||||
#define gzoffset _Cz_gzoffset
|
||||
#define gzoffset64 _Cz_gzoffset64
|
||||
#define gzopen _Cz_gzopen
|
||||
#define gzopen64 _Cz_gzopen64
|
||||
#define gzopen_w _Cz_gzopen_w
|
||||
#define gzprintf _Cz_gzprintf
|
||||
#define gzputc _Cz_gzputc
|
||||
#define gzputs _Cz_gzputs
|
||||
#define gzread _Cz_gzread
|
||||
#define gzrewind _Cz_gzrewind
|
||||
#define gzseek _Cz_gzseek
|
||||
#define gzseek64 _Cz_gzseek64
|
||||
#define gzsetparams _Cz_gzsetparams
|
||||
#define gztell _Cz_gztell
|
||||
#define gztell64 _Cz_gztell64
|
||||
#define gzungetc _Cz_gzungetc
|
||||
#define gzvprintf _Cz_gzvprintf
|
||||
#define gzwrite _Cz_gzwrite
|
||||
#define in_func _Cz_in_func
|
||||
#define inflate _Cz_inflate
|
||||
#define inflateBack _Cz_inflateBack
|
||||
#define inflateBackEnd _Cz_inflateBackEnd
|
||||
#define inflateBackInit_ _Cz_inflateBackInit_
|
||||
#define inflateCodesUsed _Cz_inflateCodesUsed
|
||||
#define inflateCopy _Cz_inflateCopy
|
||||
#define inflateEnd _Cz_inflateEnd
|
||||
#define inflateGetDictionary _Cz_inflateGetDictionary
|
||||
#define inflateGetHeader _Cz_inflateGetHeader
|
||||
#define inflateInit _Cz_inflateInit
|
||||
#define inflateInit2 _Cz_inflateInit2
|
||||
#define inflateMark _Cz_inflateMark
|
||||
#define inflatePrime _Cz_inflatePrime
|
||||
#define inflateReset _Cz_inflateReset
|
||||
#define inflateReset2 _Cz_inflateReset2
|
||||
#define inflateResetKeep _Cz_inflateResetKeep
|
||||
#define inflateSetDictionary _Cz_inflateSetDictionary
|
||||
#define inflateSync _Cz_inflateSync
|
||||
#define inflateSyncPoint _Cz_inflateSyncPoint
|
||||
#define inflateUndermine _Cz_inflateUndermine
|
||||
#define inflateValidate _Cz_inflateValidate
|
||||
#define inflate_copyright _Cz_inflate_copyright
|
||||
#define inflate_fast _Cz_inflate_fast
|
||||
#define inflate_fast_chunk_ _Cz_inflate_fast_chunk_
|
||||
#define inflate_table _Cz_inflate_table
|
||||
#define intf _Cz_intf
|
||||
#define out_func _Cz_out_func
|
||||
#define uInt _Cz_uInt
|
||||
#define uIntf _Cz_uIntf
|
||||
#define uLong _Cz_uLong
|
||||
#define uLongf _Cz_uLongf
|
||||
#define uncompress _Cz_uncompress
|
||||
#define uncompress2 _Cz_uncompress2
|
||||
#define voidp _Cz_voidp
|
||||
#define voidpc _Cz_voidpc
|
||||
#define voidpf _Cz_voidpf
|
||||
#define x86_check_features _Cz_x86_check_features
|
||||
#define x86_cpu_enable_simd _Cz_x86_cpu_enable_simd
|
||||
#define x86_cpu_enable_sse2 _Cz_x86_cpu_enable_sse2
|
||||
#define x86_cpu_enable_ssse3 _Cz_x86_cpu_enable_ssse3
|
||||
#define zError _Cz_zError
|
||||
#define z_errmsg _Cz_z_errmsg
|
||||
#define zcalloc _Cz_zcalloc
|
||||
#define zcfree _Cz_zcfree
|
||||
#define zlibCompileFlags _Cz_zlibCompileFlags
|
||||
#define zlibVersion _Cz_zlibVersion
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
typedef unsigned char Byte;
|
||||
|
|
4
third_party/zlib/zlib.h
vendored
4
third_party/zlib/zlib.h
vendored
|
@ -1730,10 +1730,10 @@ int gzgetc_(gzFile file); /* backward compatibility */
|
|||
#undef z_gzgetc
|
||||
#define z_gzgetc(g) \
|
||||
((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
|
||||
#elif defined(Z_CR_PREFIX_SET)
|
||||
#elif defined(Z_COSMO_PREFIX_SET)
|
||||
#undef gzgetc
|
||||
#define gzgetc(g) \
|
||||
((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (Cr_z_gzgetc)(g))
|
||||
((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (__gzgetc)(g))
|
||||
#else
|
||||
#define gzgetc(g) \
|
||||
((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
|
||||
|
|
Loading…
Reference in a new issue