mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 08:48:29 +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
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue