mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Remove __threaded variable
This commit is contained in:
parent
01b09bc817
commit
cf1559c448
15 changed files with 51 additions and 71 deletions
|
@ -129,6 +129,7 @@ int linkat(int, const char *, int, const char *, int) libcesque __read_only(2) _
|
|||
int mincore(void *, size_t, unsigned char *) libcesque __read_only(1) __write_only(3);
|
||||
int mkdir(const char *, unsigned) libcesque __read_only(1);
|
||||
int mkdirat(int, const char *, unsigned) libcesque __read_only(2);
|
||||
int mkfifo(const char *, unsigned);
|
||||
int mknod(const char *, unsigned, uint64_t) libcesque __read_only(1);
|
||||
int nice(int) libcesque;
|
||||
int open(const char *, int, ...) libcesque __read_only(1);
|
||||
|
|
|
@ -169,8 +169,7 @@
|
|||
* turn APE binaries into static native binaries.
|
||||
*
|
||||
* - "prot_exec" allows mmap(PROT_EXEC) and mprotect(PROT_EXEC). This is
|
||||
* needed to (1) code morph mutexes in __enable_threads(), and it's
|
||||
* needed to (2) launch non-static or non-native executables, e.g.
|
||||
* needed to launch non-static or non-native executables, e.g.
|
||||
* non-assimilated APE binaries, or dynamic-linked executables.
|
||||
*
|
||||
* - "unveil" allows unveil() to be called, as well as the underlying
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
* special; the kernel treats this as a thread id (noting that
|
||||
* `getpid() == gettid()` is always the case on Linux for the main
|
||||
* thread) and will only take effect for the specified tid.
|
||||
* Therefore this function is POSIX-compliant iif `!__threaded`.
|
||||
* @return scheduler policy, or -1 w/ errno
|
||||
* @error ESRCH if `pid` not found
|
||||
* @error EPERM if not permitted
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
* special; the kernel treats this as a thread id (noting that
|
||||
* `getpid() == gettid()` is always the case on Linux for the main
|
||||
* thread) and will only take effect for the specified tid.
|
||||
* Therefore this function is POSIX-compliant iif `!__threaded`.
|
||||
*
|
||||
* @param policy specifies the kernel's timesharing strategy.
|
||||
*
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/thread/tls.h"
|
||||
|
||||
void __enable_threads(void) {
|
||||
__threaded = 1;
|
||||
}
|
|
@ -18,11 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/thread/tls.h"
|
||||
|
||||
/**
|
||||
* Contains TID of main thread or 0 if threading isn't enabled.
|
||||
*/
|
||||
int __threaded;
|
||||
|
||||
#ifdef __x86_64__
|
||||
char __tls_enabled;
|
||||
#endif
|
||||
|
|
|
@ -113,7 +113,6 @@ static dontinline textwindows ssize_t ForkIo2(
|
|||
ssize_t rc = ForkIo(h, buf, n, fn);
|
||||
if (ischild) {
|
||||
// prevent crashes
|
||||
__threaded = false;
|
||||
__tls_enabled = false;
|
||||
__pid = __imp_GetCurrentProcessId();
|
||||
__klog_handle = 0;
|
||||
|
@ -268,7 +267,6 @@ textwindows void WinMainForked(void) {
|
|||
ReadOrDie(reader, __bss_start, __bss_end - __bss_start);
|
||||
kStartTsc = savetsc;
|
||||
__tls_enabled = false;
|
||||
__threaded = false;
|
||||
|
||||
// fixup memory manager
|
||||
__maps.maps = 0;
|
||||
|
@ -464,8 +462,6 @@ textwindows int sys_fork_nt(uint32_t dwCreationFlags) {
|
|||
// the child's pending signals is initially empty
|
||||
atomic_store_explicit(&__sig.pending, 0, memory_order_relaxed);
|
||||
atomic_store_explicit(&tib->tib_sigpending, 0, memory_order_relaxed);
|
||||
// re-enable threads
|
||||
__enable_threads();
|
||||
// re-apply code morphing for function tracing
|
||||
if (ftrace_stackdigs) {
|
||||
_weaken(__hook)(_weaken(ftrace_hook), _weaken(GetSymbolTable)());
|
||||
|
|
|
@ -236,7 +236,6 @@ static textwindows dontinstrument uint32_t __proc_worker(void *arg) {
|
|||
* Lazy initializes process tracker data structures and worker.
|
||||
*/
|
||||
static textwindows void __proc_setup(void) {
|
||||
__enable_threads();
|
||||
__proc.onbirth = CreateEvent(0, 0, 0, 0); // auto reset
|
||||
__proc.haszombies = CreateEvent(0, 1, 0, 0); // manual reset
|
||||
__proc.thread = CreateThread(0, 65536, __proc_worker, 0,
|
||||
|
|
|
@ -746,10 +746,6 @@ errno_t clone(void *func, void *stk, size_t stksz, int flags, void *arg,
|
|||
void *ptid, void *tls, void *ctid) {
|
||||
int rc;
|
||||
|
||||
if (flags & CLONE_THREAD) {
|
||||
__enable_threads();
|
||||
}
|
||||
|
||||
if (!func) {
|
||||
rc = EINVAL;
|
||||
} else if (IsLinux()) {
|
||||
|
|
|
@ -113,7 +113,6 @@ void _weakfree(void *) libcesque;
|
|||
void *_mapanon(size_t) attributeallocsize((1)) mallocesque libcesque;
|
||||
void *_mapshared(size_t) attributeallocsize((1)) mallocesque libcesque;
|
||||
void CheckForFileLeaks(void) libcesque;
|
||||
void __enable_threads(void) libcesque;
|
||||
void __oom_hook(size_t) libcesque;
|
||||
/* code morphing */
|
||||
void __morph_begin(void) libcesque;
|
||||
|
|
|
@ -42,7 +42,6 @@ struct CosmoTib {
|
|||
_Atomic(void *) tib_keys[46];
|
||||
} __attribute__((__aligned__(64)));
|
||||
|
||||
extern int __threaded;
|
||||
extern char __tls_morphed;
|
||||
extern unsigned __tls_index;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue