diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index b5c68f413..3a7cc4ece 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -101,8 +101,7 @@ ], "defines": [ "COSMO", - "MODE=", - "IMAGE_BASE_VIRTUAL=0x400000" + "MODE=" ] } ], diff --git a/ape/aarch64.lds b/ape/aarch64.lds index 5a12ffc0c..78bfe827d 100644 --- a/ape/aarch64.lds +++ b/ape/aarch64.lds @@ -11,7 +11,7 @@ OUTPUT_FORMAT("elf64-littleaarch64", SECTIONS { - . = SEGMENT_START("text-segment", IMAGE_BASE_VIRTUAL); + . = SEGMENT_START("text-segment", 0x010000000000); __executable_start = .; . += SIZEOF_HEADERS; diff --git a/ape/ape.lds b/ape/ape.lds index f08f9fce9..41b1064f6 100644 --- a/ape/ape.lds +++ b/ape/ape.lds @@ -198,6 +198,10 @@ #define SKEW 0 #endif +#ifndef IMAGE_BASE_VIRTUAL +#define IMAGE_BASE_VIRTUAL 0x400000 +#endif + #if IMAGE_BASE_VIRTUAL > 0xffffffff #error "please use 32-bit addresses for image data" #endif diff --git a/build/definitions.mk b/build/definitions.mk index 66a7d50c9..3feec394a 100644 --- a/build/definitions.mk +++ b/build/definitions.mk @@ -137,12 +137,6 @@ else TMPSAFE = $(TMPDIR)/ endif -ifeq ($(ARCH), aarch64) -IMAGE_BASE_VIRTUAL ?= 0x010000000000 -else -IMAGE_BASE_VIRTUAL ?= 0x400000 -endif - BACKTRACES = \ -fno-optimize-sibling-calls \ -mno-omit-leaf-frame-pointer @@ -222,7 +216,6 @@ MATHEMATICAL = \ DEFAULT_CPPFLAGS += \ -D_COSMO_SOURCE \ -DMODE='"$(MODE)"' \ - -DIMAGE_BASE_VIRTUAL=$(IMAGE_BASE_VIRTUAL) \ -nostdinc \ -iquote . @@ -373,7 +366,6 @@ LINK = $(LD) $(LINK.flags) ELF = o/libc/elf/elf.lds ELFLINK = $(COMPILE) -ALINK.elf $(LINK) $(LINKARGS) $(OUTPUT_OPTION) && $(COMPILE) -AFIXUP.ape -T$@ $(FIXUPOBJ) $@ LINKARGS = $(patsubst %.lds,-T %.lds,$(call uniqr,$(LD.libs) $(filter-out %.pkg,$^))) -LOLSAN = build/lolsan -b $(IMAGE_BASE_VIRTUAL) # The compiler won't generate %xmm code for sources extensioned .greg.c, # which is needed for C modules wanting to run at the executive level or diff --git a/libc/calls/state.internal.h b/libc/calls/state.internal.h index a7d0dadda..878de9e4a 100644 --- a/libc/calls/state.internal.h +++ b/libc/calls/state.internal.h @@ -1,6 +1,5 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STATE_INTERNAL_H_ #define COSMOPOLITAN_LIBC_CALLS_STATE_INTERNAL_H_ -#include "libc/intrin/nopl.internal.h" #include "libc/thread/thread.h" #include "libc/thread/tls.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) @@ -21,22 +20,6 @@ void __sig_lock(void); void __sig_unlock(void); void __sig_funlock(void); -#ifdef _NOPL0 -#define __fds_lock() _NOPL0("__threadcalls", __fds_lock) -#define __fds_unlock() _NOPL0("__threadcalls", __fds_unlock) -#else -#define __fds_lock() (__threaded ? __fds_lock() : 0) -#define __fds_unlock() (__threaded ? __fds_unlock() : 0) -#endif - -#ifdef _NOPL0 -#define __sig_lock() _NOPL0("__threadcalls", __sig_lock) -#define __sig_unlock() _NOPL0("__threadcalls", __sig_unlock) -#else -#define __sig_lock() (__threaded ? __sig_lock() : 0) -#define __sig_unlock() (__threaded ? __sig_unlock() : 0) -#endif - #define __vforked (__tls_enabled && (__get_tls()->tib_flags & TIB_FLAG_VFORKED)) COSMOPOLITAN_C_END_ diff --git a/libc/intrin/cxaatexit.internal.h b/libc/intrin/cxaatexit.internal.h index 556c217fc..f9ddf76a3 100644 --- a/libc/intrin/cxaatexit.internal.h +++ b/libc/intrin/cxaatexit.internal.h @@ -1,6 +1,5 @@ #ifndef COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_ #define COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_ -#include "libc/intrin/nopl.internal.h" #include "libc/stdio/stdio.h" #include "libc/thread/tls.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) @@ -24,14 +23,6 @@ void __cxa_lock(void); void __cxa_unlock(void); void __cxa_printexits(FILE *, void *); -#ifdef _NOPL0 -#define __cxa_lock() _NOPL0("__threadcalls", __cxa_lock) -#define __cxa_unlock() _NOPL0("__threadcalls", __cxa_unlock) -#else -#define __cxa_lock() (__threaded ? __cxa_lock() : 0) -#define __cxa_unlock() (__threaded ? __cxa_unlock() : 0) -#endif - COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_ */ diff --git a/libc/intrin/nopl.internal.h b/libc/intrin/nopl.internal.h deleted file mode 100644 index dae76ebaf..000000000 --- a/libc/intrin/nopl.internal.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_INTRIN_NOPL_H_ -#define COSMOPOLITAN_LIBC_INTRIN_NOPL_H_ -#if !(__ASSEMBLER__ + __LINKER__ + 0) && defined(__x86_64__) && \ - defined(__GNUC__) && !defined(__llvm__) && !defined(__chibicc__) && \ - defined(__MNO_RED_ZONE__) && !defined(__STRICT_ANSI__) - -/** - * @fileoverview Turns CALLs into NOPs that are fixupable at runtime. - * - * Things like lock/unlock function calls can take on average 100ms. - * Libc needs to use internal locking pervasively in order to support - * threads. So there's a lot of cost everywhere, even though most progs - * don't use threads. In ANSI mode we dispatching (__threaded && lock()) - * to solve this problem, but if we write lock statements that way, it - * adds a lot of bloat to the functions that call locking routines. So - * what we do here is replace the CALL instruction with NOP, which keeps - * the code just as fast as inlining, while making code size 10x tinier. - */ - -#define _NOPL_PROLOGUE(SECTION) \ - ".section \".sort.rodata." SECTION ".1" \ - "\",\"aG\",@progbits,\"" SECTION "\",comdat\n\t" \ - ".balign\t4\n\t" \ - ".type\t\"" SECTION "_start\",@object\n\t" \ - ".globl\t\"" SECTION "_start\"\n\t" \ - ".equ\t\"" SECTION "_start\",.\n\t" \ - ".previous\n\t" - -#define _NOPL_EPILOGUE(SECTION) \ - ".section \".sort.rodata." SECTION ".3" \ - "\",\"aG\",@progbits,\"" SECTION "\",comdat\n\t" \ - ".balign\t4\n\t" \ - ".type\"" SECTION "_end\",@object\n\t" \ - ".globl\t\"" SECTION "_end\"\n\t" \ - ".equ\t\"" SECTION "_end\",.\n\t" \ - ".previous\n\t" - -#define _NOPL0(SECTION, FUNC) __NOPL0(SECTION, FUNC, IMAGE_BASE_VIRTUAL) -#define __NOPL0(SECTION, FUNC, GARDEN) ___NOPL0(SECTION, FUNC, GARDEN) -#define ___NOPL0(SECTION, FUNC, GARDEN) \ - ({ \ - asm volatile(_NOPL_PROLOGUE(SECTION) /* */ \ - _NOPL_EPILOGUE(SECTION) /* */ \ - ".section \".sort.rodata." SECTION ".2\",\"a\",@progbits\n\t" \ - ".balign\t4\n\t" \ - ".long\t353f-" #GARDEN "\n\t" \ - ".previous\n353:\t" \ - "nopl\t" #FUNC "(%%rip)" \ - : /* no inputs */ \ - : /* no outputs */ \ - : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", \ - "r11", "memory", "cc"); \ - (void)0; \ - }) - -#define _NOPL1(SECTION, FUNC, ARG) \ - __NOPL1(SECTION, FUNC, ARG, IMAGE_BASE_VIRTUAL) -#define __NOPL1(SECTION, FUNC, ARG, GARDEN) ___NOPL1(SECTION, FUNC, ARG, GARDEN) -#define ___NOPL1(SECTION, FUNC, ARG, GARDEN) \ - ({ \ - register autotype(ARG) __arg asm("rdi") = ARG; \ - asm volatile(_NOPL_PROLOGUE(SECTION) /* */ \ - _NOPL_EPILOGUE(SECTION) /* */ \ - ".section \".sort.rodata." SECTION ".2\",\"a\",@progbits\n\t" \ - ".balign\t4\n\t" \ - ".long\t353f-" #GARDEN "\n\t" \ - ".previous\n353:\t" \ - "nopl\t" #FUNC "(%%rip)" \ - : "+D"(__arg) \ - : /* no inputs */ \ - : "rax", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11", \ - "memory", "cc"); \ - (void)0; \ - }) - -#endif /* !ASSEMBLER && !LINKER && GNUC && !CHIBICC && !LLVM && !ANSI */ -#endif /* COSMOPOLITAN_LIBC_INTRIN_NOPL_H_ */ diff --git a/libc/log/vflogf.c b/libc/log/vflogf.c index 99dd72379..a0143fc43 100644 --- a/libc/log/vflogf.c +++ b/libc/log/vflogf.c @@ -35,7 +35,6 @@ #include "libc/runtime/runtime.h" #include "libc/stdio/dprintf.h" #include "libc/stdio/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/fileno.h" diff --git a/libc/macros.internal.h b/libc/macros.internal.h index ff18895cd..e5ba80a60 100644 --- a/libc/macros.internal.h +++ b/libc/macros.internal.h @@ -445,35 +445,6 @@ #endif .endm -// Good alignment for loops where alignment actually helps. -// @note 16-byte if <10 padding otherwise 8-byte -.macro .alignloop -#ifndef __OPTIMIZE_SIZE__ - .p2align 4,,10 - .p2align 4 -#endif -.endm - -// Loads Effective Address -// Supporting security blankets -.macro plea symbol:req reg64:req reg32:req -#if __PIC__ + __PIE__ + __code_model_medium__ + __code_model_large__ + 0 > 1 - lea \symbol(%rip),\reg64 -#else - mov $\symbol,\reg32 -#endif -.endm - -// Loads Effective Address to Stack -// Supporting security blankets -.macro pshaddr symbol:req -#if __PIC__ + __PIE__ + __code_model_medium__ + __code_model_large__ + 0 > 1 - push $IMAGE_BASE_VIRTUAL+RVA(\symbol)(%rip),\reg64 -#else - push $\symbol -#endif -.endm - // TODO(jart): delete // Loads Effective Address // Supporting security blankets @@ -486,32 +457,6 @@ #endif .endm -.macro farcall symbol:req - .type \symbol,@function -#if __PIC__ + __PIE__ + __code_model_medium__ + __code_model_large__ + 0 > 1 - call *\symbol\()@gotpcrel(%rip) -#else - call \symbol\()@plt -#endif -.endm - -// Pushes RVA on stack of linktime mergeable string literal. -// @see popstr -.macro pushstr text - .section .rodata.str1.1,"aSM",@progbits,1 -.Lstr\@: .asciz "\text" - .endobj .Lstr\@ - .previous - push $.Lstr\@ - IMAGE_BASE_VIRTUAL -.endm - -// Pops off stack string address. -// @see pushstr -.macro popstr dest:req - addl $IMAGE_BASE_VIRTUAL,(%rsp) - pop \dest -.endm - // Loads address of linktime mergeable string literal into register. .macro loadstr text:req reg:req regsz bias=0 .section .rodata.str1.1,"aSM",@progbits,1 diff --git a/libc/runtime/ftracer.c b/libc/runtime/ftracer.c index 9cdc9cee6..184443f97 100644 --- a/libc/runtime/ftracer.c +++ b/libc/runtime/ftracer.c @@ -21,7 +21,6 @@ #include "libc/fmt/itoa.h" #include "libc/intrin/cmpxchg.h" #include "libc/intrin/kprintf.h" -#include "libc/intrin/nopl.internal.h" #include "libc/macros.internal.h" #include "libc/nexgen32e/stackframe.h" #include "libc/runtime/internal.h" diff --git a/libc/runtime/memtrack.internal.h b/libc/runtime/memtrack.internal.h index 639aa7a10..807e1d509 100644 --- a/libc/runtime/memtrack.internal.h +++ b/libc/runtime/memtrack.internal.h @@ -2,7 +2,6 @@ #define COSMOPOLITAN_LIBC_RUNTIME_MEMTRACK_H_ #include "ape/sections.internal.h" #include "libc/dce.h" -#include "libc/intrin/nopl.internal.h" #include "libc/macros.internal.h" #include "libc/nt/version.h" #include "libc/runtime/runtime.h" @@ -61,14 +60,6 @@ void __release_memory_nt(struct MemoryIntervals *, int, int); int __untrack_memories(void *, size_t); size_t __get_memtrack_size(struct MemoryIntervals *); -#ifdef _NOPL0 -#define __mmi_lock() _NOPL0("__threadcalls", __mmi_lock) -#define __mmi_unlock() _NOPL0("__threadcalls", __mmi_unlock) -#else -#define __mmi_lock() (__threaded ? __mmi_lock() : 0) -#define __mmi_unlock() (__threaded ? __mmi_unlock() : 0) -#endif - #ifdef __x86_64__ /* * AMD64 has 48-bit signed pointers (PML4T) diff --git a/libc/stdio/clearerr.c b/libc/stdio/clearerr.c index 02eab7b0a..bc5fad837 100644 --- a/libc/stdio/clearerr.c +++ b/libc/stdio/clearerr.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/feof.c b/libc/stdio/feof.c index ac225d98a..eeca17292 100644 --- a/libc/stdio/feof.c +++ b/libc/stdio/feof.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/ferror.c b/libc/stdio/ferror.c index 7b8905d0f..d11ef64f7 100644 --- a/libc/stdio/ferror.c +++ b/libc/stdio/ferror.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fflush.c b/libc/stdio/fflush.c index 90da7fa6b..5618a8ae4 100644 --- a/libc/stdio/fflush.c +++ b/libc/stdio/fflush.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fflush.internal.h b/libc/stdio/fflush.internal.h index fff364eff..4942e608a 100644 --- a/libc/stdio/fflush.internal.h +++ b/libc/stdio/fflush.internal.h @@ -1,6 +1,5 @@ #ifndef COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ #define COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ -#include "libc/intrin/nopl.internal.h" #include "libc/stdio/stdio.h" #include "libc/thread/thread.h" #include "libc/thread/tls.h" @@ -23,14 +22,6 @@ extern pthread_mutex_t __fflush_lock_obj; void __fflush_lock(void); void __fflush_unlock(void); -#ifdef _NOPL0 -#define __fflush_lock() _NOPL0("__threadcalls", __fflush_lock) -#define __fflush_unlock() _NOPL0("__threadcalls", __fflush_unlock) -#else -#define __fflush_lock() (__threaded ? __fflush_lock() : 0) -#define __fflush_unlock() (__threaded ? __fflush_unlock() : 0) -#endif - COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ */ diff --git a/libc/stdio/fgetc.c b/libc/stdio/fgetc.c index 9b8de9fe5..05b4e05dd 100644 --- a/libc/stdio/fgetc.c +++ b/libc/stdio/fgetc.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fgetln.c b/libc/stdio/fgetln.c index 33cff3ad9..2c295bb7d 100644 --- a/libc/stdio/fgetln.c +++ b/libc/stdio/fgetln.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/stdio/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fgets.c b/libc/stdio/fgets.c index 8551c609a..360896f66 100644 --- a/libc/stdio/fgets.c +++ b/libc/stdio/fgets.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fgetwc.c b/libc/stdio/fgetwc.c index 39cc5b2b2..ddc471ea3 100644 --- a/libc/stdio/fgetwc.c +++ b/libc/stdio/fgetwc.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fgetws.c b/libc/stdio/fgetws.c index 4ba76f11f..4ac3f156a 100644 --- a/libc/stdio/fgetws.c +++ b/libc/stdio/fgetws.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fileno.c b/libc/stdio/fileno.c index 696e7f7a2..294becdbf 100644 --- a/libc/stdio/fileno.c +++ b/libc/stdio/fileno.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/sysv/errfuns.h" diff --git a/libc/stdio/flockfile.c b/libc/stdio/flockfile.c index 8b340672f..8fee39a87 100644 --- a/libc/stdio/flockfile.c +++ b/libc/stdio/flockfile.c @@ -17,13 +17,12 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/stdio/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/thread/thread.h" /** * Acquires reentrant lock on stdio object, blocking if needed. */ -void(flockfile)(FILE *f) { +void flockfile(FILE *f) { pthread_mutex_lock(&f->lock); } diff --git a/libc/stdio/flushlbf.c b/libc/stdio/flushlbf.c index b121f6da2..7ae15fb92 100644 --- a/libc/stdio/flushlbf.c +++ b/libc/stdio/flushlbf.c @@ -19,7 +19,6 @@ #include "libc/calls/calls.h" #include "libc/stdio/fflush.internal.h" #include "libc/stdio/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/stdio/stdio_ext.h" diff --git a/libc/stdio/fprintf.c b/libc/stdio/fprintf.c index f0e9bed9b..cf8b41cb2 100644 --- a/libc/stdio/fprintf.c +++ b/libc/stdio/fprintf.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fputc.c b/libc/stdio/fputc.c index 4a4fe5b0b..f0bdac9ad 100644 --- a/libc/stdio/fputc.c +++ b/libc/stdio/fputc.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fputs.c b/libc/stdio/fputs.c index f7adc65d9..aef211a86 100644 --- a/libc/stdio/fputs.c +++ b/libc/stdio/fputs.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fputwc.c b/libc/stdio/fputwc.c index 9cecb6f8f..4ecced63f 100644 --- a/libc/stdio/fputwc.c +++ b/libc/stdio/fputwc.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fputws.c b/libc/stdio/fputws.c index f2d7c14a3..c9b533f8b 100644 --- a/libc/stdio/fputws.c +++ b/libc/stdio/fputws.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fread.c b/libc/stdio/fread.c index 6c2c36c84..24f2cc446 100644 --- a/libc/stdio/fread.c +++ b/libc/stdio/fread.c @@ -19,7 +19,6 @@ #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/strace.internal.h" #include "libc/runtime/runtime.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/freopen.c b/libc/stdio/freopen.c index 4e3d50e57..991aa59a5 100644 --- a/libc/stdio/freopen.c +++ b/libc/stdio/freopen.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/stdio/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/f.h" #include "libc/sysv/consts/fd.h" diff --git a/libc/stdio/fscanf.c b/libc/stdio/fscanf.c index 736caff76..c5bb44d72 100644 --- a/libc/stdio/fscanf.c +++ b/libc/stdio/fscanf.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/fseek.c b/libc/stdio/fseek.c index 712362f23..e78db477e 100644 --- a/libc/stdio/fseek.c +++ b/libc/stdio/fseek.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/strace.internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/ftell.c b/libc/stdio/ftell.c index 2dcd9c5f2..5210815a1 100644 --- a/libc/stdio/ftell.c +++ b/libc/stdio/ftell.c @@ -20,7 +20,6 @@ #include "libc/errno.h" #include "libc/runtime/runtime.h" #include "libc/stdio/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/o.h" diff --git a/libc/stdio/ftrylockfile.c b/libc/stdio/ftrylockfile.c index aa9b0665b..4c247c912 100644 --- a/libc/stdio/ftrylockfile.c +++ b/libc/stdio/ftrylockfile.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/stdio/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/thread/thread.h" diff --git a/libc/stdio/funlockfile.c b/libc/stdio/funlockfile.c index c23140395..89d7c54bd 100644 --- a/libc/stdio/funlockfile.c +++ b/libc/stdio/funlockfile.c @@ -17,13 +17,12 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/stdio/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/thread/thread.h" /** * Releases lock on stdio object. */ -void(funlockfile)(FILE *f) { +void funlockfile(FILE *f) { pthread_mutex_unlock(&f->lock); } diff --git a/libc/stdio/fwrite.c b/libc/stdio/fwrite.c index 3db05c335..9fddb9921 100644 --- a/libc/stdio/fwrite.c +++ b/libc/stdio/fwrite.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/strace.internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/getdelim.c b/libc/stdio/getdelim.c index 77e770a29..f785152a4 100644 --- a/libc/stdio/getdelim.c +++ b/libc/stdio/getdelim.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/lock.internal.h b/libc/stdio/lock.internal.h deleted file mode 100644 index 99775cb82..000000000 --- a/libc/stdio/lock.internal.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_STDIO_LOCK_H_ -#define COSMOPOLITAN_LIBC_STDIO_LOCK_H_ -#include "libc/intrin/nopl.internal.h" -#include "libc/stdio/stdio.h" -#include "libc/thread/tls.h" -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -#ifdef _NOPL1 -#define flockfile(f) _NOPL1("__threadcalls", flockfile, f) -#define funlockfile(f) _NOPL1("__threadcalls", funlockfile, f) -#define ftrylockfile(f) _NOPL1("__threadcalls", ftrylockfile, f) -#else -#define flockfile(f) (__threaded ? flockfile(f) : 0) -#define funlockfile(f) (__threaded ? funlockfile(f) : 0) -#define ftrylockfile(f) (__threaded ? ftrylockfile(f) : 0) -#endif - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_STDIO_LOCK_H_ */ diff --git a/libc/stdio/puts.c b/libc/stdio/puts.c index 0d395c025..d7b41b63e 100644 --- a/libc/stdio/puts.c +++ b/libc/stdio/puts.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/libc/stdio/rewind.c b/libc/stdio/rewind.c index 21fede138..4acaef2d1 100644 --- a/libc/stdio/rewind.c +++ b/libc/stdio/rewind.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/stdio/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/scanf.c b/libc/stdio/scanf.c index 09475dc41..5f91b5093 100644 --- a/libc/stdio/scanf.c +++ b/libc/stdio/scanf.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/fd.internal.h" #include "libc/fmt/fmt.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/setvbuf.c b/libc/stdio/setvbuf.c index 17f3220cf..4e29ff748 100644 --- a/libc/stdio/setvbuf.c +++ b/libc/stdio/setvbuf.c @@ -20,7 +20,6 @@ #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/sysv/errfuns.h" diff --git a/libc/stdio/ungetc.c b/libc/stdio/ungetc.c index 7c1bb6535..672e9dade 100644 --- a/libc/stdio/ungetc.c +++ b/libc/stdio/ungetc.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/ungetwc.c b/libc/stdio/ungetwc.c index 8fb59f6ea..3ec9f03df 100644 --- a/libc/stdio/ungetwc.c +++ b/libc/stdio/ungetwc.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/vfprintf.c b/libc/stdio/vfprintf.c index 7c55d7a31..715bbb0c8 100644 --- a/libc/stdio/vfprintf.c +++ b/libc/stdio/vfprintf.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/vfscanf.c b/libc/stdio/vfscanf.c index e899c08bd..e61acd9e1 100644 --- a/libc/stdio/vfscanf.c +++ b/libc/stdio/vfscanf.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/stdio/vscanf.c b/libc/stdio/vscanf.c index aea2d144c..09230df2f 100644 --- a/libc/stdio/vscanf.c +++ b/libc/stdio/vscanf.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" /** diff --git a/libc/thread/sem_open.c b/libc/thread/sem_open.c index 9017d9096..542e5ac00 100644 --- a/libc/thread/sem_open.c +++ b/libc/thread/sem_open.c @@ -23,7 +23,6 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/intrin/atomic.h" -#include "libc/intrin/nopl.internal.h" #include "libc/intrin/strace.internal.h" #include "libc/limits.h" #include "libc/mem/mem.h" @@ -71,11 +70,6 @@ static void sem_open_init(void) { pthread_once(&g_semaphores.once, sem_open_setup); } -#ifdef _NOPL0 -#define sem_open_lock() _NOPL0("__threadcalls", sem_open_lock) -#define sem_open_unlock() _NOPL0("__threadcalls", sem_open_unlock) -#endif - static sem_t *sem_open_impl(const char *path, int oflag, unsigned mode, unsigned value) { int fd; diff --git a/libc/time/localtime.c b/libc/time/localtime.c index 0878136df..ccc52662c 100644 --- a/libc/time/localtime.c +++ b/libc/time/localtime.c @@ -5,7 +5,6 @@ #include "libc/calls/blockcancel.internal.h" #include "libc/calls/calls.h" #include "libc/intrin/bits.h" -#include "libc/intrin/nopl.internal.h" #include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/str/str.h" @@ -67,11 +66,6 @@ __attribute__((__constructor__)) static void localtime_init(void) { localtime_funlock); } -#ifdef _NOPL0 -#define localtime_lock() _NOPL0("__threadcalls", localtime_lock) -#define localtime_unlock() _NOPL0("__threadcalls", localtime_unlock) -#endif - #ifndef TZ_ABBR_MAX_LEN #define TZ_ABBR_MAX_LEN 16 #endif /* !defined TZ_ABBR_MAX_LEN */ diff --git a/test/libc/calls/pledge_test.c b/test/libc/calls/pledge_test.c index 9a18f0dc4..1971ed6c6 100644 --- a/test/libc/calls/pledge_test.c +++ b/test/libc/calls/pledge_test.c @@ -37,7 +37,6 @@ #include "libc/sock/struct/sockaddr.h" #include "libc/sock/struct/sockaddr6.h" #include "libc/stdio/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/af.h" #include "libc/sysv/consts/at.h" diff --git a/test/libc/stdio/fputc_test.c b/test/libc/stdio/fputc_test.c index e11599b06..53d013212 100644 --- a/test/libc/stdio/fputc_test.c +++ b/test/libc/stdio/fputc_test.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/runtime/internal.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" diff --git a/test/libc/thread/pthread_atfork_test.c b/test/libc/thread/pthread_atfork_test.c index 1d363e036..1333036c9 100644 --- a/test/libc/thread/pthread_atfork_test.c +++ b/test/libc/thread/pthread_atfork_test.c @@ -21,7 +21,7 @@ #include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/internal.h" -#include "libc/stdio/lock.internal.h" +#include "libc/stdio/stdio.h" #include "libc/testlib/subprocess.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" diff --git a/third_party/awk/awkgram.y b/third_party/awk/awkgram.y index 900963ada..a1f1b64fe 100644 --- a/third_party/awk/awkgram.y +++ b/third_party/awk/awkgram.y @@ -25,7 +25,6 @@ THIS SOFTWARE. %{ #include "libc/calls/calls.h" #include "libc/fmt/fmt.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/temp.h" #include "libc/mem/alg.h" diff --git a/third_party/chibicc/chibicc.c b/third_party/chibicc/chibicc.c index a43090738..50a4a11da 100644 --- a/third_party/chibicc/chibicc.c +++ b/third_party/chibicc/chibicc.c @@ -668,7 +668,6 @@ static void run_linker(StringArray *inputs, char *output) { strarray_push(&arr, "--gc-sections"); strarray_push(&arr, "--build-id=none"); strarray_push(&arr, "--no-dynamic-linker"); - strarray_push(&arr, xasprintf("-Ttext-segment=%#x", IMAGE_BASE_VIRTUAL)); /* strarray_push(&arr, "-T"); */ /* strarray_push(&arr, LDS); */ /* strarray_push(&arr, APE); */ diff --git a/third_party/chibicc/chibicc.mk b/third_party/chibicc/chibicc.mk index 9e4c02091..0789da7f4 100644 --- a/third_party/chibicc/chibicc.mk +++ b/third_party/chibicc/chibicc.mk @@ -16,7 +16,6 @@ CHIBICC = o/$(MODE)/third_party/chibicc/chibicc.com CHIBICC_FLAGS = \ -fno-common \ -include libc/integral/normalize.inc \ - -DIMAGE_BASE_VIRTUAL=$(IMAGE_BASE_VIRTUAL) \ -DMODE='"$(MODE)"' o/$(MODE)/%.chibicc.o: private .UNSANDBOXED = true diff --git a/third_party/lua/liolib.c b/third_party/lua/liolib.c index e9ed633ee..a6502cd2b 100644 --- a/third_party/lua/liolib.c +++ b/third_party/lua/liolib.c @@ -30,7 +30,6 @@ #include "libc/calls/calls.h" #include "libc/calls/weirdtypes.h" #include "libc/errno.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/temp.h" #include "libc/str/str.h" diff --git a/third_party/lua/lrepl.h b/third_party/lua/lrepl.h index e2a51301d..e66232e0c 100644 --- a/third_party/lua/lrepl.h +++ b/third_party/lua/lrepl.h @@ -1,6 +1,5 @@ #ifndef COSMOPOLITAN_THIRD_PARTY_LUA_LREPL_H_ #define COSMOPOLITAN_THIRD_PARTY_LUA_LREPL_H_ -#include "libc/intrin/nopl.internal.h" #include "third_party/linenoise/linenoise.h" #include "third_party/lua/lauxlib.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) @@ -25,11 +24,6 @@ void lua_l_message(const char *, const char *); char *lua_readline_hint(const char *, const char **, const char **); void lua_readline_completions(const char *, linenoiseCompletions *); -#ifdef _NOPL0 -#define lua_repl_lock() _NOPL0("__threadcalls", lua_repl_lock) -#define lua_repl_unlock() _NOPL0("__threadcalls", lua_repl_unlock) -#endif - COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_THIRD_PARTY_LUA_LREPL_H_ */ diff --git a/third_party/python/Objects/fileobject.c b/third_party/python/Objects/fileobject.c index 4f591d0f9..afe196670 100644 --- a/third_party/python/Objects/fileobject.c +++ b/third_party/python/Objects/fileobject.c @@ -7,7 +7,6 @@ #define PY_SSIZE_T_CLEAN #include "libc/calls/calls.h" #include "libc/errno.h" -#include "libc/stdio/lock.internal.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/boolobject.h" #include "third_party/python/Include/bytesobject.h" diff --git a/third_party/python/Python/cosmomodule.c b/third_party/python/Python/cosmomodule.c index 50c29f947..6665e326d 100644 --- a/third_party/python/Python/cosmomodule.c +++ b/third_party/python/Python/cosmomodule.c @@ -67,7 +67,6 @@ This module exposes low-level utilities from the Cosmopolitan library.\n\ Static objects:\n\ \n\ MODE -- make build mode, e.g. \"\", \"tiny\", \"opt\", \"rel\", etc.\n\ -IMAGE_BASE_VIRTUAL -- base address of actually portable executable image\n\ kernel -- o/s platform, e.g. \"linux\", \"xnu\", \"metal\", \"nt\", etc.\n\ kStartTsc -- the rdtsc() value at process creation."); @@ -402,7 +401,6 @@ PyInit_cosmo(void) if (PyType_Ready(&FtracerType) < 0) return 0; if (!(m = PyModule_Create(&cosmomodule))) return 0; PyModule_AddStringConstant(m, "MODE", MODE); - PyModule_AddIntConstant(m, "IMAGE_BASE_VIRTUAL", IMAGE_BASE_VIRTUAL); PyModule_AddStringConstant(m, "kernel", GetKernelName()); PyModule_AddIntConstant(m, "kStartTsc", kStartTsc); diff --git a/third_party/sed/compile.c b/third_party/sed/compile.c index 0396832f1..bddc8d870 100644 --- a/third_party/sed/compile.c +++ b/third_party/sed/compile.c @@ -63,7 +63,6 @@ #include "third_party/regex/regex.h" #include "libc/calls/calls.h" #include "libc/fmt/fmt.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/temp.h" #include "libc/mem/alg.h" diff --git a/third_party/zlib/trees.c b/third_party/zlib/trees.c index e48374a55..84564458b 100644 --- a/third_party/zlib/trees.c +++ b/third_party/zlib/trees.c @@ -8,7 +8,6 @@ */ #include "libc/calls/calls.h" #include "libc/fmt/fmt.h" -#include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/temp.h" #include "libc/str/str.h" diff --git a/tool/build/rollup.c b/tool/build/rollup.c index 7a1e839c4..ca2533160 100644 --- a/tool/build/rollup.c +++ b/tool/build/rollup.c @@ -146,12 +146,6 @@ int main(int argc, char *argv[]) { visited = newinterner(); appends(&output, "#ifndef COSMOPOLITAN_H_\n"); appends(&output, "#define COSMOPOLITAN_H_\n"); - /* appends(&output, "#define IMAGE_BASE_VIRTUAL "); */ - /* appendf(&output, "%p", IMAGE_BASE_VIRTUAL); */ - /* appends(&output, "\n"); */ - /* appends(&output, "#define IMAGE_BASE_PHYSICAL "); */ - /* appendf(&output, "%p", IMAGE_BASE_PHYSICAL); */ - /* appends(&output, "\n"); */ getargs_init(&ga, argv + 1); while ((src = getargs_next(&ga))) { Visit(src); diff --git a/tool/emacs/c.lang b/tool/emacs/c.lang index 50bc2fedd..a2805763a 100644 --- a/tool/emacs/c.lang +++ b/tool/emacs/c.lang @@ -1698,7 +1698,6 @@ Keywords={ "__STDC_NO_THREADS__", "__STDC_NO_VLA__", "__STDC_WANT_LIB_EXT1__", -"IMAGE_BASE_VIRTUAL", "IMAGE_BASE_REAL", "IMAGE_BASE_PHYSICAL", "SCHAR_MAX", diff --git a/tool/emacs/cosmo-c-constants.el b/tool/emacs/cosmo-c-constants.el index 581647195..126b1e5eb 100644 --- a/tool/emacs/cosmo-c-constants.el +++ b/tool/emacs/cosmo-c-constants.el @@ -31,8 +31,7 @@ "__STDC_WANT_LIB_EXT1__")) (defconst cosmo-c-constants-limits - '("IMAGE_BASE_VIRTUAL" - "IMAGE_BASE_REAL" + '("IMAGE_BASE_REAL" "IMAGE_BASE_PHYSICAL" "CHAR_MAX" "SCHAR_MAX"