mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Fix some behavioral issues on Windows
This commit is contained in:
parent
41396ff48a
commit
42ba9901e4
11 changed files with 44 additions and 7 deletions
|
@ -100,7 +100,8 @@ o/$(MODE)/libc/calls/mkntenvblock.o: private \
|
|||
o/$(MODE)/libc/calls/wincrash.o \
|
||||
o/$(MODE)/libc/calls/ntcontext2linux.o: private \
|
||||
COPTS += \
|
||||
-fno-sanitize=all
|
||||
-fno-sanitize=all \
|
||||
-fpatchable-function-entry=0,0
|
||||
|
||||
ifneq ($(ARCH), aarch64)
|
||||
# we always want -O3 because:
|
||||
|
|
|
@ -50,6 +50,7 @@ o/$(MODE)/libc/nexgen32e/kbase36.o \
|
|||
o/$(MODE)/libc/nexgen32e/ktens.o \
|
||||
o/$(MODE)/libc/nexgen32e/ktolower.o \
|
||||
o/$(MODE)/libc/nexgen32e/ktoupper.o \
|
||||
o/$(MODE)/libc/nexgen32e/runlevel.o \
|
||||
o/$(MODE)/libc/nexgen32e/pid.o \
|
||||
o/$(MODE)/libc/nexgen32e/program_invocation_name2.o \
|
||||
o/$(MODE)/libc/nexgen32e/threaded.o: private \
|
||||
|
|
|
@ -29,9 +29,7 @@
|
|||
// @return %rax,%xmm0
|
||||
// @note slower than __sysv2nt
|
||||
// @see NT2SYSV() macro
|
||||
.ftrace1
|
||||
__nt2sysv:
|
||||
.ftrace2
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
// TODO(jart): We should probably find some way to use our own
|
||||
|
|
20
libc/nexgen32e/runlevel.c
Normal file
20
libc/nexgen32e/runlevel.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
|
||||
char __runlevel;
|
|
@ -22,15 +22,18 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/ucontext-netbsd.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/calls/wincrash.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/signals.h"
|
||||
#include "libc/nt/synchronization.h"
|
||||
#include "libc/nt/thread.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "third_party/puff/puff.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
|
@ -35,7 +36,10 @@
|
|||
int __inflate(void *out, size_t outsize, const void *in, size_t insize) {
|
||||
int rc;
|
||||
z_stream zs;
|
||||
if (_weaken(inflateInit2) && _weaken(inflate) && _weaken(inflateEnd)) {
|
||||
if (_weaken(inflateInit2) && //
|
||||
_weaken(inflate) && //
|
||||
_weaken(inflateEnd) && //
|
||||
__runlevel >= RUNLEVEL_MALLOC) {
|
||||
zs.next_in = in;
|
||||
zs.avail_in = insize;
|
||||
zs.total_in = insize;
|
||||
|
|
|
@ -8,10 +8,13 @@
|
|||
#define STACK_CEIL 0x700000000000ul
|
||||
#define STACK_SIZE FRAMESIZE
|
||||
|
||||
#define RUNLEVEL_MALLOC 1
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern int __pid;
|
||||
extern char __runlevel;
|
||||
extern int ftrace_stackdigs;
|
||||
extern uint32_t __ntconsolemode[3];
|
||||
extern const char v_ntsubsystem[] __attribute__((__weak__));
|
||||
|
|
|
@ -130,6 +130,12 @@ o/$(MODE)/libc/runtime/morph_tls.o: private \
|
|||
-ffreestanding \
|
||||
-fno-sanitize=all
|
||||
|
||||
# TODO(jart): We need a way to avoid WinThreadEntry() being hooked.
|
||||
o/$(MODE)/libc/runtime/clone.o: private \
|
||||
COPTS += \
|
||||
-fno-sanitize=all \
|
||||
-fpatchable-function-entry=0,0
|
||||
|
||||
# these assembly files are safe to build on aarch64
|
||||
o/$(MODE)/libc/runtime/init.o: libc/runtime/init.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#if 0 // TODO(G4Vi): improve reliability of fexecve() implementation
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/syscall_support-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
|
@ -28,8 +29,6 @@
|
|||
#include "libc/testlib/testlib.h"
|
||||
// clang-format off
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
STATIC_YOINK("zipos");
|
||||
|
||||
int fds[2];
|
||||
|
@ -151,4 +150,4 @@ TEST(fexecve, ziposAPEHasZipos) {
|
|||
close(fd);
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
#endif
|
||||
|
|
1
third_party/dlmalloc/dlmalloc.c
vendored
1
third_party/dlmalloc/dlmalloc.c
vendored
|
@ -9,6 +9,7 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/sysconf.h"
|
||||
#include "libc/stdckdint.h"
|
||||
|
|
1
third_party/dlmalloc/init.inc
vendored
1
third_party/dlmalloc/init.inc
vendored
|
@ -96,6 +96,7 @@ __attribute__((__constructor__)) int init_mparams(void) {
|
|||
|
||||
// RELEASE_MALLOC_GLOBAL_LOCK();
|
||||
|
||||
__runlevel = RUNLEVEL_MALLOC;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue