mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Get threads working on all platforms
We now have a high-quality clone() implementation for creating lightweight threads on Linux/Windows/FreeBSD/NetBSD/OpenBSD.
This commit is contained in:
parent
4e62cefa6e
commit
fec396037a
43 changed files with 850 additions and 532 deletions
|
@ -16,14 +16,12 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/setjmp.internal.h"
|
||||
#include "libc/intrin/winthread.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/thread.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/nr.h"
|
||||
|
||||
/**
|
||||
|
@ -36,18 +34,15 @@
|
|||
*/
|
||||
privileged wontreturn void _Exit1(int rc) {
|
||||
struct WinThread *wt;
|
||||
STRACE("_Exit1(%d)", rc);
|
||||
/* STRACE("_Exit1(%d)", rc); */
|
||||
if (!IsWindows() && !IsMetal()) {
|
||||
register long r10 asm("r10") = 0;
|
||||
asm volatile("syscall"
|
||||
: /* no outputs */
|
||||
: "a"(__NR_exit), "D"(IsLinux() ? rc : 0)
|
||||
: "a"(__NR_exit), "D"(IsLinux() ? rc : 0), "S"(0), "d"(0),
|
||||
"r"(r10)
|
||||
: "rcx", "r11", "memory");
|
||||
__builtin_unreachable();
|
||||
} else if (IsWindows()) {
|
||||
if ((wt = GetWinThread())) {
|
||||
__releasefd(wt->pid);
|
||||
weaken(free)(wt);
|
||||
}
|
||||
ExitThread(rc);
|
||||
}
|
||||
for (;;) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue