Remove IMAGE_BASE_VIRTUAL

This commit is contained in:
Justine Tunney 2023-09-12 01:21:36 -07:00
parent 8a0008d985
commit 20c77338e6
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
65 changed files with 10 additions and 286 deletions

View file

@ -101,8 +101,7 @@
], ],
"defines": [ "defines": [
"COSMO", "COSMO",
"MODE=", "MODE="
"IMAGE_BASE_VIRTUAL=0x400000"
] ]
} }
], ],

View file

@ -11,7 +11,7 @@ OUTPUT_FORMAT("elf64-littleaarch64",
SECTIONS { SECTIONS {
. = SEGMENT_START("text-segment", IMAGE_BASE_VIRTUAL); . = SEGMENT_START("text-segment", 0x010000000000);
__executable_start = .; __executable_start = .;
. += SIZEOF_HEADERS; . += SIZEOF_HEADERS;

View file

@ -198,6 +198,10 @@
#define SKEW 0 #define SKEW 0
#endif #endif
#ifndef IMAGE_BASE_VIRTUAL
#define IMAGE_BASE_VIRTUAL 0x400000
#endif
#if IMAGE_BASE_VIRTUAL > 0xffffffff #if IMAGE_BASE_VIRTUAL > 0xffffffff
#error "please use 32-bit addresses for image data" #error "please use 32-bit addresses for image data"
#endif #endif

View file

@ -137,12 +137,6 @@ else
TMPSAFE = $(TMPDIR)/ TMPSAFE = $(TMPDIR)/
endif endif
ifeq ($(ARCH), aarch64)
IMAGE_BASE_VIRTUAL ?= 0x010000000000
else
IMAGE_BASE_VIRTUAL ?= 0x400000
endif
BACKTRACES = \ BACKTRACES = \
-fno-optimize-sibling-calls \ -fno-optimize-sibling-calls \
-mno-omit-leaf-frame-pointer -mno-omit-leaf-frame-pointer
@ -222,7 +216,6 @@ MATHEMATICAL = \
DEFAULT_CPPFLAGS += \ DEFAULT_CPPFLAGS += \
-D_COSMO_SOURCE \ -D_COSMO_SOURCE \
-DMODE='"$(MODE)"' \ -DMODE='"$(MODE)"' \
-DIMAGE_BASE_VIRTUAL=$(IMAGE_BASE_VIRTUAL) \
-nostdinc \ -nostdinc \
-iquote . -iquote .
@ -373,7 +366,6 @@ LINK = $(LD) $(LINK.flags)
ELF = o/libc/elf/elf.lds ELF = o/libc/elf/elf.lds
ELFLINK = $(COMPILE) -ALINK.elf $(LINK) $(LINKARGS) $(OUTPUT_OPTION) && $(COMPILE) -AFIXUP.ape -T$@ $(FIXUPOBJ) $@ 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,$^))) 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, # 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 # which is needed for C modules wanting to run at the executive level or

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STATE_INTERNAL_H_ #ifndef COSMOPOLITAN_LIBC_CALLS_STATE_INTERNAL_H_
#define 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/thread.h"
#include "libc/thread/tls.h" #include "libc/thread/tls.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0) #if !(__ASSEMBLER__ + __LINKER__ + 0)
@ -21,22 +20,6 @@ void __sig_lock(void);
void __sig_unlock(void); void __sig_unlock(void);
void __sig_funlock(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)) #define __vforked (__tls_enabled && (__get_tls()->tib_flags & TIB_FLAG_VFORKED))
COSMOPOLITAN_C_END_ COSMOPOLITAN_C_END_

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_ #ifndef COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_
#define COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_ #define COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_
#include "libc/intrin/nopl.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/thread/tls.h" #include "libc/thread/tls.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0) #if !(__ASSEMBLER__ + __LINKER__ + 0)
@ -24,14 +23,6 @@ void __cxa_lock(void);
void __cxa_unlock(void); void __cxa_unlock(void);
void __cxa_printexits(FILE *, 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_ COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_ */ #endif /* COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_ */

View file

@ -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_ */

View file

@ -35,7 +35,6 @@
#include "libc/runtime/runtime.h" #include "libc/runtime/runtime.h"
#include "libc/stdio/dprintf.h" #include "libc/stdio/dprintf.h"
#include "libc/stdio/internal.h" #include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/str/str.h" #include "libc/str/str.h"
#include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/fileno.h"

View file

@ -445,35 +445,6 @@
#endif #endif
.endm .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 // TODO(jart): delete
// Loads Effective Address // Loads Effective Address
// Supporting security blankets // Supporting security blankets
@ -486,32 +457,6 @@
#endif #endif
.endm .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. // Loads address of linktime mergeable string literal into register.
.macro loadstr text:req reg:req regsz bias=0 .macro loadstr text:req reg:req regsz bias=0
.section .rodata.str1.1,"aSM",@progbits,1 .section .rodata.str1.1,"aSM",@progbits,1

View file

@ -21,7 +21,6 @@
#include "libc/fmt/itoa.h" #include "libc/fmt/itoa.h"
#include "libc/intrin/cmpxchg.h" #include "libc/intrin/cmpxchg.h"
#include "libc/intrin/kprintf.h" #include "libc/intrin/kprintf.h"
#include "libc/intrin/nopl.internal.h"
#include "libc/macros.internal.h" #include "libc/macros.internal.h"
#include "libc/nexgen32e/stackframe.h" #include "libc/nexgen32e/stackframe.h"
#include "libc/runtime/internal.h" #include "libc/runtime/internal.h"

View file

@ -2,7 +2,6 @@
#define COSMOPOLITAN_LIBC_RUNTIME_MEMTRACK_H_ #define COSMOPOLITAN_LIBC_RUNTIME_MEMTRACK_H_
#include "ape/sections.internal.h" #include "ape/sections.internal.h"
#include "libc/dce.h" #include "libc/dce.h"
#include "libc/intrin/nopl.internal.h"
#include "libc/macros.internal.h" #include "libc/macros.internal.h"
#include "libc/nt/version.h" #include "libc/nt/version.h"
#include "libc/runtime/runtime.h" #include "libc/runtime/runtime.h"
@ -61,14 +60,6 @@ void __release_memory_nt(struct MemoryIntervals *, int, int);
int __untrack_memories(void *, size_t); int __untrack_memories(void *, size_t);
size_t __get_memtrack_size(struct MemoryIntervals *); 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__ #ifdef __x86_64__
/* /*
* AMD64 has 48-bit signed pointers (PML4T) * AMD64 has 48-bit signed pointers (PML4T)

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ #ifndef COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_
#define COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ #define COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_
#include "libc/intrin/nopl.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/thread/thread.h" #include "libc/thread/thread.h"
#include "libc/thread/tls.h" #include "libc/thread/tls.h"
@ -23,14 +22,6 @@ extern pthread_mutex_t __fflush_lock_obj;
void __fflush_lock(void); void __fflush_lock(void);
void __fflush_unlock(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_ COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ */ #endif /* COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ */

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/internal.h" #include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/sysv/errfuns.h" #include "libc/sysv/errfuns.h"

View file

@ -17,13 +17,12 @@
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/internal.h" #include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/thread/thread.h" #include "libc/thread/thread.h"
/** /**
* Acquires reentrant lock on stdio object, blocking if needed. * Acquires reentrant lock on stdio object, blocking if needed.
*/ */
void(flockfile)(FILE *f) { void flockfile(FILE *f) {
pthread_mutex_lock(&f->lock); pthread_mutex_lock(&f->lock);
} }

View file

@ -19,7 +19,6 @@
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/stdio/fflush.internal.h" #include "libc/stdio/fflush.internal.h"
#include "libc/stdio/internal.h" #include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/stdio/stdio_ext.h" #include "libc/stdio/stdio_ext.h"

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -19,7 +19,6 @@
#include "libc/intrin/describeflags.internal.h" #include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h" #include "libc/intrin/strace.internal.h"
#include "libc/runtime/runtime.h" #include "libc/runtime/runtime.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -18,7 +18,6 @@
*/ */
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/stdio/internal.h" #include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/sysv/consts/f.h" #include "libc/sysv/consts/f.h"
#include "libc/sysv/consts/fd.h" #include "libc/sysv/consts/fd.h"

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/fmt/fmt.h" #include "libc/fmt/fmt.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -18,7 +18,6 @@
*/ */
#include "libc/intrin/describeflags.internal.h" #include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h" #include "libc/intrin/strace.internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -20,7 +20,6 @@
#include "libc/errno.h" #include "libc/errno.h"
#include "libc/runtime/runtime.h" #include "libc/runtime/runtime.h"
#include "libc/stdio/internal.h" #include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/sysv/consts/o.h" #include "libc/sysv/consts/o.h"

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/internal.h" #include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/thread/thread.h" #include "libc/thread/thread.h"

View file

@ -17,13 +17,12 @@
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/internal.h" #include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/thread/thread.h" #include "libc/thread/thread.h"
/** /**
* Releases lock on stdio object. * Releases lock on stdio object.
*/ */
void(funlockfile)(FILE *f) { void funlockfile(FILE *f) {
pthread_mutex_unlock(&f->lock); pthread_mutex_unlock(&f->lock);
} }

View file

@ -18,7 +18,6 @@
*/ */
#include "libc/intrin/describeflags.internal.h" #include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h" #include "libc/intrin/strace.internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -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_ */

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/str/str.h" #include "libc/str/str.h"

View file

@ -18,7 +18,6 @@
*/ */
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/stdio/internal.h" #include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -18,7 +18,6 @@
*/ */
#include "libc/calls/struct/fd.internal.h" #include "libc/calls/struct/fd.internal.h"
#include "libc/fmt/fmt.h" #include "libc/fmt/fmt.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -20,7 +20,6 @@
#include "libc/mem/mem.h" #include "libc/mem/mem.h"
#include "libc/runtime/runtime.h" #include "libc/runtime/runtime.h"
#include "libc/stdio/internal.h" #include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/sysv/errfuns.h" #include "libc/sysv/errfuns.h"

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/fmt/fmt.h" #include "libc/fmt/fmt.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/fmt/fmt.h" #include "libc/fmt/fmt.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
/** /**

View file

@ -23,7 +23,6 @@
#include "libc/dce.h" #include "libc/dce.h"
#include "libc/errno.h" #include "libc/errno.h"
#include "libc/intrin/atomic.h" #include "libc/intrin/atomic.h"
#include "libc/intrin/nopl.internal.h"
#include "libc/intrin/strace.internal.h" #include "libc/intrin/strace.internal.h"
#include "libc/limits.h" #include "libc/limits.h"
#include "libc/mem/mem.h" #include "libc/mem/mem.h"
@ -71,11 +70,6 @@ static void sem_open_init(void) {
pthread_once(&g_semaphores.once, sem_open_setup); 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, static sem_t *sem_open_impl(const char *path, int oflag, unsigned mode,
unsigned value) { unsigned value) {
int fd; int fd;

View file

@ -5,7 +5,6 @@
#include "libc/calls/blockcancel.internal.h" #include "libc/calls/blockcancel.internal.h"
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/intrin/bits.h" #include "libc/intrin/bits.h"
#include "libc/intrin/nopl.internal.h"
#include "libc/mem/gc.h" #include "libc/mem/gc.h"
#include "libc/mem/mem.h" #include "libc/mem/mem.h"
#include "libc/str/str.h" #include "libc/str/str.h"
@ -67,11 +66,6 @@ __attribute__((__constructor__)) static void localtime_init(void) {
localtime_funlock); localtime_funlock);
} }
#ifdef _NOPL0
#define localtime_lock() _NOPL0("__threadcalls", localtime_lock)
#define localtime_unlock() _NOPL0("__threadcalls", localtime_unlock)
#endif
#ifndef TZ_ABBR_MAX_LEN #ifndef TZ_ABBR_MAX_LEN
#define TZ_ABBR_MAX_LEN 16 #define TZ_ABBR_MAX_LEN 16
#endif /* !defined TZ_ABBR_MAX_LEN */ #endif /* !defined TZ_ABBR_MAX_LEN */

View file

@ -37,7 +37,6 @@
#include "libc/sock/struct/sockaddr.h" #include "libc/sock/struct/sockaddr.h"
#include "libc/sock/struct/sockaddr6.h" #include "libc/sock/struct/sockaddr6.h"
#include "libc/stdio/internal.h" #include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/sysv/consts/af.h" #include "libc/sysv/consts/af.h"
#include "libc/sysv/consts/at.h" #include "libc/sysv/consts/at.h"

View file

@ -18,7 +18,6 @@
*/ */
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/runtime/internal.h" #include "libc/runtime/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/str/str.h" #include "libc/str/str.h"
#include "libc/testlib/ezbench.h" #include "libc/testlib/ezbench.h"

View file

@ -21,7 +21,7 @@
#include "libc/mem/gc.h" #include "libc/mem/gc.h"
#include "libc/mem/mem.h" #include "libc/mem/mem.h"
#include "libc/runtime/internal.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/subprocess.h"
#include "libc/testlib/testlib.h" #include "libc/testlib/testlib.h"
#include "libc/thread/thread.h" #include "libc/thread/thread.h"

View file

@ -25,7 +25,6 @@ THIS SOFTWARE.
%{ %{
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/fmt/fmt.h" #include "libc/fmt/fmt.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/temp.h" #include "libc/temp.h"
#include "libc/mem/alg.h" #include "libc/mem/alg.h"

View file

@ -668,7 +668,6 @@ static void run_linker(StringArray *inputs, char *output) {
strarray_push(&arr, "--gc-sections"); strarray_push(&arr, "--gc-sections");
strarray_push(&arr, "--build-id=none"); strarray_push(&arr, "--build-id=none");
strarray_push(&arr, "--no-dynamic-linker"); strarray_push(&arr, "--no-dynamic-linker");
strarray_push(&arr, xasprintf("-Ttext-segment=%#x", IMAGE_BASE_VIRTUAL));
/* strarray_push(&arr, "-T"); */ /* strarray_push(&arr, "-T"); */
/* strarray_push(&arr, LDS); */ /* strarray_push(&arr, LDS); */
/* strarray_push(&arr, APE); */ /* strarray_push(&arr, APE); */

View file

@ -16,7 +16,6 @@ CHIBICC = o/$(MODE)/third_party/chibicc/chibicc.com
CHIBICC_FLAGS = \ CHIBICC_FLAGS = \
-fno-common \ -fno-common \
-include libc/integral/normalize.inc \ -include libc/integral/normalize.inc \
-DIMAGE_BASE_VIRTUAL=$(IMAGE_BASE_VIRTUAL) \
-DMODE='"$(MODE)"' -DMODE='"$(MODE)"'
o/$(MODE)/%.chibicc.o: private .UNSANDBOXED = true o/$(MODE)/%.chibicc.o: private .UNSANDBOXED = true

View file

@ -30,7 +30,6 @@
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/calls/weirdtypes.h" #include "libc/calls/weirdtypes.h"
#include "libc/errno.h" #include "libc/errno.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/temp.h" #include "libc/temp.h"
#include "libc/str/str.h" #include "libc/str/str.h"

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_THIRD_PARTY_LUA_LREPL_H_ #ifndef COSMOPOLITAN_THIRD_PARTY_LUA_LREPL_H_
#define 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/linenoise/linenoise.h"
#include "third_party/lua/lauxlib.h" #include "third_party/lua/lauxlib.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0) #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 **); char *lua_readline_hint(const char *, const char **, const char **);
void lua_readline_completions(const char *, linenoiseCompletions *); 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_ COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_LUA_LREPL_H_ */ #endif /* COSMOPOLITAN_THIRD_PARTY_LUA_LREPL_H_ */

View file

@ -7,7 +7,6 @@
#define PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/errno.h" #include "libc/errno.h"
#include "libc/stdio/lock.internal.h"
#include "third_party/python/Include/abstract.h" #include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/boolobject.h" #include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/bytesobject.h" #include "third_party/python/Include/bytesobject.h"

View file

@ -67,7 +67,6 @@ This module exposes low-level utilities from the Cosmopolitan library.\n\
Static objects:\n\ Static objects:\n\
\n\ \n\
MODE -- make build mode, e.g. \"\", \"tiny\", \"opt\", \"rel\", etc.\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\ kernel -- o/s platform, e.g. \"linux\", \"xnu\", \"metal\", \"nt\", etc.\n\
kStartTsc -- the rdtsc() value at process creation."); kStartTsc -- the rdtsc() value at process creation.");
@ -402,7 +401,6 @@ PyInit_cosmo(void)
if (PyType_Ready(&FtracerType) < 0) return 0; if (PyType_Ready(&FtracerType) < 0) return 0;
if (!(m = PyModule_Create(&cosmomodule))) return 0; if (!(m = PyModule_Create(&cosmomodule))) return 0;
PyModule_AddStringConstant(m, "MODE", MODE); PyModule_AddStringConstant(m, "MODE", MODE);
PyModule_AddIntConstant(m, "IMAGE_BASE_VIRTUAL", IMAGE_BASE_VIRTUAL);
PyModule_AddStringConstant(m, "kernel", GetKernelName()); PyModule_AddStringConstant(m, "kernel", GetKernelName());
PyModule_AddIntConstant(m, "kStartTsc", kStartTsc); PyModule_AddIntConstant(m, "kStartTsc", kStartTsc);

View file

@ -63,7 +63,6 @@
#include "third_party/regex/regex.h" #include "third_party/regex/regex.h"
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/fmt/fmt.h" #include "libc/fmt/fmt.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/temp.h" #include "libc/temp.h"
#include "libc/mem/alg.h" #include "libc/mem/alg.h"

View file

@ -8,7 +8,6 @@
*/ */
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/fmt/fmt.h" #include "libc/fmt/fmt.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/temp.h" #include "libc/temp.h"
#include "libc/str/str.h" #include "libc/str/str.h"

View file

@ -146,12 +146,6 @@ int main(int argc, char *argv[]) {
visited = newinterner(); visited = newinterner();
appends(&output, "#ifndef COSMOPOLITAN_H_\n"); appends(&output, "#ifndef COSMOPOLITAN_H_\n");
appends(&output, "#define 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); getargs_init(&ga, argv + 1);
while ((src = getargs_next(&ga))) { while ((src = getargs_next(&ga))) {
Visit(src); Visit(src);

View file

@ -1698,7 +1698,6 @@ Keywords={
"__STDC_NO_THREADS__", "__STDC_NO_THREADS__",
"__STDC_NO_VLA__", "__STDC_NO_VLA__",
"__STDC_WANT_LIB_EXT1__", "__STDC_WANT_LIB_EXT1__",
"IMAGE_BASE_VIRTUAL",
"IMAGE_BASE_REAL", "IMAGE_BASE_REAL",
"IMAGE_BASE_PHYSICAL", "IMAGE_BASE_PHYSICAL",
"SCHAR_MAX", "SCHAR_MAX",

View file

@ -31,8 +31,7 @@
"__STDC_WANT_LIB_EXT1__")) "__STDC_WANT_LIB_EXT1__"))
(defconst cosmo-c-constants-limits (defconst cosmo-c-constants-limits
'("IMAGE_BASE_VIRTUAL" '("IMAGE_BASE_REAL"
"IMAGE_BASE_REAL"
"IMAGE_BASE_PHYSICAL" "IMAGE_BASE_PHYSICAL"
"CHAR_MAX" "CHAR_MAX"
"SCHAR_MAX" "SCHAR_MAX"