mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Make some quick fixes and cleanup
This commit is contained in:
parent
fa5c2a24b5
commit
61257d48d4
63 changed files with 275 additions and 257 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -16,7 +16,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
mode: ["", tiny, opt]
|
||||
mode: ["", tiny, opt, rel]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ static void SetLimit(int resource, uint64_t soft, uint64_t hard) {
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i, rc;
|
||||
char rlnbuf[20];
|
||||
struct rlimit rlim;
|
||||
|
||||
// // example of how you might change the limits
|
||||
|
@ -64,8 +65,9 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
for (i = 0; i < RLIM_NLIMITS; ++i) {
|
||||
rc = getrlimit(i, &rlim);
|
||||
printf("SETRLIMIT(%-20s, %,16ld, %,16ld) → %d %s\n", DescribeRlimitName(i),
|
||||
rlim.rlim_cur, rlim.rlim_max, rc, !rc ? "" : strerror(errno));
|
||||
printf("SETRLIMIT(%-20s, %,16ld, %,16ld) → %d %s\n",
|
||||
(DescribeRlimitName)(rlnbuf, i), rlim.rlim_cur, rlim.rlim_max, rc,
|
||||
!rc ? "" : strerror(errno));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -16,7 +16,7 @@ void __fds_unlock(void);
|
|||
void __sig_lock(void);
|
||||
void __sig_unlock(void);
|
||||
|
||||
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__STRICT_ANSI__)
|
||||
#ifdef _NOPL0
|
||||
#define __fds_lock() _NOPL0("__threadcalls", __fds_lock)
|
||||
#define __fds_unlock() _NOPL0("__threadcalls", __fds_unlock)
|
||||
#else
|
||||
|
@ -24,7 +24,7 @@ void __sig_unlock(void);
|
|||
#define __fds_unlock() (__threaded ? __fds_unlock() : 0)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__STRICT_ANSI__)
|
||||
#ifdef _NOPL0
|
||||
#define __sig_lock() _NOPL0("__threadcalls", __sig_lock)
|
||||
#define __sig_unlock() _NOPL0("__threadcalls", __sig_unlock)
|
||||
#else
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
#define EM_RISCV 243
|
||||
#define EM_BPF 247
|
||||
|
||||
#define GRP_COMDAT 0x1
|
||||
#define GRP_COMDAT 1
|
||||
#define STN_UNDEF 0
|
||||
|
||||
#define EV_NONE 0
|
||||
|
|
|
@ -21,11 +21,13 @@ hidden extern const struct MagnumStr kErrnoDocs[];
|
|||
hidden extern const struct MagnumStr kErrnoNames[];
|
||||
hidden extern const struct MagnumStr kIpOptnames[];
|
||||
hidden extern const struct MagnumStr kOpenFlags[];
|
||||
hidden extern const struct MagnumStr kRlimitNames[];
|
||||
hidden extern const struct MagnumStr kSignalNames[];
|
||||
hidden extern const struct MagnumStr kSockOptnames[];
|
||||
hidden extern const struct MagnumStr kTcpOptnames[];
|
||||
|
||||
char *GetMagnumStr(const struct MagnumStr *, int);
|
||||
char *DescribeMagnum(char *, const struct MagnumStr *, const char *, int);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -200,6 +200,15 @@ static char *__asan_utf8cpy(char *p, unsigned c) {
|
|||
return p;
|
||||
}
|
||||
|
||||
static char *__asan_stpcpy(char *d, const char *s) {
|
||||
size_t i;
|
||||
for (i = 0;; ++i) {
|
||||
if (!(d[i] = s[i])) {
|
||||
return d + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void __asan_memset(void *p, char c, size_t n) {
|
||||
char *b;
|
||||
size_t i;
|
||||
|
@ -645,9 +654,9 @@ static char *__asan_format_section(char *p, const void *p1, const void *p2,
|
|||
intptr_t a, b;
|
||||
if ((a = (intptr_t)p1) < (b = (intptr_t)p2)) {
|
||||
p = __asan_format_interval(p, a, b), *p++ = ' ';
|
||||
p = __stpcpy(p, name);
|
||||
p = __asan_stpcpy(p, name);
|
||||
if (a <= (intptr_t)addr && (intptr_t)addr <= b) {
|
||||
p = __stpcpy(p, " ←address");
|
||||
p = __asan_stpcpy(p, " ←address");
|
||||
}
|
||||
*p++ = '\n';
|
||||
}
|
||||
|
@ -822,9 +831,9 @@ dontdiscard static __asan_die_f *__asan_report(const void *addr, int size,
|
|||
y = m->p[i].y;
|
||||
p = __asan_format_interval(p, x << 16, (y << 16) + (FRAMESIZE - 1));
|
||||
z = (intptr_t)addr >> 16;
|
||||
if (x <= z && z <= y) p = __stpcpy(p, " ←address");
|
||||
if (x <= z && z <= y) p = __asan_stpcpy(p, " ←address");
|
||||
z = (((intptr_t)addr >> 3) + 0x7fff8000) >> 16;
|
||||
if (x <= z && z <= y) p = __stpcpy(p, " ←shadow");
|
||||
if (x <= z && z <= y) p = __asan_stpcpy(p, " ←shadow");
|
||||
*p++ = '\n';
|
||||
}
|
||||
__mmi_unlock();
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/intrin/cxaatexit.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/runtime/cxaatexit.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ void __cxa_lock(void);
|
|||
void __cxa_unlock(void);
|
||||
void __cxa_printexits(FILE *, void *);
|
||||
|
||||
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__STRICT_ANSI__)
|
||||
#ifdef _NOPL0
|
||||
#define __cxa_lock() _NOPL0("__threadcalls", __cxa_lock)
|
||||
#define __cxa_unlock() _NOPL0("__threadcalls", __cxa_unlock)
|
||||
#else
|
|
@ -16,6 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/runtime/cxaatexit.internal.h"
|
||||
#include "libc/intrin/cxaatexit.internal.h"
|
||||
|
||||
struct CxaAtexitBlocks __cxa_blocks;
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/intrin/cxaatexit.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/bsf.h"
|
||||
#include "libc/runtime/cxaatexit.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/cxaatexit.internal.h"
|
||||
#include "libc/intrin/pthread.h"
|
||||
#include "libc/runtime/cxaatexit.internal.h"
|
||||
|
||||
static pthread_mutex_t __cxa_lock_obj;
|
||||
|
||||
|
|
|
@ -16,39 +16,12 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
|
||||
static inline char *StpCpy(char *d, const char *s) {
|
||||
size_t i;
|
||||
for (i = 0;; ++i) {
|
||||
if (!(d[i] = s[i])) {
|
||||
return d + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes clock_gettime() clock argument.
|
||||
*/
|
||||
const char *(DescribeClockName)(char buf[32], int x) {
|
||||
int i;
|
||||
char *s, *p;
|
||||
if ((s = GetMagnumStr(kClockNames, x))) {
|
||||
p = buf;
|
||||
*p++ = 'C';
|
||||
*p++ = 'L';
|
||||
*p++ = 'O';
|
||||
*p++ = 'C';
|
||||
*p++ = 'K';
|
||||
*p++ = '_';
|
||||
StpCpy(p, s);
|
||||
return buf;
|
||||
} else {
|
||||
FormatInt32(buf, x);
|
||||
return buf;
|
||||
}
|
||||
return DescribeMagnum(buf, kClockNames, "CLOCK_", x);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ const char *DescribePrctlOperation(int);
|
|||
const char *DescribeProtFlags(char[48], int);
|
||||
const char *DescribeRemapFlags(char[48], int);
|
||||
const char *DescribeRlimit(char[64], int, const struct rlimit *);
|
||||
const char *DescribeRlimitName(char[12], int);
|
||||
const char *DescribeRlimitName(char[20], int);
|
||||
const char *DescribeSeccompOperation(int);
|
||||
const char *DescribeSigaction(char[128], int, const struct sigaction *);
|
||||
const char *DescribeSigaltstk(char[128], int, const struct sigaltstack *);
|
||||
|
@ -94,7 +94,7 @@ void DescribeIovNt(const struct NtIovec *, uint32_t, ssize_t);
|
|||
#define DescribeProtFlags(dirfd) DescribeProtFlags(alloca(48), dirfd)
|
||||
#define DescribeRemapFlags(dirfd) DescribeRemapFlags(alloca(48), dirfd)
|
||||
#define DescribeRlimit(rc, rl) DescribeRlimit(alloca(64), rc, rl)
|
||||
#define DescribeRlimitName(rl) DescribeRlimitName(alloca(12), rl)
|
||||
#define DescribeRlimitName(rl) DescribeRlimitName(alloca(20), rl)
|
||||
#define DescribeSigaction(rc, sa) DescribeSigaction(alloca(128), rc, sa)
|
||||
#define DescribeSigaltstk(rc, ss) DescribeSigaltstk(alloca(128), rc, ss)
|
||||
#define DescribeSigset(rc, ss) DescribeSigset(alloca(64), rc, ss)
|
||||
|
|
32
libc/intrin/describemagnums.c
Normal file
32
libc/intrin/describemagnums.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
char *DescribeMagnum(char *b, const struct MagnumStr *m, const char *p, int x) {
|
||||
char *s;
|
||||
if ((s = GetMagnumStr(m, x))) {
|
||||
stpcpy(stpcpy(b, p), s);
|
||||
return b;
|
||||
} else {
|
||||
FormatInt32(b, x);
|
||||
return b;
|
||||
}
|
||||
}
|
|
@ -16,31 +16,13 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/sysv/consts/rlimit.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
|
||||
const char *(DescribeRlimitName)(char buf[12], int resource) {
|
||||
if (resource == 127) return "n/a";
|
||||
if (resource == RLIMIT_AS) return "RLIMIT_AS";
|
||||
if (resource == RLIMIT_CPU) return "RLIMIT_CPU";
|
||||
if (resource == RLIMIT_FSIZE) return "RLIMIT_FSIZE";
|
||||
if (resource == RLIMIT_NPROC) return "RLIMIT_NPROC";
|
||||
if (resource == RLIMIT_NOFILE) return "RLIMIT_NOFILE";
|
||||
if (resource == RLIMIT_RSS) return "RLIMIT_RSS";
|
||||
if (resource == RLIMIT_DATA) return "RLIMIT_DATA";
|
||||
if (resource == RLIMIT_CORE) return "RLIMIT_CORE";
|
||||
if (resource == RLIMIT_STACK) return "RLIMIT_STACK";
|
||||
if (resource == RLIMIT_SIGPENDING) return "RLIMIT_SIGPENDING";
|
||||
if (resource == RLIMIT_MEMLOCK) return "RLIMIT_MEMLOCK";
|
||||
if (resource == RLIMIT_LOCKS) return "RLIMIT_LOCKS";
|
||||
if (resource == RLIMIT_MSGQUEUE) return "RLIMIT_MSGQUEUE";
|
||||
if (resource == RLIMIT_NICE) return "RLIMIT_NICE";
|
||||
if (resource == RLIMIT_RTPRIO) return "RLIMIT_RTPRIO";
|
||||
if (resource == RLIMIT_RTTIME) return "RLIMIT_RTTIME";
|
||||
if (resource == RLIMIT_SWAP) return "RLIMIT_SWAP";
|
||||
if (resource == RLIMIT_SBSIZE) return "RLIMIT_SBSIZE";
|
||||
if (resource == RLIMIT_NPTS) return "RLIMIT_NPTS";
|
||||
FormatInt32(buf, resource);
|
||||
return buf;
|
||||
/**
|
||||
* Describes setrlimit() / getrlimit() argument.
|
||||
*/
|
||||
const char *(DescribeRlimitName)(char buf[20], int x) {
|
||||
if (x == 127) return "n/a";
|
||||
return DescribeMagnum(buf, kRlimitNames, "RLIMIT_", x);
|
||||
}
|
|
@ -21,34 +21,25 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sock.h"
|
||||
|
||||
static char *StpCpy(char *d, const char *s) {
|
||||
size_t i;
|
||||
for (i = 0;; ++i) {
|
||||
if (!(d[i] = s[i])) {
|
||||
return d + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *(DescribeSocketType)(char buf[64], int type) {
|
||||
int x;
|
||||
char *p;
|
||||
p = buf;
|
||||
x = type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK);
|
||||
if (x == SOCK_STREAM) {
|
||||
p = StpCpy(p, "SOCK_STREAM");
|
||||
p = stpcpy(p, "SOCK_STREAM");
|
||||
} else if (x == SOCK_DGRAM) {
|
||||
p = StpCpy(p, "SOCK_DGRAM");
|
||||
p = stpcpy(p, "SOCK_DGRAM");
|
||||
} else if (x == SOCK_RAW) {
|
||||
p = StpCpy(p, "SOCK_RAW");
|
||||
p = stpcpy(p, "SOCK_RAW");
|
||||
} else if (x == SOCK_RDM) {
|
||||
p = StpCpy(p, "SOCK_RDM");
|
||||
p = stpcpy(p, "SOCK_RDM");
|
||||
} else if (x == SOCK_SEQPACKET) {
|
||||
p = StpCpy(p, "SOCK_SEQPACKET");
|
||||
p = stpcpy(p, "SOCK_SEQPACKET");
|
||||
} else {
|
||||
p = FormatInt32(p, x);
|
||||
}
|
||||
if (type & SOCK_CLOEXEC) p = StpCpy(p, "|SOCK_CLOEXEC");
|
||||
if (type & SOCK_NONBLOCK) p = StpCpy(p, "|SOCK_NONBLOCK");
|
||||
if (type & SOCK_CLOEXEC) p = stpcpy(p, "|SOCK_CLOEXEC");
|
||||
if (type & SOCK_NONBLOCK) p = stpcpy(p, "|SOCK_NONBLOCK");
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -22,15 +22,6 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
|
||||
static inline char *StpCpy(char *d, const char *s) {
|
||||
size_t i;
|
||||
for (i = 0;; ++i) {
|
||||
if (!(d[i] = s[i])) {
|
||||
return d + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes setsockopt() optname arguments.
|
||||
*/
|
||||
|
@ -65,7 +56,7 @@ const char *(DescribeSockOptname)(char buf[32], int l, int x) {
|
|||
ms = 0;
|
||||
}
|
||||
if (ms && (s = GetMagnumStr(ms, x))) {
|
||||
StpCpy(p, s);
|
||||
stpcpy(p, s);
|
||||
} else {
|
||||
FormatInt32(p, x);
|
||||
}
|
||||
|
|
55
libc/intrin/krlimitnames.S
Normal file
55
libc/intrin/krlimitnames.S
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
.macro .e e s
|
||||
.long \e - kRlimitNames
|
||||
.long 1f - kRlimitNames
|
||||
.rodata.str1.1
|
||||
1: .string "\s"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
.section .rodata
|
||||
.align 4
|
||||
.underrun
|
||||
kRlimitNames:
|
||||
.e RLIMIT_AS,"AS"
|
||||
.e RLIMIT_CPU,"CPU"
|
||||
.e RLIMIT_FSIZE,"FSIZE"
|
||||
.e RLIMIT_NPROC,"NPROC"
|
||||
.e RLIMIT_NOFILE,"NOFILE"
|
||||
.e RLIMIT_RSS,"RSS"
|
||||
.e RLIMIT_DATA,"DATA"
|
||||
.e RLIMIT_CORE,"CORE"
|
||||
.e RLIMIT_STACK,"STACK"
|
||||
.e RLIMIT_SIGPENDING,"SIGPENDING"
|
||||
.e RLIMIT_MEMLOCK,"MEMLOCK"
|
||||
.e RLIMIT_LOCKS,"LOCKS"
|
||||
.e RLIMIT_MSGQUEUE,"MSGQUEUE"
|
||||
.e RLIMIT_NICE,"NICE"
|
||||
.e RLIMIT_RTPRIO,"RTPRIO"
|
||||
.e RLIMIT_RTTIME,"RTTIME"
|
||||
.e RLIMIT_SWAP,"SWAP"
|
||||
.e RLIMIT_SBSIZE,"SBSIZE"
|
||||
.e RLIMIT_NPTS,"NPTS"
|
||||
.long MAGNUM_TERMINATOR
|
||||
.endobj kRlimitNames,globl,hidden
|
||||
.overrun
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN_NOPL_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN_NOPL_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0) && defined(__GNUC__) && \
|
||||
!defined(__llvm__) && !defined(__chibicc__) && !defined(__STRICT_ANSI__)
|
||||
|
||||
/**
|
||||
* @fileoverview Turns CALLs into NOPs that are fixupable at runtime.
|
||||
|
@ -66,5 +67,5 @@
|
|||
0; \
|
||||
})
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* !ASSEMBLER && !LINKER && GNUC && !CHIBICC && !LLVM && !ANSI */
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_NOPL_H_ */
|
||||
|
|
|
@ -16,18 +16,17 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/pcmpeqb.h"
|
||||
#include "libc/intrin/pmovmskb.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
typedef char xmm_u __attribute__((__vector_size__(16), __aligned__(1)));
|
||||
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
|
||||
static inline noasan size_t stpcpy_sse2(char *d, const char *s, size_t i) {
|
||||
uint8_t v1[16], v2[16], vz[16];
|
||||
xmm_t v, z = {0};
|
||||
for (;;) {
|
||||
__builtin_memset(vz, 0, 16);
|
||||
__builtin_memcpy(v1, s + i, 16);
|
||||
pcmpeqb(v2, v1, vz);
|
||||
if (!pmovmskb(v2)) {
|
||||
__builtin_memcpy(d + i, v1, 16);
|
||||
v = *(xmm_t *)(s + i);
|
||||
if (!__builtin_ia32_pmovmskb128(v == z)) {
|
||||
*(xmm_u *)(d + i) = v;
|
||||
i += 16;
|
||||
} else {
|
||||
break;
|
|
@ -16,18 +16,17 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/pcmpeqb.h"
|
||||
#include "libc/intrin/pmovmskb.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
static noasan size_t strcpy_sse2(char *d, const char *s, size_t i) {
|
||||
uint8_t v1[16], v2[16], vz[16];
|
||||
typedef char xmm_u __attribute__((__vector_size__(16), __aligned__(1)));
|
||||
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
|
||||
static inline noasan size_t strcpy_sse2(char *d, const char *s, size_t i) {
|
||||
xmm_t v, z = {0};
|
||||
for (;;) {
|
||||
__builtin_memset(vz, 0, 16);
|
||||
__builtin_memcpy(v1, s + i, 16);
|
||||
pcmpeqb(v2, v1, vz);
|
||||
if (!pmovmskb(v2)) {
|
||||
__builtin_memcpy(d + i, v1, 16);
|
||||
v = *(xmm_t *)(s + i);
|
||||
if (!__builtin_ia32_pmovmskb128(v == z)) {
|
||||
*(xmm_u *)(d + i) = v;
|
||||
i += 16;
|
||||
} else {
|
||||
break;
|
|
@ -204,6 +204,15 @@ static void __ubsan_exit(void) {
|
|||
_Exit(99);
|
||||
}
|
||||
|
||||
static char *__ubsan_stpcpy(char *d, const char *s) {
|
||||
size_t i;
|
||||
for (i = 0;; ++i) {
|
||||
if (!(d[i] = s[i])) {
|
||||
return d + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dontdiscard static __ubsan_die_f *__ubsan_die(void) {
|
||||
if (weaken(__die)) {
|
||||
return weaken(__die);
|
||||
|
@ -246,11 +255,11 @@ static char *__ubsan_describe_shift_out_of_bounds(
|
|||
char *p = buf;
|
||||
lhs = __ubsan_extend(info->lhs_type, lhs);
|
||||
rhs = __ubsan_extend(info->rhs_type, rhs);
|
||||
p = __stpcpy(p, __ubsan_describe_shift(info, lhs, rhs)), *p++ = ' ';
|
||||
p = __ubsan_stpcpy(p, __ubsan_describe_shift(info, lhs, rhs)), *p++ = ' ';
|
||||
p = __ubsan_itpcpy(p, info->lhs_type, lhs), *p++ = ' ';
|
||||
p = __stpcpy(p, info->lhs_type->name), *p++ = ' ';
|
||||
p = __ubsan_stpcpy(p, info->lhs_type->name), *p++ = ' ';
|
||||
p = __ubsan_itpcpy(p, info->rhs_type, rhs), *p++ = ' ';
|
||||
p = __stpcpy(p, info->rhs_type->name);
|
||||
p = __ubsan_stpcpy(p, info->rhs_type->name);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -272,12 +281,12 @@ void __ubsan_handle_shift_out_of_bounds_abort(
|
|||
void __ubsan_handle_out_of_bounds(struct UbsanOutOfBoundsInfo *info,
|
||||
uintptr_t index) {
|
||||
char buf[512], *p = buf;
|
||||
p = __stpcpy(p, info->index_type->name);
|
||||
p = __stpcpy(p, " index ");
|
||||
p = __ubsan_stpcpy(p, info->index_type->name);
|
||||
p = __ubsan_stpcpy(p, " index ");
|
||||
p = __ubsan_itpcpy(p, info->index_type, index);
|
||||
p = __stpcpy(p, " into ");
|
||||
p = __stpcpy(p, info->array_type->name);
|
||||
p = __stpcpy(p, " out of bounds");
|
||||
p = __ubsan_stpcpy(p, " into ");
|
||||
p = __ubsan_stpcpy(p, info->array_type->name);
|
||||
p = __ubsan_stpcpy(p, " out of bounds");
|
||||
__ubsan_abort(&info->location, buf)();
|
||||
__ubsan_unreachable();
|
||||
}
|
||||
|
@ -294,19 +303,19 @@ static __ubsan_die_f *__ubsan_type_mismatch_handler(
|
|||
if (!pointer) return __ubsan_abort(&info->location, "null pointer access");
|
||||
kind = __ubsan_dubnul(kUbsanTypeCheckKinds, info->type_check_kind);
|
||||
if (info->alignment && (pointer & (info->alignment - 1))) {
|
||||
p = __stpcpy(p, "unaligned ");
|
||||
p = __stpcpy(p, kind), *p++ = ' ';
|
||||
p = __stpcpy(p, info->type->name), *p++ = ' ', *p++ = '@';
|
||||
p = __ubsan_stpcpy(p, "unaligned ");
|
||||
p = __ubsan_stpcpy(p, kind), *p++ = ' ';
|
||||
p = __ubsan_stpcpy(p, info->type->name), *p++ = ' ', *p++ = '@';
|
||||
p = __ubsan_itpcpy(p, info->type, pointer);
|
||||
p = __stpcpy(p, " align ");
|
||||
p = __ubsan_stpcpy(p, " align ");
|
||||
p = __intcpy(p, info->alignment);
|
||||
} else {
|
||||
p = __stpcpy(p, "insufficient size ");
|
||||
p = __stpcpy(p, kind);
|
||||
p = __stpcpy(p, " address 0x");
|
||||
p = __ubsan_stpcpy(p, "insufficient size ");
|
||||
p = __ubsan_stpcpy(p, kind);
|
||||
p = __ubsan_stpcpy(p, " address 0x");
|
||||
p = __fixcpy(p, pointer, sizeof(pointer) * CHAR_BIT);
|
||||
p = __stpcpy(p, " with insufficient space for object of type ");
|
||||
p = __stpcpy(p, info->type->name);
|
||||
p = __ubsan_stpcpy(p, " with insufficient space for object of type ");
|
||||
p = __ubsan_stpcpy(p, info->type->name);
|
||||
}
|
||||
return __ubsan_abort(&info->location, buf);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,14 @@
|
|||
#include "tool/decode/lib/x86idnames.h"
|
||||
|
||||
const struct IdName kX86GradeNames[] = {
|
||||
{X86_GRADE_UNKNOWN, "Unknown"}, {X86_GRADE_APPLIANCE, "Appliance"},
|
||||
{X86_GRADE_MOBILE, "Mobile"}, {X86_GRADE_TABLET, "Tablet"},
|
||||
{X86_GRADE_DESKTOP, "Desktop"}, {X86_GRADE_CLIENT, "Client"},
|
||||
{X86_GRADE_DENSITY, "Density"}, {X86_GRADE_SERVER, "Server"},
|
||||
{X86_GRADE_SCIENCE, "Science"}, {0, 0},
|
||||
{X86_GRADE_UNKNOWN, "Unknown"}, //
|
||||
{X86_GRADE_APPLIANCE, "Appliance"}, //
|
||||
{X86_GRADE_MOBILE, "Mobile"}, //
|
||||
{X86_GRADE_TABLET, "Tablet"}, //
|
||||
{X86_GRADE_DESKTOP, "Desktop"}, //
|
||||
{X86_GRADE_CLIENT, "Client"}, //
|
||||
{X86_GRADE_DENSITY, "Density"}, //
|
||||
{X86_GRADE_SERVER, "Server"}, //
|
||||
{X86_GRADE_SCIENCE, "Science"}, //
|
||||
{0}, //
|
||||
};
|
||||
|
|
|
@ -20,27 +20,27 @@
|
|||
#include "tool/decode/lib/x86idnames.h"
|
||||
|
||||
const struct IdName kX86MarchNames[] = {
|
||||
{X86_MARCH_UNKNOWN, "Unknown"},
|
||||
{X86_MARCH_CORE2, "Core 2"},
|
||||
{X86_MARCH_NEHALEM, "Nehalem"},
|
||||
{X86_MARCH_WESTMERE, "Westmere"},
|
||||
{X86_MARCH_SANDYBRIDGE, "Sandybridge"},
|
||||
{X86_MARCH_IVYBRIDGE, "Ivybridge"},
|
||||
{X86_MARCH_HASWELL, "Haswell"},
|
||||
{X86_MARCH_BROADWELL, "Broadwell"},
|
||||
{X86_MARCH_SKYLAKE, "Skylake"},
|
||||
{X86_MARCH_KABYLAKE, "Kabylake"},
|
||||
{X86_MARCH_CANNONLAKE, "Cannonlake"},
|
||||
{X86_MARCH_ICELAKE, "Icelake"},
|
||||
{X86_MARCH_TIGERLAKE, "Tigerlake"},
|
||||
{X86_MARCH_BONNELL, "Bonnell"},
|
||||
{X86_MARCH_SALTWELL, "Saltwell"},
|
||||
{X86_MARCH_SILVERMONT, "Silvermont"},
|
||||
{X86_MARCH_AIRMONT, "Airmont"},
|
||||
{X86_MARCH_GOLDMONT, "Goldmont"},
|
||||
{X86_MARCH_GOLDMONTPLUS, "Goldmont Plus"},
|
||||
{X86_MARCH_TREMONT, "Tremont"},
|
||||
{X86_MARCH_KNIGHTSLANDING, "Knights Landing"},
|
||||
{X86_MARCH_KNIGHTSMILL, "Knights Mill"},
|
||||
{0, 0},
|
||||
{X86_MARCH_UNKNOWN, "Unknown"}, //
|
||||
{X86_MARCH_CORE2, "Core 2"}, //
|
||||
{X86_MARCH_NEHALEM, "Nehalem"}, //
|
||||
{X86_MARCH_WESTMERE, "Westmere"}, //
|
||||
{X86_MARCH_SANDYBRIDGE, "Sandybridge"}, //
|
||||
{X86_MARCH_IVYBRIDGE, "Ivybridge"}, //
|
||||
{X86_MARCH_HASWELL, "Haswell"}, //
|
||||
{X86_MARCH_BROADWELL, "Broadwell"}, //
|
||||
{X86_MARCH_SKYLAKE, "Skylake"}, //
|
||||
{X86_MARCH_KABYLAKE, "Kabylake"}, //
|
||||
{X86_MARCH_CANNONLAKE, "Cannonlake"}, //
|
||||
{X86_MARCH_ICELAKE, "Icelake"}, //
|
||||
{X86_MARCH_TIGERLAKE, "Tigerlake"}, //
|
||||
{X86_MARCH_BONNELL, "Bonnell"}, //
|
||||
{X86_MARCH_SALTWELL, "Saltwell"}, //
|
||||
{X86_MARCH_SILVERMONT, "Silvermont"}, //
|
||||
{X86_MARCH_AIRMONT, "Airmont"}, //
|
||||
{X86_MARCH_GOLDMONT, "Goldmont"}, //
|
||||
{X86_MARCH_GOLDMONTPLUS, "Goldmont Plus"}, //
|
||||
{X86_MARCH_TREMONT, "Tremont"}, //
|
||||
{X86_MARCH_KNIGHTSLANDING, "Knights Landing"}, //
|
||||
{X86_MARCH_KNIGHTSMILL, "Knights Mill"}, //
|
||||
{0}, //
|
||||
};
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/cxaatexit.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/nexgen32e/bsf.h"
|
||||
#include "libc/runtime/cxaatexit.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void ReleaseMemoryNt(struct MemoryIntervals *, int, int) hidden;
|
|||
int UntrackMemoryIntervals(void *, size_t) hidden;
|
||||
size_t GetMemtrackSize(struct MemoryIntervals *);
|
||||
|
||||
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__STRICT_ANSI__)
|
||||
#ifdef _NOPL0
|
||||
#define __mmi_lock() _NOPL0("__threadcalls", __mmi_lock)
|
||||
#define __mmi_unlock() _NOPL0("__threadcalls", __mmi_unlock)
|
||||
#else
|
||||
|
|
|
@ -294,7 +294,7 @@ textstartup void __printargs(const char *prologue) {
|
|||
PRINT("RESOURCE LIMITS");
|
||||
for (i = 0; i < RLIM_NLIMITS; ++i) {
|
||||
if (!getrlimit(i, &rlim)) {
|
||||
char buf[12];
|
||||
char buf[20];
|
||||
if (rlim.rlim_cur == RLIM_INFINITY) rlim.rlim_cur = -1;
|
||||
if (rlim.rlim_max == RLIM_INFINITY) rlim.rlim_max = -1;
|
||||
PRINT(" ☼ %-20s %,16ld %,16ld", (DescribeRlimitName)(buf, i),
|
||||
|
|
|
@ -21,7 +21,7 @@ hidden extern struct StdioFlush __fflush;
|
|||
void __fflush_lock(void);
|
||||
void __fflush_unlock(void);
|
||||
|
||||
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__STRICT_ANSI__)
|
||||
#ifdef _NOPL0
|
||||
#define __fflush_lock() _NOPL0("__threadcalls", __fflush_lock)
|
||||
#define __fflush_unlock() _NOPL0("__threadcalls", __fflush_unlock)
|
||||
#else
|
||||
|
|
|
@ -173,7 +173,7 @@ int vfprintf_unlocked(FILE *, const char *, va_list)
|
|||
#define putc_unlocked(c, f) fputc_unlocked(c, f)
|
||||
#define putwc_unlocked(c, f) fputwc_unlocked(c, f)
|
||||
|
||||
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__STRICT_ANSI__)
|
||||
#ifdef _NOPL1
|
||||
#define flockfile(f) _NOPL1("__threadcalls", flockfile, f)
|
||||
#define funlockfile(f) _NOPL1("__threadcalls", funlockfile, f)
|
||||
#define ftrylockfile(f) _NOPL1("__threadcalls", ftrylockfile, f)
|
||||
|
|
|
@ -2789,36 +2789,6 @@ syscon icmp6 ICMP6_ROUTER_RENUMBERING 138 138 138 138 138 0 # unix
|
|||
syscon icmp6 ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 0x0100 0x0100 0x0100 0x0100 0 # unix consensus
|
||||
syscon icmp6 ICMP6_RR_RESULT_FLAGS_OOB 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus
|
||||
|
||||
# java's computational model
|
||||
# solves the sharing problem by defining everything as shared
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
|
||||
syscon misc PTHREAD_MUTEX_STALLED 0 0 0 0 0 0 # consensus
|
||||
syscon misc PTHREAD_PRIO_NONE 0 0 0 0 0 0 # consensus
|
||||
syscon misc PTHREAD_PRIO_INHERIT 0 1 1 1 1 0 # bsd consensus
|
||||
syscon misc PTHREAD_PRIO_PROTECT 0 2 2 2 2 0 # bsd consensus
|
||||
syscon misc PTHREAD_DESTRUCTOR_ITERATIONS 4 4 4 4 4 0 # unix consensus
|
||||
syscon misc PTHREAD_PROCESS_SHARED 1 1 1 1 1 0 # unix consensus
|
||||
syscon misc PTHREAD_CREATE_DETACHED 1 2 1 1 1 0
|
||||
syscon misc PTHREAD_KEYS_MAX 0x0400 0x0200 0x0100 0x0100 0x0100 0
|
||||
syscon misc PTHREAD_STACK_MIN 0x4000 0x2000 0x0800 0x1000 0x1000 0
|
||||
syscon misc PTHREAD_BARRIER_SERIAL_THREAD -1 0 -1 -1 -1 0
|
||||
syscon misc PTHREAD_CANCEL_ASYNCHRONOUS 1 0 2 2 2 0
|
||||
syscon misc PTHREAD_CANCEL_DISABLE 1 0 1 1 1 0
|
||||
syscon misc PTHREAD_INHERIT_SCHED 0 1 4 4 4 0
|
||||
syscon misc PTHREAD_SCOPE_SYSTEM 0 1 2 2 2 0
|
||||
syscon misc PTHREAD_EXPLICIT_SCHED 1 2 0 0 0 0
|
||||
syscon misc PTHREAD_MUTEX_DEFAULT 0 0 1 4 4 0
|
||||
syscon misc PTHREAD_MUTEX_ERRORCHECK 0 1 0 1 1 0
|
||||
syscon misc PTHREAD_MUTEX_RECURSIVE 0 2 0 2 2 0
|
||||
syscon misc PTHREAD_SCOPE_PROCESS 1 2 0 0 0 0
|
||||
syscon misc PTHREAD_CANCEL_DEFERRED 0 2 0 0 0 0
|
||||
syscon misc PTHREAD_CANCEL_ENABLE 0 1 0 0 0 0
|
||||
syscon misc PTHREAD_CREATE_JOINABLE 0 1 0 0 0 0
|
||||
syscon misc PTHREAD_MUTEX_NORMAL 0 0 0 3 3 0
|
||||
syscon misc PTHREAD_MUTEX_ROBUST 0 0 1 0 0 0
|
||||
syscon misc PTHREAD_PROCESS_PRIVATE 0 2 0 0 0 0
|
||||
|
||||
# man fanotify(7)
|
||||
syscon fan FAN_CLASS_NOTIF 0 0 0 0 0 0 # consensus
|
||||
syscon fan FAN_ACCESS 1 0 0 0 0 0
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_BARRIER_SERIAL_THREAD,-1,0,-1,-1,-1,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_CANCEL_ASYNCHRONOUS,1,0,2,2,2,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_CANCEL_DEFERRED,0,2,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_CANCEL_DISABLE,1,0,1,1,1,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_CANCEL_ENABLE,0,1,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_CREATE_DETACHED,1,2,1,1,1,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_CREATE_JOINABLE,0,1,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_DESTRUCTOR_ITERATIONS,4,4,4,4,4,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_EXPLICIT_SCHED,1,2,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_INHERIT_SCHED,0,1,4,4,4,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_KEYS_MAX,0x0400,0x0200,0x0100,0x0100,0x0100,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_MUTEX_DEFAULT,0,0,1,4,4,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_MUTEX_ERRORCHECK,0,1,0,1,1,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_MUTEX_NORMAL,0,0,0,3,3,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_MUTEX_RECURSIVE,0,2,0,2,2,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_MUTEX_ROBUST,0,0,1,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_MUTEX_STALLED,0,0,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_PRIO_INHERIT,0,1,1,1,1,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_PRIO_NONE,0,0,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_PRIO_PROTECT,0,2,2,2,2,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_PROCESS_PRIVATE,0,2,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_PROCESS_SHARED,1,1,1,1,1,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_SCOPE_PROCESS,1,2,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_SCOPE_SYSTEM,0,1,2,2,2,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,PTHREAD_STACK_MIN,0x4000,0x2000,0x0800,0x1000,0x1000,0
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
int cthread_memory_wait32(int* addr, int val, const struct timespec* timeout) {
|
||||
size_t size;
|
||||
if (IsLinux() || IsOpenbsd()) {
|
||||
if (IsLinux() /* || IsOpenbsd() */) {
|
||||
return _futex_wait(addr, val, timeout);
|
||||
} else {
|
||||
return sched_yield();
|
||||
|
@ -34,7 +34,7 @@ int cthread_memory_wait32(int* addr, int val, const struct timespec* timeout) {
|
|||
}
|
||||
|
||||
int cthread_memory_wake32(int* addr, int n) {
|
||||
if (IsLinux() || IsOpenbsd()) {
|
||||
if (IsLinux() /* || IsOpenbsd() */) {
|
||||
return _futex_wake(addr, n);
|
||||
} else {
|
||||
return 0;
|
||||
|
|
|
@ -56,7 +56,7 @@ void localtime_unlock(void) {
|
|||
pthread_mutex_unlock(&locallock);
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__STRICT_ANSI__)
|
||||
#ifdef _NOPL0
|
||||
#define localtime_lock() _NOPL0("__threadcalls", localtime_lock)
|
||||
#define localtime_unlock() _NOPL0("__threadcalls", localtime_unlock)
|
||||
#else
|
||||
|
|
|
@ -49,7 +49,7 @@ int64_t __zipos_lseek(struct ZiposHandle *, int64_t, unsigned) hidden;
|
|||
int __zipos_fcntl(int, int, uintptr_t) hidden;
|
||||
int __zipos_notat(int, const char *) hidden;
|
||||
|
||||
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__STRICT_ANSI__)
|
||||
#ifdef _NOPL0
|
||||
#define __zipos_lock() _NOPL0("__threadcalls", __zipos_lock)
|
||||
#define __zipos_unlock() _NOPL0("__threadcalls", __zipos_unlock)
|
||||
#else
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/cxaatexit.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/rand/rand.h"
|
||||
#include "libc/runtime/cxaatexit.internal.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/runtime/memtrack.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
17
third_party/chibicc/as.c
vendored
17
third_party/chibicc/as.c
vendored
|
@ -1653,7 +1653,8 @@ static int SymbolType(struct As *a, struct Slice s) {
|
|||
}
|
||||
}
|
||||
|
||||
static int GrabSection(struct As *a, int name, int flags, int type) {
|
||||
static int GrabSection(struct As *a, int name, int flags, int type, int group,
|
||||
int comdat) {
|
||||
int i;
|
||||
for (i = 0; i < a->sections.n; ++i) {
|
||||
if (!strcmp(a->strings.p[name], a->strings.p[a->sections.p[i].name])) {
|
||||
|
@ -1664,7 +1665,7 @@ static int GrabSection(struct As *a, int name, int flags, int type) {
|
|||
}
|
||||
|
||||
static void OnSection(struct As *a, struct Slice s) {
|
||||
int name, flags, type;
|
||||
int name, flags, type, group = -1, comdat = -1;
|
||||
name = SliceDup(a, GetSlice(a));
|
||||
if (startswith(a->strings.p[name], ".text")) {
|
||||
flags = SHF_ALLOC | SHF_EXECINSTR;
|
||||
|
@ -1685,9 +1686,17 @@ static void OnSection(struct As *a, struct Slice s) {
|
|||
if (IsComma(a)) {
|
||||
++a->i;
|
||||
type = SectionType(a, GetSlice(a));
|
||||
if (IsComma(a)) {
|
||||
++a->i;
|
||||
group = SectionType(a, GetSlice(a));
|
||||
if (IsComma(a)) {
|
||||
++a->i;
|
||||
comdat = SectionType(a, GetSlice(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SetSection(a, GrabSection(a, name, flags, type));
|
||||
SetSection(a, GrabSection(a, name, flags, type, group, comdat));
|
||||
}
|
||||
|
||||
static void OnPushsection(struct As *a, struct Slice s) {
|
||||
|
@ -1705,7 +1714,7 @@ static void OnIdent(struct As *a, struct Slice s) {
|
|||
struct Slice arg;
|
||||
int comment, oldsection;
|
||||
comment = GrabSection(a, StrDup(a, ".comment"), SHF_MERGE | SHF_STRINGS,
|
||||
SHT_PROGBITS);
|
||||
SHT_PROGBITS, -1, -1);
|
||||
oldsection = a->section;
|
||||
a->section = comment;
|
||||
arg = GetSlice(a);
|
||||
|
|
2
third_party/gdtoa/lock.h
vendored
2
third_party/gdtoa/lock.h
vendored
|
@ -10,7 +10,7 @@ int __gdtoa_unlock(void);
|
|||
int __gdtoa_lock1(void);
|
||||
int __gdtoa_unlock1(void);
|
||||
|
||||
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__STRICT_ANSI__)
|
||||
#ifdef _NOPL0
|
||||
#define __gdtoa_lock() _NOPL0("__threadcalls", __gdtoa_lock)
|
||||
#define __gdtoa_unlock() _NOPL0("__threadcalls", __gdtoa_unlock)
|
||||
#define __gdtoa_lock1() _NOPL0("__threadcalls", __gdtoa_lock1)
|
||||
|
|
2
third_party/sqlite3/sqliteInt.inc
vendored
2
third_party/sqlite3/sqliteInt.inc
vendored
|
@ -144,7 +144,7 @@
|
|||
/*
|
||||
** Macro to disable warnings about missing "break" at the end of a "case".
|
||||
*/
|
||||
#if GCC_VERSION>=7000000
|
||||
#if GCC_VERSION>=7000000 && !defined(__chibicc__)
|
||||
# define deliberate_fall_through __attribute__((fallthrough));
|
||||
#else
|
||||
# define deliberate_fall_through
|
||||
|
|
|
@ -16,9 +16,11 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/elf/elf.h"
|
||||
#include "libc/elf/struct/rela.h"
|
||||
#include "libc/elf/struct/shdr.h"
|
||||
|
@ -177,6 +179,42 @@ static void printelfsectionheaders(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static void printelfgroups(void) {
|
||||
for (int i = 0; i < elf->e_shnum; ++i) {
|
||||
Elf64_Shdr *shdr = GetElfSectionHeaderAddress(elf, st->st_size, i);
|
||||
if (shdr->sh_type == SHT_GROUP) {
|
||||
const Elf64_Shdr *symhdr =
|
||||
GetElfSectionHeaderAddress(elf, st->st_size, shdr->sh_link);
|
||||
const Elf64_Shdr *strhdr =
|
||||
GetElfSectionHeaderAddress(elf, st->st_size, symhdr->sh_link);
|
||||
Elf64_Sym *syms = GetElfSectionAddress(elf, st->st_size, symhdr);
|
||||
char *strs = GetElfSectionAddress(elf, st->st_size, strhdr);
|
||||
printf("\n");
|
||||
printf("//\t%s group\n",
|
||||
GetElfString(elf, st->st_size, strs, syms[shdr->sh_info].st_name));
|
||||
printf("\t.org\t%#x\n", shdr->sh_offset);
|
||||
bool first = true;
|
||||
for (char *p = (char *)elf + shdr->sh_offset;
|
||||
p < (char *)elf + shdr->sh_offset + shdr->sh_size; p += 4) {
|
||||
if (first) {
|
||||
first = false;
|
||||
if (READ32LE(p) == GRP_COMDAT) {
|
||||
printf("\t.long\tGRP_COMDAT\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const Elf64_Shdr *section =
|
||||
GetElfSectionHeaderAddress(elf, st->st_size, READ32LE(p));
|
||||
printf("\t.long\t%#x\t\t\t# %s\n", READ32LE(p),
|
||||
GetElfString(elf, st->st_size,
|
||||
GetElfSectionNameStringTable(elf, st->st_size),
|
||||
section->sh_name));
|
||||
}
|
||||
shdr->sh_offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void printelfsymbolinfo(Elf64_Sym *sym) {
|
||||
int bind = (sym->st_info >> 4) & 0xf;
|
||||
const char *bindname = findnamebyid(kElfSymbolBindNames, bind);
|
||||
|
@ -346,6 +384,7 @@ int main(int argc, char *argv[]) {
|
|||
printelfehdr();
|
||||
printelfsegmentheaders();
|
||||
printelfsectionheaders();
|
||||
printelfgroups();
|
||||
printelfrelocations();
|
||||
printelfsymboltable();
|
||||
printelfdynsymboltable();
|
||||
|
|
Loading…
Reference in a new issue