mirror of
https://github.com/jart/cosmopolitan.git
synced 2026-11-13 04:34:03 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9152b6f14 | ||
|
|
5b9862907c | ||
|
|
c2420860e6 | ||
|
|
6baf6cdb10 | ||
|
|
06a1193b4d | ||
|
|
884d89235f | ||
|
|
610c951f71 | ||
|
|
12ecaf8650 | ||
|
|
185e957696 | ||
|
|
ebe1cbb1e3 | ||
|
|
e7b586e7f8 | ||
|
|
111ec9a989 | ||
|
|
f3ce684aef | ||
|
|
908b7a82ca | ||
|
|
bb06230f1e | ||
|
|
38cc4b3c68 | ||
|
|
37ca1badaf | ||
|
|
1a9f82bc9f | ||
|
|
df1aee7ce5 | ||
|
|
2d44142444 | ||
|
|
4bbc16e2cc | ||
|
|
863c704684 | ||
|
|
60e697f7b2 | ||
|
|
4389f4709a | ||
|
|
ca2c30c977 | ||
|
|
eb6e96f036 | ||
|
|
77be460290 | ||
|
|
8e14b27749 | ||
|
|
1d532ba3f8 | ||
|
|
b2a1811c01 | ||
|
|
2eda50929b | ||
|
|
098638cc6c | ||
|
|
732554ce3a | ||
|
|
914d521090 | ||
|
|
11d9fb521d | ||
|
|
de0cde8def | ||
|
|
5bd22aef12 | ||
|
|
1671283f1a | ||
|
|
0a79c6961f | ||
|
|
3fd275f59f | ||
|
|
2045e87b7c | ||
|
|
24666e121d | ||
|
|
ff1a0d1c40 | ||
|
|
7f0db3e3b9 | ||
|
|
31194165d2 | ||
|
|
c265c17d54 | ||
|
|
7499367060 | ||
|
|
3f26dfbb31 | ||
|
|
761c6ad615 | ||
|
|
a80ab3f8fe | ||
|
|
9ebacb7892 | ||
|
|
6ac3d3b804 | ||
|
|
f8cfc89eba | ||
|
|
4ed4a1095a | ||
|
|
8d8aecb6d9 | ||
|
|
1fba310e22 | ||
|
|
bb815eafaf | ||
|
|
d0360bf4bd | ||
|
|
8cdb3e136b | ||
|
|
3dab207351 | ||
|
|
1092d9b7e8 | ||
|
|
d40acc60b1 | ||
|
|
cf1559c448 | ||
|
|
01b09bc817 | ||
|
|
c1a0b017e9 | ||
|
|
77d3a07ff2 | ||
|
|
0d7c272d3f | ||
|
|
18964e5d76 | ||
|
|
e18fe1e112 |
No files matched your search
@@ -27,3 +27,5 @@ da8baf2aa5ce93b958aca90a0ae69f537806324b
|
||||
369f9740de4534c28d0e81ab2afc99decbb9a3e6
|
||||
# Get rid of .internal.h convention in LIBC_INTRIN
|
||||
86d884cce24d773e298a2714c1e3d91ecab9be45
|
||||
# Remove .internal from more header filenames
|
||||
31194165d2afca36c2315a6e7ca2f0797dde09e3
|
||||
@@ -0,0 +1,24 @@
|
||||
name: Nightly cosmocc
|
||||
on:
|
||||
schedule:
|
||||
# https://crontab.guru/#37_4_*_*_*
|
||||
- cron: "37 4 * * *"
|
||||
workflow_dispatch:
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
build-cosmocc:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: |
|
||||
sudo cp build/bootstrap/ape.elf /usr/bin/ape
|
||||
sudo sh -c "echo ':APE:M::MZqFpD::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register"
|
||||
- run: tool/cosmocc/package.sh
|
||||
# https://github.com/actions/upload-artifact/issues/590
|
||||
- uses: actions/[email protected]
|
||||
with:
|
||||
name: cosmocc
|
||||
path: cosmocc
|
||||
compression-level: 9
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"C_Cpp.default.compilerPath": ".cosmocc/3.8.0/bin/aarch64-linux-cosmo-c++",
|
||||
"C_Cpp.default.compilerArgs": [
|
||||
"-nostdinc",
|
||||
"-nostdlib",
|
||||
"-iquote.",
|
||||
"-isystemlibc/isystem",
|
||||
"-isystemthird_party/libcxx",
|
||||
"-includelibc/integral/normalize.inc",
|
||||
"-D_COSMO_SOURCE",
|
||||
"-D__aarch64__"
|
||||
],
|
||||
"[c]": {
|
||||
"editor.tabSize": 2,
|
||||
"editor.insertSpaces": true
|
||||
},
|
||||
"[cpp]": {
|
||||
"editor.tabSize": 2,
|
||||
"editor.insertSpaces": true
|
||||
},
|
||||
"[makefile]": {
|
||||
"editor.tabSize": 8,
|
||||
"editor.insertSpaces": false
|
||||
},
|
||||
"[make]": {
|
||||
"editor.tabSize": 8,
|
||||
"editor.insertSpaces": false
|
||||
},
|
||||
"[assembly]": {
|
||||
"editor.tabSize": 8,
|
||||
"editor.insertSpaces": true
|
||||
},
|
||||
"files.associations": {
|
||||
"log.h": "c"
|
||||
}
|
||||
}
|
||||
@@ -115,10 +115,8 @@ ZIPCOPY = $(BOOTSTRAP)/zipcopy
|
||||
PECHECK = $(BOOTSTRAP)/pecheck
|
||||
FIXUPOBJ = $(BOOTSTRAP)/fixupobj
|
||||
OBJBINCOPY = $(BOOTSTRAP)/objbincopy
|
||||
MKDIR = build/bootstrap/mkdir -p
|
||||
COMPILE = build/bootstrap/compile -V9 -M2048m -P8192 $(QUOTA)
|
||||
|
||||
IGNORE := $(shell $(MKDIR) $(TMPDIR))
|
||||
MKDIR = $(BOOTSTRAP)/mkdir.ape -p
|
||||
COMPILE = $(BOOTSTRAP)/compile.ape -V9 -M2048m -P8192 $(QUOTA)
|
||||
|
||||
# the default build modes is empty string
|
||||
# on x86_64 hosts, MODE= is the same as MODE=x86_64
|
||||
@@ -134,14 +132,13 @@ endif
|
||||
|
||||
ifneq ($(findstring aarch64,$(MODE)),)
|
||||
ARCH = aarch64
|
||||
HOSTS ?= pi studio freebsdarm
|
||||
HOSTS ?= pi pi5 studio freebsdarm
|
||||
else
|
||||
ARCH = x86_64
|
||||
HOSTS ?= freebsd rhel7 xnu openbsd netbsd win10
|
||||
endif
|
||||
|
||||
ZIPOBJ_FLAGS += -a$(ARCH)
|
||||
IGNORE := $(shell $(MKDIR) $(TMPDIR))
|
||||
|
||||
export ADDR2LINE
|
||||
export LC_ALL
|
||||
@@ -150,10 +147,12 @@ export MODE
|
||||
export SOURCE_DATE_EPOCH
|
||||
export TMPDIR
|
||||
|
||||
COSMOCC = .cosmocc/3.6.0
|
||||
COSMOCC = .cosmocc/3.8.0
|
||||
BOOTSTRAP = $(COSMOCC)/bin
|
||||
TOOLCHAIN = $(COSMOCC)/bin/$(ARCH)-linux-cosmo-
|
||||
DOWNLOAD := $(shell build/download-cosmocc.sh $(COSMOCC) 3.6.0 4918c45ac3e0972ff260e2a249e25716881e39fb679d5e714ae216a2ef6c3f7e)
|
||||
DOWNLOAD := $(shell build/download-cosmocc.sh $(COSMOCC) 3.8.0 813c6b2f95062d2e0a845307a79505424cb98cb038e8013334f8a22e3b92a474)
|
||||
|
||||
IGNORE := $(shell $(MKDIR) $(TMPDIR))
|
||||
|
||||
AS = $(TOOLCHAIN)as
|
||||
CC = $(TOOLCHAIN)gcc
|
||||
@@ -541,7 +540,7 @@ COSMOCC_HDRS = \
|
||||
$(foreach x,$(COSMOCC_PKGS),$($(x)_HDRS)) \
|
||||
$(foreach x,$(COSMOCC_PKGS),$($(x)_INCS))
|
||||
|
||||
o/cosmocc.h.txt: Makefile
|
||||
o/cosmocc.h.txt: Makefile libc $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(INCS),$(dir $(x)))) $(HDRS) $(INCS)
|
||||
$(file >$@, $(call uniq,$(COSMOCC_HDRS)))
|
||||
|
||||
COSMOPOLITAN_H_ROOT_HDRS = \
|
||||
|
||||
+10
-12
@@ -45,10 +45,10 @@ o/$(MODE)/ape: $(APE)
|
||||
|
||||
o/$(MODE)/ape/aarch64.lds: \
|
||||
ape/aarch64.lds \
|
||||
libc/zip.internal.h \
|
||||
libc/zip.h \
|
||||
libc/thread/tls.h \
|
||||
libc/calls/struct/timespec.h \
|
||||
libc/macros.internal.h \
|
||||
libc/macros.h \
|
||||
libc/str/str.h
|
||||
|
||||
APE_LOADER_LDFLAGS = \
|
||||
@@ -162,8 +162,8 @@ o/$(MODE)/ape/ape-no-modify-self.o: \
|
||||
libc/dce.h \
|
||||
libc/elf/def.h \
|
||||
libc/thread/tls.h \
|
||||
libc/macho.internal.h \
|
||||
libc/macros.internal.h \
|
||||
libc/macho.h \
|
||||
libc/macros.h \
|
||||
libc/nexgen32e/uart.internal.h \
|
||||
libc/calls/metalfile.internal.h \
|
||||
libc/nt/pedef.internal.h \
|
||||
@@ -188,8 +188,8 @@ o/$(MODE)/ape/ape-copy-self.o: \
|
||||
libc/dce.h \
|
||||
libc/elf/def.h \
|
||||
libc/thread/tls.h \
|
||||
libc/macho.internal.h \
|
||||
libc/macros.internal.h \
|
||||
libc/macho.h \
|
||||
libc/macros.h \
|
||||
libc/nexgen32e/uart.internal.h \
|
||||
libc/calls/metalfile.internal.h \
|
||||
libc/nt/pedef.internal.h \
|
||||
@@ -246,8 +246,6 @@ o/$(MODE)/ape: $(APE_CHECKS) \
|
||||
o/$(MODE)/ape/ape.lds \
|
||||
o/$(MODE)/ape/ape.elf \
|
||||
o/$(MODE)/ape/ape.macho \
|
||||
o/$(MODE)/ape/ape-copy-self.o \
|
||||
o/$(MODE)/ape/ape-no-modify-self.o
|
||||
|
||||
endif
|
||||
|
||||
@@ -261,8 +259,8 @@ o/$(MODE)/ape/ape.o: \
|
||||
libc/thread/tls.h \
|
||||
ape/ape.internal.h \
|
||||
ape/macros.internal.h \
|
||||
libc/macho.internal.h \
|
||||
libc/macros.internal.h \
|
||||
libc/macho.h \
|
||||
libc/macros.h \
|
||||
libc/sysv/consts/prot.h \
|
||||
libc/nt/pedef.internal.h \
|
||||
libc/runtime/pc.internal.h \
|
||||
@@ -283,7 +281,7 @@ o/$(MODE)/ape/ape.lds: \
|
||||
libc/dce.h \
|
||||
libc/elf/def.h \
|
||||
libc/elf/pf2prot.internal.h \
|
||||
libc/macros.internal.h \
|
||||
libc/macros.h \
|
||||
libc/nt/pedef.internal.h \
|
||||
libc/str/str.h \
|
||||
libc/zip.internal.h
|
||||
libc/zip.h
|
||||
+5
-5
@@ -103,10 +103,8 @@ SECTIONS {
|
||||
*(.eh_frame_entry .eh_frame_entry.*)
|
||||
}
|
||||
|
||||
.eh_frame : ONLY_IF_RO {
|
||||
KEEP(*(.eh_frame))
|
||||
*(.eh_frame.*)
|
||||
}
|
||||
__eh_frame_hdr_start = SIZEOF(.eh_frame_hdr) > 0 ? ADDR(.eh_frame_hdr) : 0;
|
||||
__eh_frame_hdr_end = SIZEOF(.eh_frame_hdr) > 0 ? . : 0;
|
||||
|
||||
.gcc_except_table : ONLY_IF_RO {
|
||||
*(.gcc_except_table .gcc_except_table.*)
|
||||
@@ -127,9 +125,11 @@ SECTIONS {
|
||||
. += CONSTANT(MAXPAGESIZE);
|
||||
. = DATA_SEGMENT_ALIGN(CONSTANT(MAXPAGESIZE), CONSTANT(COMMONPAGESIZE));
|
||||
|
||||
.eh_frame : ONLY_IF_RW {
|
||||
.eh_frame : {
|
||||
__eh_frame_start = .;
|
||||
KEEP(*(.eh_frame))
|
||||
*(.eh_frame.*)
|
||||
__eh_frame_end = .;
|
||||
}
|
||||
|
||||
.gnu_extab : ONLY_IF_RW {
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#ifndef __APPLE__
|
||||
#error "ape/ape-m1.c is for apple silicon. chances you want ape/loader.c"
|
||||
#endif
|
||||
#ifndef __aarch64__
|
||||
#error "ape/ape-m1.c is for apple silicon; you want: make o//ape/ape.macho"
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <dispatch/dispatch.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "libc/calls/metalfile.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/macho.internal.h"
|
||||
#include "libc/macho.h"
|
||||
#include "libc/nexgen32e/uart.internal.h"
|
||||
#include "libc/nt/pedef.internal.h"
|
||||
#include "libc/runtime/pc.internal.h"
|
||||
|
||||
+13
-1
@@ -310,7 +310,7 @@ SECTIONS {
|
||||
. = ALIGN(__privileged_end > __privileged_start ? CONSTANT(COMMONPAGESIZE) : 0);
|
||||
/*END: morphable code */
|
||||
__privileged_start = .;
|
||||
*(.privileged)
|
||||
*(.privileged .privileged.*)
|
||||
__privileged_end = .;
|
||||
|
||||
KEEP(*(.ape.pad.text))
|
||||
@@ -329,6 +329,10 @@ SECTIONS {
|
||||
*(.ubsan.types)
|
||||
*(.ubsan.data)
|
||||
|
||||
__eh_frame_hdr_start_actual = .;
|
||||
*(.eh_frame_hdr)
|
||||
__eh_frame_hdr_end_actual = .;
|
||||
|
||||
/* Legal Notices */
|
||||
__notices = .;
|
||||
KEEP(*(.notice))
|
||||
@@ -422,6 +426,11 @@ SECTIONS {
|
||||
KEEP(*(.dtors))
|
||||
__fini_array_end = .;
|
||||
|
||||
__eh_frame_start = .;
|
||||
KEEP(*(.eh_frame))
|
||||
*(.eh_frame.*)
|
||||
__eh_frame_end = .;
|
||||
|
||||
/*BEGIN: Post-Initialization Read-Only */
|
||||
. = ALIGN(. != 0 ? __SIZEOF_POINTER__ : 0);
|
||||
KEEP(*(SORT_BY_NAME(.piro.relo.sort.*)))
|
||||
@@ -601,6 +610,9 @@ ape_text_memsz = ape_text_filesz;
|
||||
ape_text_align = CONSTANT(COMMONPAGESIZE);
|
||||
ape_text_rva = RVA(ape_text_vaddr);
|
||||
|
||||
__eh_frame_hdr_start = __eh_frame_hdr_end_actual > __eh_frame_hdr_start_actual ? __eh_frame_hdr_start_actual : 0;
|
||||
__eh_frame_hdr_end = __eh_frame_hdr_end_actual > __eh_frame_hdr_start_actual ? __eh_frame_hdr_end_actual : 0;
|
||||
|
||||
/* we roundup here because xnu wants the file load segments page-aligned */
|
||||
/* but we don't want to add the nop padding to the ape program, so we'll */
|
||||
/* let ape.S dd read past the end of the file into the wrapping binaries */
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
// Calls _start() function of loaded program.
|
||||
//
|
||||
|
||||
+2
-2
@@ -16,10 +16,10 @@
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macho.internal.h"
|
||||
#include "libc/macho.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
// Apple Mach-O Executable Headers
|
||||
// Fixups are applied by objbincopy
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#ifndef APE_MACROS_H_
|
||||
#define APE_MACROS_H_
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#ifdef __ASSEMBLER__
|
||||
/* clang-format off */
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "ape/ape.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
#ifdef __aarch64__
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
// Invokes system call.
|
||||
//
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2
-11
@@ -92,10 +92,7 @@ DEFAULT_COPTS ?= \
|
||||
-fno-gnu-unique \
|
||||
-fstrict-aliasing \
|
||||
-fstrict-overflow \
|
||||
-fno-semantic-interposition \
|
||||
-fno-dwarf2-cfi-asm \
|
||||
-fno-unwind-tables \
|
||||
-fno-asynchronous-unwind-tables
|
||||
-fno-semantic-interposition
|
||||
|
||||
ifeq ($(ARCH), x86_64)
|
||||
# Microsoft says "[a]ny memory below the stack beyond the red zone
|
||||
@@ -115,14 +112,10 @@ ifeq ($(ARCH), aarch64)
|
||||
# - Cosmopolitan Libc uses x28 for thread-local storage because Apple
|
||||
# forbids us from using tpidr_el0 too.
|
||||
#
|
||||
# - Cosmopolitan currently lacks an implementation of the runtime
|
||||
# libraries needed by the -moutline-atomics flag
|
||||
#
|
||||
DEFAULT_COPTS += \
|
||||
-ffixed-x18 \
|
||||
-ffixed-x28 \
|
||||
-fsigned-char \
|
||||
-mno-outline-atomics
|
||||
-fsigned-char
|
||||
endif
|
||||
|
||||
MATHEMATICAL = \
|
||||
@@ -143,8 +136,6 @@ DEFAULT_CFLAGS = \
|
||||
|
||||
DEFAULT_CXXFLAGS = \
|
||||
-std=gnu++23 \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-fuse-cxa-atexit \
|
||||
-Wno-int-in-bool-context \
|
||||
-Wno-narrowing \
|
||||
|
||||
+8
-8
@@ -6,14 +6,14 @@ if [ -n "$OBJDUMP" ]; then
|
||||
fi
|
||||
|
||||
find_objdump() {
|
||||
if [ -x .cosmocc/3.6.0/bin/$1-linux-cosmo-objdump ]; then
|
||||
OBJDUMP=.cosmocc/3.6.0/bin/$1-linux-cosmo-objdump
|
||||
elif [ -x .cosmocc/3.6.0/bin/$1-linux-musl-objdump ]; then
|
||||
OBJDUMP=.cosmocc/3.6.0/bin/$1-linux-musl-objdump
|
||||
elif [ -x "$COSMO/.cosmocc/3.6.0/bin/$1-linux-cosmo-objdump" ]; then
|
||||
OBJDUMP="$COSMO/.cosmocc/3.6.0/bin/$1-linux-cosmo-objdump"
|
||||
elif [ -x "$COSMO/.cosmocc/3.6.0/bin/$1-linux-musl-objdump" ]; then
|
||||
OBJDUMP="$COSMO/.cosmocc/3.6.0/bin/$1-linux-musl-objdump"
|
||||
if [ -x .cosmocc/3.8.0/bin/$1-linux-cosmo-objdump ]; then
|
||||
OBJDUMP=.cosmocc/3.8.0/bin/$1-linux-cosmo-objdump
|
||||
elif [ -x .cosmocc/3.8.0/bin/$1-linux-musl-objdump ]; then
|
||||
OBJDUMP=.cosmocc/3.8.0/bin/$1-linux-musl-objdump
|
||||
elif [ -x "$COSMO/.cosmocc/3.8.0/bin/$1-linux-cosmo-objdump" ]; then
|
||||
OBJDUMP="$COSMO/.cosmocc/3.8.0/bin/$1-linux-cosmo-objdump"
|
||||
elif [ -x "$COSMO/.cosmocc/3.8.0/bin/$1-linux-musl-objdump" ]; then
|
||||
OBJDUMP="$COSMO/.cosmocc/3.8.0/bin/$1-linux-musl-objdump"
|
||||
else
|
||||
echo "error: toolchain not found (try running 'cosmocc --update' or 'make' in the cosmo monorepo)" >&2
|
||||
exit 1
|
||||
|
||||
@@ -4,5 +4,5 @@ UNAMES=$(uname -s)
|
||||
if [ x"$UNAMES" = x"Darwin" ] && [ x"$UNAMEM" = x"arm64" ]; then
|
||||
exec ape "$@"
|
||||
else
|
||||
exec "$@"
|
||||
exec rusage "$@"
|
||||
fi
|
||||
@@ -241,8 +241,9 @@ class set
|
||||
private:
|
||||
friend class set;
|
||||
node_type* node_;
|
||||
node_type* root_;
|
||||
|
||||
explicit reverse_iterator(node_type* node) : node_(node)
|
||||
explicit reverse_iterator(node_type* node, node_type* root) : node_(node), root_(root)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -347,17 +348,17 @@ class set
|
||||
|
||||
reverse_iterator rbegin()
|
||||
{
|
||||
return reverse_iterator(rightmost(root_));
|
||||
return reverse_iterator(rightmost(root_), root_);
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const
|
||||
{
|
||||
return const_reverse_iterator(rightmost(root_));
|
||||
return const_reverse_iterator(rightmost(root_), root_);
|
||||
}
|
||||
|
||||
const_reverse_iterator crbegin() const
|
||||
{
|
||||
return const_reverse_iterator(rightmost(root_));
|
||||
return const_reverse_iterator(rightmost(root_), root_);
|
||||
}
|
||||
|
||||
iterator end() noexcept
|
||||
@@ -377,17 +378,17 @@ class set
|
||||
|
||||
reverse_iterator rend()
|
||||
{
|
||||
return reverse_iterator(nullptr);
|
||||
return reverse_iterator(nullptr, root_);
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const
|
||||
{
|
||||
return const_reverse_iterator(nullptr);
|
||||
return const_reverse_iterator(nullptr, root_);
|
||||
}
|
||||
|
||||
const_reverse_iterator crend() const
|
||||
{
|
||||
return const_reverse_iterator(nullptr);
|
||||
return const_reverse_iterator(nullptr, root_);
|
||||
}
|
||||
|
||||
void clear() noexcept
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_C161_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_C161_H_
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
#define EXTRA_SHARP 2
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_C161S_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_C161S_H_
|
||||
#include "dsp/core/c161.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
__funline signed char C161S(signed char al, signed char bl, signed char cl) {
|
||||
short ax, bx, cx;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "libc/assert.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "dsp/core/core.h"
|
||||
#include "dsp/core/q.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_HALF_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_HALF_H_
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
/**
|
||||
* Divides integer in half w/ rounding.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_KS8_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_KS8_H_
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
/**
|
||||
* Performs 16-bit scaled rounded madd w/ eight coefficients or fewer.
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_KSS8_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_KSS8_H_
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
/**
|
||||
* Performs 16-bit scaled rounded saturated madd w/ eight coefficients or fewer.
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_Q_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_Q_H_
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "third_party/aarch64/arm_neon.internal.h"
|
||||
#include "third_party/intel/emmintrin.internal.h"
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
clamp4int256$core:
|
||||
.leafprologue
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
│ SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/mpeg/mpeg.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
__static_yoink("pl_mpeg_notice");
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,6 +45,12 @@ $(DSP_SCALE_A).pkg: \
|
||||
$(DSP_SCALE_A_OBJS) \
|
||||
$(foreach x,$(DSP_SCALE_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
ifeq ($(ARCH),x86_64)
|
||||
o/$(MODE)/dsp/scale/cdecimate2xuint8x8.o: private \
|
||||
CFLAGS += \
|
||||
-mssse3
|
||||
endif
|
||||
|
||||
o/$(MODE)/dsp/scale/cdecimate2xuint8x8.o \
|
||||
o/$(MODE)/dsp/scale/gyarados.o \
|
||||
o/$(MODE)/dsp/scale/magikarp.o \
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "dsp/core/ks8.h"
|
||||
#include "dsp/core/kss8.h"
|
||||
#include "dsp/scale/cdecimate2xuint8x8.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
// TODO(jart): write me
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
#include "libc/assert.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/tty/quant.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
struct TtyRgb rgb2ttyi2f_(int r, int g, int b) {
|
||||
return rgb2ttyf((ttyrgb_m128){r, g, b} / 255);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/tty/quant.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
struct TtyRgb rgb2xterm24_(int r, int g, int b) {
|
||||
return (struct TtyRgb){MAX(MIN(r, 255), 0), MAX(MIN(g, 255), 0),
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/tty/quant.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/math.h"
|
||||
#include "third_party/intel/xmmintrin.internal.h"
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/calls/ucontext.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
// Returns index of minimum uint16 in array.
|
||||
//
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
// Returns index of minimum positive int16 in array.
|
||||
//
|
||||
|
||||
@@ -53,6 +53,7 @@ EXAMPLES_DIRECTDEPS = \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_NT_ADVAPI32 \
|
||||
LIBC_NT_IPHLPAPI \
|
||||
LIBC_NT_MEMORY \
|
||||
LIBC_NT_KERNEL32 \
|
||||
LIBC_NT_NTDLL \
|
||||
LIBC_NT_USER32 \
|
||||
@@ -93,6 +94,7 @@ EXAMPLES_DIRECTDEPS = \
|
||||
THIRD_PARTY_VQSORT \
|
||||
THIRD_PARTY_XED \
|
||||
THIRD_PARTY_LIBCXXABI \
|
||||
THIRD_PARTY_LIBUNWIND \
|
||||
THIRD_PARTY_ZLIB \
|
||||
TOOL_ARGS \
|
||||
TOOL_BUILD_LIB \
|
||||
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <cosmo.h>
|
||||
#include <pthread.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// lockless push / pop tutorial
|
||||
//
|
||||
// this file demonstrates how to create a singly linked list that can be
|
||||
// pushed and popped across multiple threads, using only atomics. atomic
|
||||
// operations (rather than using a mutex) make push/pop go faster and it
|
||||
// ensures asynchronous signal safety too. therefore it will be safe for
|
||||
// use in a variety of contexts, such as signal handlers.
|
||||
|
||||
#define THREADS 128
|
||||
#define ITERATIONS 10000
|
||||
|
||||
// adjust mask based on alignment of list struct
|
||||
//
|
||||
// - 0x00fffffffffffff0 may be used if List* is always 16-byte aligned.
|
||||
// We know that's the case here, because we call malloc() to create
|
||||
// every List* object, and malloc() results are always max aligned.
|
||||
//
|
||||
// - 0x00fffffffffffff8 may be used if List* is always 8-byte aligned.
|
||||
// This might be the case if you're pushing and popping stuff that was
|
||||
// allocated from an array, to avoid malloc() calls. This has one
|
||||
// fewer byte of safeguards against the ABA problem though.
|
||||
//
|
||||
// - 0x00fffffffffff000 may be used if List* is always page aligned.
|
||||
// This is a good choice if you use mmap() to allocate each List*
|
||||
// element, since it offers maximum protection against ABA.
|
||||
//
|
||||
// - only the highest byte of a 64-bit pointer is safe to use on our
|
||||
// supported platforms. on most x86 and arm systems, it's possible to
|
||||
// use the top sixteen bits. however that's not the case on more
|
||||
// recent high end x86-64 systems that have pml5t.
|
||||
//
|
||||
#define MASQUE 0x00fffffffffffff0
|
||||
|
||||
#define PTR(x) ((uintptr_t)(x) & MASQUE)
|
||||
#define TAG(x) ROL((uintptr_t)(x) & ~MASQUE, 8)
|
||||
#define ABA(p, t) ((uintptr_t)(p) | (ROR((uintptr_t)(t), 8) & ~MASQUE))
|
||||
#define ROL(x, n) (((x) << (n)) | ((x) >> (64 - (n))))
|
||||
#define ROR(x, n) (((x) >> (n)) | ((x) << (64 - (n))))
|
||||
|
||||
struct List {
|
||||
struct List* next;
|
||||
int count;
|
||||
};
|
||||
|
||||
atomic_uintptr_t list;
|
||||
|
||||
void push(struct List* elem) {
|
||||
uintptr_t tip;
|
||||
assert(!TAG(elem));
|
||||
for (tip = atomic_load_explicit(&list, memory_order_relaxed);;) {
|
||||
elem->next = (struct List*)PTR(tip);
|
||||
if (atomic_compare_exchange_weak_explicit(
|
||||
&list, &tip, ABA(elem, TAG(tip) + 1), memory_order_release,
|
||||
memory_order_relaxed))
|
||||
break;
|
||||
pthread_pause_np();
|
||||
}
|
||||
}
|
||||
|
||||
struct List* pop(void) {
|
||||
uintptr_t tip;
|
||||
struct List* elem;
|
||||
tip = atomic_load_explicit(&list, memory_order_relaxed);
|
||||
while ((elem = (struct List*)PTR(tip))) {
|
||||
if (atomic_compare_exchange_weak_explicit(
|
||||
&list, &tip, ABA(elem->next, TAG(tip) + 1), memory_order_acquire,
|
||||
memory_order_relaxed))
|
||||
break;
|
||||
pthread_pause_np();
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
|
||||
void* tester(void* arg) {
|
||||
struct List* elem;
|
||||
for (int i = 0; i < ITERATIONS; ++i) {
|
||||
while (!(elem = pop())) {
|
||||
elem = malloc(sizeof(*elem));
|
||||
elem->count = 0;
|
||||
push(elem);
|
||||
}
|
||||
elem->count++;
|
||||
push(elem);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
printf("testing aba problem...");
|
||||
fflush(stdout);
|
||||
pthread_t th[THREADS];
|
||||
for (int i = 0; i < THREADS; ++i)
|
||||
pthread_create(&th[i], 0, tester, 0);
|
||||
for (int i = 0; i < THREADS; ++i)
|
||||
pthread_join(th[i], 0);
|
||||
int sum = 0;
|
||||
struct List* elem;
|
||||
while ((elem = pop())) {
|
||||
printf(" %d", elem->count);
|
||||
sum += elem->count;
|
||||
free(elem);
|
||||
}
|
||||
printf("\n");
|
||||
assert(sum == ITERATIONS * THREADS);
|
||||
printf("you are the dancing queen\n");
|
||||
CheckForMemoryLeaks();
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/enum/timezoneid.h"
|
||||
#include "libc/nt/struct/timezoneinformation.h"
|
||||
#include "libc/nt/time.h"
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/linger.h"
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@
|
||||
#include "libc/inttypes.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/arraylist2.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
@@ -47,7 +47,7 @@
|
||||
#include "libc/time.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "libc/x/xsigaction.h"
|
||||
#include "libc/zip.internal.h"
|
||||
#include "libc/zip.h"
|
||||
#include "third_party/getopt/getopt.internal.h"
|
||||
#include "third_party/libcxx/vector"
|
||||
#include "tool/viz/lib/knobs.h"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include <cosmo.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
printf("%d\n", __get_cpu_count());
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
// Example assembly function.
|
||||
//
|
||||
|
||||
+1022
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -41,7 +41,7 @@
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/bswap.h"
|
||||
#include "libc/log/bsd.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/paths.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
@@ -154,6 +154,66 @@ o/$(MODE)/libc/calls/sigcrashsig.o: private \
|
||||
CFLAGS += \
|
||||
-Os
|
||||
|
||||
# avoid legacy sse decoding penalty on avx systems
|
||||
o//libc/calls/cfmakeraw.o \
|
||||
o//libc/calls/clock_gettime-xnu.o \
|
||||
o//libc/calls/CPU_AND.o \
|
||||
o//libc/calls/CPU_OR.o \
|
||||
o//libc/calls/CPU_XOR.o \
|
||||
o//libc/calls/dl_iterate_phdr.o \
|
||||
o//libc/calls/dup-nt.o \
|
||||
o//libc/calls/fcntl-nt.o \
|
||||
o//libc/calls/flock-nt.o \
|
||||
o//libc/calls/fstatfs-nt.o \
|
||||
o//libc/calls/fstat-nt.o \
|
||||
o//libc/calls/futimesat.o \
|
||||
o//libc/calls/futimes.o \
|
||||
o//libc/calls/getrlimit.o \
|
||||
o//libc/calls/gettimeofday.o \
|
||||
o//libc/calls/ioctl.o \
|
||||
o//libc/calls/lutimes.o \
|
||||
o//libc/calls/metaflock.o \
|
||||
o//libc/calls/ntaccesscheck.o \
|
||||
o//libc/calls/ntspawn.o \
|
||||
o//libc/calls/open-nt.o \
|
||||
o//libc/calls/pledge-linux.o \
|
||||
o//libc/calls/ppoll.o \
|
||||
o//libc/calls/preadv.o \
|
||||
o//libc/calls/pselect.o \
|
||||
o//libc/calls/pwritev.o \
|
||||
o//libc/calls/read-nt.o \
|
||||
o//libc/calls/readv.o \
|
||||
o//libc/calls/readwrite-nt.o \
|
||||
o//libc/calls/releasefd.o \
|
||||
o//libc/calls/select.o \
|
||||
o//libc/calls/sigaction.o \
|
||||
o//libc/calls/sigenter-freebsd.o \
|
||||
o//libc/calls/sigenter-netbsd.o \
|
||||
o//libc/calls/sigenter-openbsd.o \
|
||||
o//libc/calls/sigenter-xnu.o \
|
||||
o//libc/calls/sigignore.o \
|
||||
o//libc/calls/siginfo2cosmo.o \
|
||||
o//libc/calls/signal.o \
|
||||
o//libc/calls/sig.o \
|
||||
o//libc/calls/sigtimedwait.o \
|
||||
o//libc/calls/stat2cosmo.o \
|
||||
o//libc/calls/statfs2cosmo.o \
|
||||
o//libc/calls/statfs2statvfs.o \
|
||||
o//libc/calls/tcgetattr-nt.o \
|
||||
o//libc/calls/tcgetattr.o \
|
||||
o//libc/calls/tcgetwinsize-nt.o \
|
||||
o//libc/calls/tcsetattr-nt.o \
|
||||
o//libc/calls/tcsetwinsize-nt.o \
|
||||
o//libc/calls/termios2host.o \
|
||||
o//libc/calls/timespec_sleep.o \
|
||||
o//libc/calls/uname.o \
|
||||
o//libc/calls/utimensat-old.o \
|
||||
o//libc/calls/utimes.o \
|
||||
o//libc/calls/winexec.o \
|
||||
o//libc/calls/writev.o: private \
|
||||
COPTS += \
|
||||
-mgeneral-regs-only
|
||||
|
||||
# these assembly files are safe to build on aarch64
|
||||
o/$(MODE)/libc/calls/getcontext.o: libc/calls/getcontext.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/cpuset.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
void CPU_AND(cpu_set_t *d, cpu_set_t *x, cpu_set_t *y) {
|
||||
int i;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/cpuset.h"
|
||||
#include "libc/intrin/popcnt.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
int CPU_COUNT(cpu_set_t *set) {
|
||||
int i, c;
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/cpuset.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
void CPU_OR(cpu_set_t *d, cpu_set_t *x, cpu_set_t *y) {
|
||||
int i;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/cpuset.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
void CPU_XOR(cpu_set_t *d, cpu_set_t *x, cpu_set_t *y) {
|
||||
int i;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/errors.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/process.h"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/calls/struct/timeval.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#ifdef __x86_64__
|
||||
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/intrin/fds.h"
|
||||
#include "libc/calls/syscall-nt.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/intrin/fds.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/nt/enum/filetype.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/zipos.internal.h"
|
||||
#include "libc/sock/syscall_fd.internal.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
@@ -64,5 +65,7 @@ textwindows int sys_close_nt(int fd, int fildes) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (f->cursor)
|
||||
__cursor_unref(f->cursor);
|
||||
return CloseHandle(f->handle) ? 0 : __winerr();
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "libc/calls/struct/sigset.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/fds.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/nt/files.h"
|
||||
@@ -82,6 +83,7 @@ static textwindows int sys_dup_nt_impl(int oldfd, int newfd, int flags,
|
||||
|
||||
g_fds.p[newfd] = g_fds.p[oldfd];
|
||||
g_fds.p[newfd].handle = handle;
|
||||
__cursor_ref(g_fds.p[newfd].cursor);
|
||||
if (flags & _O_CLOEXEC) {
|
||||
g_fds.p[newfd].flags |= _O_CLOEXEC;
|
||||
} else {
|
||||
|
||||
+11
-6
@@ -20,18 +20,18 @@
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/createfileflags.internal.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/intrin/fds.h"
|
||||
#include "libc/calls/struct/flock.h"
|
||||
#include "libc/calls/struct/sigset.internal.h"
|
||||
#include "libc/calls/syscall-nt.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/calls/wincrash.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/fds.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/backtrace.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/mem/leaks.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/createfile.h"
|
||||
@@ -151,7 +151,7 @@ static textwindows int sys_fcntl_nt_lock(struct Fd *f, int fd, int cmd,
|
||||
case SEEK_SET:
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
off = f->pointer + off;
|
||||
off = f->cursor->shared->pointer + off;
|
||||
break;
|
||||
case SEEK_END: {
|
||||
int64_t size;
|
||||
@@ -351,9 +351,14 @@ textwindows int sys_fcntl_nt(int fd, int cmd, uintptr_t arg) {
|
||||
}
|
||||
rc = 0;
|
||||
} else if (cmd == F_SETLK || cmd == F_SETLKW || cmd == F_GETLK) {
|
||||
pthread_mutex_lock(&g_locks.mu);
|
||||
rc = sys_fcntl_nt_lock(g_fds.p + fd, fd, cmd, arg);
|
||||
pthread_mutex_unlock(&g_locks.mu);
|
||||
struct Fd *f = g_fds.p + fd;
|
||||
if (f->cursor) {
|
||||
pthread_mutex_lock(&g_locks.mu);
|
||||
rc = sys_fcntl_nt_lock(f, fd, cmd, arg);
|
||||
pthread_mutex_unlock(&g_locks.mu);
|
||||
} else {
|
||||
rc = ebadf();
|
||||
}
|
||||
} else if (cmd == F_DUPFD || cmd == F_DUPFD_CLOEXEC) {
|
||||
rc = sys_fcntl_nt_dupfd(fd, cmd, arg);
|
||||
} else {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "libc/elf/tinyelf.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/directmap.h"
|
||||
#include "libc/intrin/promises.h"
|
||||
#include "libc/nt/memory.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
@@ -69,42 +70,35 @@ static int GetElfMachine(void) {
|
||||
}
|
||||
|
||||
static bool IsMyDebugBinary(const char *path) {
|
||||
void *addr;
|
||||
int64_t size;
|
||||
uintptr_t value;
|
||||
bool res = false;
|
||||
int fd, e = errno;
|
||||
struct DirectMap dm;
|
||||
BLOCK_CANCELATION;
|
||||
if ((fd = open(path, O_RDONLY | O_CLOEXEC, 0)) != -1) {
|
||||
// sanity test that this .com.dbg file (1) is an elf image, and (2)
|
||||
// contains the same number of bytes of code as our .com executable
|
||||
// which is currently running in memory.
|
||||
if ((size = lseek(fd, 0, SEEK_END)) != -1 &&
|
||||
(dm = sys_mmap((void *)0x12345000000, size, PROT_READ, MAP_SHARED, fd,
|
||||
0))
|
||||
.addr != MAP_FAILED) {
|
||||
if (READ32LE((char *)dm.addr) == READ32LE("\177ELF") &&
|
||||
((Elf64_Ehdr *)dm.addr)->e_machine == GetElfMachine() &&
|
||||
GetElfSymbolValue(dm.addr, "_etext", &value)) {
|
||||
(addr = mmap(0, size, PROT_READ, MAP_SHARED, fd, 0)) != MAP_FAILED) {
|
||||
if (READ32LE((char *)addr) == READ32LE("\177ELF") &&
|
||||
((Elf64_Ehdr *)addr)->e_machine == GetElfMachine() &&
|
||||
GetElfSymbolValue(addr, "_etext", &value)) {
|
||||
res = !_etext || value == (uintptr_t)_etext;
|
||||
}
|
||||
if (!IsWindows()) {
|
||||
sys_munmap(dm.addr, size);
|
||||
} else {
|
||||
CloseHandle(dm.maphandle);
|
||||
UnmapViewOfFile(dm.addr);
|
||||
}
|
||||
munmap(addr, size);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
ALLOW_CANCELATION;
|
||||
errno = e;
|
||||
return res;
|
||||
}
|
||||
|
||||
static void FindDebugBinaryInit(void) {
|
||||
const char *comdbg;
|
||||
if ((comdbg = getenv("COMDBG")) && IsMyDebugBinary(comdbg)) {
|
||||
if (issetugid())
|
||||
return;
|
||||
if ((comdbg = getenv("COMDBG"))) {
|
||||
g_comdbg.res = comdbg;
|
||||
return;
|
||||
}
|
||||
@@ -123,9 +117,19 @@ static void FindDebugBinaryInit(void) {
|
||||
/**
|
||||
* Returns path of binary with the debug information, or null.
|
||||
*
|
||||
* @return path to debug binary, or NULL
|
||||
* You can specify the COMDBG environment variable, with the path of the
|
||||
* debug binary, in case the automatic heuristics fail. What we look for
|
||||
* is GetProgramExecutableName() with ".dbg", ".com.dbg", etc. appended.
|
||||
*
|
||||
* @return path to debug binary, or NULL if we couldn't find it
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
const char *FindDebugBinary(void) {
|
||||
cosmo_once(&g_comdbg.once, FindDebugBinaryInit);
|
||||
return g_comdbg.res;
|
||||
}
|
||||
|
||||
// pay startup cost to make this signal safe from the user's perspective
|
||||
__attribute__((__constructor__(10))) static void FindDebugBinaryCtor(void) {
|
||||
cosmo_once(&g_comdbg.once, FindDebugBinaryInit);
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/intrin/strace.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/mem/alloca.h"
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/nt/enum/fileinfobyhandleclass.h"
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "libc/calls/struct/statfs.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/enum/fsinformationclass.h"
|
||||
#include "libc/nt/enum/status.h"
|
||||
#include "libc/nt/files.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
// Gets machine state.
|
||||
//
|
||||
|
||||
+51
-27
@@ -30,39 +30,63 @@
|
||||
|
||||
int sys_getcpu(unsigned *opt_cpu, unsigned *opt_node, void *tcache);
|
||||
|
||||
/**
|
||||
* Determines ID of CPU on which thread is currently scheduled.
|
||||
*
|
||||
* This is the same as sched_getcpu(), except it also supports returning
|
||||
* the ID of the current NUMA node. On some platforms this functionality
|
||||
* isn't available, in which case `out_opt_node` is always be set to 0.
|
||||
*/
|
||||
int getcpu(unsigned *out_opt_cpu, unsigned *out_opt_node) {
|
||||
unsigned cpu;
|
||||
unsigned node;
|
||||
if (X86_HAVE(RDTSCP)) {
|
||||
|
||||
if (IsWindows()) {
|
||||
struct NtProcessorNumber pn;
|
||||
if (out_opt_cpu) {
|
||||
GetCurrentProcessorNumberEx(&pn);
|
||||
*out_opt_cpu = 64 * pn.Group + pn.Number;
|
||||
}
|
||||
if (out_opt_node) {
|
||||
unsigned short node16;
|
||||
if (GetNumaProcessorNodeEx(&pn, &node16)) {
|
||||
*out_opt_node = node16;
|
||||
} else {
|
||||
return __winerr();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
if (X86_HAVE(RDTSCP) && (IsLinux() || IsFreebsd())) {
|
||||
unsigned tsc_aux;
|
||||
rdtscp(&tsc_aux);
|
||||
cpu = TSC_AUX_CORE(tsc_aux);
|
||||
node = TSC_AUX_NODE(tsc_aux);
|
||||
} else if (IsWindows()) {
|
||||
struct NtProcessorNumber pn;
|
||||
GetCurrentProcessorNumberEx(&pn);
|
||||
cpu = 64 * pn.Group + pn.Number;
|
||||
unsigned short node16;
|
||||
if (GetNumaProcessorNodeEx(&pn, &node16)) {
|
||||
node = node16;
|
||||
} else {
|
||||
return __winerr();
|
||||
if (out_opt_cpu)
|
||||
*out_opt_cpu = TSC_AUX_CORE(tsc_aux);
|
||||
if (out_opt_node)
|
||||
*out_opt_node = TSC_AUX_NODE(tsc_aux);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (IsXnu() || IsOpenbsd() || IsNetbsd() || IsFreebsd()) {
|
||||
if (out_opt_cpu) {
|
||||
int rc = sched_getcpu();
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
*out_opt_cpu = rc;
|
||||
}
|
||||
} else if (IsAarch64()) {
|
||||
long tpidr_el0;
|
||||
asm("mrs\t%0,tpidr_el0" : "=r"(tpidr_el0));
|
||||
cpu = tpidr_el0 & 255;
|
||||
node = 0;
|
||||
} else {
|
||||
int rc = sys_getcpu(&cpu, &node, 0);
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
if (out_opt_node)
|
||||
*out_opt_node = 0;
|
||||
return 0;
|
||||
}
|
||||
if (out_opt_cpu) {
|
||||
|
||||
unsigned cpu, node;
|
||||
int rc = sys_getcpu(&cpu, &node, 0);
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
if (out_opt_cpu)
|
||||
*out_opt_cpu = cpu;
|
||||
}
|
||||
if (out_opt_node) {
|
||||
if (out_opt_node)
|
||||
*out_opt_node = node;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "libc/calls/syscall_support-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/strace.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/enum/computernameformat.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/rlimit.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/rlimit.h"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/enum/computernameformat.h"
|
||||
#include "libc/nt/systeminfo.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/accounting.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
// Obtains WIN32 magic path, e.g. GetTempPathA.
|
||||
//
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "libc/intrin/getenv.h"
|
||||
#include "libc/intrin/strace.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/serialize.h"
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "libc/intrin/asmflag.h"
|
||||
#include "libc/intrin/strace.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nexgen32e/kcpuids.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/nexgen32e/vendor.internal.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/accounting.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/strace.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ COSMOPOLITAN_C_START_
|
||||
int sys_getgroups(int size, uint32_t list[]);
|
||||
int sys_setgroups(size_t size, const uint32_t list[]);
|
||||
|
||||
const char *DescribeGidList(char[128], int, int, const uint32_t list[]);
|
||||
const char *_DescribeGidList(char[128], int, int, const uint32_t list[]);
|
||||
#define DescribeGidList(rc, length, gidlist) \
|
||||
DescribeGidList(alloca(128), rc, length, gidlist)
|
||||
_DescribeGidList(alloca(128), rc, length, gidlist)
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_GROUPS_INTERNAL_H_ */
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "libc/intrin/fds.h"
|
||||
#include "libc/calls/struct/sigval.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/stdbool.h"
|
||||
|
||||
#define kSigactionMinRva 8 /* >SIG_{ERR,DFL,IGN,...} */
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
#include "libc/intrin/fds.h"
|
||||
#include "libc/intrin/strace.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/mem/alloca.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/console.h"
|
||||
|
||||
@@ -25,6 +25,5 @@
|
||||
bool IsApeLoadable(char buf[8]) {
|
||||
return READ32LE(buf) == READ32LE("\177ELF") ||
|
||||
READ64LE(buf) == READ64LE("MZqFpD='") ||
|
||||
READ64LE(buf) == READ64LE("jartsr='") ||
|
||||
READ64LE(buf) == READ64LE("APEDBG='");
|
||||
READ64LE(buf) == READ64LE("jartsr='");
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
#define BYTES 64
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
#define BYTES 64
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/intrin/fds.h"
|
||||
#include "libc/nt/enum/filetype.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/struct/byhandlefileinformation.h"
|
||||
@@ -31,7 +32,7 @@ static textwindows int64_t GetPosition(struct Fd *f, int whence) {
|
||||
case SEEK_SET:
|
||||
return 0;
|
||||
case SEEK_CUR:
|
||||
return f->pointer;
|
||||
return f->cursor->shared->pointer;
|
||||
case SEEK_END: {
|
||||
struct NtByHandleFileInformation wst;
|
||||
if (!GetFileInformationByHandle(f->handle, &wst)) {
|
||||
@@ -67,11 +68,14 @@ textwindows int64_t sys_lseek_nt(int fd, int64_t offset, int whence) {
|
||||
} else if (__isfdkind(fd, kFdFile)) {
|
||||
struct Fd *f = g_fds.p + fd;
|
||||
int filetype = GetFileType(f->handle);
|
||||
if (filetype != kNtFileTypePipe && filetype != kNtFileTypeChar) {
|
||||
if (filetype != kNtFileTypePipe && //
|
||||
filetype != kNtFileTypeChar && //
|
||||
f->cursor->shared) {
|
||||
int64_t res;
|
||||
if ((res = Seek(f, offset, whence)) != -1) {
|
||||
f->pointer = res;
|
||||
}
|
||||
__cursor_lock(f->cursor);
|
||||
if ((res = Seek(f, offset, whence)) != -1)
|
||||
f->cursor->shared->pointer = res;
|
||||
__cursor_unlock(f->cursor);
|
||||
return res;
|
||||
} else {
|
||||
return espipe();
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "libc/intrin/directmap.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/pc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
│ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR │
|
||||
│ OTHER DEALINGS IN THE SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/calls/metalfile.internal.h"
|
||||
|
||||
.init.start 102,_init_metalfile
|
||||
|
||||
+14
-1
@@ -20,7 +20,7 @@
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/strace.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/systeminfo.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
@@ -55,6 +55,19 @@ textwindows size_t __normntpath(char16_t *p, size_t n) {
|
||||
// matched "/../" or "/..$"
|
||||
while (j && p[j - 1] == '\\')
|
||||
--j;
|
||||
if (j && p[j - 1] == '.') {
|
||||
// matched "." before
|
||||
if (j >= 2 && p[j - 2] == '.' && //
|
||||
(j == 2 || p[j - 3] == '\\')) {
|
||||
// matched "^.." or "/.." before
|
||||
p[++j] = '.';
|
||||
++j;
|
||||
continue;
|
||||
} else if (j == 1 || p[j - 2] == '\\') {
|
||||
// matched "^." or "/." before
|
||||
continue;
|
||||
}
|
||||
}
|
||||
while (j && p[j - 1] != '\\')
|
||||
--j;
|
||||
} else {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/intrin/strace.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
.privileged
|
||||
|
||||
__restore_rt_netbsd:
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "libc/nt/struct/startupinfo.h"
|
||||
#include "libc/nt/struct/startupinfoex.h"
|
||||
#include "libc/proc/ntspawn.h"
|
||||
#include "libc/stdalign.internal.h"
|
||||
#include "libc/stdalign.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#ifdef __x86_64__
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
#include "libc/calls/syscall-nt.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/intrin/fds.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/console.h"
|
||||
#include "libc/nt/createfile.h"
|
||||
#include "libc/nt/enum/accessmask.h"
|
||||
@@ -138,6 +139,7 @@ static textwindows int sys_open_nt_file(int dirfd, const char *file,
|
||||
int64_t handle;
|
||||
if ((handle = sys_open_nt_impl(dirfd, file, flags, mode,
|
||||
kNtFileFlagOverlapped)) != -1) {
|
||||
g_fds.p[fd].cursor = __cursor_new();
|
||||
g_fds.p[fd].handle = handle;
|
||||
g_fds.p[fd].kind = kFdFile;
|
||||
g_fds.p[fd].flags = flags;
|
||||
@@ -170,15 +172,15 @@ static textwindows int sys_open_nt_no_handle(int fd, int flags, int mode,
|
||||
|
||||
static textwindows int sys_open_nt_dup(int fd, int flags, int mode, int oldfd) {
|
||||
int64_t handle;
|
||||
if (!__isfdopen(oldfd)) {
|
||||
if (!__isfdopen(oldfd))
|
||||
return enoent();
|
||||
}
|
||||
if (DuplicateHandle(GetCurrentProcess(), g_fds.p[oldfd].handle,
|
||||
GetCurrentProcess(), &handle, 0, true,
|
||||
kNtDuplicateSameAccess)) {
|
||||
g_fds.p[fd] = g_fds.p[oldfd];
|
||||
g_fds.p[fd].handle = handle;
|
||||
g_fds.p[fd].mode = mode;
|
||||
__cursor_ref(g_fds.p[fd].cursor);
|
||||
if (!sys_fcntl_nt_setfl(fd, flags)) {
|
||||
return fd;
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "libc/calls/metalfile.internal.h"
|
||||
#include "libc/intrin/directmap.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/pc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
Loaded 100 of 2129 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user